[BioPython] Biopython GenBank

JINLING HUANG jinling@cs.uga.edu
Tue, 19 Nov 2002 09:25:25 -0500 (EST)


Hello,

I am writing a script to parse GenBank records using biopython.
Essentially I just copied the script from the biopython tutorial as
follows:

from Bio import GenBank

gb_file = 'ncbiSamples'

gb_handle = open(gb_file, 'r')
fp1 = open('ncbiSeq', 'w+')

feature_parser = GenBank.FeatureParser()

gb_iterator = GenBank.Iterator(gb_handle, feature_parser)

while 1:
    cur_record = gb_iterator.next()
    if cur_record is None:
       break
    print cur_record.id
    sequence=cur_record.seq.data
    print sequence
    fp1.write('>'+cur_record.id[:-2]+'\n'+sequence+'\n')


The script worked well for some records. The I got error messages:

Traceback (most recent call last):
  File "getSeq.py", line 13, in ?
    cur_record = gb_iterator.next()
  File "/bio/python2.2/lib/python2.2/site-packages/Bio/GenBank/__init__.py", line
    183, in next return self._parser.parse(File.StringHandle(data))
  File "/bio/python2.2/lib/python2.2/site-packages/Bio/GenBank/__init__.py", line
    268, in parse self._scanner.feed(handle, self._consumer)
  File "/bio/python2.2/lib/python2.2/site-packages/Bio/GenBank/__init__.py", line
    1252, in feed self._parser.parseFile(handle)
  File "/bio/python2.2/lib/python2.2/site-packages/Martel/Parser.py", line
    338, in parseFile self.parseString(fileobj.read())
  File "/bio/python2.2/lib/python2.2/site-packages/Martel/Parser.py", line
    366, in parseString self._err_handler.fatalError(result)
  File "/bio/python2.2/lib/python2.2/xml/sax/handler.py", line 38, in
    fatalError raise exception
Martel.Parser.ParserPositionException: error parsing at or beyond
character 1525


Has everyone encountered the same problem? How do we get rid of this
problem?

Best wishes,

Jinling Huang