Entrez.esearch url bug
1
0
Entering edit mode
6.8 years ago
Joe 21k

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 • 1.9k views
ADD COMMENT
2
Entering edit mode
6.8 years ago

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 COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2437 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6