comparison commons/pyRepetUnit/hmmer/hmmOutput/HmmOutputProcessing.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
comparison
equal deleted inserted replaced
30:5677346472b5 31:0ab839023fe4
1 import os
2 from commons.pyRepetUnit.hmmer.hmmOutput.HmmOutput import HmmOutput
3
4 ##Concrete implementation for hmmscan and hmmpfam output methods
5 #
6 class HmmOutputProcessing (object):
7
8 ## write a align file from a HmmOutput object
9 #
10 # @param fout handle of align file
11 # @param HmmOutput HmmOutput object in fact a list of hmmOutput containing datas required
12 #
13 def writeHmmOutputToAlignFile( self, pfamOutput, fout ):
14 for item in pfamOutput.getList():
15 for i in item:
16 fout.write(i + "\t")
17 fout.write("0\n")
18
19 ## read an output file from hmm profiles search program and write the corresponding .align file
20 #
21 # @param inputFile file
22 # @param outputFile file
23 #
24 def readHmmOutputsAndWriteAlignFile( self, inputFile, outputFile ):
25 if not os.path.exists(inputFile):
26 print "Warning your input file " + inputFile + " does not exist!\n"
27 return
28 file2parse = open( inputFile )
29 pfamOutput = HmmOutput()
30 if outputFile == "":
31 print "Warning have to specify an output name file!\n"
32 return
33 fout = open(outputFile, "w")
34 while pfamOutput != None:
35 pfamOutput = self.readHmmOutput(file2parse)
36 if pfamOutput != None:
37 self.writeHmmOutputToAlignFile(pfamOutput, fout)
38 fout.close()
39 file2parse.close()