JAL-4182 patch - map selection group onto sequence positions - fixes failing test..
[jalview.git] / src / jalview / analysis / AlignmentUtils.java
index 403991a..0fdabc8 100644 (file)
@@ -1539,8 +1539,9 @@ public class AlignmentUtils
         int endRes = ann.annotations.length;
         if (selectionGroup != null)
         {
-          startRes = selectionGroup.getStartRes();
-          endRes = selectionGroup.getEndRes();
+          startRes = -1+Math.min(seq.getEnd(), Math.max(seq.getStart(),seq.findPosition(selectionGroup.getStartRes())));
+          endRes = -1+Math.min(seq.getEnd(),seq.findPosition(selectionGroup.getEndRes()));
+          
         }
         copyAnn.restrict(startRes, endRes + 0);