From c8e4ebe3d5bd3d946fe4968315ff2987e9002008 Mon Sep 17 00:00:00 2001
From: Magali Ruffier <mr6@ebi.ac.uk>
Date: Tue, 13 Sep 2016 09:43:54 +0100
Subject: [PATCH] ENSCORESW-1894: deal with stop codons across exons

---
 modules/Bio/EnsEMBL/Utils/IO/GTFSerializer.pm | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Utils/IO/GTFSerializer.pm b/modules/Bio/EnsEMBL/Utils/IO/GTFSerializer.pm
index 26370e1d69..ed776deda8 100644
--- a/modules/Bio/EnsEMBL/Utils/IO/GTFSerializer.pm
+++ b/modules/Bio/EnsEMBL/Utils/IO/GTFSerializer.pm
@@ -319,18 +319,18 @@ sub print_feature {
 
       my $exon_start = $cdsexon->start;
       my $exon_end   = $cdsexon->end;
-      if ( $translation &&
-           $hasend &&
-           ( $exon->end >= $endcodons[0]->start &&
-             $exon->start <= $endcodons[0]->end ) )
-      {
-        # Only the first stop-codon feature is used to adjust the end of the exon
-        # This may not be sufficient all the time
-        if ( $cdsexon->strand == 1 ) {
-          $exon_end = $cdsexon->end - $endcodons[0]->length;
-        }
-        else {
-          $exon_start = $cdsexon->start + $endcodons[0]->length;
+      foreach my $endcodon (@endcodons) {
+        if ( $translation &&
+             $hasend &&
+             ( $exon->end >= $endcodon->start &&
+               $exon->start <= $endcodon->end ) )
+        {
+          if ( $cdsexon->strand == 1 ) {
+            $exon_end = $cdsexon->end - $endcodon->length;
+          }
+          else {
+            $exon_start = $cdsexon->start + $endcodon->length;
+          }
         }
       }
 
-- 
GitLab