Mercurial > repos > yufei-luo > s_mart
diff commons/pyRepetUnit/profilesDB/ProfilesDatabankUtils.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commons/pyRepetUnit/profilesDB/ProfilesDatabankUtils.py Mon Apr 29 03:20:15 2013 -0400 @@ -0,0 +1,38 @@ +""" +Utility to handle a databank of HMM profiles. +""" + +import sys +from commons.pyRepetUnit.profilesDB.Profiles import Profiles +from commons.pyRepetUnit.profilesDB.ProfilesDatabank import ProfilesDatabank +from commons.core.utils.FileUtils import FileUtils + +class ProfilesDatabankUtils: + """ + Utility to handle a databank of HMM profiles. + """ + + def read( inFileName, verbose=0 ): + """ + Read a file in Pfam format and return a L[ProfilesDatabank<commons.core.ProfilesDatabank>} instance. + @param inFileName: name of the input file + @type inFileName: string + @param verbose: verbosity level + @type verbose: integer + """ + if verbose > 0: print "reading file '%s'..." % ( inFileName ); sys.stdout.flush() + + + if FileUtils.isEmpty(inFileName): + return (None) + profilesInstance = Profiles() + profilesDBInstance = ProfilesDatabank() + f = open( inFileName , "r") + while profilesInstance.read( f ): + profilesDBInstance.append( profilesInstance ) + profilesInstance = Profiles() + f.close() + if verbose > 0: print "file '%s' is loaded" % ( inFileName ); sys.stdout.flush() + return (profilesDBInstance) + + read = staticmethod( read )