[BioPython] SyntaxError: Line does not start with '>': .....
Francois-regis Chalaoux
Francois-regis.Chalaoux@sanofi-synthelabo.com
Thu, 11 Oct 2001 18:57:23 +0200
Hi,
Trying to extract information from fasta records I got an error.
I can avoid this error when I insert a blank line between each record but when I download a ncbi fasta file, it does not contain blank line between records by default !!
Is it a bug in BioPython, should I implement myself 'end_sequence()', Is there a bug in my program ?
Read you soon, FR.
==========
fasta_ex.py
==========
import string
from Bio.ParserSupport import AbstractConsumer
class TitleSearchConsumer(AbstractConsumer):
def title(self, line):
# see if the title contains a reference to humans
location = string.find(line, "Homo sapiens")
if location != -1:
# split the string to give us the accession number
result = string.split(line, '|')
print 'Accession:', result[3]
# set up the scanner, consumer and file to parse
from Bio import Fasta
scanner = Fasta._Scanner()
consumer = TitleSearchConsumer()
file = open('U:??python??biopython??taxol2.fasta', 'r')
# parse all fasta records in the file
for n in range(55):
scanner.feed(file, consumer)
file.close()
==========
Traceback
==========
Traceback (most recent call last):
File "E:?softwares?Python21?Pythonwin?pywin?framework?scriptutils.py", line 298, in RunScript
debugger.run(codeObject, __main__.__dict__, start_stepping=0)
File "E:?softwares?Python21?Pythonwin?pywin?debugger?__init__.py", line 60, in run
_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
File "E:?softwares?Python21?Pythonwin?pywin?debugger?debugger.py", line 582, in run
_doexec(cmd, globals, locals)
File "E:?softwares?Python21?Pythonwin?pywin?debugger?debugger.py", line 924, in _doexec
exec cmd in globals, locals
File "U:?python?biopython?fasta_ex.py", line 23, in ?
scanner.feed(file, consumer)
File "E:?softwares?Python21?Bio?Fasta?__init__.py", line 225, in feed
self._scan_record(uhandle, consumer)
File "E:?softwares?Python21?Bio?Fasta?__init__.py", line 229, in _scan_record
self._scan_title(uhandle, consumer)
File "E:?softwares?Python21?Bio?Fasta?__init__.py", line 234, in _scan_title
read_and_call(uhandle, consumer.title, start='>')
File "E:?softwares?Python21?Bio?ParserSupport.py", line 326, in read_and_call
raise SyntaxError, errmsg
SyntaxError: Line does not start with '>':
TTCCCCTGCCTCTCTGGAGAAATGGCTCAGCTCTCATTTAATGCAGCGCTGAAGATGAACGCATTGGGGA