[Biopython] Bio/Entrez/efetch: Getting HTTP Error 500 Bio/Entrez/efetch: Getting HTTP Error 500 Bio/Entrez/efetch: Getting HTTP Error 500

Matej Repič Matej.Repic at ki.si
Fri Feb 17 08:14:10 EST 2012


Fortunately, the fix is quite simple:

Substitute the id=idlist in you fetch line with id=",".join(idlist).


Explanation:

This has something to do with how Pubmed accepts a python list. If you enter PMIDs by hand it works ok, but if you feed it a python list you get an internal server error.

Instead of using the procedure from the Cookbook, where you feed the list:

>>> fetch_handle = Entrez.esearch(db="pubmed", term="orchid", retmax=463)
>>> record = Entrez.read(fetch_handle)
>>> idlist = record["IdList"]
>>> record_handle = Entrez.efetch(db="pubmed", id=idlist, rettype="medline", retmode="text")

Use this slightly modified line for record_handle. With the ",".join(idlist) you convert the idlist python list to a comma separated string, which works as expected. 

>>> fetch_handle = Entrez.esearch(db="pubmed", term="orchid", retmax=463)
>>> record = Entrez.read(fetch_handle)
>>> idlist = record["IdList"]
>>> record_handle = Entrez.efetch(db="pubmed", id=",".join(idlist), rettype="medline", retmode="text")


Kind regards,
Matej



----------------------------------------------------------
Matej Repič
Junior Researcher

Laboratory for Biocomputing and Bioinformatics
National Institute of Chemistry
Hajdrihova 19
SI-1001 Ljubljana POB 660
Slovenia

tel: +386-1-4760457
e-mail: matej.repic at ki.si
----------------------------------------------------------




More information about the Biopython mailing list