[Biopython] NCBIXML: 'generator' objecthas no attribute 'alignments'
Mic
mictadlo at gmail.com
Mon Apr 22 00:27:12 EDT 2013
My mistake. This is the solution
from Bio.Blast import NCBIXML
with open("test/XA10m_v3.0.aa.snap_vs_uniref90.blastp.xml") as bf:
blast_records = NCBIXML.parse(bf)
for blast_record in blast_records:
for alignment in *blast_record.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] + '...'
On Mon, Apr 22, 2013 at 2:05 PM, Mic <mictadlo at gmail.com> wrote:
> 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