Elink 函数 returns HTTP 414 问题
Elink function returns HTTP 414 issue
我正在 pubmed 中搜索术语并在 pubmed central 中查找相应的 ID。这是我的代码
Entrez.email = "Afsrtfgdsfg@bobxx.com"
batch_size = 10000
def idconv(idkeys):
handle = Entrez.elink(db='pmc', dbfrom='pubmed', id=idkeys)
return [each['LinkSetDb'][0]['Link'][0]['Id'] for each in Entrez.read(handle)]
def search(Term):
handle = Entrez.esearch(db='pubmed', term=Term, retmax=100000000)
record = Entrez.read(handle)
idlist = record["IdList"]
return idlist
mylist = search('"bacterial infections and mycoses"[MeSH Terms] AND pmc cc license[filter]AND ("review"[Publication Type]) AND "journal article"[Publication Type] NOT "letter"[Publication Type] NOT "comment"[Publication Type]')
print(len(idconv(mylist)))
我总是得到错误。
HTTP Error 414: Request-URI Too Large
我该如何解决这个问题?
我一次使用了 600 个块并得到了结果
from Bio import Entrez
Entrez.email = "Afsrtfgdsfg@bobxx.com"
batch_size = 10000
#['LinkSetDb'][0]['Link'][0]['Id']
def idconv(idkeys):
res=[]
for i in range(0, len(idkeys), 600):
handle = Entrez.elink(db='pmc', dbfrom='pubmed', id=idkeys[i:i+600])
for each in Entrez.read(handle):
try:
res.append(each['LinkSetDb'][0]['Link'][0]['Id'])
except IndexError:
pass
return res
def search(Term):
handle = Entrez.esearch(db='pubmed', term=Term, retmax=100000000)
record = Entrez.read(handle)
idlist = record["IdList"]
return idlist
mylist = search('"bacterial infections and mycoses"[MeSH Terms] AND pmc cc license[filter]AND ("review"[Publication Type]) AND "journal article"[Publication Type] NOT "letter"[Publication Type] NOT "comment"[Publication Type]')
print(len(mylist))
print (len(idconv(mylist)))
Biopython 1.67(即将发布)应该通过在需要非常长的 HTTP GET URL 时切换到使用 HTTP POST 来解决这个问题。参见:
https://github.com/biopython/biopython/commit/674da1122593cdc492c3ae480c7c1b7db06343b7
同时,您可以尝试从源代码安装 Biopython 吗?
我正在 pubmed 中搜索术语并在 pubmed central 中查找相应的 ID。这是我的代码
Entrez.email = "Afsrtfgdsfg@bobxx.com"
batch_size = 10000
def idconv(idkeys):
handle = Entrez.elink(db='pmc', dbfrom='pubmed', id=idkeys)
return [each['LinkSetDb'][0]['Link'][0]['Id'] for each in Entrez.read(handle)]
def search(Term):
handle = Entrez.esearch(db='pubmed', term=Term, retmax=100000000)
record = Entrez.read(handle)
idlist = record["IdList"]
return idlist
mylist = search('"bacterial infections and mycoses"[MeSH Terms] AND pmc cc license[filter]AND ("review"[Publication Type]) AND "journal article"[Publication Type] NOT "letter"[Publication Type] NOT "comment"[Publication Type]')
print(len(idconv(mylist)))
我总是得到错误。
HTTP Error 414: Request-URI Too Large
我该如何解决这个问题?
我一次使用了 600 个块并得到了结果
from Bio import Entrez
Entrez.email = "Afsrtfgdsfg@bobxx.com"
batch_size = 10000
#['LinkSetDb'][0]['Link'][0]['Id']
def idconv(idkeys):
res=[]
for i in range(0, len(idkeys), 600):
handle = Entrez.elink(db='pmc', dbfrom='pubmed', id=idkeys[i:i+600])
for each in Entrez.read(handle):
try:
res.append(each['LinkSetDb'][0]['Link'][0]['Id'])
except IndexError:
pass
return res
def search(Term):
handle = Entrez.esearch(db='pubmed', term=Term, retmax=100000000)
record = Entrez.read(handle)
idlist = record["IdList"]
return idlist
mylist = search('"bacterial infections and mycoses"[MeSH Terms] AND pmc cc license[filter]AND ("review"[Publication Type]) AND "journal article"[Publication Type] NOT "letter"[Publication Type] NOT "comment"[Publication Type]')
print(len(mylist))
print (len(idconv(mylist)))
Biopython 1.67(即将发布)应该通过在需要非常长的 HTTP GET URL 时切换到使用 HTTP POST 来解决这个问题。参见:
https://github.com/biopython/biopython/commit/674da1122593cdc492c3ae480c7c1b7db06343b7
同时,您可以尝试从源代码安装 Biopython 吗?