JAL-3855 JAL-2349 AlignmentI.getContactList takes care of mapping columns to sequence...
authorJim Procter <j.procter@dundee.ac.uk>
Thu, 20 Oct 2022 14:14:31 +0000 (15:14 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Thu, 20 Oct 2022 14:14:31 +0000 (15:14 +0100)
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/ContactMapHolder.java
src/jalview/gui/AnnotationPanel.java

index 3ae6831..fe65829 100755 (executable)
@@ -2062,10 +2062,15 @@ public class Alignment implements AlignmentI, AutoCloseable
     }
     if (cl == null && _aa.sequenceRef != null)
     {
-      cl = _aa.sequenceRef.getContactListFor(_aa, column);
-      if (cl == null && _aa.sequenceRef.getDatasetSequence() != null)
+      int spos = _aa.sequenceRef.findPosition(column) - 1;
+      if (spos >= _aa.sequenceRef.getStart()
+              && spos <= 1 + _aa.sequenceRef.getEnd())
       {
-        _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, column);
+        cl = _aa.sequenceRef.getContactListFor(_aa, spos);
+        if (cl == null && _aa.sequenceRef.getDatasetSequence() != null)
+        {
+          _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, spos);
+        }
       }
     }
     return cl;
index ac1b267..4b46d7d 100644 (file)
@@ -28,6 +28,9 @@ public class ContactMapHolder implements ContactMapHolderI
     {
       return null;
     }
+    // TODO: could resolve sequence position to column position here
+    // TODO: what about for complexes - where contactMatrix may involve two or
+    // more sequences
     return cm.getContactList(column);
   }
 
index f0c2404..2149266 100755 (executable)
@@ -906,14 +906,30 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
       System.err.println("Marking " + fr + " to " + to);
       for (int c = fr; c <= to; c++)
       {
-        av.getColumnSelection().addElement(c);
+        if (cma.sequenceRef != null)
+        {
+          int col = cma.sequenceRef.findIndex(c);
+          av.getColumnSelection().addElement(col);
+        }
+        else
+        {
+          av.getColumnSelection().addElement(c);
+        }
       }
       fr = Math.min(cXci.cStart, cXci.cEnd);
       to = Math.max(cXci.cStart, cXci.cEnd);
       System.err.println("Marking " + fr + " to " + to);
       for (int c = fr; c <= to; c++)
       {
-        av.getColumnSelection().addElement(c);
+        if (cma.sequenceRef != null)
+        {
+          int col = cma.sequenceRef.findIndex(c);
+          av.getColumnSelection().addElement(col);
+        }
+        else
+        {
+          av.getColumnSelection().addElement(c);
+        }
       }
       fr = Math.min(lastX, currentX);
       to = Math.max(lastX, currentX);