从 Entrez 下载完整记录

Downloading full records from Entrez

提问人:Jevgenij Posaškov 提问时间:10/24/2023 最后编辑:Jevgenij Posaškov 更新时间:10/24/2023 访问量:28

问:

我无法从NCBI获得大肠杆菌基因组的数据。为此,我使用了两个文档来获取数据 http://biopython.org/DIST/docs/tutorial/Tutorial.html#sec149 http://biopython.org/DIST/docs/tutorial/Tutorial.html#sec37

所以我写了一个代码:

from Bio import Entrez
from Bio import SeqIO

Entrez.email = "may mail"

organism_id = "NC_000913"
handle = Entrez.efetch(db="nucleotide", id=organism_id, rettype="gbwithparts", retmode="text")
record = SeqIO.read(handle, "genbank")
handle.close()
genome_length = len(record.seq)


但是,我收到一个奇怪的错误。例如:

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:1348, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
   1347 try:
-> 1348     h.request(req.get_method(), req.selector, req.data, headers,
   1349               encode_chunked=req.has_header('Transfer-encoding'))
   1350 except OSError as err: # timeout error

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1282, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
   1281 """Send a complete request to the server."""
-> 1282 self._send_request(method, url, body, headers, encode_chunked)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1328, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
   1327     body = _encode(body, 'body')
-> 1328 self.endheaders(body, encode_chunked=encode_chunked)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1277, in HTTPConnection.endheaders(self, message_body, encode_chunked)
   1276     raise CannotSendHeader()
-> 1277 self._send_output(message_body, encode_chunked=encode_chunked)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1037, in HTTPConnection._send_output(self, message_body, encode_chunked)
   1036 del self._buffer[:]
-> 1037 self.send(msg)
   1039 if message_body is not None:
   1040 
...
-> 1351         raise URLError(err)
   1352     r = h.getresponse()
   1353 except:

URLError: 
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

我不知道我该如何解决这个问题?你能帮帮我吗?提前致谢。

Python 熊猫 数据科学 信息学 生物 蟒蛇

评论

0赞 Nick ODell 10/24/2023
无法重现 - 代码示例对我有用。您是否在阻止访问此内容的 Web 过滤器后面?其次,错误消息已被截断。完整的错误消息可能会有所帮助。
0赞 Jevgenij Posaškov 10/24/2023
@NickODell 有完整的代码执行响应:SSLCertVerificationError Traceback(最近一次调用最后一次)
0赞 Nick ODell 10/24/2023
您是否在应用SSL拦截的大学或公司?
0赞 Jevgenij Posaškov 10/24/2023
@NickODell 是的,我是硕士课程的学生。至于错误,我发现了一个有用的链接 [link(]stackoverflow.com/questions/62339003/...),但它没有帮助。现在我还有另一个错误:URLError Traceback(最近一次调用)

答: 暂无答案