From: gmungoc Date: Fri, 17 Feb 2017 10:31:11 +0000 (+0000) Subject: JAL-2403 constants for "NJ", "AV" X-Git-Tag: Release_2_10_2~3^2~105^2~2^2~116 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d87d21c30c8d1f6a70f7d04f3f33e5210d0f367a;p=jalview.git JAL-2403 constants for "NJ", "AV" --- diff --git a/src/jalview/analysis/NJTree.java b/src/jalview/analysis/NJTree.java index fcf208c..a7ead1d 100644 --- a/src/jalview/analysis/NJTree.java +++ b/src/jalview/analysis/NJTree.java @@ -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; 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); } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 6a0b390..221f793 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -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) diff --git a/src/jalview/gui/TreeChooser.java b/src/jalview/gui/TreeChooser.java index 40c683d..8e2bff0 100644 --- a/src/jalview/gui/TreeChooser.java +++ b/src/jalview/gui/TreeChooser.java @@ -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); diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index 7a205b6..477c28d 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -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(), diff --git a/src/jalview/io/vamsas/Tree.java b/src/jalview/io/vamsas/Tree.java index a3781a7..89877e2 100644 --- a/src/jalview/io/vamsas/Tree.java +++ b/src/jalview/io/vamsas/Tree.java @@ -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