JAL-3095 account for sequence start when highlighting selections in trimmed VARNA...
authorJim Procter <jprocter@issues.jalview.org>
Fri, 31 Aug 2018 15:08:32 +0000 (16:08 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Fri, 31 Aug 2018 15:08:32 +0000 (16:08 +0100)
src/jalview/gui/AppVarna.java

index aad4a96..3a64716 100644 (file)
@@ -428,15 +428,28 @@ public class AppVarna extends JInternalFrame
     {
       return;
     }
-    if (seqsel != null && seqsel.getSize() > 0)
+
+    RnaModel rnaModel = models.get(rna);
+
+    if (seqsel != null && seqsel.getSize() > 0
+            && seqsel.contains(rnaModel.seq))
     {
       int start = seqsel.getStartRes(), end = seqsel.getEndRes();
-      ShiftList shift = offsets.get(rna);
-      if (shift != null)
+      if (rnaModel.gapped)
+      {
+        ShiftList shift = offsets.get(rna);
+        if (shift != null)
+        {
+          start = shift.shift(start);
+          end = shift.shift(end);
+        }
+      }
+      else
       {
-        start = shift.shift(start);
-        end = shift.shift(end);
+        start = rnaModel.seq.findPosition(start) - rnaModel.seq.getStart();
+        end = rnaModel.seq.findPosition(end) - rnaModel.seq.getStart();
       }
+
       selectionHighlighter.highlightRegion(rna, start, end);
       selectionHighlighter.getLastHighlight()
               .setOutlineColor(seqsel.getOutlineColour());