[Biopython-dev] derive from Seq

Peter Cock p.j.a.cock at googlemail.com
Wed Feb 17 02:48:01 UTC 2010


On Tue, Feb 16, 2010 at 1:09 PM, Brad Chapman <chapmanb at 50mail.com> wrote:
> Hi Matthias;
>
>> I've implemented a class derived from Seq. Many of the Seq functions
>> return Seq. Thus, I can not use those functions because I need
>> instances of the derived class.
>>
>> This can easily be fixed by returning:
>>
>> self.__class__( .. )

We debated this on the mailing list a while ago (I'd hack to search
a little harder to find the thread). While switching to this form makes
subclassing easier in some cases, it doesn't in all.

> More generally, it is interesting that you are subclassing Seq. Can
> you describe your application for this? ... I'd be interested in
> hearing ... additional functionality is needed on a Seq object.
>
> Brad

Last time this (subclassing the Seq object) was mentioned, the
specific use was to change the equality operations to be string
like. This is a change we're considering making in Biopython itself
(and again was something Brad, Michiel and I chatted about
last week - I will be sending out an email about that next week,
I'm on holiday right now and haven't had internet access till
today).

But to echo Brad, use cases for subclassing the Seq are
of great interest.

Regards,

Peter



More information about the Biopython-dev mailing list