[Bioperl-l] circular refs/ unattach_seq in SeqFeatureI

Hilmar Lapp hlapp@gnf.org
Fri Jan 24 03:06:25 EST 2003


What about detach_seq()?

I recommend not adding this to remove_SeqFeatures() in Bio::Seq, 
because it is a newly introduced side effect. Can lead to nasty bugs to 
track down if someone (like me in bioperl-db? not sure) was relying on 
remove_SeqFeatures() having no side-effects (which is not a bad 
assumption to make, even though the absence of side-effects is not 
reciprocal to add_SeqFeature). I'd add a separate method, or add a flag 
which is off by default.

	-hilmar

On Thursday, January 23, 2003, at 07:04  PM, Jason Stajich wrote:

> I propose adding a method unattach_seq to SeqFeatureI to allow one to
> insure that no circular references exist for a seqfeature which 
> attached
> to a sequence. I am worried that memory is not be freed for Sequences
> which have features attached when I was doing some iterations with
> sequences that came from a Bio::Index::Fasta and then had features
> attached and the memory allocation blew up on me.   Anyone else had
> similar experiences?
>
> Basically would add the method to SeqFeatureI:
>
> =head2 unattach_seq
>
>  Title   : unattach_seq
>  Usage   : $f->unattach_seq();
>  Function: Insure circular references are cleaned up
>  Returns : none
>  Args    : none
>
>
> =cut
>
> sub { return } # to deal with backwards compatibility more gracefully?
>
>
> # implementation in Bio::SeqFeature::Generic
>
> sub unattach_seq{
>     my $self = shift;
>
>     $self->{'_gsf_seq'} = undef;
>
>     # attach to sub features if they want it
>     foreach ( $self->sub_SeqFeature() ) {
> 	$_->unattach_seq();
>     }
> }
>
> Bio::Seq remove_SeqFeatures would also use this method to unattach
> features from a seq
>
> sub remove_SeqFeatures {
>     my $self = shift;
>
>     return () unless $self->{'_as_feat'};
>     my @feats = @{$self->{'_as_feat'}};
>     $self->{'_as_feat'} = [];
> # add this next line
>     foreach ( @feats ) { $_->unattach_seq() }
>     return @feats;
> }
>
>
> Comments?
>
> -jason
>
> --
> Jason Stajich
> Duke University
> jason at cgt.mc.duke.edu
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>
-- 
-------------------------------------------------------------
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
-------------------------------------------------------------




More information about the Bioperl-l mailing list