From 17c888b4e04ed6c29f96345afa85be553c0d1b3d Mon Sep 17 00:00:00 2001 From: Stephen Searle <searle@sanger.ac.uk> Date: Tue, 5 Apr 2005 18:41:21 +0000 Subject: [PATCH] Added supporting feature lazy loading --- modules/Bio/EnsEMBL/Transcript.pm | 34 ++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/Bio/EnsEMBL/Transcript.pm b/modules/Bio/EnsEMBL/Transcript.pm index 4c3bb36d1b..05b5d5c34a 100755 --- a/modules/Bio/EnsEMBL/Transcript.pm +++ b/modules/Bio/EnsEMBL/Transcript.pm @@ -243,6 +243,14 @@ sub add_DBEntry { sub get_all_supporting_features { my $self = shift; + + if( !exists $self->{_supporting_evidence} ) { + if($self->adaptor) { + my $tsfa = $self->adaptor->db->get_TranscriptSupportingFeatureAdaptor(); + $self->{_supporting_evidence} = $tsfa->fetch_all_by_Transcript($self); + } + } + return $self->{_supporting_evidence} || []; } @@ -273,7 +281,11 @@ sub add_supporting_features { # check whether this feature object has been added already FEATURE: foreach my $feature (@features) { - unless($feature && $feature->isa("Bio::EnsEMBL::FeaturePair")) { + if (!defined($feature) || ref($feature) eq "ARRAY") { + throw("Element in transcript supporting features array is undefined or is an ARRAY for " . $self->dbID); + } + if (!$feature || !$feature->isa("Bio::EnsEMBL::FeaturePair")) { + print "feature = " . $feature . "\n"; throw("Supporting feat [$feature] not a " . "Bio::EnsEMBL::FeaturePair"); } @@ -1603,6 +1615,16 @@ sub transform { $new_transcript->{'_trans_exon_array'} = \@new_exons; } + if( exists $self->{'_supporting_evidence'} ) { + my @new_features; + for my $old_feature ( @{$self->{'_supporting_evidence'}} ) { + my $new_feature = $old_feature->transform( @_ ); + push( @new_features, $new_feature ); + } + $new_transcript->{'_supporting_evidence'} = \@new_features; + } + + # flush cached internal values that depend on the exon coords $new_transcript->{'transcript_mapper'} = undef; $new_transcript->{'coding_region_start'} = undef; @@ -1658,6 +1680,16 @@ sub transfer { $new_transcript->{'_trans_exon_array'} = \@new_exons; } + if( exists $self->{'_supporting_evidence'} ) { + my @new_features; + for my $old_feature ( @{$self->{'_supporting_evidence'}} ) { + my $new_feature = $old_feature->transfer( @_ ); + push( @new_features, $new_feature ); + } + $new_transcript->{'_supporting_evidence'} = \@new_features; + } + + # flush cached internal values that depend on the exon coords $new_transcript->{'transcript_mapper'} = undef; $new_transcript->{'coding_region_start'} = undef; -- GitLab