我正在尝试通过 BLAST 解析几十个序列,在 Python 2.7 中使用 Bio.Blast 和 NCBIWWW。一个或几个序列没有问题,但 NCBIWWW.qblast() 总是在大约 5-7 次迭代 BLAST 搜索后停止。重要的是,程序不会因错误而崩溃和退出——它只是停止,并永远冻结。我必须手动退出应用程序。这也不是 Internet 连接的问题 - 没有错误表明这一点。
我不知道出了什么问题。我的代码中是否存在阻止多次 BLAST 搜索的错误,或者是否有用于此目的的替代算法?
我的代码:
from Bio.Blast import NCBIWWW
import urllib
def load_uniprot_fasta(identifier): #loads fasta file for a given UniProt identifier
link = "http://www.uniprot.org/uniprot/" + identifier + ".fasta"
f = urllib.urlopen(link)
content = f.read()
print content
print "\n"
new_file = open(str(identifier)+".seq", "w")
new_file.write(content)
evalue = 0.00001
id_list = open("list.list", "r") #this file is a list of UniProt identifiers, every line is a new identifier
for line in id_list:
uniprot_id = ""
uniprot_id = str(line).strip("\n")
load_uniprot_fasta(uniprot_id) #creates a <uniprot_id>.fasta file
fasta_object = open(str(uniprot_id)+".seq").read()
result_handle = NCBIWWW.qblast("blastp", "swissprot", fasta_object)
print "SUCCESS\n"