| 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 IntervalKStatistic extends AbstractTreeSummaryStatistic { |
| 39 |
|
| 40 |
public IntervalKStatistic() { |
| 41 |
this.k = 2; |
| 42 |
} |
| 43 |
|
| 44 |
public void setInteger(int value) { |
| 45 |
this.k = value; |
| 46 |
} |
| 47 |
|
| 48 |
public double[] getSummaryStatistic(Tree tree) { |
| 49 |
|
| 50 |
TreeIntervals intervals = new TreeIntervals(tree); |
| 51 |
|
| 52 |
double totalTime = 0.0; |
| 53 |
int intervalCount = intervals.getIntervalCount(); |
| 54 |
for (int i = 0; i < intervalCount; i++) { |
| 55 |
if (intervals.getLineageCount(i) == k) { |
| 56 |
totalTime += intervals.getInterval(i); |
| 57 |
} |
| 58 |
} |
| 59 |
return new double[] { totalTime }; |
| 60 |
} |
| 61 |
|
| 62 |
public String getSummaryStatisticName() { |
| 63 |
return "TotalTime(" + k + ")"; |
| 64 |
} |
| 65 |
|
| 66 |
public String getSummaryStatisticDescription() { |
| 67 |
return getSummaryStatisticName() + " is the total amount of time in the genealogy that " + |
| 68 |
"exactly " + k + " lineages exist."; |
| 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 SummaryStatisticDescription.Category getCategory() { return FACTORY.getCategory(); } |
| 76 |
|
| 77 |
public static final TreeSummaryStatistic.Factory FACTORY = new TreeSummaryStatistic.Factory() { |
| 78 |
|
| 79 |
public TreeSummaryStatistic createStatistic() { |
| 80 |
return new IntervalKStatistic(); |
| 81 |
} |
| 82 |
|
| 83 |
public String getSummaryStatisticName() { |
| 84 |
return "TotalTime(k)"; |
| 85 |
} |
| 86 |
|
| 87 |
public String getSummaryStatisticDescription() { |
| 88 |
return getSummaryStatisticName() + " is the total amount of time in the genealogy that " + |
| 89 |
"exactly k lineages exist."; |
| 90 |
} |
| 91 |
|
| 92 |
public String getSummaryStatisticReference() { |
| 93 |
return "-"; |
| 94 |
} |
| 95 |
|
| 96 |
public String getValueName() { return "The number of lineaeges (k):"; } |
| 97 |
|
| 98 |
public boolean allowsPolytomies() { return true; } |
| 99 |
|
| 100 |
public boolean allowsNonultrametricTrees() { return true; } |
| 101 |
|
| 102 |
public boolean allowsUnrootedTrees() { return false; } |
| 103 |
|
| 104 |
public TreeSummaryStatistic.Category getCategory() { return TreeSummaryStatistic.Category.POPULATION_GENETIC; } |
| 105 |
|
| 106 |
public boolean allowsWholeTree() { return true; } |
| 107 |
public boolean allowsCharacter() { return false; } |
| 108 |
public boolean allowsCharacterState() { return false; } |
| 109 |
public boolean allowsTaxonList() { return false; } |
| 110 |
public boolean allowsInteger() { return true; } |
| 111 |
public boolean allowsDouble() { return false; } |
| 112 |
}; |
| 113 |
|
| 114 |
int k = 1; |
| 115 |
} |