Debian Codegraph @

src/dr/app/treestat/statistics/InternalBranchRates.java

raw symbols SCIP
1 /*
2 * InternalBranchRates.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.app.treestat.statistics;
27
28 import dr.evolution.tree.NodeRef;
29 import dr.evolution.tree.Tree;
30 import dr.evolution.util.TaxonList;
31
32 /**
33 * @author Alexei Drummond
34 */
35 public class InternalBranchRates implements TreeSummaryStatistic {
36
37 private InternalBranchRates() {
38 }
39
40 public int getStatisticDimensions(Tree tree) {
41 return tree.getInternalNodeCount() - 1;
42 }
43
44 public String getStatisticLabel(Tree tree, int i) {
45 return "Branch Rate " + Integer.toString(i + 1);
46 }
47
48 public double[] getSummaryStatistic(Tree tree) {
49
50 int internalNodeCount = tree.getInternalNodeCount();
51 double[] stats = new double[internalNodeCount - 1];
52 int count = 0;
53 for (int i = 0; i < internalNodeCount; i++) {
54 NodeRef node = tree.getInternalNode(i);
55 if (!tree.isRoot(node)) {
56 stats[count++] = (Double) tree.getNodeAttribute(node, "rate");
57 }
58 }
59 //Arrays.sort(stats);
60
61 return stats;
62 }
63
64 public void setTaxonList(TaxonList taxonList) {
65 throw new UnsupportedOperationException("not implemented in this statistic");
66 }
67
68 public void setInteger(int value) {
69 throw new UnsupportedOperationException("not implemented in this statistic");
70 }
71
72 public void setDouble(double value) {
73 throw new UnsupportedOperationException("not implemented in this statistic");
74 }
75
76 public void setString(String value) {
77 throw new UnsupportedOperationException("not implemented in this statistic");
78 }
79
80 public String getSummaryStatisticName() {
81 return FACTORY.getSummaryStatisticName();
82 }
83
84 public String getSummaryStatisticDescription() {
85 return FACTORY.getSummaryStatisticDescription();
86 }
87
88 public String getSummaryStatisticReference() {
89 return FACTORY.getSummaryStatisticReference();
90 }
91
92 public boolean allowsPolytomies() {
93 return FACTORY.allowsPolytomies();
94 }
95
96 public boolean allowsNonultrametricTrees() {
97 return FACTORY.allowsNonultrametricTrees();
98 }
99
100 public boolean allowsUnrootedTrees() {
101 return FACTORY.allowsUnrootedTrees();
102 }
103
104 public Category getCategory() {
105 return FACTORY.getCategory();
106 }
107
108 public static final Factory FACTORY = new Factory() {
109
110 public TreeSummaryStatistic createStatistic() {
111 return new InternalBranchRates();
112 }
113
114 public String getSummaryStatisticName() {
115 return "Internal Branch Rates";
116 }
117
118 public String getSummaryStatisticDescription() {
119
120 return "The rates of the internal edges of the tree.";
121 }
122
123 public String getSummaryStatisticReference() {
124
125 return "-";
126 }
127
128 public boolean allowsPolytomies() {
129 return true;
130 }
131
132 public boolean allowsNonultrametricTrees() {
133 return true;
134 }
135
136 public boolean allowsUnrootedTrees() {
137 return false;
138 }
139
140 public Category getCategory() {
141 return Category.GENERAL;
142 }
143 };
144 }