[BioPython] parsing blast results - SyntaxError: I missed the Length in an alignment header

Olivier Sand oly at scmbb.ulb.ac.be
Thu Jun 17 05:47:46 EDT 2004


Hi,

I have been trying to use the code for parsing WWW blast results you  
give in the biopython tutorial with biopython 1.30. But I get an error  
message mentionned in the title of this mail. From looking at the  
mailling list, I understand this used to be bug due to changing blast  
output format, but has been fixed in version 1.30. Would it be possible  
the blast format changed again, or am I doing something wrong?

Here is the code I use:
#! /usr/bin/python

from Bio import Fasta

file_for_blast = open('m_cold.fasta', 'r')
f_iterator = Fasta.Iterator(file_for_blast)

f_record = f_iterator.next()

from Bio.Blast import NCBIWWW
b_results = NCBIWWW.blast(program='blastn', database='nr',  
query=f_record, format_type = "HTML")

save_file = open('blast_m_cold.out', 'w')
blast_results = b_results.read()
save_file.write(blast_results)
save_file.close()

import cStringIO
string_result_handle = cStringIO.StringIO(blast_results)

b_parser = NCBIWWW.BlastParser()
b_record = b_parser.parse(string_result_handle)

Here is the content of the file m_cold.fasta:
 >gi|8332116|gb|BE037100.1|BE037100 MP14H09 MP Mesembryanthemum  
crystallinum cDNA 5' similar to cold acclimation protein, mRNA sequence
CACTAGTACTCGAGCGTNCTGCACCAATTCGGCACGAGCAAGTGACTACGTTNTGTGAACAGAAAATGGG
GAGAGAAATGAAGTACTTGGCCATGAAAACTGATCAATTGGCCGTGGCTAATATGATCGATTCCGATATC
AATGAGCTTAAAATGGCAACAATGAGGCTCATCAATGATGCTAGTATGCTCGGTCATTACGGGTTTGGCA
CTCATTTCCTCAAATGGCTCGCCTGCCTTGCGGCTATTTACTTGTTGATATTGGATCGAACAAACTGGAG
AACCAACATGCTCACGTCACTTTTAGTCCCTTACATATTCCTCAGTCTTCCATCCGGGCCATTTCATCTG
TTCAGAGGCGAGGTCGGGAAATGGATTGCCATCATTGCAGTCGTGTTAAGGCTGTTCTTCAACCGGCATT
TCCCAGTTTGGCTGGAAATGCCTGGATCGTTGATACTCCTCCTGGTGGTGGCACCAGACTTCTTTACACA
CAAAGTGAAGGAGAGCTGGATCGGAATTGCAATTATGATAGCGATAGGGTGTCACCTGATGCAAGAACAT
ATCAGAGCCACTGGTGGCTTTTGGAATTCCTTCACACAGAGCCACGGAACTTTTAACACAATTGGGCTTA
TCCTTCTACTGGCTTACCCTGTCTGTTTATGGTCATCTTCATGATGTAGTAGCTTAGTCTTGATCCTAAT
CCTCAAATNTACTTTTCCAGCTCTTTCGACGCTCTTGCTAAAGCCCATTCAATTCGCCCCATATTTCGCA
CACATTCATTTCACCACCCAATACGTGCTCTCCTTCTCCCTCTCTCCCTCTCCTCCCTCTTTTCTTCCTC
TCACTTCTCTTCTCTTCTCTTCTTCAATACTCCCCTGGAGCGCCCTCTTCACCTCCCTACTCTCTACTCC
TCTCTCTCACTCTCTCTTCCTCTCTTATCTCTCTCCTCCTCTCCTTCTCATCCCTCCTCCTTCTCTTCCT
TTTCTTCTTTCTATCCACGCGCCATCCTCCCTCTTCCCTCTTCCCTTCTCTCTCCTCTCTTTCTCTCTCC
TCTCTTCCTCATCTCACCACCTCCTCCTCTCTTTCTTCCGTCCTCCTTCCCTTCCTTCTTC

Here is the error message:
Traceback (most recent call last):
   File "/Users/oly/Programmes/python/blast_and_parse.py", line 22, in ?
     b_record = b_parser.parse(string_result_handle)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/Bio/Blast/NCBIWWW.py", line 47, in parse
     self._scanner.feed(handle, self._consumer)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/Bio/Blast/NCBIWWW.py", line 99, in feed
     self._scan_rounds(uhandle, consumer)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/Bio/Blast/NCBIWWW.py", line 242, in  
_scan_rounds
     self._scan_alignments(uhandle, consumer)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/Bio/Blast/NCBIWWW.py", line 325, in  
_scan_alignments
     self._scan_pairwise_alignments(uhandle, consumer)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/Bio/Blast/NCBIWWW.py", line 348, in  
_scan_pairwise_alignments
     self._scan_one_pairwise_alignment(uhandle, consumer)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/Bio/Blast/NCBIWWW.py", line 379, in  
_scan_one_pairwise_alignment
     self._scan_alignment_header(uhandle, consumer)
   File  
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
python2.3/site-packages/Bio/Blast/NCBIWWW.py", line 417, in  
_scan_alignment_header
     raise SyntaxError, "I missed the Length in an alignment header"
SyntaxError: I missed the Length in an alignment header

Thanks

Olivier

------------------------------------------------------------------------ 
----------------------
Olivier Sand
The aMAZE Project				Tel.: +32(0)2 650 5427
SCMBB - ULB					Fax: +32(0)2 650 5425
Campus Plaine, bd du Triomphe - CP263
B-1050 Bruxelles
Belgium



More information about the BioPython mailing list