[BioPython] Parsing BLAST

Alex Garbino agarbino at gmail.com
Wed Aug 27 21:01:53 UTC 2008


Thanks for the help; that was a lot of time wasted for something simple....

I do have an additional request: once I parse these out, I only get 50
entries. however, if I do the same search online, I get 138... what
accounts for the difference?

This is my code:

from Bio import SeqIO
from Bio.Blast import NCBIWWW
from Bio.Blast import NCBIXML

record = SeqIO.read(open("protein_fasta.txt"), format="fasta")
result_handle = NCBIWWW.qblast("blastp", "nr", record.seq.tostring())

blast_records = NCBIXML.parse(result_handle)
blast_record = blast_records.next()

for x in blast_record.alignments:
    print x.title, x.accession, x.length

acc_list = []
for x in blast_record.alignments:
    acc_list.append(x.accession)

len(acc_list) tells me 50...

Is there a default limit somewhere?

Thanks!
Alex

On Wed, Aug 27, 2008 at 12:27 PM, C. G. <cg5x6 at yahoo.com> wrote:
>
>
>
> --- On Wed, 8/27/08, Alex Garbino <agarbino at gmail.com> wrote:
>
>> From: Alex Garbino <agarbino at gmail.com>
>> Subject: [BioPython] Parsing BLAST
>> To: biopython at lists.open-bio.org
>> Date: Wednesday, August 27, 2008, 11:12 AM
>> Hello,
>>
>> I'm following the tutorials to do BLAST queries,
>> however, I can't get
>> the Blast object to work.
>>
>> I've downloaded the blast search, saved it in XML, etc,
>> as the
>> tutorial does. However, when I get to the step where
>> I'm trying to get
>> actual data out, it fails (the for loops part).
>> Here is a simplified version that illustrates the problem:
>>
>> for x in blast_record.alignments:
>>     print alignment.title
>>
>> Traceback (most recent call last):
>>   File "<input>", line 2, in <module>
>> NameError: name 'alignment' is not defined
>>
>> -----------------------
>
> It's a Python coding error. Try:
>
>     print x.title
>
> Or change the name of your variable in the "for" loop to "alignment".
>
>
>
>
> _______________________________________________
> BioPython mailing list  -  BioPython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>



More information about the Biopython mailing list