api*_*jic 5 python bioinformatics biopython pubmed
我正在尝试使用Entrez将发布数据导入数据库.搜索部分工作正常,但当我尝试解析时:
from Bio import Entrez
def create_publication(pmid):
handle = Entrez.efetch("pubmed", id=pmid, retmode="xml")
records = Entrez.parse(handle)
item_data = records.next()
handle.close()
Run Code Online (Sandbox Code Playgroud)
...我收到以下错误:
文件"/venv/lib/python2.7/site-packages/Bio/Entrez/Parser.py",第296行,解析引发ValueError("XML文件不代表列表.请使用Entrez.read而不是Entrez .parse")ValueError:XML文件不代表列表.请使用Entrez.read而不是Entrez.parse
这段代码以前一直工作到几天前.有什么想法可能会出错吗?
此外,查看源代码(http://biopython.org/DIST/docs/api/Bio.Entrez-pysrc.html)并尝试按照列出的示例,给出相同的错误:
from Bio import Entrez
Entrez.email = "Your.Name.Here@example.org"
handle = Entrez.efetch("pubmed", id="19304878,14630660", retmode="xml")
records = Entrez.parse(handle)
for record in records:
print(record['MedlineCitation']['Article']['ArticleTitle'])
handle.close()
Run Code Online (Sandbox Code Playgroud)
正如其他评论和GitHub Issue中记录的那样,该问题是由 NCBI Entrez Utilities Developers 故意更改引起的。正如 Jhird 在本期中所记录的,您可以将代码更改为以下内容:
from Bio import Entrez
Entrez.email = "Your.Name.Here@example.org"
handle = Entrez.efetch("pubmed", id="19304878,14630660", retmode="xml")
records = Entrez.read(handle) # Difference here
records = records['PubmedArticle'] # New line here
for record in records:
print(record['MedlineCitation']['Article']['ArticleTitle'])
handle.close()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
482 次 |
| 最近记录: |