[Biopython] MutableSeq (reverse) complement methods

Peter biopython at maubp.freeserve.co.uk
Wed Jun 16 10:04:41 UTC 2010


Hi all,

I've been meaning to discuss the following issue for a while - I find
this to be an annoying difference between the Seq and MutableSeq
objects:

The Seq object's (reverse) complement method returns a new Seq
object (it has to because we regard the Seq object as read only).

The MutableSeq object'  (reverse) complement method instead
currently modifies the object in place (and has no return value).

Writing general code that expects a sequence object is difficult
because this requires a special case for MutableSeq objects. I
would therefore like to make the MutableSeq object's complement
and reverse_complement methods act like those of the Seq object
by default, and return a new object.

This discrepancy was the main reason why I didn't add (back)
transcribe and translate methods to the MutableSeq object
when they were added to the Seq object.

So, people you use the MutableSeq object, do you find the
in situ complement and reverse_complement methods useful?
If so, should we add an optional argument to the methods to
control this (e.g. in_place or in_situ). Via a warning mechanism
for a few releases, we can then switch over to the new default
behaviour being consistent with the Seq object.

If on the other hand, the in situ (reverse) complement methods
are not seen as useful we can handle this with a simple change
in behaviour (again with warning messages for a few releases).

Peter



More information about the Biopython mailing list