[Biopython] Qblast

Chris Mitchell chris.mit7 at gmail.com
Wed Mar 27 03:49:00 UTC 2013


You could do a try except block and reschedule the job in 10 minutes or
whatever.  It would require a few tweaks to your setup, like:
while jobs and <time check function>:
    try:
        job = jobs[0]
        <call function to process job>
        jobs.pop(0)#pop the job when it's done, if it finished without
error you reach this point
    except urllib2.HTTPError, error:
        print 'error in blast!', error
        time.sleep(600)#wait 10 minutes

This will also tell you the error so you can know why it's failing.


On Tue, Mar 26, 2013 at 11:12 PM, Dan <dan837446 at gmail.com> wrote:

> Hi, I have a script that runs Qblast over a multiline fasta file
> (protein).. the relevant code is:
>
> for seq_record in SeqIO.parse(args.infile,"fasta"):
> # For each individual fasta record in a multiline fasta file..
> # check that it's an appropriate time to search and wait if not
>     <random irrelevant code to do this: I only search between 10pm and 5AM
> EST>
> # do the search
>
>     blast_result_handle = NCBIWWW.qblast(args.program, args.database, \
>     seq_record.format("fasta"),expect=args.expect,
> hitlist_size=args.num_hits, \
>     service=args.service)
>     time.sleep(5)
>
> Most of the time it works fine, but every so often it fails, like so:
>
> Traceback (most recent call last):
>   File "remote_blast_multiline_fasta.py", line 174, in <module>
>     service=args.service)
>   File "/usr/lib/pymodules/python2.7/Bio/Blast/NCBIWWW.py", line 122, in
> qblast
>     handle = urllib2.urlopen(request)
>   File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
>     return _opener.open(url, data, timeout)
>   File "/usr/lib/python2.7/urllib2.py", line 406, in open
>     response = meth(req, response)
>   File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
>     'http', request, response, code, msg, hdrs)
>   File "/usr/lib/python2.7/urllib2.py", line 444, in error
>     return self._call_chain(*args)
>   File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
>     result = func(*args)
>   File "/usr/lib/python2.7/urllib2.py", line 527, in http_error_default
>     raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
> urllib2.HTTPError: HTTP Error 502: Bad Gateway
>
> I'm assuming that this is a "overloaded blast server" error..
> Is there any way of handling this error in better way? Sorry if this
> question is a bit general.
> _______________________________________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>



More information about the Biopython mailing list