Réf. : Re: [BioPython] SyntaxError: Line does not start with '>': .....
Francois-regis Chalaoux
Francois-regis.Chalaoux@sanofi-synthelabo.com
Fri, 12 Oct 2001 11:04:01 +0200
It works fine, thanks.
Ok for your advice as describe in Biopython Tutorial and CookBook (06/05/2001)
FR.
jchang@SMI.Stanford.EDU%internet le 11/10/2001 22:26:58
Pour : Francois-regis Chalaoux/FR-LABEGE/RESEARCH/SANOFI@Research
BioPython@biopython.org%internet@WTFR
cc :
Objet : Re: [BioPython] SyntaxError: Line does not start with '>': .....
X-Sender: jchang@smi.stanford.edu (Unverified)
Try adding the lines:
from Bio import File
(after this line)
>file = open('U:??python??biopython??taxol2.fasta', 'r')
file = File.UndoHandle(file)
The _Scanner class actually saves some state in the file handle
between calls, and really wants to be called with an UndoHandle.
Without it, it loses information.
BTW, the _Scanner class (actually all classes beginning with an
underscore) is private to the package, and should not be used
outside. The preferred method of reading through the file is with an
Iterator and RecordParser. It's probably a bug that the class is
documented in the module docstring...
Please let me know if this does not fix the problem.
Jeff
At 6:57 PM +0200 10/11/01, Francois-regis Chalaoux wrote:
>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
>_______________________________________________
>BioPython mailing list - BioPython@biopython.org
>http://biopython.org/mailman/listinfo/biopython