Question: Entrez.esearch url bug
0
gravatar for jrj.healey
4 months ago by
jrj.healey2.8k
United Kingdom
jrj.healey2.8k wrote:

Currently troubleshooting a Twitter bot that broke down, and it seems to be failing to retrieve from the Entrez API whereas it was working until about 2 weeks ago.

Has something changed in the Entrez API or is this a biopython issue?

It seems to come down to this, though there may be other issues we haven't gotten to yet.

>>> handle = Entrez.esearch(db="pubmed", term="Alikhan NF", field="author", retmode="xml", retmax=10)
>>> record = Entrez.read(handle)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/__init__.py", line 376, in read
    record = handler.read(handle)
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/Parser.py", line 205, in read
    self.parser.ParseFile(handle)
  File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/Bio/Entrez/Parser.py", line 513, in externalEntityRefHandler
    self.dtd_urls.append(url)
UnboundLocalError: local variable 'url' referenced before assignment

So it's complaining about the url being missing, but:

>>> handle.url
'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?term=Alikhan+NF&retmax=10&retmode=xml&tool=biopython&db=pubmed&field=author&email=gibsongroupbot%40gmail.com'

Anyone know if something changed recently?

biopython • 268 views
ADD COMMENTlink modified 4 months ago by Istvan Albert ♦♦ 74k • written 4 months ago by jrj.healey2.8k
2
gravatar for Istvan Albert
4 months ago by
Istvan Albert ♦♦ 74k
University Park, USA
Istvan Albert ♦♦ 74k wrote:

Something is not right with your setup.

Your code works for me, and, in addition, it is quite unlikely that a variable would be missing inside BioPython. That's really what that says there - it is not an API problem, it is a coding problem that claims that a variable is not initialized at all.

Perhaps reinstall the package.

ADD COMMENTlink modified 4 months ago • written 4 months ago by Istvan Albert ♦♦ 74k

Right you are. Unbeknownst to me, the requirements.txt was using biopython 1.65. Moving to 1.70 seems to have fixed it.

ADD REPLYlink written 4 months ago by jrj.healey2.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1010 users visited in the last hour