JAL-2403 constants for "NJ", "AV"
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 17 Feb 2017 10:31:11 +0000 (10:31 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 17 Feb 2017 10:31:11 +0000 (10:31 +0000)
src/jalview/analysis/NJTree.java
src/jalview/appletgui/AlignFrame.java
src/jalview/gui/TreeChooser.java
src/jalview/gui/TreePanel.java
src/jalview/io/vamsas/Tree.java

index fcf208c..a7ead1d 100644 (file)
@@ -44,6 +44,10 @@ import java.util.Vector;
  */
 public class NJTree
 {
+  public static final String AVERAGE_DISTANCE = "AV";
+
+  public static final String NEIGHBOUR_JOINING = "NJ";
+
   Vector<Cluster> cluster;
 
   SequenceI[] sequence;
@@ -237,9 +241,9 @@ public class NJTree
       this.seqData = new AlignmentView(sdata, start);
     }
     // System.err.println("Made seqData");// dbg
-    if (!(type.equals("NJ")))
+    if (!(type.equals(NEIGHBOUR_JOINING)))
     {
-      type = "AV";
+      type = AVERAGE_DISTANCE;
     }
 
     if (sm == null && !(pwtype.equals("PID")))
@@ -384,7 +388,7 @@ public class NJTree
   {
     while (noClus > 2)
     {
-      if (type.equals("NJ"))
+      if (type.equals(NEIGHBOUR_JOINING))
       {
         findMinNJDistance();
       }
@@ -466,7 +470,7 @@ public class NJTree
     ri = findr(i, j);
     rj = findr(j, i);
 
-    if (type.equals("NJ"))
+    if (type.equals(NEIGHBOUR_JOINING))
     {
       findClusterNJDistance(i, j);
     }
@@ -483,7 +487,7 @@ public class NJTree
     SequenceNode tmpi = (node.elementAt(i));
     SequenceNode tmpj = (node.elementAt(j));
 
-    if (type.equals("NJ"))
+    if (type.equals(NEIGHBOUR_JOINING))
     {
       findNewNJDistances(tmpi, tmpj, dist);
     }
index 6a0b390..221f793 100644 (file)
@@ -22,6 +22,7 @@ package jalview.appletgui;
 
 import jalview.analysis.AlignmentSorter;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
+import jalview.analysis.NJTree;
 import jalview.api.AlignViewControllerGuiI;
 import jalview.api.AlignViewControllerI;
 import jalview.api.AlignViewportI;
@@ -2805,22 +2806,26 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   public void averageDistanceTreeMenuItem_actionPerformed()
   {
-    NewTreePanel("AV", "PID", "Average distance tree using PID");
+    NewTreePanel(NJTree.AVERAGE_DISTANCE, "PID",
+            "Average distance tree using PID");
   }
 
   public void neighbourTreeMenuItem_actionPerformed()
   {
-    NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
+    NewTreePanel(NJTree.NEIGHBOUR_JOINING, "PID",
+            "Neighbour joining tree using PID");
   }
 
   protected void njTreeBlosumMenuItem_actionPerformed()
   {
-    NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
+    NewTreePanel(NJTree.NEIGHBOUR_JOINING, "BL",
+            "Neighbour joining tree using BLOSUM62");
   }
 
   protected void avTreeBlosumMenuItem_actionPerformed()
   {
-    NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62");
+    NewTreePanel(NJTree.AVERAGE_DISTANCE, "BL",
+            "Average distance tree using BLOSUM62");
   }
 
   void NewTreePanel(String type, String pwType, String title)
index 40c683d..8e2bff0 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.gui;
 
+import jalview.analysis.NJTree;
 import jalview.analysis.scoremodels.ScoreModels;
 import jalview.api.analysis.ScoreModelI;
 import jalview.util.MessageManager;
@@ -148,7 +149,8 @@ public class TreeChooser extends JPanel
     try
     {
       frame.setClosed(true);
-      String treeType = neighbourJoining.isSelected() ? "NJ" : "AV";
+      String treeType = neighbourJoining.isSelected() ? NJTree.NEIGHBOUR_JOINING
+              : NJTree.AVERAGE_DISTANCE;
       ScoreModelI sm = ScoreModels.getInstance().forName(
               matrixNames.getSelectedItem().toString());
       af.newTreePanel(treeType, sm);
index 7a205b6..477c28d 100755 (executable)
@@ -402,7 +402,7 @@ public class TreePanel extends GTreePanel
 
     StringBuffer buffer = new StringBuffer();
 
-    if (type.equals("AV"))
+    if (type.equals(NJTree.AVERAGE_DISTANCE))
     {
       buffer.append("Average distance tree using ");
     }
@@ -411,17 +411,10 @@ public class TreePanel extends GTreePanel
       buffer.append("Neighbour joining tree using ");
     }
 
-    if (pwtype.equals("BL"))
-    {
-      buffer.append("BLOSUM62");
-    }
-    else
-    {
-      buffer.append("PID");
-    }
+    ScoreModelI sm = ScoreModels.getInstance().forName(pwtype);
+    buffer.append(sm.getName());
 
-    jalview.io.NewickFile fout = new jalview.io.NewickFile(
-            tree.getTopNode());
+    NewickFile fout = new NewickFile(tree.getTopNode());
     try
     {
       cap.setText(fout.print(tree.isHasBootstrap(), tree.isHasDistances(),
index a3781a7..89877e2 100644 (file)
@@ -239,8 +239,8 @@ public class Tree extends DatastoreItem
       prov.getEntry(0).addParam(new Param());
       prov.getEntry(0).getParam(0).setName("treeType");
       prov.getEntry(0).getParam(0).setType("utf8");
-      prov.getEntry(0).getParam(0).setContent("NJ"); // TODO: type of tree is a
-      // general parameter
+      prov.getEntry(0).getParam(0).setContent(NJTree.NEIGHBOUR_JOINING);
+      // TODO: type of tree is a general parameter
       int ranges[] = tp.getTree().seqData.getVisibleContigs();
       // VisibleContigs are with respect to alignment coordinates. Still need
       // offsets