0

我正在使用带有 Python 3.x 的 Biopython 从 PubMed 数据库中进行搜索。我正确获得了搜索结果,但接下来我需要提取搜索结果的所有期刊名称(全名,而不仅仅是缩写)。目前我正在使用以下代码:

from Bio import Entrez
from Bio import Medline

Entrez.email = "my_email@gmail.com"
handle = Entrez.esearch(db="pubmed", term="search_term", retmax=20)
record = Entrez.read(handle)
handle.close()

idlist = record["IdList"]

records = list(records)

for record in records:
    print("source:", record.get("SO", "?"))

所以这很好用,但是 record.get("SO"), "?") 只返回期刊的缩写(例如,N Engl J Med,而不是New England Journal of Medicine)。根据我手动 PubMed 搜索的经验,您可以使用缩写词或全名进行搜索,PubMed 将以相同的方式处理它们,所以我想是否还有一些参数可以获取全名?

4

1 回答 1

2

So this works fine, but record.get("SO"), "?") returns only the abbreviation of the journal

No it doesn't. It won't even run due to this line:

records = list(records)

as records isn't defined. And even if you fix that, all you get back from:

idlist = record["IdList"]

is a list of numbers like: ['17510654', '2246389'] that are intended to be passed back via an Entrez.efetch() call to get the actual data. So when you do record.get("SO", "?") on one of these number strings, your code blows up (again).

First, the "SO" field abbreviation is defined to return Journal Title Abbreviation (TA) as part of what it returns. You likely want "JT" Journal Title instead as defined in MEDLINE/PubMed Data Element (Field) Descriptions. But neither of these has anything to do with this lookup.

Here's a rework of your code to get the article title and the title of the journal that it's in:

from Bio import Entrez

Entrez.email = "my_email@gmail.com"  # change this to be your email address
handle = Entrez.esearch(db="pubmed", term="cancer AND wombats", retmax=20)
record = Entrez.read(handle)
handle.close()

for identifier in record['IdList']:
    pubmed_entry = Entrez.efetch(db="pubmed", id=identifier, retmode="xml")
    result = Entrez.read(pubmed_entry)
    article = result['PubmedArticle'][0]['MedlineCitation']['Article']

    print('"{}" in "{}"'.format(article['ArticleTitle'], article['Journal']['Title']))

OUTPUT

> python3 test.py
"Of wombats and whales: telomere tales in Madrid. Conference on telomeres and telomerase." in "EMBO reports"
"Spontaneous proliferations in Australian marsupials--a survey and review. 1. Macropods, koalas, wombats, possums and gliders." in "Journal of comparative pathology"
>

Details can be found in the document: MEDLINE PubMed XML Element Descriptions

于 2017-10-05T05:58:12.133 回答