From e6f80908db5b4f1fc8312735ec213170412c3938 Mon Sep 17 00:00:00 2001
From: Graham McVicker <mcvicker@sanger.ac.uk>
Date: Wed, 5 Mar 2003 15:58:04 +0000
Subject: [PATCH] coding_start/end => coding_region_start/end

---
 modules/Bio/EnsEMBL/Lite/GeneAdaptor.pm     |   8 +-
 modules/Bio/EnsEMBL/PredictionTranscript.pm |  58 ++++------
 modules/Bio/EnsEMBL/Transcript.pm           | 117 ++++++++++++++------
 modules/t/predictionTranscript.t            |  13 +--
 modules/t/transcript.t                      |  18 +--
 5 files changed, 119 insertions(+), 95 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Lite/GeneAdaptor.pm b/modules/Bio/EnsEMBL/Lite/GeneAdaptor.pm
index baac7c5d00..767574030c 100644
--- a/modules/Bio/EnsEMBL/Lite/GeneAdaptor.pm
+++ b/modules/Bio/EnsEMBL/Lite/GeneAdaptor.pm
@@ -491,8 +491,8 @@ sub _objects_from_sth {
     my $transcript = Bio::EnsEMBL::Transcript->new();
     $transcript->adaptor( $core_db_adaptor->get_TranscriptAdaptor() );
     $transcript->dbID( $hr->{'transcript_id'});
-    $transcript->coding_start( $coding_start );
-    $transcript->coding_end( $coding_end );
+    $transcript->coding_region_start( $coding_start );
+    $transcript->coding_region_end( $coding_end );
     $transcript->stable_id( $hr->{ 'transcript_name' });
     $transcript->type( $hr->{ 'type' } );
     $transcript->external_status( $hr->{'external_status'} );
@@ -831,8 +831,8 @@ sub store {
 
     $sth->execute( $gene->source(), $gene->analysis()->logic_name(),
 		   $gene->type, $tr->dbID(), $tr->stable_id, $gene->chr_name,
-		   $tr->start(), $tr->end(), $gene->strand(), $tr->coding_start(),
-		   $tr->coding_end(), $tr->translation->dbID(), 
+		   $tr->start(), $tr->end(), $gene->strand(), $tr->coding_region_start(),
+		   $tr->coding_region_end(), $tr->translation->dbID(), 
 		   $tr->translation->stable_id(), $gene->dbID(), $gene->stable_id(),
 		   $exon_structure, $exon_ids, $tr->external_db(), $tr->external_status(),
 		   $tr->external_name() );
diff --git a/modules/Bio/EnsEMBL/PredictionTranscript.pm b/modules/Bio/EnsEMBL/PredictionTranscript.pm
index d4711899a2..3f22c41610 100644
--- a/modules/Bio/EnsEMBL/PredictionTranscript.pm
+++ b/modules/Bio/EnsEMBL/PredictionTranscript.pm
@@ -133,7 +133,7 @@ sub stable_id {
 
 
 
-=head2 coding_start
+=head2 coding_region_start
 
   Arg [1]  :  The new coding start of this prediction transcript in slice 
               coords.
@@ -142,32 +142,32 @@ sub stable_id {
               and so that it can be drawn as a Transcript. Since prediction
               transcripts do not currently have UTRs the coding start should
               return the same value as the start method.
-              By convention, the coding_start is always lower than the value
-              returned by the coding_end method.  The value returned by this
-              function is NOT the biological coding start since on the 
-              reverse strand the biological coding start would be the 
-              higher genomic value. 
+              By convention, the coding_region_start is always lower than the 
+              value returned by the coding_region_end method.  The value 
+              returned by this function is NOT the biological coding start 
+              since on the reverse strand the biological coding start would 
+              be the higher genomic value. 
   Returntype: scalar int
   Exceptions: none
   Caller    : GlyphSet_transcript
 
 =cut
 
-sub coding_start {
+sub coding_region_start {
   my ($self, $arg) = @_;
 
   if(defined $arg) {
-    $self->{'coding_start'} = $arg;
-  } elsif(!defined $self->{'coding_start'}) {
+    $self->{'coding_region_start'} = $arg;
+  } elsif(!defined $self->{'coding_region_start'}) {
     #if the coding start is not defined, use the start of the transcript
     return $self->start();
   }
 
-  return $self->{'coding_start'};
+  return $self->{'coding_region_start'};
 }
 
 
-=head2 coding_end
+=head2 coding_region_end
 
   Arg [1]  :  (optional) The new coding end of this prediction transcript 
               in slice coords.
@@ -176,27 +176,27 @@ sub coding_start {
               and so that it can be drawn as a Transcript. Since prediction
               transcripts do not currently have UTRs the coding end should
               be the same as the end of the transcript.
-              By convention, the coding_start is always lower than the value
-              returned by the coding_end method.  The value returned by this
-              function is NOT the biological coding start since on the 
-              reverse strand the biological coding start would be the 
-              higher genomic value. 
+              By convention, the coding_region_start is always lower than the 
+              value returned by the coding_region_end method.  The value 
+              returned by this function is NOT the biological coding start 
+              since on the reverse strand the biological coding start would 
+              be the higher genomic value. 
   Returntype: scalar int
   Exceptions: none
   Caller    : GlyphSet_transcript
 
 =cut
 
-sub coding_end {
+sub coding_region_end {
   my ($self, $arg) = @_;
 
   if(defined $arg) {
-    $self->{'coding_end'} = $arg;
-  } elsif(!defined $self->{'coding_end'}) {
+    $self->{'coding_region_end'} = $arg;
+  } elsif(!defined $self->{'coding_region_end'}) {
     #if the coding end is not defined, use the end of the transcript
     return $self->end();
   }
-  return $self->{'coding_end'};
+  return $self->{'coding_region_end'};
 }
 
 
@@ -351,7 +351,7 @@ sub get_all_Exons {
                thus all exons are entirely translateable.
   Returntype : listref of Bio::EnsEMBL::Exon
   Exceptions : none
-  Caller     : Embl_Dumper
+  Caller     : general
 
 =cut
 
@@ -783,22 +783,6 @@ sub _get_cdna_coord_mapper {
 }
 
 
-# debug helper
-sub _dump {
-  my $self = shift;
-  my $res = "";
-  if( ! defined $self->{'_exon_align'} ) {
-    $self->get_cdna();
-  }
-
-  for my $ex ( @{$self->{'_exon_align'}} ) {
-    $res .= "pep: ".$ex->{'pep_start'}." ".$ex->{pep_end}."\n";
-    $res .= "exon: ".$ex->{'exon'}->start()." ".$ex->{'exon'}->end().
-      " ".$ex->{'exon'}->strand()."\n";
-  }
-  return $res;
-}
-
 
 =head2 type
 
diff --git a/modules/Bio/EnsEMBL/Transcript.pm b/modules/Bio/EnsEMBL/Transcript.pm
index be0bfecf92..305f83314d 100755
--- a/modules/Bio/EnsEMBL/Transcript.pm
+++ b/modules/Bio/EnsEMBL/Transcript.pm
@@ -38,11 +38,6 @@ Manipulation:
 
 Email questions to the ensembl developer mailing list <ensembl-dev@ebi.ac.uk>
 
-=head1 APPENDIX
-
-The rest of the documentation details each of the object methods. 
-Internal methods are usually preceded with a _
-
 =cut
 
 
@@ -537,7 +532,7 @@ sub cdna_coding_start {
 =head2 cdna_coding_end
 
   Arg [1]    : (optional) $value
-  Example    : $cdna_coding_end = $transcript->coding_end;
+  Example    : $cdna_coding_end = $transcript->cdna_coding_end;
   Description: Retrieves the end of the coding region of this transcript in
                cdna coordinates (relative to the five prime end of the
                transcript, excluding introns, including utrs).
@@ -575,29 +570,30 @@ sub cdna_coding_end {
 
 
 
-=head2 coding_start
+=head2 coding_region_start
 
   Arg [1]    : (optional) $value
-  Example    : $coding_start = $transcript->coding_start
+  Example    : $coding_region_start = $transcript->coding_region_start
   Description: Retrieves the start of the coding region of this transcript
                in genomic coordinates (i.e. in either slice or contig coords).
-               By convention, the coding_start is always lower than the value
-               returned by the coding_end method.  The value returned by this
-               function is NOT the biological coding start since on the 
-               reverse strand the biological coding start would be the 
-               higher genomic value. 
+               By convention, the coding_region_start is always lower than 
+               the value returned by the coding_end method.  
+               The value returned by this function is NOT the biological 
+               coding start since on the reverse strand the biological coding 
+               start would be the higher genomic value. 
   Returntype : int
   Exceptions : none
   Caller     : general
 
 =cut
 
-sub coding_start {
+sub coding_region_start {
   my ($self, $value) = @_;
 
   if( defined $value ) {
-    $self->{'coding_start'} = $value;
-  } elsif(!defined $self->{'coding_start'} && defined $self->translation) {
+    $self->{'coding_region_start'} = $value;
+  } elsif(!defined $self->{'coding_region_start'} && 
+	  defined $self->translation) {
     #calculate the coding start from the translation
     my $start;
     my $strand = $self->translation()->start_Exon->strand();
@@ -608,40 +604,41 @@ sub coding_start {
       $start = $self->translation()->end_Exon->end();
       $start -= ( $self->translation()->end() - 1 );
     }
-    $self->{'coding_start'} = $start;
+    $self->{'coding_region_start'} = $start;
   }
 
-  return $self->{'coding_start'};
+  return $self->{'coding_region_start'};
 }
 
 
 
-=head2 coding_end
+=head2 coding_region_end
 
   Arg [1]    : (optional) $value
-  Example    : $coding_end = $transcript->coding_end
+  Example    : $coding_region_end = $transcript->coding_region_end
   Description: Retrieves the start of the coding region of this transcript
                in genomic coordinates (i.e. in either slice or contig coords).
-               By convention, the coding_end is always higher than the value
-               returned by the coding_start method.  The value returned by this
-               function is NOT the biological coding start since on the 
-               reverse strand the biological coding end would be the 
-               lower genomic value.
+               By convention, the coding_region_end is always higher than the 
+               value returned by the coding_region_start method.  
+               The value returned by this function is NOT the biological 
+               coding start since on the reverse strand the biological coding 
+               end would be the lower genomic value.
   Returntype : int
   Exceptions : none
   Caller     : general
 
 =cut
 
-sub coding_end {
+sub coding_region_end {
   my ($self, $value ) = @_;
 
   my $strand;
   my $end;
 
   if( defined $value ) {
-    $self->{'coding_end'} = $value;
-  } elsif( ! defined $self->{'coding_end'} && defined $self->translation() ) {
+    $self->{'coding_region_end'} = $value;
+  } elsif( ! defined $self->{'coding_region_end'} 
+	   && defined $self->translation() ) {
     $strand = $self->translation()->start_Exon->strand();
     if( $strand == 1 ) {
       $end = $self->translation()->end_Exon->start();
@@ -650,10 +647,10 @@ sub coding_end {
       $end = $self->translation()->start_Exon->end();
       $end -= ( $self->translation()->start() - 1 );
     }
-    $self->{'coding_end'} = $end;
+    $self->{'coding_region_end'} = $end;
   }
 
-  return $self->{'coding_end'};
+  return $self->{'coding_region_end'};
 }
 
 
@@ -956,14 +953,18 @@ sub get_all_SNPs {
 	if($snp->end >= $e->start && $snp->start <= $e->end) {
 	  #this snp is in an exon
 
-	  if(($trans_strand == 1 && $snp->end < $transcript->coding_start) ||
-	  ($trans_strand == -1 && $snp->start > $transcript->coding_end)) {
+	  if(($trans_strand == 1 && 
+	      $snp->end < $transcript->coding_region_start) ||
+	     ($trans_strand == -1 && 
+	      $snp->start > $transcript->coding_region_end)) {
 	    #this snp is in the 5' UTR
 	    $key = 'five prime UTR';
 	  }
 
-	  elsif(($trans_strand == 1 && $snp->start > $transcript->coding_end)||
-	     ($trans_strand == -1 && $snp->end < $transcript->coding_start)) {
+	  elsif(($trans_strand == 1 && 
+		 $snp->start > $transcript->coding_region_end)||
+		($trans_strand == -1 && 
+		 $snp->end < $transcript->coding_region_start)) {
 	    #this snp is in the 3' UTR
 	    $key = 'three prime UTR';
 	  }
@@ -1093,8 +1094,8 @@ sub get_all_cdna_SNPs {
 sub flush_Exons{
    my ($self,@args) = @_;
    $self->{'_exon_coord_mapper'} = undef;
-   $self->{'coding_start'} = undef;
-   $self->{'coding_end'} = undef;
+   $self->{'coding_region_start'} = undef;
+   $self->{'coding_region_end'} = undef;
    $self->{'_start'} = undef;
    $self->{'_end'} = undef;
    $self->{'_strand'} = undef;
@@ -1868,4 +1869,48 @@ sub species {
 }
 
 
+
+=head2 coding_start
+
+  Arg [1]    : none
+  Example    : none
+  Description: DEPRECATED use coding_region_start instead
+  Returntype : none
+  Exceptions : none
+  Caller     : none
+
+=cut
+
+sub coding_start {
+  my ($self, @args) = @_;
+
+  $self->warn("coding_start has been renamed coding_region_start\n" . 
+	      join(':'. caller));
+
+  return $self->coding_region_start(@args);
+}
+
+
+=head2 coding_end
+
+  Arg [1]    : none
+  Example    : none
+  Description: DEPRECATED use coding_region_end instead
+  Returntype : none
+  Exceptions : none
+  Caller     : none
+
+=cut
+
+sub coding_end {
+  my ($self, @args) = @_;
+
+  $self->warn("coding_end has been renamed coding_region_end\n" . 
+	      join(':',caller));
+
+  return $self->coding_region_end(@args);
+}
+
+
+
 1;
diff --git a/modules/t/predictionTranscript.t b/modules/t/predictionTranscript.t
index d5413280da..621c69c10e 100644
--- a/modules/t/predictionTranscript.t
+++ b/modules/t/predictionTranscript.t
@@ -5,7 +5,7 @@ use lib 't';
 
 BEGIN { $| = 1;
 	use Test;
-	plan tests => 33;
+	plan tests => 32;
 }
 
 use MultiTestDB;
@@ -59,12 +59,12 @@ ok($pt->stable_id =~ /(\w+\.\d+\.\d+\.\d+)\.(\d+)\.(\d+)/);
 #
 # 6 test coding start
 #
-ok(&TestUtils::test_getter_setter($pt, 'coding_start', 6));
+ok(&TestUtils::test_getter_setter($pt, 'coding_region_start', 6));
 
 #
 # 7 test coding end
 #
-ok(&TestUtils::test_getter_setter($pt, 'coding_end', 7));
+ok(&TestUtils::test_getter_setter($pt, 'coding_region_end', 7));
 
 
 #
@@ -205,12 +205,7 @@ ok($defined_exons_count == $pt->cdna2genomic($cstart, $cend));
 
 
 #
-# 32 test _dump executes
-#
-ok($pt->_dump || 1);
-
-#
-# 33 test type
+# 32 test type
 #
 ok(&TestUtils::test_getter_setter($pt, 'type', 'test'));
 
diff --git a/modules/t/transcript.t b/modules/t/transcript.t
index e4debf3f43..125e329f8f 100644
--- a/modules/t/transcript.t
+++ b/modules/t/transcript.t
@@ -40,8 +40,8 @@ for my $gene ( @$genes ) {
       debug( $trans->stable_id()." does not translate." );
       last;
     }
-    if( $trans->coding_start() != $trans->start() &&
-	$trans->coding_end() != $trans->end() ) {
+    if( $trans->coding_region_start() != $trans->start() &&
+	$trans->coding_region_end() != $trans->end() ) {
       $utr_trans = $trans->stable_id();
     }
   }
@@ -100,11 +100,11 @@ ok( substr( $tr->spliced_seq(), 0, 10 ) eq "ACGAGACGAA" );
 debug( "translateable_seq->substr == \"".substr( $tr->translateable_seq(),0,10 )."\"" );
 ok( substr( $tr->translateable_seq(),0,10 ) eq "ATGGCAGTGA" );
 
-debug( "coding_start() == ".$tr->coding_start() );
-ok( $tr->coding_start() == 85834 );
+debug( "coding_region_start() == ".$tr->coding_region_start() );
+ok( $tr->coding_region_start() == 85834 );
 
-debug( "coding_end() == ".$tr->coding_end() );
-ok( $tr->coding_end() == 108631 );
+debug( "coding_region_end() == ".$tr->coding_region_end() );
+ok( $tr->coding_region_end() == 108631 );
 
 debug( "pep2genomic: ".($tr->pep2genomic( 10,20 ))[0]->start());
 my @pepcoords = $tr->pep2genomic( 10, 20 );
@@ -116,11 +116,11 @@ my $t_strand = $tr->get_all_Exons->[0]->strand;
 my $pep_len = ($tr->cdna_coding_end - $tr->cdna_coding_start + 1) / 3;
 
 my $coord_num = 0;
-my $coding_start = $tr->coding_start;
-my $coding_end   = $tr->coding_end;
+my $coding_region_start = $tr->coding_region_start;
+my $coding_region_end   = $tr->coding_region_end;
 #expect coordinate for each exon with coding sequence 
 foreach my $e (@{$tr->get_all_Exons}) {
-  if($e->end > $coding_start && $e->start < $coding_end) {
+  if($e->end > $coding_region_start && $e->start < $coding_region_end) {
     $coord_num++;
   }
 }
-- 
GitLab