【问题标题】:HTTPError with example biopython code querying pubmedHTTPError 与示例 biopython 代码查询 pubmed
【发布时间】:2012-12-31 03:36:10
【问题描述】:

我想通过python查询pubmed。我找到了一个很好的生物学相关库来做到这一点: http://biopython.org/DIST/docs/tutorial/Tutorial.html

我在这里找到了一些示例代码: http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc116

from Bio import Entrez
Entrez.email = "A.N.Other@example.com"     
handle = Entrez.egquery(term="orchid")
record = Entrez.read(handle)
for row in record["eGQueryResult"]:
  if row["DbName"]=="pubmed":
    print row["Count"]

当我更改电子邮件并运行此代码时,我收到以下错误:

Traceback (most recent call last):
  File "pubmed.py", line 15, in <module>
    handle = Entrez.egquery(term=my_query)
  File "/usr/lib/pymodules/python2.7/Bio/Entrez/__init__.py", line 299, in egquery
    return _open(cgi, variables)
  File "/usr/lib/pymodules/python2.7/Bio/Entrez/__init__.py", line 442, in _open
    raise exception
urllib2.HTTPError: HTTP Error 404: Not Found

没有太多线索可以找到问题的根源。我不知道它试图访问什么 url。 当我搜索“pubmed entrez urllib2.HTTPError: HTTP Error 404: Not Found”时,我得到 8 个结果,没有一个是相关的(除了这个线程)。

【问题讨论】:

  • 您可以通过捕获异常找出它试图访问的 URL。 try: handle = Entrez.egquery(term="orchid")except Exception as e: pass,然后是print e.geturl()。我得到'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi?term=orchid&amp;tool=biopython&amp;email=A.N.Other%40example.com'
  • 谢谢。我正要这样做。我得到以下网址:eutils.ncbi.nlm.nih.gov/entrez/eutils/…。这是否表明 pubmed 服务器/服务已关闭?
  • 从异常中获取 URL 的好技巧 :)

标签: python api biopython pubmed


【解决方案1】:

这个例子对我有用。看起来这是一个临时的 NCBI 问题,尽管“错误 404”非常不寻常,并且不是我在 Entrez 中看到的典型网络问题。一般来说,对于任何网络资源,在担心出现问题之前给它几个小时或一天的时间。

还有一个您可能希望订阅的 Entrez Utilities 公告邮件列表,但如果最近有计划的服务中断,此处未提及: http://www.ncbi.nlm.nih.gov/mailman/listinfo/utilities-announce

【讨论】:

  • 现在对我也很好。
猜你喜欢
  • 1970-01-01
  • 2013-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-15
  • 1970-01-01
相关资源
最近更新 更多