[BioPython] Copy Constructors for Bio.Seq.Seq?

Peter biopython at maubp.freeserve.co.uk
Sun Oct 5 11:06:57 UTC 2008


On Sat, Oct 4, 2008 at 10:50 PM, Bryan Lunt <lunt at ctbp.ucsd.edu> wrote:
> Greetings All!
> I would like to make the following humble suggestion:
> A copy-constructor for Bio.Seq.Seq would be helpful, ...

You can use the string idiom of my_seq[:] to make a copy of a Seq object.

> currently it
> seems that calling Bio.Align.Generic.Alignment.add_sequence on a
> Seq object breaks because it tries to initialize a new Seq object on
> whatever data you provided, and there is no copy-constructor, nor does
> Bio.Align.Generic.Alignment.add_sequence handled just adding a Seq
> object directly.

Yes, the Bio.Align.Generic.Alignment.add_sequence() method currently
expects a string (which its docstring is fairly clear about), and
giving it a Seq does fail.  I suppose allowing it to take a Seq object
would be sensible (with a check on the alphabet being compatible with
that declared for the alignment).

We have been debating making the generic Alignment a little more list
like, by allowing .append() or .extend() for use with SeqRecord
objects (Bug 2553).
http://bugzilla.open-bio.org/show_bug.cgi?id=2553

> Thanks for considering this, I think this addition will help make
> client-code cleaner.

Would the SeqRecord append/extend idea suit you just as well?

Peter



More information about the Biopython mailing list