生物。爆炸(NCBIWWW)在多个序列上失败并暂停

2024-09-28 20:58:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图通过BLAST解析几十个序列,使用生物。爆炸在Python2.7中使用NCBIWWW。一个或几个序列没有问题,但是NCBIWWW.qblast()总是在大约5-7次迭代的BLAST搜索之后停止。重要的是,程序不会崩溃并带错误退出-它只是暂停,并永远冻结。我必须手动退出应用程序。这也不是互联网连接的问题,没有错误可以说明这一点。在

我不知道怎么了。我的代码中是否存在阻止多次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"

Tags: idnew错误lineopencontentlistfasta
1条回答
网友
1楼 · 发布于 2024-09-28 20:58:29

我看不出你的代码有任何故意的延迟你读过NCBI BLAST Usage Guidlines:

The NCBI BLAST servers are a shared resource. We give priority to interactive users. ... To avoid problems, API users should comply with the following guidelines:

  • 不要每隔10秒联系服务器一次以上。在
  • 不要为任何单个RID轮询超过一分钟一次。在
  • 使用URL参数email和tool,以便NCBI可以在以下情况下联系您 有个问题。在
  • 在周末或晚上9点到早上5点之间运行脚本 如果工作日的搜索次数超过50次 提交。在

尽管NCBIWWW有一个延迟机制来确定它检查查询结果的频率,但我看不出它在查询之间增加了延迟。我不是说这绝对是你的问题,但你可能不在NCBI的指导范围之内。关于这个问题,我看到了另一条建议:

DO NOT submit searches that contain only single sequence! You need to batch the query and submit a set in a single search request.

相关问题 更多 >