Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * ExternalBranchRates.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 ExternalBranchRates implements TreeSummaryStatistic {
36
37 private ExternalBranchRates() {
38 }
39
40 public int getStatisticDimensions(Tree tree) {
41 return tree.getExternalNodeCount();
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 externalNodeCount = tree.getExternalNodeCount();
51 double[] stats = new double[externalNodeCount];
52 int count = 0;
53 for (int i = 0; i < externalNodeCount; i++) {
54 NodeRef node = tree.getExternalNode(i);
55 stats[count++] = (Double) tree.getNodeAttribute(node, "rate");
56 }
57 //Arrays.sort(stats);
58
59 return stats;
60 }
61
62 public void setTaxonList(TaxonList taxonList) {
63 throw new UnsupportedOperationException("not implemented in this statistic");
64 }
65
66 public void setInteger(int value) {
67 throw new UnsupportedOperationException("not implemented in this statistic");
68 }
69
70 public void setDouble(double value) {
71 throw new UnsupportedOperationException("not implemented in this statistic");
72 }
73
74 public void setString(String value) {
75 throw new UnsupportedOperationException("not implemented in this statistic");
76 }
77
78 public String getSummaryStatisticName() {
79 return FACTORY.getSummaryStatisticName();
80 }
81
82 public String getSummaryStatisticDescription() {
83 return FACTORY.getSummaryStatisticDescription();
84 }
85
86 public String getSummaryStatisticReference() {
87 return FACTORY.getSummaryStatisticReference();
88 }
89
90 public boolean allowsPolytomies() {
91 return FACTORY.allowsPolytomies();
92 }
93
94 public boolean allowsNonultrametricTrees() {
95 return FACTORY.allowsNonultrametricTrees();
96 }
97
98 public boolean allowsUnrootedTrees() {
99 return FACTORY.allowsUnrootedTrees();
100 }
101
102 public Category getCategory() {
103 return FACTORY.getCategory();
104 }
105
106 public static final Factory FACTORY = new Factory() {
107
108 public TreeSummaryStatistic createStatistic() {
109 return new ExternalBranchRates();
110 }
111
112 public String getSummaryStatisticName() {
113 return "External Branch Rates";
114 }
115
116 public String getSummaryStatisticDescription() {
117
118 return "The rates of the external edges of the tree.";
119 }
120
121 public String getSummaryStatisticReference() {
122
123 return "-";
124 }
125
126 public boolean allowsPolytomies() {
127 return true;
128 }
129
130 public boolean allowsNonultrametricTrees() {
131 return true;
132 }
133
134 public boolean allowsUnrootedTrees() {
135 return false;
136 }
137
138 public Category getCategory() {
139 return Category.GENERAL;
140 }
141 };
142 }