[Biopython-dev] Bio.SeqIO.convert function?

Eric Talevich eric.talevich at gmail.com
Tue Jul 28 15:49:29 UTC 2009

Hi Peter,

On Tue, Jul 28, 2009 at 9:14 AM, Peter <biopython at maubp.freeserve.co.uk>wrote:

> On Tue, Jul 28, 2009 at 12:19 PM, Peter<biopython at maubp.freeserve.co.uk>
> wrote:
> >
> > Any thoughts? Would this all just make SeqIO too complicated?
> >
> The idea of the Bio.SeqIO.convert function was two fold:
> (1) Syntactic sugar (and for this alone I wouldn't add it)
> (2) Faster file format conversion (e.g. for scripts or pipelines)
This would be nice if it was implemented in AlignIO and TreeIO, too. The
naming is pretty intuitive, and the concept is general, so I don't think it
makes the API any more difficult to understand. (Personally, I like having a
sugary API to use inside ipython.)

But the main reason I piped up was that some time ago, we observed that some
popular Python libraries have functions that can accept either an open file
handle or a file name, and do the right thing. The xml.etree module in the
standard lib does this by checking if the 'file' argument has a 'read'
method, and if not, trying to open it. I didn't see any reason for
Bio.TreeIO to be any fussier than the standard library, so...


Implementing this for SeqIO.convert() (or ideally, read/parse/write on all
the *IO modules) would make it very nice for files other than stdin and
stdout -- otherwise, the user needs to open and maybe close two file handles
before calling convert().

What do you think?


More information about the Biopython-dev mailing list