【问题标题】:How to handle IncompleteRead: in biopython如何处理 IncompleteRead:在 biopython
【发布时间】:2016-11-25 19:10:26
【问题描述】:

我正在尝试使用 Biopython 从 NCBI 获取登录号的 fasta 序列。通常序列已成功下载。但偶尔我会收到以下错误:

http.client.IncompleteRead: IncompleteRead(61808640字节读取)

我已经搜索了答案How to handle IncompleteRead: in python

我已经尝试过最佳答案https://stackoverflow.com/a/14442358/4037275。这是工作。但是,问题是,它会下载部分序列。有没有其他办法。谁能指出我正确的方向?

from Bio import Entrez
from Bio import SeqIO
Entrez.email = "my email id"


def extract_fasta_sequence(NC_accession):
    "This takes the NC_accession number and fetches their fasta sequence"
    print("Extracting the fasta sequence for the NC_accession:", NC_accession)
    handle = Entrez.efetch(db="nucleotide", id=NC_accession, rettype="fasta", retmode="text")
    record = handle.read()

【问题讨论】:

    标签: python biopython http.client


    【解决方案1】:

    您需要添加一个 try/except 来捕获像这样的常见网络错误。请注意,异常 httplib.IncompleteRead 是更一般的 HTTPException 的子类,请参阅:https://docs.python.org/3/library/http.client.html#http.client.IncompleteRead

    例如http://lists.open-bio.org/pipermail/biopython/2011-October/013735.html

    另请参阅https://github.com/biopython/biopython/pull/590 会捕获您使用 NCBI Entrez API 可能遇到的一些其他错误(NCBI 应该处理但不处理的错误)。

    【讨论】:

      猜你喜欢
      • 2013-01-04
      • 2012-08-09
      • 2015-09-12
      • 1970-01-01
      • 2018-08-10
      • 1970-01-01
      • 2014-08-27
      • 2015-02-05
      相关资源
      最近更新 更多