[BioPython] What to do with BLAST XML syntax error?
Julius Lucks
lucks at fas.harvard.edu
Sun Jun 17 14:52:03 EDT 2007
Why not wrap the try/except block in a while loop:
done = 0
while not done:
#wait some time
try:
#your code
done = 1
except SyntaxError:
#your code
Julius
------------------------------------------------------------------------
---
http://www.openwetware.org/wiki/User:Julius_B._Lucks
------------------------------------------------------------------------
---
On Jun 17, 2007, at 2:34 PM, Jolanda Reek wrote:
> 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.
> _______________________________________________
> BioPython mailing list - BioPython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
More information about the BioPython
mailing list