Commit 5311ca65 authored by Graham McVicker's avatar Graham McVicker
Browse files

removed potential memory leak problems with external feature adaptors

parent d36d1cd9
......@@ -776,6 +776,36 @@ sub dnadb {
}
=head2 deleteObj
Arg [1] : none
Example : none
Description: Cleans up circular reference loops so proper garbage collection
can occur.
Returntype : none
Exceptions : none
Caller : DBAdaptorContainer::DESTROY
=cut
sub deleteObj {
my $self = shift;
#print "called deleteObj on DBAdaptor\n";
#clean up external feature adaptor references
if(exists $self->{'_xf_adaptors'}) {
foreach my $key (keys %{$self->{'_xf_adaptors'}}) {
$self->{'_xf_adaptors'}->{$key} = undef;
}
}
#call the superclass deleteObj method
$self->SUPER::deleteObj;
}
###########################################################
#
# Support for DAS
......@@ -881,9 +911,9 @@ sub add_ExternalFeatureAdaptor {
}
#if the track name exists add numbers to the end until a free name is found
if(exists $self->{'_xf_adaptor'}->{"$track_name"}) {
if(exists $self->{'_xf_adaptors'}->{"$track_name"}) {
my $num = 2;
$num++ while(exists $self->{'_xf_adaptor'}->{"$track_name$num"});
$num++ while(exists $self->{'_xf_adaptors'}->{"$track_name$num"});
$self->{'_xf_adaptors'}->{"$track_name$num"} = $adaptor;
} else {
$self->{'_xf_adaptors'}->{"$track_name"} = $adaptor;
......@@ -1541,7 +1571,6 @@ sub get_all_Transcript_id{
}
=head2 delete_Exon
Arg [1] : none
......
......@@ -479,7 +479,7 @@ sub deleteObj {
foreach my $adaptor_name (keys %{$self->{'_adaptors'}}) {
#print STDERR "\tcleaning [$adaptor_name]\n";
my $adaptor = $self->{'_adaptors'}{$adaptor_name};
my $adaptor = $self->{'_adaptors'}->{$adaptor_name};
#call each of the adaptor deleteObj methods
if($adaptor && $adaptor->can('deleteObj')) {
......@@ -488,7 +488,7 @@ sub deleteObj {
}
#break dbadaptor -> object adaptor references
$self->{'_adaptors'}{$adaptor_name} = undef;
$self->{'_adaptors'}->{$adaptor_name} = undef;
}
#print STDERR "Cleaning up attached databases\n";
......
......@@ -18,7 +18,7 @@ Bio::EnsEMBL::External::ExternalFeatureAdaptor - Allows features created externa
$xf_adaptor = new ExternalFeatureAdaptorSubClass;
#explicitly add db, (can be done automatically by add_ExternalFeatureAdaptor)
#Connect the EnsEMBL core database:
$xf_adaptor->db($database_adaptor);
#get some features in RawContig coords
......@@ -40,15 +40,14 @@ Bio::EnsEMBL::External::ExternalFeatureAdaptor - Allows features created externa
$clone = $clone_adaptor->fetch_by_accession('AC000087');
@feats = ${$xf_adaptor->fetch_all_by_Clone($clone);
#Add the adaptor to the ensembl core dbadaptor (implicitly sets db attribute)
$database_adaptor->add_ExternalFeatureAdaptor($xf_adaptor);
#get some features in Slice coords
$slice_adaptor = $database_adaptor->get_SliceAdaptor;
$slice = $slice_adaptor->fetch_by_chr_start_end(1,100000,200000);
@feats = @{$xf_adaptor->fetch_all_by_Slice($slice)};
#Add the external adaptor to the EnsEMBL system
#this also implicitly adds the dbadaptor so you don't have to call 'db'
$database_adaptor->add_ExternalFeatureAdaptor($xf_adaptor);
#now features can be retrieved directly from slice or RawContig
@feats = @{$slice->get_all_ExternalFeatures};
@feats = @{$contig->get_all_ExternalFeatures};
......@@ -93,10 +92,10 @@ ExternalFeature adaptor will be altered by the functions called.
Before the non-overridden ExternalFeatureAdaptor fetch methods may be called
an EnsEMBL core database adaptor must be attached to the ExternalFeatureAdaptor
. This database adaptor is required to perform the remappings between various
coordinate system. This may be done explicitly through a call to the db
accessor method, or implicitly by adding the ExternalFeatureAdaptor to the
database adaptor through a call to the DBAdaptor add_ExternalFeatureAdaptor
method.
coordinate system. This may be done implicitly by adding the
ExternalFeatureAdaptor to the database adaptor through a call to the
DBAdaptor add_ExternalFeatureAdaptor method or explicitly by calling the
ExternalFeatureAdaptor db method.
=head1 CONTACT
......@@ -164,7 +163,10 @@ sub db {
my ($self, $value) = @_;
if($value) {
$self->{'db'} = $value;
#avoid potentially nasty memory leaks
if(ref $value && $value->isa("Bio::EnsEMBL::Container")) {
$self->{'db'} = $value->_obj;
}
}
return $self->{'db'};
......
......@@ -913,7 +913,8 @@ sub get_landmark_MarkerFeatures {
my $lma = $self->adaptor()->db()->get_LandmarkMarkerAdaptor();
if( ! defined $lma ) {
return [];
$self->warn("Lite database must be available to retrieve landmark markers");
return [];
} else {
return $lma->fetch_all_by_Slice( $self );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment