[Biopython] Qblast

Dan dan837446 at gmail.com
Wed Mar 27 03:12:29 UTC 2013


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.



More information about the Biopython mailing list