def reset( self ): Path.reset( self ) self.query_length = -1 self.query_length_perc = -1 self.query_seqlength = -1 self.match_length_perc = -1 self.subject_length = -1 self.subject_length_perc = -1 self.subject_seqlength = -1
def __init__(self): Path.__init__(self) self.query_length = -1 self.query_length_perc = -1 # length of the match on the query / length of the query self.query_seqlength = -1 self.match_length_perc = -1 # length of the match on the query / total length of the subject self.subject_length = -1 self.subject_length_perc = -1 # length of the match on the subject / length of the subject self.subject_seqlength = -1
def getPathListFromFile( pathFile ): lPaths = [] pathFileHandler = open( pathFile, "r" ) while True: line = pathFileHandler.readline() if line == "": break iPath = Path() iPath.setFromString( line ) lPaths.append( iPath ) pathFileHandler.close() return lPaths
def convertPathFileIntoSetFile( pathFile, setFile ): pathFileHandler = open( pathFile, "r" ) setFileHandler = open( setFile, "w" ) iPath = Path() while True: line = pathFileHandler.readline() if line == "": break iPath.setFromString( line ) iSet = iPath.getSubjectAsSetOfQuery() iSet.write( setFileHandler ) pathFileHandler.close() setFileHandler.close()
def convertPathFileIntoAlignFile(pathFile, alignFile): pathFileHandler = open( pathFile, "r" ) alignFileHandler = open( alignFile, "w" ) iPath = Path() while True: line = pathFileHandler.readline() if line == "": break iPath.setFromString( line ) iAlign = iPath.getAlignInstance() iAlign.write( alignFileHandler ) pathFileHandler.close() alignFileHandler.close()
def getPathInstance( self ): p = Path() tuple = ( self.id, self.range_query.seqname, self.range_query.start, self.range_query.end, self.range_subject.seqname, self.range_subject.start, self.range_subject.end, self.e_value, self.score, self.identity ) p.setFromTuple( tuple ) return p
def getDictOfListsWithIdAsKeyFromFile( pathFile ): dId2PathList = {} pathFileHandler = open( pathFile, "r" ) while True: line = pathFileHandler.readline() if line == "": break iPath = Path() iPath.setFromString( line ) if dId2PathList.has_key( iPath.id ): dId2PathList[ iPath.id ].append( iPath ) else: dId2PathList[ iPath.id ] = [ iPath ] pathFileHandler.close() return dId2PathList
def __eq__(self, o): if self.query_length != o.query_length or self.query_length_perc != o.query_length_perc\ or self.query_seqlength != o.query_seqlength or self.subject_length != o.subject_length\ or self.subject_length_perc != o.subject_length_perc or self.subject_seqlength != o.subject_seqlength\ or self.match_length_perc != o.match_length_perc: return False else: return Path.__eq__(self, o)
def retrieveInitialSequenceHeadersForPathFile( self, dNew2Init ): inFileHandler = open( self._inFile, "r" ) outFileHandler = open( self._outFile, "w" ) p = Path() while True: line = inFileHandler.readline() if line == "": break p.setFromTuple( line.split("\t") ) nameToBeReplaced = p.range_query.seqname if dNew2Init.has_key( nameToBeReplaced ): p.range_query.seqname = dNew2Init[ nameToBeReplaced ] nameToBeReplaced = p.range_subject.seqname if dNew2Init.has_key( nameToBeReplaced ): p.range_subject.seqname = dNew2Init[ nameToBeReplaced ] p.write( outFileHandler ) inFileHandler.close() outFileHandler.close()
def convertPathFileIntoMapFileWithQueryCoordsOnly( pathFile, mapFile ): pathFileHandler = open( pathFile, "r" ) mapFileHandler = open( mapFile, "w" ) p = Path() while True: line = pathFileHandler.readline() if line == "": break p.reset() p.setFromTuple( line.split("\t") ) p.writeSubjectAsMapOfQuery( mapFileHandler ) pathFileHandler.close() mapFileHandler.close()