[Bioperl-l] Subclassing Bio::Seq ? Extending Bio::Perl

JK (Jesper Agerbo Krogh) JK at novozymes.com
Tue Oct 24 10:28:22 EDT 2006


Hi. 

We're trying to "extend" bioperl in our own setup. We have some funtions

that we'd like to "allways" have available on a Bio::Seq-object. As an
example, 
I'd like to have the sequence-digest available on ->digest that just
returns
A hex-encoded message-digest of the sequence in the object. This is
really comfortable
when trying to figure out wether we've got some computations stored in
the cache
for this particular sequence. 

Another example is that we have some fields we want to be mandatory in
the objects,
thus adding additional checks in the constructor is nessesary. 

Our approach has been to "subclass" Bio::Seq in a new object: (Nz::Seq)
and add 
the functionality there. This generally works fine (->translate() calls
->can_call_new()
and instantiates the correct subclassed object. 

But the logic fails when the ->seq of a feature just instantiates a
Bio::PrimarySeq 
without trying to get the subclassed object. 

So the question basically is: 
What is the preferred way of extending/subclassing Bio-perl -objects
with 
our own methods? 

Jesper




More information about the Bioperl-l mailing list