[Biopython-dev] fixes on the tutorials
Peter Cock
p.j.a.cock at googlemail.com
Mon Oct 17 07:55:54 UTC 2011
On Mon, Oct 17, 2011 at 2:24 AM, carl crott <carlcrott at gmail.com> wrote:
> So the tutorials I'm running through have some bugs in them ...
>
> would anyone like me to fix these?
>
Hi Carl,
What's the bug?
>
> tutorial 2.4.1 should be something like:
>
> from Bio import SeqIO
> handle = open("ls_orchid.fasta", "rU")
> for seq_record in SeqIO.parse(handle, "fasta"):
> print seq_record.id
> print repr(seq_record.seq)
> print len(seq_record)
> handle.close()
>
Your example above looks fine (and the tutorial
used to say that), but the current version is shorter:
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)
We could alternatively (now that we've dropped
Python 2.4) open the handle with a with statement.
The same applies to the GenBank example.
Perhaps you are using an old version of Biopython
(where Bio.SeqIO.parse(...) does not accept a
filename)?
Could you clarify please,
Thanks,
Peter
More information about the Biopython-dev
mailing list