[Biopython] Biopython Digest, Vol 102, Issue 16

Peter Thorpe pjthorpe at gmail.com
Mon Jun 27 16:06:06 UTC 2011


On 27 June 2011 17:00, <biopython-request at lists.open-bio.org> wrote:

> Send Biopython mailing list submissions to
>        biopython at lists.open-bio.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.open-bio.org/mailman/listinfo/biopython
> or, via email, send a message with subject or body 'help' to
>        biopython-request at lists.open-bio.org
>
> You can reach the person managing the list at
>        biopython-owner at lists.open-bio.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Biopython digest..."
>
>
> Today's Topics:
>
>   1. biopython cookbook error (A M Torres, Hugo)
>   2. Re: biopython cookbook error (Brad Chapman)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 27 Jun 2011 04:00:37 -0300
> From: "A M Torres, Hugo" <mnemonico at posthocergopropterhoc.net>
> Subject: [Biopython] biopython cookbook error
> To: biopython at lists.open-bio.org
> Message-ID:
>        <BANLkTim__OXzYwa5FXnaj8b_h0vrnOQTBG3STfdpvAUM_+o=TQ at mail.gmail.com
> >
> Content-Type: text/plain; charset=UTF-8
>
> 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
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 27 Jun 2011 06:38:34 -0400
> From: Brad Chapman <chapmanb at 50mail.com>
> Subject: Re: [Biopython] biopython cookbook error
> To: biopython at lists.open-bio.org
> Message-ID: <20110627103834.GA22214 at sobchak>
> Content-Type: text/plain; charset=us-ascii
>
> Hugo;
> Thanks for the e-mail and reporting the problem you were running
> into.
>
> > 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:
> [...]
> > Which outputs the error:
> [...]
> > > TypeError: Need a file handle, not a string (i.e. not a filename)
>
> It sounds like you have an old version of Biopython. SeqIO was
> changed a few releases ago to support string filenames instead of
> handles for the reason you mention: to make it easier for new Python
> developers. See FAQ #14 for more information, and #3 for information
> about checking your version of Biopython:
>
> http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc5
>
> If you have easy_install available, you can update with:
>
> sudo easy_install -U biopython
>
> Hope this helps,
> Brad
>
>
> Subject: Re: [Biopython] biopython cookbook error

Hi All,

This is my first post too... The current version of biopython and current
cookbook example does work fine. So, as Brad says, you may be using an old
version.

Pete Thorpe

> ------------------------------
>
> _______________________________________________
> Biopython mailing list  -  Biopython at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython
>
>
> End of Biopython Digest, Vol 102, Issue 16
> ******************************************
>



More information about the Biopython mailing list