X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FMappedFeatures.java;fp=src%2Fjalview%2Fdatamodel%2FMappedFeatures.java;h=1f672befcc5df3912bfe9f19c1fababb13770479;hb=881dd37ce1077bce230b6b04690112d9d6eafecd;hp=d652a97db6edfeef5f25feb347208552b24273f9;hpb=e6a84268f419fa16fd87f484842150cb0a103ce6;p=jalview.git diff --git a/src/jalview/datamodel/MappedFeatures.java b/src/jalview/datamodel/MappedFeatures.java index d652a97..1f672be 100644 --- a/src/jalview/datamodel/MappedFeatures.java +++ b/src/jalview/datamodel/MappedFeatures.java @@ -276,7 +276,8 @@ public class MappedFeatures /** * Answers the mapped ranges (as one or more [start, end] positions) which - * correspond to the given [begin, end] range of the linked sequence. + * correspond to the given [begin, end] range of (some feature on) the linked + * sequence. * *
    * Example: MappedFeatures with CDS features mapped to peptide 
@@ -293,9 +294,27 @@ public class MappedFeatures
    */
   public int[] getMappedPositions(int begin, int end)
   {
+    int[] result = null;
     MapList map = mapping.getMap();
-    return mapping.to == featureSequence ? map.locateInFrom(begin, end)
-            : map.locateInTo(begin, end);
+    if (mapping.to == featureSequence)
+    {
+      result = map.locateInFrom(begin, end);
+      if (result == null)
+      {
+        // fudge for feature (e.g. CDS) extending to a mapped stop codon
+        result = map.locateInFrom(begin, end-3);
+      }
+    }
+    else
+    {
+      result = map.locateInTo(begin, end);
+      if (result == null)
+      {
+        // fudge for feature (e.g. CDS) extending to a mapped stop codon
+        result = map.locateInTo(begin, end-3);
+      }
+    }
+    return result;
   }
 
   /**