我试着用Biopython远程爆炸大约70,200-nt序列.几个小时以来,我一直试图弄明白为什么下面的Python脚本不能工作。
我可以将它用于一个使用SeqIO.read只包含一个fasta的读取文件,但是当我尝试切换到SeqIO.parse时,我创建的.xml保存文件中没有任何内容。
有什么想法吗?
作为附带说明,如果有人知道将生物体排除在结果之外的选择语法(在使用ncbi网站时是可能的,请告诉我)。
非常感谢您的帮助。
哑光
from Bio.Blast import NCBIWWW
from Bio import SeqIO
import tkinter.filedialog as tkfd
in_file=tkfd.askopenfilename()
record = SeqIO.parse(in_file, format="fasta")
out_file = tkfd.asksaveasfilename()
save_file = open(out_file, "w")
for 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()这是我作为测试文件使用的in_file的内容(我的文件的行格式设置为80个字符,可能在下面丢失,而且记录之间的空格不在我的测试文件中):
165613 GAGTGGCGGACGGGTGAGTAATGCGTAGGAATCTACCTTG 165875 GAATATTGGACAATGGGGGAAACCCTGATCCAGCAATGCC
发布于 2015-04-29 18:00:16
您的问题是库tkinter,下一个代码运行良好(生物工程).是否强制使用GUI?
from Bio.Blast import NCBIWWW
from Bio import SeqIO
in_file = open("input.fasta")
record = SeqIO.parse(in_file, format="fasta")
save_file = open("out_file.blast", "w")
for 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()得到以下结果:
<?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, and David J. Lipman (1997), "Gapped BLAST and PSI-BLAST: a 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>
....我测试了您的代码,我发现下面的陈述是错误的
record = SeqIO.parse(open(in_file), format="fasta")既然,in_file是string y不是file类型
https://stackoverflow.com/questions/29950531
复制相似问题