[BioPython] Problems with the standalone blast parser.

Brad Chapman chapmanb@arches.uga.edu
Thu, 4 Apr 2002 16:01:20 -0500


Hi Humberto;

> I've got a problem with the Bio.Blast.NCBIStandalone module in 
> biopython-1.00a4 on a redhat 6.2 system. 

[Bad nucleotide input into BLAST causes errors and malformed BLAST
output]

> What I would like is for my 
> script to continue, perhaps printing an error message, instead of crashing.

I had this problem myself with bad input sequences (in my case I was
just BLASTing a bunch of ESTs, some of which were junky), and added a
BlastErrorParser class to NCBIStandalone which allows you to detect
these errors, record them if necessary, and then skip on to the next
record. 

The on-line documentation at:

http://www.bioinformatics.org/bradstuff/bp/tut/Tutorial003.html#toc12

describes this in section 3.1.7. Basically, all you do is use
BlastErrorParser instead of BlastParser, and protect your next() with a
try/except something like:

try:
    next_record = iterator.next()
except NCBIStandalone.LowQualityBlastError, info:
    print "LowQualityBlastError detected in id %s" % info[1]

I think this does what you want. If you have more questions feel free to
ask.

Brad