[Bioperl-l] circular refs/ unattach_seq in SeqFeatureI

Jason Stajich jason@cgt.mc.duke.edu
Fri Jan 24 03:04:35 EST 2003


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



More information about the Bioperl-l mailing list