python - Blasting remotely from biopython -
i'm trying remotely blast 70 200-nt sequences using biopython. i've been trying hours figure out why following python script won't work.
i can work read file contains 1 fasta using seqio.read, when try switch seqio.parse, don't in .xml save file create.
any ideas?
as side note, if knows option syntax excluding organisms results (as possible when using ncbi website, please let me know).
thanks help.
matt
from bio.blast import ncbiwww bio import seqio import tkinter.filedialog tkfd in_file=tkfd.askopenfilename() record = seqio.parse(in_file, format="fasta") out_file = tkfd.asksaveasfilename() save_file = open(out_file, "w") rec in record: print(rec) result_handle = ncbiwww.qblast("blastn", "nt", rec.format("fasta")) save_file.write(result_handle.read()) result_handle.close() else: save_file.close()
this content of in_file i'm using test file (the line formatting of file set @ 80 char, might have been lost below, also, space shown below between records not in test file):
>165613 taactgcagtgttttgtgtcgagccttttttgtgccttttttataaaggcataacgttatatttaattgaagagtttgat tctggctcagattgaacgctagcggcatgcttaacacatgcaagtcgaacggcagcgcggggagcttgctccctggcggc gagtggcggacgggtgagtaatgcgtaggaatctaccttg
>165875 gggatcttcggacctcgtgctataagatgagcctacgtcggattagcttgttggtggggtaatggcctaccaaggcgacg atccgtagctggtctgagaggacgatcagccacactgggactgagacacggcccagactcctacgggaggcagcagtggg gaatattggacaatgggggaaaccctgatccagcaatgcc
you problem library tkinter, next code works (biopython) ..... mandatory use gui ?
from bio.blast import ncbiwww bio import seqio in_file = open("input.fasta") record = seqio.parse(in_file, format="fasta") save_file = open("out_file.blast", "w") rec in record: print(rec) result_handle = ncbiwww.qblast("blastn", "nt", rec.format("fasta")) save_file.write(result_handle.read()) result_handle.close() else: save_file.close()
get following result:
<?xml version="1.0"?> <!doctype blastoutput public "-//ncbi//ncbi blastoutput/en" "http://www.ncbi.nlm.nih.gov/dtd/ncbi_blastoutput.dtd"> <blastoutput> <blastoutput_program>blastn</blastoutput_program> <blastoutput_version>blastn 2.2.31+</blastoutput_version> <blastoutput_reference>stephen f. altschul, thomas l. madden, alejandro a. sch&auml;ffer, jinghui zhang, zheng zhang, webb miller, , david j. lipman (1997), "gapped blast , psi-blast: new generation of protein database search programs", nucleic acids res. 25:3389-3402.</blastoutput_reference> <blastoutput_db>nt</blastoutput_db> <blastoutput_query-id>query_142405</blastoutput_query-id> <blastoutput_query-def>165613</blastoutput_query-def> <blastoutput_query-len>200</blastoutput_query-len> ....
i tested code , find following statement wrong
record = seqio.parse(open(in_file), format="fasta")
since, in_file
string
y don't type file
Comments
Post a Comment