快速提问--第一次使用生物技术--我只是试着陪审团--在教程的基础上快速地操纵一些东西。
我似乎无法让Entrez.efetch()返回给定文章的网格条件,唯一的方法似乎是我正在做的事情,即:
handle = Entrez.efetch(db="pubmed", id=pmids, rettype="medline", retmode="xml")
records = Entrez.read(handle)其中,pmids是一个公共ID列表。
这将返回以下内容:http://pastie.org/5459700
我尝试过在没有运气的情况下调整每个http://www.ncbi.nlm.nih.gov/books/NBK25499/的rettype和retmode参数。我有什么明显的遗漏吗?
发布于 2012-11-30 21:50:00
这个问题最好在Biopython邮件列表或者http://www.biostars.org/上提出。在那里更有可能找到有Entrez经验的人。
问题是,PMID 23165874的记录没有任何MeSH术语。将该记录的原始XML与有MeSH术语的进行比较。后者有一节开始:
<MeshHeadingList>
<MeshHeading>
<DescriptorName MajorTopicYN="N">ADP Ribose Transferases</DescriptorName>
<QualifierName MajorTopicYN="Y">genetics</QualifierName>
</MeshHeading>
<MeshHeading>
<DescriptorName MajorTopicYN="N">Acinetobacter</DescriptorName>
<QualifierName MajorTopicYN="Y">drug effects</QualifierName>
<QualifierName MajorTopicYN="Y">genetics</QualifierName>
</MeshHeading>
..换句话说,很难得到不存在的东西。
发布于 2014-02-27 09:28:14
这对我来说很管用:
from Bio import Entrez # install with 'pip install biopython'
from Bio.Entrez import efetch, read
Entrez.email = "your@email.com" # register your email
def get_mesh(pmid):
# call PubMed API
handle = efetch(db='pubmed', id=str(pmid), retmode='xml')
xml_data = read(handle)[0]
# skip articles without MeSH terms
if u'MeshHeadingList' in xml_data['MedlineCitation']:
for mesh in xml_data['MedlineCitation'][u'MeshHeadingList']:
# grab the qualifier major/minor flag, if any
major = 'N'
qualifiers = mesh[u'QualifierName']
if len(qualifiers) > 0:
major = str(qualifiers[0].attributes.items()[0][1])
# grab descriptor name
descr = mesh[u'DescriptorName']
name = descr.title()
yield(name, major)
# example output
for name, major in get_mesh(128):
print '{}, {}'.format(name, major)https://stackoverflow.com/questions/13652230
复制相似问题