[BioPython] Syntax error while parsing Blast output
David Garfield
dag23 at duke.edu
Tue Oct 23 21:06:53 UTC 2007
Hey list,
I'm having an issue with the BlastParser and Iterator from
NCBIStandalone. I assume its because NCBI has gone and changed the
output file (again)...or I'm an idiot....but maybe there's a real
problem here.
I'm trying to parse a blast result using the following code:
def filter_blast_results(blast_results, blast_cut_off):
b_parser = NCBIStandalone.BlastParser()
b_iterator = NCBIStandalone.Iterator(blast_results, b_parser)
hit_results = {}
while 1:
b_record = b_iterator.next()
if b_record is None:
break
header = b_record.Header.query
temp = []
for alignment in b_record.alignments:
for hsp in alignment.hsps:
if hsp.expect < blast_cut_off:
temp.append(alignment.title)
#we now remove duplicates from the temp list and add that the the
hit_results
hit_results[header] = remove_duplicates(temp)
return hit_results
And I get the error I've included at the bottom of this message,
something about "SyntaxError: Line does not start with 'Reference':"
I know that blast is working because I can print out what appears to
my untrained eye to be a perfectly good XML of the results I see when
I run blast manually.
Any help would be very much appreciated,
David
Traceback (most recent call last):
File "test_scripts.py", line 7, in <module>
single_blast_sequence.run_2way_blast('single_test_in.fasta','/
Users/dagarfield/urchins/blastdbs/urchin_2.0','/Users/dagarfield/
urchins/blastdbs/urchin_2.0','NA',.001,'/Users/dagarfield/urchins/
urchin_bin/blastall')
File "/private/var/automount/Network/Share2/genomeScans/urchins/
alignment_methods/blast/single_blast_sequence.py", line 57, in
run_2way_blast
input_to_other_blast_matches = filter_blast_results
(blast_results, blast_cut_off)
File "/private/var/automount/Network/Share2/genomeScans/urchins/
alignment_methods/blast/single_blast_sequence.py", line 39, in
filter_blast_results
b_record = b_iterator.next()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/Bio/Blast/NCBIStandalone.py", line 1403, in next
return self._parser.parse(File.StringHandle(data))
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/Bio/Blast/NCBIStandalone.py", line 616, in parse
self._scanner.feed(handle, self._consumer)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/Bio/Blast/NCBIStandalone.py", line 96, in feed
self._scan_header(uhandle, consumer)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/Bio/Blast/NCBIStandalone.py", line 125, in
_scan_header
read_and_call(uhandle, consumer.reference, start='Reference')
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/Bio/ParserSupport.py", line 300, in
read_and_call
raise SyntaxError, errmsg
SyntaxError: Line does not start with 'Reference':
<BlastOutput_db>/Users/dagarfield/urchins/blastdbs/urchin_2.0</
BlastOutput_db>
More information about the Biopython
mailing list