JAL-3759 exclude hidden columns when processing column selection
authorJim Procter <jprocter@issues.jalview.org>
Thu, 29 Oct 2020 15:17:37 +0000 (15:17 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 29 Oct 2020 15:17:37 +0000 (15:17 +0000)
src/jalview/analysis/Grouping.java
src/jalview/controller/AlignViewController.java

index 066814e..88d3525 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.analysis;
 
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 
@@ -109,10 +110,12 @@ public class Grouping
    * @param sequences
    * @param columnSelection
    * @param list
+   * @param hiddenColumns
    * @return
    */
   public static SequenceGroup[] makeGroupsFromCols(SequenceI[] sequences,
-          ColumnSelection cs, List<SequenceGroup> list)
+          ColumnSelection cs, List<SequenceGroup> list,
+          HiddenColumns hiddenColumns)
   {
     // TODO: determine how to get/recover input data for group generation
     Map<String, List<SequenceI>> gps = new HashMap<String, List<SequenceI>>();
@@ -137,9 +140,17 @@ public class Grouping
     int i = 0;
     for (Integer pos : cs.getSelected())
     {
-      spos[i++] = pos.intValue();
+      if (hiddenColumns == null || hiddenColumns.isVisible(pos.intValue()))
+      {
+        spos[i++] = pos.intValue();
+      }
     }
-
+    if (i < spos.length)
+    {
+      // mark end of visible column position
+      spos[i] = -1;
+    }
+    // actual number of visible columns
     for (i = 0; i < sequences.length; i++)
     {
       int slen = sequences[i].getLength();
@@ -156,6 +167,10 @@ public class Grouping
       }
       for (int p : spos)
       {
+        if (p < 0)
+        {
+          break;
+        }
         if (p >= slen)
         {
           schar.append("~");
index 0bb2d03..1fc1946 100644 (file)
@@ -90,7 +90,8 @@ public class AlignViewController implements AlignViewControllerI
         gps = jalview.analysis.Grouping.makeGroupsFromCols(
                 (sg == null) ? viewport.getAlignment().getSequencesArray()
                         : sg.getSequences().toArray(new SequenceI[0]),
-                cs, viewport.getAlignment().getGroups());
+                cs, viewport.getAlignment().getGroups(),
+                viewport.getAlignment().getHiddenColumns());
       }
     }
     if (gps != null)