From 8b6666d7f564c29bf323483004dca1e99388ba8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kusalananda=20K=C3=A4h=C3=A4ri?= <ak4@sanger.ac.uk> Date: Wed, 1 Sep 2010 13:51:27 +0000 Subject: [PATCH] Michael S. noticed that we're blowing away the exon sequence cache unneccesarily in add_Attributes(). Transcript attributes do not affect exon sequences. Also, the code tried to fiddle with the internals of the exon object, which is a no-no (especially since those particular internals did not exist!). While at it, I changed a few of "$hash->{'key'} = undef" into "delete($hash->{'key'})". --- modules/Bio/EnsEMBL/Transcript.pm | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/modules/Bio/EnsEMBL/Transcript.pm b/modules/Bio/EnsEMBL/Transcript.pm index c645e09fa1..83fc4c91b1 100755 --- a/modules/Bio/EnsEMBL/Transcript.pm +++ b/modules/Bio/EnsEMBL/Transcript.pm @@ -1137,39 +1137,34 @@ sub get_all_Attributes { =cut sub add_Attributes { - my $self = shift; - my @attribs = @_; + my ( $self, @attribs ) = @_; - if ( !exists $self->{'attributes'} ) { + if ( !exists( $self->{'attributes'} ) ) { $self->{'attributes'} = []; } my $seq_change = 0; - for my $attrib (@attribs) { - if ( !$attrib->isa("Bio::EnsEMBL::Attribute") ) { - throw("Argument to add_Attribute " - . "has to be an Bio::EnsEMBL::Attribute" ); - } + foreach my $attrib (@attribs) { + assert_ref( $attrib, 'Bio::EnsEMBL::Attribute' ); + push( @{ $self->{'attributes'} }, $attrib ); - if ( $attrib->code eq "_rna_edit" ) { + + if ( $attrib->code() eq "_rna_edit" ) { $seq_change = 1; } } + if ($seq_change) { - foreach my $ex ( @{ $self->get_all_Exons() } ) { - $ex->{'_trans_exon_array'} = undef; - $ex->{'_seq_cache'} = undef; - } - my $translation = $self->translation; + my $translation = $self->translation(); if ( defined($translation) ) { - $translation->{seq} = undef; + delete( $translation->{'seq'} ); } } # flush cdna coord cache b/c we may have added a SeqEdit - $self->{'cdna_coding_start'} = undef; - $self->{'cdna_coding_end'} = undef; - $self->{'transcript_mapper'} = undef; + delete( $self->{'cdna_coding_start'} ); + delete( $self->{'cdna_coding_end'} ); + delete( $self->{'transcript_mapper'} ); } ## end sub add_Attributes -- GitLab