【问题标题】:Different result on browser search vs Bio.entrez search浏览器搜索与 Bio.entrez 搜索的不同结果
【发布时间】:2020-10-21 01:42:37
【问题描述】:

当我使用 Bio Entrez 进行搜索时,我得到了不同的结果。例如,当我使用查询“covid side effect”在浏览器上搜索时,我得到 344 个结果,而当我使用 Bio Entrez 时我只得到 92 个结果。这是我使用的代码。

from Bio import Entrez
Entrez.email = "Your.Name.Here@example.org"
handle = Entrez.esearch(db="pubmed", retmax=40, term="covid side effect", idtype="acc")
record = Entrez.read(handle)
handle.close()
print(record['Count'])

我希望有人可以帮助我解决这种差异。

【问题讨论】:

  • 奇怪的是,它在 PubMed 下的 ncbi.nlm.nih.gov/search/all/?term=%22covid+side+effect%22 看起来像 93(匹配 Biopython),但是当你点击 pubmed.ncbi.nlm.nih.gov/… 时它是 >350
  • @Chris_Rands 没错,这真的很奇怪。这似乎是一个众所周知的问题。我根本找不到这个问题的解决方案。数量可能会增加,因为可能会有新的出版物:D
  • @Chris_Rands,我找到了解决此问题的方法,但我认为 pubmed API 没有返回相同的结果肯定有问题

标签: python bioinformatics biopython pubmed


【解决方案1】:

由于某种原因,无论是 R api 还是 Python API,每个人似乎都有同样的问题。我找到了一种解决方法来获得相同的结果。它很慢,但可以完成工作。如果您的结果小于 10k,您可能会使用 Selenium 来获取 pubmedid。否则,我们可以使用下面的代码抓取数据。我希望这对将来的某人有所帮助。

import requests
# # Custom Date Range
# req = requests.get("https://pubmed.ncbi.nlm.nih.gov/?term=covid&filter=dates.2009/01/01-2020/03/01&format=pmid&sort=pubdate&size=200&page={}".format(i))

# # Custom Year Range
# req = requests.get("https://pubmed.ncbi.nlm.nih.gov/?term=covid&filter=years.2010-2019&format=pmid&sort=pubdate&size=200&page={}".format(i))


# #Relative Date 
# req = requests.get("https://pubmed.ncbi.nlm.nih.gov/?term=covid&filter=datesearch.y_1&format=pmid&sort=pubdate&size=200&page={}".format(i))

# # filter language 
# # &filter=lang.english

# # filter human 
# #&filter=hum_ani.humans

# Systematic Review
#&filter=pubt.systematicreview

# Case Reports 
# &filter=pubt.casereports

# Age
# &filter=age.newborn

search = "covid lungs"
# search_list = "+".join(search.split(' '))

def id_retriever(search_string):
    string = "+".join(search_string.split(' '))
    result = []
    old_result = len(result)
    for page in range(1,10000000):
        req = requests.get("https://pubmed.ncbi.nlm.nih.gov/?term={string}&format=pmid&sort=pubdate&size=200&page={page}".format(page=page,string=string))

        for j in req.iter_lines():
            decoded = j.decode("utf-8").strip(" ")
            length = len(decoded)
            if "log_displayeduids" in decoded and length > 46:
                data = (str(j).split('"')[-2].split(","))
                result = result + data
                data = []
        new_result = len(result)
        if new_result != old_result:
            old_result = new_result
        else:
            break
    return result

ids=id_retriever(search)
len(ids)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-27
    • 1970-01-01
    • 2014-12-22
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    • 2017-05-10
    • 2015-05-06
    相关资源
    最近更新 更多