JAL-3806 require mapping extent covers both sequence’s dataset sequence to avoid...
[jalview.git] / src / jalview / util / MappingUtils.java
index c992243..c66fe00 100644 (file)
@@ -36,6 +36,7 @@ import jalview.commands.EditCommand.Action;
 import jalview.commands.EditCommand.Edit;
 import jalview.commands.OrderCommand;
 import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentOrder;
 import jalview.datamodel.ColumnSelection;
@@ -367,11 +368,11 @@ public final class MappingUtils
       {
         int mappedStartResidue = 0;
         int mappedEndResidue = 0;
-
         for (AlignedCodonFrame acf : codonFrames)
         {
-          Mapping map = acf.getMappingBetween(seq, selected);
-          if (map != null)
+          for (SequenceToSequenceMapping map: acf.getMappings())
+          {
+          if (map.covers(selected) && map.covers(seq))
           {
             /*
              * Found a sequence mapping. Locate the start/end mapped residues.
@@ -379,6 +380,7 @@ public final class MappingUtils
             List<AlignedCodonFrame> mapping = Arrays
                     .asList(new AlignedCodonFrame[]
                     { acf });
+            // locate start 
             SearchResultsI sr = buildSearchResults(selected,
                     startResiduePos, mapping);
             for (SearchResultMatchI m : sr.getResults())
@@ -386,6 +388,7 @@ public final class MappingUtils
               mappedStartResidue = m.getStart();
               mappedEndResidue = m.getEnd();
             }
+            // locate end - allowing for adjustment of start range
             sr = buildSearchResults(selected, endResiduePos, mapping);
             for (SearchResultMatchI m : sr.getResults())
             {
@@ -407,7 +410,7 @@ public final class MappingUtils
             mappedGroup.addSequence(seq, false);
             break;
           }
-        }
+        }}
       }
     }
     mappedGroup.setStartRes(minStartCol < 0 ? 0 : minStartCol);