[Biopython] parsing hmmer results
Michael Thon
mike.thon at gmail.com
Tue Mar 11 12:43:23 UTC 2014
I’m trying to parse a batch hmmer v3.1b1 report but I keep getting this error. I think its happening when the parser hits a hmmer report with no hits, but I’m not sure.
Here’s the error:
Traceback (most recent call last):
File "parse-dbcan.py", line 6, in <module>
for qresult in SearchIO.parse(argv[1], 'hmmer3-text'):
File "/Library/Python/2.7/site-packages/Bio/SearchIO/__init__.py", line 316, in parse
for qresult in generator:
File "/Library/Python/2.7/site-packages/Bio/SearchIO/HmmerIO/hmmer3_text.py", line 47, in __iter__
for qresult in self._parse_qresult():
File "/Library/Python/2.7/site-packages/Bio/SearchIO/HmmerIO/hmmer3_text.py", line 109, in _parse_qresult
qid = regx.group(1).strip()
AttributeError: 'NoneType' object has no attribute ‘group'
Here’s my script:
#!/usr/bin/python
from Bio import SearchIO
from sys import argv
import pdb
for qresult in SearchIO.parse(argv[1], 'hmmer3-text'):
hits = qresult.hits
if len(hits) > 0:
beste = hits[0].hsps[0].evalue
query = hits[0].query_id
hit = hits[0].id.replace('.hmm', '')
print query + ',' + hit + ',' + str(beste)
#pdb.set_trace()
I ran hmmscan like this:
hmmscan --cpu 2 -E 1e-3 HMMs.txt prots.fasta >oute-3.txt
More information about the Biopython
mailing list