| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.app.treestat.statistics; |
| 27 |
|
| 28 |
import dr.evolution.coalescent.TreeIntervals; |
| 29 |
import dr.evolution.tree.Tree; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 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 |
} |