[Biopython] 400 error, Did Entrez block me or is it something else?

phyrexian.kavu at gmail.com phyrexian.kavu at gmail.com
Thu Dec 5 15:13:02 UTC 2013


Hi David!

I had the same error while trying to download hundreds of sequences from Entrez.efetch, I'm afraid this error cannot be resolved, since as Peter says it is an internet error. I avoided it by making a loop and adding the try - except statements, so whenever this error appeared, the script just returned and tried it again until the sequences were downloaded correctly. I know it is a brute force-like approach, but this was the best solution I could think of, I hope It helps you too.

Miguel


[Theropoda is my profession]

> On 05/12/2013, at 06:31, Peter Cock <p.j.a.cock at googlemail.com> wrote:
> 
> Hi David,
> 
> This is probably an intermittent failure, perhaps the NCBI
> is very busy or there could be a temporary network problem
> somewhere. The chances are it will work tomorrow...
> 
> Peter
> 
> 
>> On Thu, Dec 5, 2013 at 12:05 PM, David Shin <davidsshin at lbl.gov> wrote:
>> Hi all -
>> 
>> During off peak times, I was working on a script that takes a list of gi
>> numbers (a list of 8) for protein sequences to use as input to get fasta
>> sequences via Entrez.efetch. I passed along my email address during the
>> searches. I am still new to python, etc. so had been testing my program.
>> 
>> At some point I started getting the error below, and I'm not sure if it is
>> my program, my web provider, or if ncbi got mad at me. It's been like this
>> for about an hour, so giving up for the night.
>> 
>> Thanks
>> 
>> error:
>> 
>> Traceback (most recent call last):
>>  File "../gi-to-fasta5.py", line 11, in <module>
>>    handle = Entrez.efetch(db="protein", rettype="fasta", retmode="text",
>> id=gi_numbers)
>>  File
>> "/Users/daanac/onda/lib/python2.7/site-packages/Bio/Entrez/__init__.py",
>> line 144, in efetch
>>    return _open(cgi, variables, post)
>>  File
>> "/Users/daanac/onda/lib/python2.7/site-packages/Bio/Entrez/__init__.py",
>> line 460, in _open
>>    raise exception
>> urllib2.HTTPError: HTTP Error 400: Bad Request
>> 
>> 
>> 
>> 
>> 
>> --
>> David Shin, Ph.D
>> Lawrence Berkeley National Labs
>> 1 Cyclotron Road
>> MS 83-R0101
>> Berkeley, CA 94720
>> USA
>> _______________________________________________
>> Biopython mailing list  -  Biopython at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/biopython
> _______________________________________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython




More information about the Biopython mailing list