【问题标题】:Entrez (biopython): how to restrict the term search to a specific journal? (PubMed)Entrez (biopython):如何将术语搜索限制在特定期刊? (考研)
【发布时间】:2019-03-04 07:36:24
【问题描述】:

我想获取特定期刊中与特定术语/主题相关的所有文章。

我正在尝试通过 PubMed 使用 Biopython 中包含的 Entrez 包来执行此操作。 相应的 Advanced PubMed 搜索是: (主题/术语)和“期刊名称”[期刊]

到目前为止,我所尝试的都是基于 Marco Bonzanini 编写的代码(包含原始代码 https://gist.github.com/bonzanini/5a4c39e4c02502a8451d 的 GitHub 页面)。

from Bio import Entrez
def search(query):
    Entrez.email = 'example@mail.com'
    handle = Entrez.esearch(db='pubmed',
                        sort='relevance',
                        retmax='20',
                        retmode='xml',
                        term=query,
                        mindate= "2018/11",
                        maxdate= "2019/02")
     results = Entrez.read(handle)
     return results

 def fetch_details(id_list):
     ids = ','.join(id_list)
     Entrez.email = 'example@mail.com'
     handle = Entrez.efetch(db='pubmed',
                       retmode='xml',
                       id=ids)
    results = Entrez.read(handle)
    return results

if __name__ == '__main__':
    results = search('attention')
    id_list = results['IdList']
    papers = fetch_details(id_list)
    for i, paper in enumerate(papers['PubmedArticle']):
        print("%d) %s" % (i + 1, paper['MedlineCitation']['Article']['ArticleTitle']))

【问题讨论】:

  • 这里的问题是什么?您提供的代码似乎工作得很好。在相关的说明中,如果您不想打扰 BioPython 并且只需在 Unix 命令行上完成整个操作,您可能需要查看 Entrez Direct。将搜索词 attention 更改为 "crispr" AND "Cell"[Journal] 之类的内容,您应该可以开始了。

标签: python biopython pubmed


【解决方案1】:

例如要查找出现在《实验儿童心理学杂志》上的文章,请像这样更改您的主体:

if __name__ == '__main__':
    results = search('attention')
    id_list = results['IdList']
    papers = fetch_details(id_list)
    i = 0
    for paper in papers['PubmedArticle']:
        if (paper['MedlineCitation']['Article']['Journal']['Title'] ==
            'Journal of experimental child psychology'):
            i += 1
            print("%d) %s" % (i, paper['MedlineCitation']['Article']
                              ['ArticleTitle']))

【讨论】:

    猜你喜欢
    • 2023-02-06
    • 1970-01-01
    • 2012-04-05
    • 1970-01-01
    • 1970-01-01
    • 2016-10-26
    • 1970-01-01
    • 2019-02-07
    • 1970-01-01
    相关资源
    最近更新 更多