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

Adam Sjøgren adsj at novozymes.com
Mon Nov 6 08:03:21 EST 2006


On Tue, 24 Oct 2006 14:57:02 -0400, Hilmar wrote:

> On Oct 24, 2006, at 1:59 PM, JK ((Jesper Agerbo Krogh)) wrote:

>>> The reason that this is a Bio::PrimarySeq and not a Bio::Seq or your
>>> extension of the latter is that the Perl garbage collector can't deal
>>> with circular references.

>> Doesn't Scalar::Util::weaken solve that?

> You're welcome to test and try. It should be a simple change in  
> Bio::Seq::add_SeqFeature(). You will see that it is this method and  
> not the feature object that makes sure the wrapped primarySeq gets  
> passed as sequence reference. Just change that to creating a new  
> reference to the sequence object and make it a weak reference before  
> passing it to the feature object.

> (The feature object has no requirement (or knowledge) that the  
> referenced sequence object is a PrimarySeq.)

I've tried implementing this approach - the only test that failed was
FootPrinter.t, which I "solved" by not weakening if the object is a
Bio::PrimarySeq.

I am not sure how fragile this approach is; any comments (patch
attached)?

[...]

> I'm not following you why this would make any difference (it would be  
> $seq->message_digest() compared to $seqCompute->message_digest 
> ($seq)), unless what you are saying is that you would like to cache  
> the result of the computation.

You would have to create, or pass around, a $seqCompute object
everywhere your $seq-object's digest was needed, which would be a bit
of a pain?


  Best regards,

    Adam

-- 
                                                          Adam Sjøgren
                                                    adsj at novozymes.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: feature_seq_weaken.patch
Type: text/x-patch
Size: 3675 bytes
Desc: not available
Url : http://lists.open-bio.org/pipermail/bioperl-l/attachments/20061106/3dd65a9d/attachment.bin 


More information about the Bioperl-l mailing list