X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FCalculationChooser.java;fp=src%2Fjalview%2Fgui%2FCalculationChooser.java;h=c43d59b8c1f5d3983e14ba43449d40b32e955f15;hb=f96e6a945e2df8a844f428c08cfc08210d937fc0;hp=f7e5413b3c4958f13f1180346bffebe087551f10;hpb=11346f873e4ecb2d191499fd1d52b8de07a65bf3;p=jalview.git diff --git a/src/jalview/gui/CalculationChooser.java b/src/jalview/gui/CalculationChooser.java index f7e5413..c43d59b 100644 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@ -21,12 +21,15 @@ package jalview.gui; import jalview.analysis.TreeBuilder; +import jalview.analysis.TreeCalculator; +import jalview.analysis.TreeModel; import jalview.analysis.scoremodels.ScoreModels; import jalview.analysis.scoremodels.SimilarityParams; import jalview.api.analysis.ScoreModelI; import jalview.api.analysis.SimilarityParamsI; import jalview.bin.Cache; import jalview.datamodel.SequenceGroup; +import jalview.ext.archaeopteryx.AptxInit; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -424,7 +427,6 @@ public class CalculationChooser extends JPanel Object curSel = comboBox.getSelectedItem(); toolTips.clear(); DefaultComboBoxModel model = new DefaultComboBoxModel<>(); - /* * select the score models applicable to the alignment type */ @@ -514,34 +516,54 @@ public class CalculationChooser extends JPanel protected void calculate_actionPerformed() { boolean doPCA = pca.isSelected(); - String modelName = modelNames.getSelectedItem().toString(); + String substitutionMatrix = modelNames.getSelectedItem().toString(); SimilarityParamsI params = getSimilarityParameters(doPCA); if (doPCA) { - openPcaPanel(modelName, params); + openPcaPanel(substitutionMatrix, params); } else { - openTreePanel(modelName, params); + createTree(substitutionMatrix, params); + + + + + + } // closeFrame(); } - /** - * Open a new Tree panel on the desktop - * - * @param modelName - * @param params - */ - protected void openTreePanel(String modelName, SimilarityParamsI params) + protected void createTree(String substitutionMatrix, + SimilarityParamsI params) + { + String treeAlgo = determineTreeAlgo(); + TreeCalculator treeCalculator = new TreeCalculator(treeAlgo, + substitutionMatrix, params); + TreeBuilder calculatedTree = treeCalculator.makeTree(af.getViewport()); + + AptxInit.createInstance(calculatedTree); + + TreeModel tree = new TreeModel(calculatedTree); + openTreePanel(tree, treeAlgo, substitutionMatrix); + } + + + protected String determineTreeAlgo() // to be modified & expanded + { + String treeAlgorithm = neighbourJoining.isSelected() + ? TreeBuilder.NEIGHBOUR_JOINING + : TreeBuilder.AVERAGE_DISTANCE; + + return treeAlgorithm; + + } + + protected void checkEnoughSequences(AlignViewport viewport) { - /* - * gui validation shouldn't allow insufficient sequences here, but leave - * this check in in case this method gets exposed programmatically in future - */ - AlignViewport viewport = af.getViewport(); SequenceGroup sg = viewport.getSelectionGroup(); if (sg != null && sg.getSize() < MIN_TREE_SELECTION) { @@ -553,11 +575,25 @@ public class CalculationChooser extends JPanel JvOptionPane.WARNING_MESSAGE); return; } + } - String treeType = neighbourJoining.isSelected() - ? TreeBuilder.NEIGHBOUR_JOINING - : TreeBuilder.AVERAGE_DISTANCE; - af.newTreePanel(treeType, modelName, params); + /** + * Open a new Tree panel on the desktop + * + * @param tree + * @param params + * @param treeAlgo + */ + protected void openTreePanel(TreeModel tree, String treeAlgo, + String substitutionMatrix) + { + /* + * gui validation shouldn't allow insufficient sequences here, but leave + * this check in in case this method gets exposed programmatically in future + */ + checkEnoughSequences(af.getViewport()); + + af.newTreePanel(tree, treeAlgo, substitutionMatrix); } /**