Debian Codegraph @

src/dr/evomodel/tree/TreeShapeStatistic.java

raw symbols SCIP
1 /*
2 * TreeShapeStatistic.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.evomodel.tree;
27
28 import dr.evolution.tree.Tree;
29 import dr.evolution.tree.TreeShape;
30 import dr.evolution.tree.TreeUtils;
31 import dr.inference.model.Statistic;
32
33
34 /**
35 * A statistic that returns the values of various tree shape statistics.
36 *
37 * @author Alexei Drummond
38 * @version $Id: TreeShapeStatistic.java,v 1.4 2005/07/11 14:06:25 rambaut Exp $
39 */
40 public class TreeShapeStatistic extends TreeStatistic {
41
42 public TreeShapeStatistic(String name, TreeModel target) {
43 super(name);
44 this.target = target;
45 ultrametric = TreeUtils.isUltrametric(target);
46 }
47
48 public void setTree(Tree tree) {
49 this.target = tree;
50 }
51
52 public Tree getTree() {
53 return target;
54 }
55
56 public int getDimension() {
57 if (ultrametric) return 5;
58 return 4;
59 }
60
61 public String getDimensionName(int dim) {
62 switch (dim) {
63 case 0:
64 return "N-bar";
65 case 1:
66 return "N-bar-var";
67 case 2:
68 return "C";
69 case 3:
70 return "B1";
71 case 4:
72 return "gamma";
73 }
74 throw new IllegalArgumentException("Dimension doesn't exist!");
75 }
76
77 /**
78 * @return value.
79 */
80 public double getStatisticValue(int dim) {
81
82 switch (dim) {
83 case 0:
84 return TreeShape.getNBarStatistic(target);
85 case 1:
86 return TreeShape.getVarNBarStatistic(target);
87 case 2:
88 return TreeShape.getCStatistic(target);
89 case 3:
90 return TreeShape.getB1Statistic(target);
91 case 4:
92 return TreeShape.getGammaStatistic(target);
93 }
94 throw new IllegalArgumentException("Dimension doesn't exist!");
95 }
96
97 private Tree target = null;
98 private boolean ultrametric = false;
99 }