[Biopython] NCBIXML: 'generator' objecthas no attribute 'alignments'
Mic
mictadlo at gmail.com
Mon Apr 22 00:05:58 EDT 2013
Hi,
The following code (BioPython 1.61, Blast+ 2.2.26):
from Bio.Blast import NCBIXML
with open("test/X.xml") as bf:
blast_records = NCBIXML.parse(bf)
for blast_record in blast_records:
for alignment in blast_records.alignments:
for hsp in alignment.hsps:
if hsp.expect < 0.04:
print '****Alignment****'
print 'sequence:', alignment.title
print 'length:', alignment.length
print 'e value:', hsp.expect
print hsp.query[0:75] + '...'
print hsp.match[0:75] + '...'
print hsp.sbjct[0:75] + '...'
caused the following error:
$ python parseBlastXML.py
Traceback (most recent call last):
File "parseBlastXML.py", line 8, in <module>
for alignment in blast_records.alignments:
AttributeError: 'generator' object has no attribute 'alignments'
What did I do wrong?
Thank you in advance.
Mic
More information about the Biopython
mailing list