2017-10-04 44 views
0

我使用Biopython和Python 3.x从PubMed数据库进行搜索。我正确地获得搜索结果,但接下来我需要提取搜索结果的所有日记名称(全名,而不仅仅是缩写)。目前我使用下面的代码:Biopython和检索日志的全名

from Bio import Entrez 
from Bio import Medline 

Entrez.email = "[email protected]" 
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”),)只返回该杂志的缩写(例如,新英格兰医学杂志“?”,而不是新英格兰医学杂志)。根据我的手册PubMed搜索的经验,您可以使用缩写或全名进行搜索,PubMed将以相同的方式处理这些内容,因此我计算是否还有一些参数可以获取全名?

回答

2

所以这个工作得很好,但record.get( “SO”), “?”)只返回该杂志

没有的缩写它没有。它甚至不会因这条线运行:

records = list(records) 

records没有定义。即使你解决这个问题,你得到回:

idlist = record["IdList"] 

就像号码清单:即旨在传递通过Entrez.efetch()回调得到实际数据['17510654', '2246389']。所以当你在这些数字串中的一个上做record.get("SO", "?")时,你的代码就会再次出现。

首先,"SO"字段缩写定义为返回期刊标题缩写(TA)作为其返回的一部分。您可能需要使用"JT" Journal Title,而不是MEDLINE/PubMed Data Element (Field) Descriptions中定义的。但是这些都与这个查询没有任何关系。

这是你的代码的返工,以获得文章的标题,它是在该杂志的标题:

from Bio import Entrez 

Entrez.email = "[email protected]" # 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'])) 

输出

> 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" 
> 

详细信息可以在文档中找到: MEDLINE PubMed XML Element Descriptions