[BioPython] Cannot __add__ two DBSeq objects

Peter biopython at maubp.freeserve.co.uk
Tue Nov 11 08:02:18 EST 2008


On Tue, Nov 11, 2008 at 12:39 PM, Cymon Cox <cy at cymon.org> wrote:
> Hi All,
>
> Two DBSeq objects cannot be concatenated, although the DBSeq object inherits
> __add__ from Seq.

Interesting point - not something I'd considered (nor anyone else until now!)

> It tries to init a new DBSeq object rather than returning a Seq object as would be expected.
> ...
> Presumably, DBSeq needs to overide Seq.__add__
> (Using CVS as of yesterday...)

Clearly we can't create a new DBSeq object (there wouldn't be any
suitable sequence in the database to point to), and returning a Seq
object is sensible.  We should probably continue this discussion on
the dev mailing list (CC'd).

Either we have the DBSeq override the __add__ method (and __radd__),
or we could make the base Seq class always use new Seq objects in
__add__ etc.  This would affect anyone writing their own Seq
subclass...

On balance, I think you're right and its DBSeq which needs to be
changed.  Would you like to tackle this, or should I?  We'd also want
to extend the BioSQL unit test to cover adding DBSeq+DBSeq, DBSeq+Seq,
Seq+DBSeq, DBSeq+MutableSeq, MutableSeq+DBSeq, etc.

Peter


More information about the BioPython mailing list