Bravo, maestro! ",".join(idlist) has solved the problem. Many thanks!
Hi everyone,
I'm trying to run an example from the Biopython cookbook and it returns an error. I'm wondering if anything serious has changed in the PubMed API recently...
from Bio import Medline
handle = Entrez.esearch(db="pubmed", term="orchid", retmax=463)
record = Entrez.read(handle)
idlist = record["IdList"]
handle = Entrez.efetch(db="pubmed", id=idlist, rettype="medline", retmode="text")
I'm getting:
HTTPError Traceback (most recent call last)
<ipython console> in <module>()
python-2.7.1-shared/lib/python2.7/site-packages/biopython-1.58-py2.7-linux-x86_64.egg/Bio/Entrez/__init__.pyc in efetch(db, **keywds)
111 variables = {'db' : db}
112 variables.update(keywds)
--> 113 return _open(cgi, variables)
114
115 def esearch(db, term, **keywds):
python-2.7.1-shared/lib/python2.7/site-packages/biopython-1.58-py2.7-linux-x86_64.egg/Bio/Entrez/__init__.pyc in _open(cgi, params, post)
358 handle = urllib2.urlopen(cgi)
359 except urllib2.HTTPError, exception:
--> 360 raise exception
361
362 return handle
HTTPError: HTTP Error 500: Internal server error
I checked and idlist is, as expected, a list of PubMed IDs as strings, so Entrez.esearch seems to be working.
['22499266', '22496851', '22483052', '22418255', '22415688', '22408409', '22397405', '22391855', '22375900', '22367365', ...]
Would appreciate your help!
1 answer
Which version of Biopython are you using? My hunch would be this FAQ entry from the tutorial - http://biopython.org/DIST/docs/tutorial/Tutorial.html
Why has my script using Bio.Entrez.efetch() stopped working? This could be due to NCBI changes in February 2012 introducing EFetch 2.0. First, they changed the default return modes - you probably want to add retmode="text" to your call. Second, they are now stricter about how to provide a list of IDs – Biopython 1.59 onwards turns a list into a comma separated string automatically.
Try updating your Biopython or using ",".join(idlist) instead.
Log in to answer this question.