[BioPython] Error XML Parser and another doubt

Rodrigo faccioli rodrigo_faccioli at uol.com.br
Tue Jan 27 16:31:41 UTC 2009


I have a error about read a XML file which is result from NCBIWWW.qblast.
For this work, I used biopython 1.45 and python 2.5.

The source-code is below:

from Bio.Blast import NCBIXML
import sys

def readxml(filenamexml):
    E_VALUE_THRESH = 0.04
    result_handle = open(filenamexml)
    blast_records = NCBIXML.parse(result_handle)
    for alignment in blast_records:
     for hsp in alignment.hsps:
         if hsp.expect < E_VALUE_THRESH:
             print '****Alignment****'
             print 'sequence:', alignment.title
             print 'length:', alignment.length
             print 'e value:', hsp.expect
             print hsp.query[0:75] + '...'
             print hsp.match[0:75] + '...'
             print hsp.sbjct[0:75] + '...'

def main():
    filenamexml = sys.argv[1]
    readxml(filenamexml)
    print "Done"

main()

The error message is:

Traceback (most recent call last):
  File "src/readxml.py", line 26, in <module>
    main()
  File "src/readxml.py", line 23, in main
    readxml(filenamexml)
  File "src/readxml.py", line 10, in readxml
    for alignment in blast_records:
  File "/usr/lib/python2.5/site-packages/Bio/Blast/NCBIXML.py", line 574, in
parse
    expat_parser.Parse(text, False)
  File "/usr/lib/python2.5/site-packages/Bio/Blast/NCBIXML.py", line 98, in
endElement
    eval("self.%s()" % method)
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/Bio/Blast/NCBIXML.py", line 214, in
_end_BlastOutput_version
    self._header.date = self._value.split()[2][1:-1]
IndexError: list index out of range

I'm very new in Python and BioPython. Sincerely, this is my first program
without tutorial.

I have another doubt: Is there a way (website, program) that read a xml file
from blast and shows like ncbi web site?

Thanks for any help.

-- 
Rodrigo Antonio Faccioli
Ph.D Student in Electrical Engineering
University of Sao Paulo - USP
Engineering School of Sao Carlos - EESC
Department of Electrical Engineering - SEL
Intelligent System in Structure Bioinformatics
http://laips.sel.eesc.usp.br
Phone: 55 (16) 3373-9366 Ext 229
Curriculum Lattes - http://lattes.cnpq.br/1025157978990218



More information about the Biopython mailing list