Commit 08daed32 authored by Monika Komorowska's avatar Monika Komorowska
Browse files

circular reference fix

parent b3616e19
......@@ -296,7 +296,7 @@ sub get_all_Slices {
-START => $self->Slice->{'start'},
-END => $self->Slice->{'end'},
-STRAND => $self->Slice->{'strand'},
-ADAPTOR => $self->Slice->{'adaptor'},
-ADAPTOR => $self->Slice->adaptor(),
-SEQ => $self->Slice->{'seq'},
-SEQ_REGION_NAME => $self->Slice->{'seq_region_name'},
-SEQ_REGION_LENGTH => $self->Slice->{'seq_region_length'},
......
......@@ -84,7 +84,7 @@ use Bio::EnsEMBL::Root;
our @ISA = qw(Bio::EnsEMBL::Root);
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Scalar::Util qw(weaken isweak);
=head2 new
......@@ -124,7 +124,7 @@ sub new {
$self->{'release'} = $release;
$self->{'assembly'} = $assembly;
$self->{'type'} = $type;
$self->{'adaptor'} = $adaptor;
$self->adaptor($adaptor);
return $self;
}
......@@ -166,6 +166,8 @@ sub new_fast {
'current_version' => $_[7],
}, $class;
weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
return $self;
}
......@@ -395,9 +397,9 @@ sub current_version {
if (@_) {
$self->{'current_version'} = shift;
} elsif (! defined $self->{'current_version'}) {
if (defined $self->{'adaptor'}) {
if (defined $self->adaptor()) {
# lazy load
$self->{'adaptor'}->lookup_current($self);
$self->adaptor()->lookup_current($self);
}
}
......@@ -522,7 +524,7 @@ sub type {
sub adaptor {
my $self = shift;
$self->{'adaptor'} = shift if (@_);
weaken($self->{'adaptor'} = shift) if (@_);
return $self->{'adaptor'};
}
......
......@@ -52,6 +52,7 @@ use vars qw(@ISA);
use Bio::EnsEMBL::Feature;
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Scalar::Util qw(weaken isweak);
@ISA = qw(Bio::EnsEMBL::Feature);
......@@ -105,7 +106,9 @@ sub new {
sub new_fast {
my $class = shift;
my $hashref = shift;
return bless $hashref, $class;
my $self = bless $hashref, $class;
weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
return $self;
}
......
......@@ -75,6 +75,7 @@ use warnings;
use Bio::EnsEMBL::Mapper;
use Bio::EnsEMBL::Utils::Exception qw(throw deprecate);
use Scalar::Util qw(weaken);
my $ASSEMBLED = 'assembled';
my $COMPONENT = 'component';
......@@ -340,7 +341,7 @@ sub fastmap {
my $mapper = $self->{'mapper'};
my $asm_cs = $self->{'asm_cs'};
my $cmp_cs = $self->{'cmp_cs'};
my $adaptor = $self->{'adaptor'};
my $adaptor = $self->adaptor();
my $frm;
my @tmp;
......@@ -777,7 +778,7 @@ sub adaptor {
my ( $self, $value ) = @_;
if ( defined($value) ) {
$self->{'adaptor'} = $value;
weaken($self->{'adaptor'} = $value);
}
return $self->{'adaptor'};
......
......@@ -55,6 +55,7 @@ use strict;
use warnings;
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Scalar::Util qw(weaken isweak);
=head2 new
......@@ -106,7 +107,9 @@ sub new {
sub new_fast {
my $class = shift;
my $hashref = shift;
return bless $hashref, $class;
my $self = bless $hashref, $class;
weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
return $self;
}
......
......@@ -102,6 +102,7 @@ package Bio::EnsEMBL::BaseAlignFeature;
use Bio::EnsEMBL::FeaturePair;
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Bio::EnsEMBL::Utils::Exception qw(throw warning);
use Scalar::Util qw(weaken isweak);
use vars qw(@ISA);
use strict;
......@@ -174,8 +175,9 @@ sub new {
sub new_fast {
my ($class, $hashref) = @_;
return bless $hashref, $class;
my $self = bless $hashref, $class;
weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
return $self;
}
......
......@@ -84,6 +84,7 @@ use integer; #use proper arithmetic bitshifts
use Bio::EnsEMBL::Mapper;
use Bio::EnsEMBL::Mapper::RangeRegistry;
use Bio::EnsEMBL::Utils::Exception qw(throw deprecate);
use Scalar::Util qw(weaken);
#2^20 = approx 10^6
my $CHUNKFACTOR = 20;
......@@ -719,7 +720,7 @@ sub component_CoordSystem {
sub adaptor {
my $self = shift;
$self->{'adaptor'} = shift if(@_);
weaken($self->{'adaptor'} = shift) if(@_);
return $self->{'adaptor'};
}
......
This diff is collapsed.
......@@ -45,6 +45,7 @@ use Bio::Annotation::DBLink;
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Bio::EnsEMBL::Utils::Exception qw(deprecate);
use Scalar::Util qw(weaken isweak);
our @ISA = qw(Bio::EnsEMBL::Storable Bio::Annotation::DBLink);
......@@ -65,10 +66,9 @@ our @ISA = qw(Bio::EnsEMBL::Storable Bio::Annotation::DBLink);
sub new_fast {
my $class = shift;
my $hashref = shift;
bless $hashref, $class;
return $hashref;
my $self = bless $hashref, $class;
weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
return $self;
}
......@@ -120,7 +120,7 @@ sub new {
'DB_DISPLAY_NAME', 'INFO_TYPE', 'INFO_TEXT', 'TYPE',
'SECONDARY_DB_NAME', 'SECONDARY_DB_TABLE', 'LINKAGE_ANNOTATION', 'ANALYSIS'], @args );
$self->{'adaptor'} = $adaptor;
$self->adaptor($adaptor);
$self->{'dbID'} = $dbID;
if( defined $primary_id ) { $self->primary_id( $primary_id ) }
......@@ -569,8 +569,8 @@ sub get_all_synonyms {
my $self = shift;
# lazy-load synonyms if required
if (!$self->{synonyms} && $self->{adaptor}) {
$self->{synonyms} = $self->{adaptor}->fetch_all_synonyms($self->dbID());
if (!$self->{synonyms} && $self->adaptor()) {
$self->{synonyms} = $self->adaptor()->fetch_all_synonyms($self->dbID());
}
return $self->{synonyms};
......@@ -595,7 +595,7 @@ sub get_all_dependents {
my $self = shift;
my $ensembl_object = shift;
return $self->{adaptor}->get_all_dependents($self->dbID(), $ensembl_object);
return $self->adaptor()->get_all_dependents($self->dbID(), $ensembl_object);
}
=head2 get_all_masters
......@@ -616,7 +616,7 @@ sub get_all_masters {
my $self = shift;
my $ensembl_object = shift;
return $self->{adaptor}->get_all_masters($self->dbID(), $ensembl_object);
return $self->adaptor()->get_all_masters($self->dbID(), $ensembl_object);
}
......
......@@ -827,7 +827,6 @@ sub fetch_all_by_Transcript_list {
my $tl = Bio::EnsEMBL::Translation->new
(-dbID => $tl_id,
-adaptor => $self,
-seq_start => $seq_start,
-seq_end => $seq_end,
-start_exon => $start_exon,
......@@ -836,7 +835,8 @@ sub fetch_all_by_Transcript_list {
-version => $version,
-created_date => $created_date || undef,
-modified_date => $modified_date || undef);
$tl->adaptor($self);
$tr->translation($tl);
push @out, $tl;
......
......@@ -35,6 +35,7 @@ package Bio::EnsEMBL::DnaPepAlignFeature;
use strict;
use Bio::EnsEMBL::BaseAlignFeature;
use Scalar::Util qw(weaken isweak);
use vars qw(@ISA);
......@@ -62,8 +63,9 @@ use vars qw(@ISA);
sub new_fast {
my ($class, $hashref) = @_;
return bless $hashref, $class;
my $self = bless $hashref, $class;
weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
return $self;
}
......
......@@ -74,6 +74,8 @@ use Bio::EnsEMBL::Slice;
use Bio::EnsEMBL::StrainSlice;
use vars qw(@ISA);
use Scalar::Util qw(weaken isweak);
@ISA = qw(Bio::EnsEMBL::Storable);
......@@ -145,14 +147,16 @@ sub new {
}
}
return bless({'start' => $start,
my $self = bless({'start' => $start,
'end' => $end,
'strand' => $strand,
'slice' => $slice,
'analysis' => $analysis,
'adaptor' => $adaptor,
'seqname' => $seqname,
'dbID' => $dbID}, $class);
$self->adaptor($adaptor);
return $self;
}
......@@ -171,7 +175,9 @@ sub new {
sub new_fast {
my $class = shift;
my $hashref = shift;
return bless $hashref, $class;
my $self = bless $hashref, $class;
weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) );
return $self;
}
=head2 start
......@@ -1544,5 +1550,4 @@ sub id {
return $self->{'dbID'};
}
1;
......@@ -26,6 +26,7 @@ use Bio::EnsEMBL::Utils::Sequence qw(reverse_comp);
use Bio::EnsEMBL::Slice;
use Bio::EnsEMBL::Mapper;
use Bio::EnsEMBL::Utils::Exception qw(throw deprecate warning);
use Scalar::Util qw(weaken);
=head2 new
=cut
......@@ -38,26 +39,42 @@ sub new{
my ($population_name, $coord_system, $start, $end, $strand, $seq_region_name, $seq_region_length, $adaptor) = rearrange(['POPULATION', 'COORD_SYSTEM','START','END','STRAND','SEQ_REGION_NAME','SEQ_REGION_LENGTH', 'ADAPTOR'],@_);
return bless {
my $self = bless {
population_name => $population_name,
coord_system => $coord_system,
start => $start,
end => $end,
strand => $strand,
seq_region_name => $seq_region_name,
seq_region_length => $seq_region_length,
adaptor => $adaptor},$class;
seq_region_length => $seq_region_length},$class;
$self->adaptor($adaptor);
return $self;
}
sub adaptor {
my $self = shift;
if(@_) {
my $ad = shift;
if($ad && (!ref($ad) || !$ad->isa('Bio::EnsEMBL::DBSQL::BaseAdaptor'))) {
throw('Adaptor argument must be a Bio::EnsEMBL::DBSQL::BaseAdaptor');
}
weaken($self->{'adaptor'} = $ad);
}
return $self->{'adaptor'}
}
sub get_all_IndividualSlice{
my $self = shift;
my $slice;
if(!$self->{'adaptor'}) {
if(!$self->adaptor) {
warning('Cannot get IndividualSlice features without attached adaptor');
return '';
}
my $variation_db = $self->{'adaptor'}->db->get_db_adaptor('variation');
my $variation_db = $self->adaptor->db->get_db_adaptor('variation');
unless($variation_db) {
warning("Variation database must be attached to core database to " .
......@@ -80,7 +97,7 @@ sub get_all_IndividualSlice{
-strand => $self->{'strand'},
-seq_region_name => $self->{'seq_region_name'},
-seq_region_length => $self->{'seq_region_length'},
-adaptor => $self->{'adaptor'}
-adaptor => $self->adaptor
);
my $population = $population_adaptor->fetch_by_name($self->{'population_name'});
#check that there is such population in the database
......
......@@ -100,10 +100,10 @@ sub new {
'name' => $name,
'type' => $type,
'tag_count' => $tag_count,
'sequence' => $sequence,
'adaptor' => $adaptor,
'sequence' => $sequence
}, $class);
$self->adaptor($adaptor);
return $self;
}
......
......@@ -134,7 +134,6 @@ sub new {
my $self = bless( {'dbID' => $dbID,
'analysis' => $analysis,
'adaptor' => $adaptor,
'slice' => $slice,
'start' => $start,
'end' => $end,
......@@ -150,6 +149,7 @@ sub new {
'ditag' => $ditag,
}, $class);
$self->adaptor($adaptor);
return $self;
}
......
......@@ -78,7 +78,6 @@ sub new {
my $class = ref($caller) || $caller;
my $self = bless( {'dbID' => $dbID,
'adaptor' => $adaptor,
'left_primer' => $left_primer,
'right_primer' => $right_primer,
'min_primer_dist' => $min_primer_dist,
......@@ -88,6 +87,8 @@ sub new {
'display_marker_synonym' => $display_synonym
}, $class);
$self->adaptor($adaptor);
#only load the marker synononyms if they were supplied, otherwise they
# will be lazy-loaded
if($syns && @$syns) {
......@@ -275,7 +276,7 @@ sub get_all_MarkerSynonyms {
#lazy-load the marker synonyms if they haven't been retrieved
if(!exists $self->{'marker_synonyms'} &&
$self->{'adaptor'} && $self->{'dbID'}) {
$self->adaptor && $self->{'dbID'}) {
$self->adaptor->fetch_attributes($self);
}
......@@ -404,7 +405,7 @@ sub get_all_MapLocations {
#lazy-load the map locations if they have not been fetched yet
if(!exists $self->{'map_locations'} &&
$self->{'adaptor'} && $self->{'dbID'}) {
$self->adaptor && $self->{'dbID'}) {
$self->adaptor->fetch_attributes($self);
}
......@@ -435,7 +436,7 @@ sub get_MapLocation {
#lazy-load the map locations if they have not been fetched yet
if(!exists $self->{'map_locations'} &&
$self->{'adaptor'} && $self->{'dbID'}) {
$self->adaptor && $self->{'dbID'}) {
$self->adaptor->fetch_attributes($self);
}
......
......@@ -73,9 +73,8 @@ sub new {
my $class = ref($caller) || $caller;
return bless( {
my $self = bless( {
'dbID' => $dbID,
'adaptor' => $adaptor,
'start' => $start,
'end' => $end,
'strand' => 0,
......@@ -84,6 +83,9 @@ sub new {
'marker_id' => $marker_id,
'marker' => $marker,
'map_weight' => $map_weight }, $class);
$self->adaptor($adaptor);
return $self;
}
......@@ -132,9 +134,9 @@ sub marker {
if(@_) {
$self->{'marker'} = shift;
} elsif(!$self->{'marker'} && $self->{'adaptor'} && $self->{'marker_id'}) {
} elsif(!$self->{'marker'} && $self->adaptor && $self->{'marker_id'}) {
#lazy load the marker if it is not already loaded
my $ma = $self->{'adaptor'}->db->get_MarkerAdaptor;
my $ma = $self->adaptor->db->get_MarkerAdaptor;
$self->{'marker'} = $ma->fetch_by_dbID($self->{'marker_id'});
}
......
......@@ -75,7 +75,6 @@ sub new {
$class = ref( $class ) ||$class;
my $self = bless( {
'dbID' => $dbID,
'adaptor' => $adaptor,
'flank_marker_1' => $flank_marker_1,
'flank_marker_2' => $flank_marker_2,
'peak_marker' => $peak_marker,
......@@ -83,7 +82,7 @@ sub new {
'lod_score' => $lod_score,
'synonyms' => $synonyms
}, $class );
$self->adaptor($adaptor);
return $self;
}
......
......@@ -62,7 +62,6 @@ sub new {
$class = ref( $class ) ||$class;
my $self = bless( {
'adaptor' => $adaptor,
'slice' => $slice,
'start' => $start,
'end' => $end,
......@@ -71,6 +70,7 @@ sub new {
'strand' => 0
}, $class );
$self->adaptor($adaptor);
return $self;
}
......
......@@ -181,7 +181,7 @@ sub new {
# need to weaken reference to prevent circular reference
weaken($self->{'container'} = $container);
$self->{'adaptor'} = $adaptor if (defined($adaptor));
$self->adaptor($adaptor) if (defined($adaptor));
$self->{'name'} = $name if (defined($name));
$self->{'slice_mapper_pairs'} = [];
......@@ -275,7 +275,7 @@ sub get_all_Slice_Mapper_pairs {
sub adaptor {
my $self = shift;
$self->{'adaptor'} = shift if (@_);
weaken($self->{'adaptor'} = shift) if (@_);
return $self->{'adaptor'};
}
......
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