[Biopython] biopython cookbook error

A M Torres, Hugo mnemonico at posthocergopropterhoc.net
Mon Jun 27 07:00:37 UTC 2011


Hi, I am new to this list excuse me if this is not the appropriate place to
report this:

I am just trying to teach myself some biopython and at section "2.4.1  Simple
FASTA parsing example" of the biopython tutorial it suggests us to run this
code:

from Bio import SeqIO
> for seq_record in SeqIO.parse("ls_orchid.fasta", "fasta"):
>     print seq_record.id
>     print repr(seq_record.seq)
>     print len(seq_record)
>
>
Which outputs the error:

Traceback (most recent call last):
> File "simple_parser_2_4_1.py", line 4, in <module>
> for seq_record in SeqIO.parse("ls_orchid.fasta", "fasta"): #this seems
> wrong in the tutorial
> File "/usr/lib/pymodules/python2.6/Bio/SeqIO/__init__.py", line 424, in
> parse
> raise TypeError("Need a file handle, not a string (i.e. not a filename)")
> TypeError: Need a file handle, not a string (i.e. not a filename)
>

Python novices like me might have a problem understanding what a "file
handle" is. I tryed this and it seems to work:

from Bio import SeqIO
>
> with open("ls_orchid.fasta", 'rU') as data:
>     for seq_record in SeqIO.parse(data, "fasta"):
>         print seq_record.id
>         print repr(seq_record.seq)
>         print len(seq_record)
>

Maybe someone here can help me notify whoever maintains the tutorial.

Thanks,

Hugo Torres



More information about the Biopython mailing list