Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * MRCAOlderThanStatistic.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.coalescent.TreeIntervals;
29 import dr.evolution.tree.Tree;
30
31 /**
32 * Returns the total time in the genealogy in which exactly k lineages are present.
33 *
34 * @version $Id: IntervalKStatistic.java,v 1.2 2005/09/28 13:50:56 rambaut Exp $
35 *
36 * @author Alexei Drummond
37 */
38 public class MRCAOlderThanStatistic extends AbstractTreeSummaryStatistic {
39
40 public MRCAOlderThanStatistic() {
41 this.t = 1.0;
42 }
43
44 public void setDouble(double value) {
45 this.t = value;
46 }
47
48 public double[] getSummaryStatistic(Tree tree) {
49
50 TreeIntervals intervals = new TreeIntervals(tree);
51
52 double totalTime = 0.0;
53 for (int i = 0; i < intervals.getIntervalCount(); i++) {
54 totalTime += intervals.getInterval(i);
55 if (totalTime > t) {
56 return new double[] { 1.0 };
57 }
58 }
59 return new double[] { 0.0 };
60 }
61
62 public String getSummaryStatisticName() {
63 return "MRCAOlderThan(" + t + ")";
64 }
65
66 public String getSummaryStatisticDescription() {
67 return getSummaryStatisticName() + " is 1 if the MRCA of the genealogy older than " +
68 "time " + t + ".";
69 }
70
71 public String getSummaryStatisticReference() { return FACTORY.getSummaryStatisticReference(); }
72 public boolean allowsPolytomies() { return FACTORY.allowsPolytomies(); }
73 public boolean allowsNonultrametricTrees() { return FACTORY.allowsNonultrametricTrees(); }
74 public boolean allowsUnrootedTrees() { return FACTORY.allowsUnrootedTrees(); }
75 public Category getCategory() { return FACTORY.getCategory(); }
76
77 public static final Factory FACTORY = new Factory() {
78
79 public TreeSummaryStatistic createStatistic() {
80 return new MRCAOlderThanStatistic();
81 }
82
83 public String getSummaryStatisticName() {
84 return "LineageCount(t)";
85 }
86
87 public String getSummaryStatisticDescription() {
88 return getSummaryStatisticName() + " is 1 if the MRCA of the genealogy older than " +
89 "time t.";
90 }
91
92 public String getSummaryStatisticReference() {
93 return "-";
94 }
95
96 public String getValueName() { return "The time (t):"; }
97 public boolean allowsPolytomies() { return true; }
98
99 public boolean allowsNonultrametricTrees() { return true; }
100
101 public boolean allowsUnrootedTrees() { return false; }
102
103 public Category getCategory() { return Category.POPULATION_GENETIC; }
104
105 public boolean allowsWholeTree() { return true; }
106
107 public boolean allowsCharacter() { return false; }
108
109 public boolean allowsCharacterState() { return false; }
110
111 public boolean allowsTaxonList() { return false; }
112
113 public boolean allowsInteger() { return false; }
114
115 public boolean allowsDouble() { return true; }
116 };
117
118 double t = 1.0;
119 }