JAL-4134 only build tree when showing it in the tree viewer..
authorJames Procter <j.procter@dundee.ac.uk>
Mon, 22 May 2023 14:37:15 +0000 (15:37 +0100)
committerJames Procter <j.procter@dundee.ac.uk>
Mon, 22 May 2023 14:39:01 +0000 (15:39 +0100)
src/jalview/gui/AlignFrame.java
src/jalview/gui/AnnotationLabels.java
src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java
src/jalview/ws/dbsources/EBIAlfaFold.java

index 71905c1..ae945fe 100644 (file)
@@ -112,6 +112,7 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentOrder;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.ContactMatrixI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SeqCigar;
@@ -4202,7 +4203,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   }
 
   public void showContactMapTree(AlignmentAnnotation aa,
-          PAEContactMatrix cm)
+          ContactMatrixI cm)
   {
     int x = 4, y = 5;
     int w = 400, h = 500;
@@ -4211,8 +4212,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     {
       NewickFile fin = new NewickFile(
               new FileParse(cm.getNewick(), DataSourceType.PASTE));
-      String title = "PAE Matrix Tree for "
-              + cm.getReferenceSeq().getDisplayId(false);
+      String title = cm.getAnnotLabel() + " " + cm.getTreeMethod() + " tree"
+              + aa.sequenceRef != null
+                      ? (" for " + aa.sequenceRef.getDisplayId(false))
+                      : "";
 
       showColumnWiseTree(fin, aa, title, w, h, x, y);
     } catch (Throwable xx)
index 0a9d35f..e3cc36e 100755 (executable)
@@ -41,6 +41,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Locale;
+import java.util.concurrent.Callable;
 
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JMenuItem;
@@ -56,6 +57,7 @@ import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.ContactMatrixI;
+import jalview.datamodel.GroupSet;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
@@ -422,30 +424,60 @@ public class AnnotationLabels extends JPanel
         consclipbrd.addActionListener(this);
         pop.add(consclipbrd);
       }
-      if (aa[selectedRow].graph == AlignmentAnnotation.CONTACT_MAP
-              && PAEContactMatrix.PAEMATRIX
-                      .equals(aa[selectedRow].getCalcId()))
+      if (aa[selectedRow].graph == AlignmentAnnotation.CONTACT_MAP)
       {
-        final PAEContactMatrix cm = (PAEContactMatrix) av
-                .getContactMatrix(aa[selectedRow]);
-        if (cm != null && cm.hasTree())
+        
+        final ContactMatrixI cm = av.getContactMatrix(aa[selectedRow]);
+        if (cm != null)
         {
-          item = new JMenuItem("Show Tree for Matrix");
-          item.addActionListener(new ActionListener()
-          {
+          pop.addSeparator();
 
-            @Override
-            public void actionPerformed(ActionEvent e)
+          if (cm.hasTree())
+          {
+            item = new JMenuItem("Show Tree for Matrix");
+            item.addActionListener(new ActionListener()
             {
 
-              ap.alignFrame.showContactMapTree(aa[selectedRow], cm);
+              @Override
+              public void actionPerformed(ActionEvent e)
+              {
 
-            }
-          });
-          pop.addSeparator();
-          pop.add(item);
-        }
+                ap.alignFrame.showContactMapTree(aa[selectedRow], cm);
 
+              }
+            });
+            pop.add(item);
+          }
+          else
+          {
+            item = new JMenuItem("Calculate Tree for Matrix");
+            item.addActionListener(new ActionListener()
+            {
+              // TODO - refactor to analysis background thread
+              @Override
+              public void actionPerformed(ActionEvent e)
+              {
+                new Thread(new Runnable()
+                {
+                  @Override
+                  public void run()
+                  {
+                    AlignmentAnnotation alan = aa[selectedRow];
+                    cm.setGroupSet(GroupSet.makeGroups(cm, 5f, true));
+                    ap.alignFrame.showContactMapTree(alan, cm);
+                  }
+                }).start();
+              }
+            });
+            pop.add(item);
+
+          }
+          // Show/Hide group shading on matrix view
+          // Set/adjust threshold for grouping ?
+          // colour alignment by this [type]
+          // select/hide columns by this row
+          
+        }
       }
     }
     pop.show(this, evt.getX(), evt.getY());
index ce072e0..c822ef4 100644 (file)
@@ -1,36 +1,22 @@
 package jalview.ws.datamodel.alphafold;
 
-import java.awt.Color;
-import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.json.simple.JSONObject;
 
-import jalview.analysis.AverageDistanceEngine;
-import jalview.bin.Console;
-import jalview.datamodel.Annotation;
-import jalview.datamodel.BinaryNode;
 import jalview.datamodel.ContactListI;
 import jalview.datamodel.ContactListImpl;
 import jalview.datamodel.ContactListProviderI;
 import jalview.datamodel.ContactMatrixI;
 import jalview.datamodel.GroupSet;
-import jalview.datamodel.GroupSetI;
-import jalview.datamodel.Mapping;
 import jalview.datamodel.SequenceDummy;
 import jalview.datamodel.SequenceI;
-import jalview.io.DataSourceType;
 import jalview.io.FileFormatException;
-import jalview.io.FileParse;
 import jalview.util.MapList;
 import jalview.util.MapUtils;
 import jalview.ws.dbsources.EBIAlfaFold;
@@ -296,13 +282,13 @@ public class PAEContactMatrix extends
   @Override
   public int getWidth()
   {
-    return length;
+    return maxcol;
   }
 
   @Override
   public int getHeight()
   {
-    return length;
+    return maxrow;
   }
   public static void validateContactMatrixFile(String fileName)
           throws FileFormatException, IOException
index fd10c79..5ab05e0 100644 (file)
@@ -448,7 +448,6 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
     }
     ContactMatrixI matrix = new PAEContactMatrix(sequence,
             (Map<String, Object>) paeDict);
-    matrix.setGroupSet(GroupSet.makeGroups(matrix, 5f, true));
 
     AlignmentAnnotation cmannot = sequence.addContactList(matrix);
     if (label != null)
@@ -506,7 +505,6 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
     SequenceI seq = sm.getSequence();
     ContactMatrixI matrix = new PAEContactMatrix(seq,
             (Map<String, Object>) pae_obj);
-    matrix.setGroupSet(GroupSet.makeGroups(matrix, 5f, true));
     AlignmentAnnotation cmannot = sm.getSequence().addContactList(matrix);
     /* this already happens in Sequence.addContactList()
      seq.addAlignmentAnnotation(cmannot);