Mercurial > repos > yufei-luo > s_mart
comparison commons/pyRepetUnit/profilesDB/ProfilesDatabankUtils.py @ 18:94ab73e8a190
Uploaded
| author | m-zytnicki |
|---|---|
| date | Mon, 29 Apr 2013 03:20:15 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 17:b0e8584489e6 | 18:94ab73e8a190 |
|---|---|
| 1 """ | |
| 2 Utility to handle a databank of HMM profiles. | |
| 3 """ | |
| 4 | |
| 5 import sys | |
| 6 from commons.pyRepetUnit.profilesDB.Profiles import Profiles | |
| 7 from commons.pyRepetUnit.profilesDB.ProfilesDatabank import ProfilesDatabank | |
| 8 from commons.core.utils.FileUtils import FileUtils | |
| 9 | |
| 10 class ProfilesDatabankUtils: | |
| 11 """ | |
| 12 Utility to handle a databank of HMM profiles. | |
| 13 """ | |
| 14 | |
| 15 def read( inFileName, verbose=0 ): | |
| 16 """ | |
| 17 Read a file in Pfam format and return a L[ProfilesDatabank<commons.core.ProfilesDatabank>} instance. | |
| 18 @param inFileName: name of the input file | |
| 19 @type inFileName: string | |
| 20 @param verbose: verbosity level | |
| 21 @type verbose: integer | |
| 22 """ | |
| 23 if verbose > 0: print "reading file '%s'..." % ( inFileName ); sys.stdout.flush() | |
| 24 | |
| 25 | |
| 26 if FileUtils.isEmpty(inFileName): | |
| 27 return (None) | |
| 28 profilesInstance = Profiles() | |
| 29 profilesDBInstance = ProfilesDatabank() | |
| 30 f = open( inFileName , "r") | |
| 31 while profilesInstance.read( f ): | |
| 32 profilesDBInstance.append( profilesInstance ) | |
| 33 profilesInstance = Profiles() | |
| 34 f.close() | |
| 35 if verbose > 0: print "file '%s' is loaded" % ( inFileName ); sys.stdout.flush() | |
| 36 return (profilesDBInstance) | |
| 37 | |
| 38 read = staticmethod( read ) |
