From 100cca1841feab47d637610246964ade27ac9033 Mon Sep 17 00:00:00 2001
From: Magali Ruffier <mr6@ebi.ac.uk>
Date: Fri, 18 Mar 2016 11:41:50 +0000
Subject: [PATCH] ENSCORESW-1673: added intron rank method

---
 modules/Bio/EnsEMBL/Intron.pm | 18 ++++++++++++++++++
 modules/t/intron.t            |  4 +++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/modules/Bio/EnsEMBL/Intron.pm b/modules/Bio/EnsEMBL/Intron.pm
index 815da51ca2..69414fb1ab 100644
--- a/modules/Bio/EnsEMBL/Intron.pm
+++ b/modules/Bio/EnsEMBL/Intron.pm
@@ -162,6 +162,24 @@ sub next_Exon {
   return $self->{'next'};
 }
 
+=head2 rank
+
+  Args       : none
+  Example    : $rank = $intron->rank
+  Description: Returns the rank of this Intron
+  Returntype : Integer
+  Exceptions : none
+  Caller     : general
+  Status     : Stable
+
+=cut
+
+sub rank {
+  my ($self, $transcript) = @_;
+
+  return $self->prev_Exon->rank($transcript);
+}
+
 =head2 is_splice_canonical
 
   Example     : my $canonical = $intron->is_splice_canonical(); 
diff --git a/modules/t/intron.t b/modules/t/intron.t
index 09cd7a3433..4cd0c36466 100644
--- a/modules/t/intron.t
+++ b/modules/t/intron.t
@@ -42,8 +42,10 @@ my $transcript =
 my @exons = (@{$transcript->get_all_Exons()});  
 my @introns = (@{$transcript->get_all_Introns()});  
 
-my $i=0;
+my $rank=1;
 foreach my $intron (@introns){
+  is($intron->rank($transcript), $rank, "Checking intron rank");
+  $rank++;
   ok($intron->prev_Exon->end == $intron->start-1);
   ok($intron->next_Exon->start == $intron->end+1);
   ok($intron->is_splice_canonical(), 'Checking Intron is canonical in its splicing');
-- 
GitLab