[BioPython] What to do with BLAST XML syntax error?

Jolanda Reek kawaiichiko at gmail.com
Sun Jun 17 18:34:05 UTC 2007


Hello,

I'm using BioPython to send some protein sequences to the NCBI WWWBlast
server and parse the output. Sometimes, like once every few minutes, instead
of giving the output, BLAST returns a XML syntax error. It states something
along the lines of 'SyntaxError: This XML doesn't start with...'. and then
BioPython can't parse the output (duh). I've written a try/except statement
to resend the protein query when this problem occurs,however, sometimes the
problem occurs multiple times in a row, leaving me with no other option then
to nest try/except statements (= ugly code).

     print "BLAST search: "+proteinLijst[x].id
     try:
      acNr, evalueNr = blast(proteinLijst[x].sequentie)
      idList.append(acNr)
     except SyntaxError:
      print "SyntaxError: BLAST server send incomplete results. Resubmitting
query..."
      try:
       acNr, evalueNr = blast(proteinLijst[x].sequentie)
       idList.append(acNr)
      except SyntaxError:
       print "SyntaxError: BLAST server send incomplete results.
Resubmitting query..."
       try:
        acNr, evalueNr = blast(proteinLijst[x].sequentie)
        idList.append(acNr)
       except SyntaxError:
        print "SyntaxError: BLAST server send incomplete results.
Resubmitting query..."
        acNr, evalueNr = blast(proteinLijst[x].sequentie)
        idList.append(acNr)

<< Etc. Yuck. It works, but it is still yuck. :)

Can anyone help me think up a solution? And what is causing those faulty XML
files? (Avoiding the problem altogether is better than fixing it.)

Thank you.

Chiko.



More information about the Biopython mailing list