我有一些代码看起来像这样: 我使用 esearch 的第一段代码有效,但在使用 efetch 时我的错误消息开始出现。
from Bio import Entrez
Entrez.email = "my email address"
handle = Entrez.esearch(db ="pubmed", retmax =100, term = "terminase large")
record = Entrez.read(handle)
print(record["IdList"])
import shutil
import os
TermList = record["IdList"]
Term = Entrez.efetch(db ='pubmed', id = TermList, rettype ='fasta', retmode = 'text')
file = "file path"
file_out = open(file,'w')
file_out.write(Term.read())
file_out.close()
输出:
EGFR = Entrez.efetch(db ='protein', id = EGFRList, rettype ='fasta', retmode = 'text')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/Bio/Entrez/__init__.py", line 196, in efetch
return _open(request)
^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/Bio/Entrez/__init__.py", line 594, in _open
handle = urlopen(request)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 525, in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 634, in http_response
response = self.parent.error(
^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 563, in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 496, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request