[Biopython-dev] Relaxing SeqIO, AlignIO, etc write functions?

Peter biopython at maubp.freeserve.co.uk
Mon Mar 15 15:40:20 UTC 2010


Hi all (especially Eric),

As recently discussed SeqIO and AlignIO will now take filenames as
well as handles. This matches the existing behaviour of Bio.Nexus,
Eric's Bio.Phylo, and several big 3rd partly libraries like ReportLab.
http://lists.open-bio.org/pipermail/biopython-dev/2010-February/007352.html
I've updated most of the tutorial to take advantage of this, and quickly
got used less typing when working at the Python prompt. It does make
things easier, and I probably should have conceded this earlier.

It made me wonder about relaxing another restraint of the SeqIO
and AlignIO write functions - they currently insist on a list or iterator
of records or alignments. Giving a single object raises an error,
but we could handle this unambiguously. Amusingly Eric just
updated Bio.Phylo to match this strict behaviour - one reason I
sat down and wrote this email.

So, should we continue to insist on:

record = SeqRecord(...)
SeqIO.write([record], filename, format)

or should be relax a little more and allow this too?:

record = SeqRecord(...)
SeqIO.write(record, filename, format)

For SeqIO and AlignIO we can do a simple isinstance check
for a SeqRecord or alignment object - there isn't really a
problem with ambiguity here. Probably also try for Phylo?

What's the general consensus on the dev list?

Peter



More information about the Biopython-dev mailing list