Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 生物物理学与检索杂志';她的全名_Python 3.x_Biopython_Pubmed - Fatal编程技术网

Python 3.x 生物物理学与检索杂志';她的全名

Python 3.x 生物物理学与检索杂志';她的全名,python-3.x,biopython,pubmed,Python 3.x,Biopython,Pubmed,我正在使用Biopython和Python3.x从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) r

我正在使用Biopython和Python3.x从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,而不是新英格兰医学杂志)。根据我在手动PubMed搜索中的经验,您可以使用缩写或全名进行搜索,PubMed将以相同的方式处理这些内容,因此我想是否还有一些参数可以获取全名

所以这很好,但是record.get(“So”),“?”)只返回日志的缩写

不,没有。由于以下原因,它甚至无法运行:

records = list(records)
未定义as
记录
。即使你解决了这个问题,你从以下方面得到的一切:

idlist = record["IdList"]
是一个数字列表,如:
['17510654','2246389']
,打算通过
Entrez.efetch()
调用传回以获取实际数据。因此,当您对其中一个数字字符串执行
record.get(“So”,“?”)
时,您的代码(再次)爆炸

首先,将
“SO”
字段缩写定义为返回日记标题缩写(TA),作为其返回内容的一部分。您可能希望使用中定义的
“JT”
期刊标题。但这两者都与查找无关

下面是对代码的修改,以获得文章标题及其所在期刊的标题:

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']))
输出

> 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"
>
详细信息可在文档中找到:

所以这很好,但是record.get(“So”),“?”)只返回日志的缩写

不,没有。由于以下原因,它甚至无法运行:

records = list(records)
未定义as
记录
。即使你解决了这个问题,你从以下方面得到的一切:

idlist = record["IdList"]
是一个数字列表,如:
['17510654','2246389']
,打算通过
Entrez.efetch()
调用传回以获取实际数据。因此,当您对其中一个数字字符串执行
record.get(“So”,“?”)
时,您的代码(再次)爆炸

首先,将
“SO”
字段缩写定义为返回日记标题缩写(TA),作为其返回内容的一部分。您可能希望使用中定义的
“JT”
期刊标题。但这两者都与查找无关

下面是对代码的修改,以获得文章标题及其所在期刊的标题:

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']))
输出

> 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"
>
详细信息可在文档中找到: