[BioPython] NCBIWWW.qblast

Michiel Jan Laurens de Hoon mdehoon at c2b2.columbia.edu
Fri Jun 2 01:12:57 UTC 2006


Try this instead:

from Bio import Fasta
file_for_blast = open('fasta', 'r')
f_iterator = Fasta.Iterator(file_for_blast)

from Bio.Blast import NCBIWWW

seqnum = 0

for f_record in f_iterator:
     result_handle = NCBIWWW.qblast('blastp', 'nr', f_record)
     save_file = open('my_blast'+str(seqnum)+'.out', 'w')
     blast_results = result_handle.read()
     save_file.write(blast_results)
     save_file.close()
     seqnum += 1


--Michiel.

alper soyler wrote:
> Dear All,
> 
> I have a fasta file (called fasta) containing 20 proteins. I want to blast them in an order. How can I write the results of these 20 proteins in different output files. I tried to write the below script but the 'my_blast2.out' file turned empty. Can you help me please?
> 
> regards,
> Alper
> 
> #!usr/local/bin/python
> 
> from Bio import Fasta
> file_for_blast = open('fasta', 'r')
> f_iterator = Fasta.Iterator(file_for_blast)
> f_record = f_iterator.next()
> 
> from Bio.Blast import NCBIWWW
> result_handle = NCBIWWW.qblast('blastp', 'nr', f_record)
> 
> seqnum = 0
> 
> for f_record  in f_iterator:
>     save_file = open('my_blast.out', 'w')
>     blast_results = result_handle.read()
>     save_file.write(blast_results)
>     save_file.close()
>     seqnum += 1
>     save_file2 = open('my_blast2.out', 'w')
>     blast_results = result_handle.read()
>     save_file2.write(blast_results)
>     save_file2.close()
> 		
> ---------------------------------
> Be a chatter box. Enjoy free PC-to-PC calls  with Yahoo! Messenger with Voice.
> _______________________________________________
> BioPython mailing list  -  BioPython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython


-- 
Michiel de Hoon
Center for Computational Biology and Bioinformatics
Columbia University
1130 St Nicholas Avenue
New York, NY 10032



More information about the Biopython mailing list