Merge branch 'kjvdh/features/PhylogenyViewer_tabbedsupport' into merge/2_11_2/kjvdh...
[jalview.git] / src / jalview / analysis / TreeCalculator.java
diff --git a/src/jalview/analysis/TreeCalculator.java b/src/jalview/analysis/TreeCalculator.java
new file mode 100644 (file)
index 0000000..84deba2
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($Version-Rel$)
+ * Copyright (C) $Year-Rel$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.analysis;
+
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.api.analysis.ScoreModelI;
+import jalview.api.analysis.SimilarityParamsI;
+import jalview.gui.AlignViewport;
+
+/**
+ * @author kjvanderheide
+ *
+ */
+public class TreeCalculator extends Thread// add threading
+{
+  SimilarityParamsI similarityParams;
+
+  String treeType;
+
+  String scoreModelName; // if tree computed
+
+  /**
+   * 
+   * @param treeAlgo
+   * @param substitutionMatrix
+   * @param calculateParams
+   */
+  public TreeCalculator(String treeAlgo, String substitutionMatrix,
+          SimilarityParamsI calculateParams)
+  {
+    this.treeType = treeAlgo;
+    this.scoreModelName = substitutionMatrix;
+    this.similarityParams = calculateParams;
+  }
+
+  /**
+   * 
+   * @param alignViewport
+   * @return
+   */
+  public TreeBuilder makeTree(AlignViewport alignViewport)
+  {
+    ScoreModelI sm = ScoreModels.getInstance().getScoreModel(scoreModelName,
+            alignViewport.getAlignPanel());
+
+    TreeBuilder builtTree = treeType.equals(TreeBuilder.NEIGHBOUR_JOINING)
+            ? new NJTree(alignViewport, sm, similarityParams)
+            : new AverageDistanceTree(alignViewport, sm, similarityParams);
+
+    return builtTree;
+
+  }
+
+  public SimilarityParamsI getSimilarityParams()
+  {
+    return similarityParams;
+  }
+
+  public void setSimilarityParams(SimilarityParamsI similarityParams)
+  {
+    this.similarityParams = similarityParams;
+  }
+
+  public String getTreeType()
+  {
+    return treeType;
+  }
+
+  public void setTreeType(String treeType)
+  {
+    this.treeType = treeType;
+  }
+
+  public String getScoreModelName()
+  {
+    return scoreModelName;
+  }
+
+  public void setScoreModelName(String scoreModelName)
+  {
+    this.scoreModelName = scoreModelName;
+  }
+
+
+
+
+}