[Biopython] Having a hard time getting a handle on handles

Eric Talevich eric.talevich at gmail.com
Fri Jul 1 03:24:04 UTC 2011


On Thu, Jun 30, 2011 at 9:21 PM, Dilara Ally <dilara.ally at gmail.com> wrote:

> Hi All
>
> I have ~700,000 contigs that I would like to blast search and then from the
> blast record parse out particular pieces of information from the BLAST
> report.  I can get my code to pull in files and then loop over seq_records,
> blast, and then write a BLAST report.  But since I don't want to have
> 700,000 BLAST reports, I'd like to parse particular pieces of information
> from the report and store it in a table.  This is the error I get from the
> code I have pasted below:
>
> /Users/dally/Desktop/**NextGenData/Python_Scripts/**
> batchedfastafiles/group_1.**fasta
> 1
> 0
> GTCTTCGGCGTTGCACCGGCGATGAAGAAC**CAGTACGAGGCGTCTGGCGAGAGTAACAAC**GCTG
> Traceback (most recent call last):
>  File "<stdin>", line 13, in <module>
> NameError: name 'NCBIXML' is not defined
>
> Do i have to close the result_handle and then reopen it?  If so why?
>  Thanks in advance for your help.
>

Try adding this import to the top of your script:

from Bio.Blast import NCBIXML

Does it work now?

In general, whenever you see a NameError you should check for (a) missing
imports and (b) mis-typed variable names. The problem is usually one of
those.

Cheers,
Eric



More information about the Biopython mailing list