diff --git a/src/beast/app/tools/SATreeTraceAnalysis.java b/src/beast/app/tools/SATreeTraceAnalysis.java index 1801dee..4a2aec6 100644 --- a/src/beast/app/tools/SATreeTraceAnalysis.java +++ b/src/beast/app/tools/SATreeTraceAnalysis.java @@ -18,7 +18,6 @@ */ public class SATreeTraceAnalysis extends TreeTraceAnalysis { - FrequencySet pairs = new FrequencySet(); public SATreeTraceAnalysis(List posteriorTreeList, double burninFraction) { @@ -79,7 +78,7 @@ public List getNewickTrees () { * @return a report string * @throws Exception */ - public String toReportString(boolean printCladeFrequencies, boolean printPairs, boolean printFrequencies, boolean printTopologyCredibleSet, boolean isHTML) throws Exception { + public String toReportString(boolean printCladeFrequencies, boolean printPairs, boolean printFrequencies, boolean printTopologyCredibleSet, Double credSetProbability, boolean isHTML) throws Exception { FrequencySet clades = new FrequencySet(); ArrayList tmp = new ArrayList(); @@ -168,7 +167,7 @@ public String toReportString(boolean printCladeFrequencies, boolean printPairs, } if (printTopologyCredibleSet) { - countTopologies(output); + countTopologies(output, credSetProbability); } ps.flush(); @@ -324,8 +323,9 @@ public FrequencySet countSAFrequencies(boolean print, boolean useRanking /** * */ - public void countTopologies(ResultsOutput output) { + public void countTopologies(ResultsOutput output, Double credSetProbability) { FrequencySet topologies = new FrequencySet(); + topologies.setCredSetProbability(credSetProbability); List trees; trees = getNewickTrees(true); diff --git a/src/beast/app/tools/SampledAncestorTreeAnalyser.java b/src/beast/app/tools/SampledAncestorTreeAnalyser.java index 68aef12..6a95c70 100644 --- a/src/beast/app/tools/SampledAncestorTreeAnalyser.java +++ b/src/beast/app/tools/SampledAncestorTreeAnalyser.java @@ -33,19 +33,25 @@ public class SampledAncestorTreeAnalyser extends beast.core.Runnable { private Boolean printCladeFrequencies = false; private Boolean printTopologyCredibleSet = false; private Boolean toStandardOutput = true; + private Double credibleSetProportion = 0.95; + private Double burninProportion = 0.1; public SampledAncestorTreeAnalyser() {} public SampledAncestorTreeAnalyser(@Param(name="file", description="tree file containing set of ancestral ancestor trees") File file, + @Param(name="burnin", description="percentage of trees to be discarded as burn-in", defaultValue="10.0") Double burninPercentage, @Param(name="printFrequencies", description="show sampled ancestor frequencies in output table", defaultValue="true") Boolean printFrequencies, @Param(name="printPairs", description="show ancestor-descendant pair frequencies in output table", defaultValue="false") Boolean printPairs, @Param(name="printCladeFrequencies", description="show sampled ancestor clade frequencies in output table", defaultValue="false") Boolean printCladeFrequencies, @Param(name="printTopologyCredibleSet", description="show sampled ancestor tree topology frequencies in output table", defaultValue="false") Boolean printTopologyCredibleSet, + @Param(name="credibleSet", description="percent coverage of the credible set (used for printTopologyCredibleSet)", defaultValue="95.0") Double credibleSetPercentage, @Param(name="toStandardOutput", description="print to standard output", defaultValue="true") Boolean toStdOut) { this.file = file; + this.burninProportion = burninPercentage / 100.0; this.printFrequencies = printFrequencies; this.printPairs = printPairs; this.printCladeFrequencies = printCladeFrequencies; this.printTopologyCredibleSet = printTopologyCredibleSet; + this.credibleSetProportion = credibleSetPercentage / 100.0; this.toStandardOutput = toStdOut; } @@ -87,7 +93,23 @@ public Boolean getPrintTopologyCredibleSet() { public void setPrintTopologyCredibleSet(Boolean printTopologyCredibleSet) { this.printTopologyCredibleSet = printTopologyCredibleSet; } + + public Double getBurnin() { + return this.burninProportion * 100.0; + } + public void setBurnin(Double burnin) { + this.burninProportion = burnin / 100.0; + } + + public Double getCredibleSet() { + return this.credibleSetProportion * 100.0; + } + + public void setCredibleSet(Double credibleSet) { + this.credibleSetProportion = credibleSet / 100.0; + } + public void run() throws Exception { FileReader reader = null; @@ -96,9 +118,9 @@ public void run() throws Exception { System.out.println("Reading file " + file.getName()); reader = new FileReader(file); List trees = SATreeTraceAnalysis.Utils.getTrees(file); - SATreeTraceAnalysis analysis = new SATreeTraceAnalysis(trees, 0.1); + SATreeTraceAnalysis analysis = new SATreeTraceAnalysis(trees, burninProportion); - String result = analysis.toReportString(printCladeFrequencies, printPairs, printFrequencies, printTopologyCredibleSet, !toStandardOutput); + String result = analysis.toReportString(printCladeFrequencies, printPairs, printFrequencies, printTopologyCredibleSet, credibleSetProportion, !toStandardOutput); if (toStandardOutput) { System.out.println(result);