annotate commons/pyRepetUnit/hmmer/hmmOutput/HmmscanOutputProcessing.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
1 import re
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2 from commons.pyRepetUnit.hmmer.hmmOutput.HmmOutput import HmmOutput
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 from commons.pyRepetUnit.hmmer.hmmOutput.HmmOutputProcessing import HmmOutputProcessing
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5 ##Concrete implementation for hmmscan output specific methods
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 #
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7 class HmmscanOutputProcessing (HmmOutputProcessing):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 ## read an hmmscan output from a file, return a array with results useful to build a .align file
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 #
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 # @param file handle of file generated by software searching hmm profiles
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 #
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 def readHmmOutput( self, hmmerOutputFile ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 #Tested with HMMER 3 on Linux
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 line = hmmerOutputFile.readline()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 tabResult = None
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 if (line == ""):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 tabResult = None
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 return tabResult
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 tabResult = HmmOutput()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 while line != "":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 line = hmmerOutputFile.readline()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 if not(re.match("^#.*$", line)) and line != "":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 lLines = re.split("\s+", line)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 seqName = lLines[3]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 profilName = lLines[0]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 iValue = lLines[12]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 score = lLines[13]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 queryCoordStart =lLines[17]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 queryCoordEnd = lLines[18]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 subjectCoordStart = lLines[15]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 subjectCoordEnd = lLines[16]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 tabResult.append([seqName, queryCoordStart, queryCoordEnd, profilName, subjectCoordStart, subjectCoordEnd, iValue, score])
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 return tabResult
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36