Skip to content

Commit

Permalink
make MultiPartitionTreeLikelihood work with ThreadedTreeLikelihoods
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Oct 16, 2024
1 parent 8b32cb9 commit f431489
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/testMultiParitionTreeLikelihood.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec="Alignment">
</distribution>
<distribution id="likelihood" spec="CompoundDistribution" useThreads="true">
<distribution id="MultiPartitionTreeLikelihood0" spec="CompoundDistribution" useThreads="true">
<distribution id="treeLikelihood.firsthalf" spec="TreeLikelihood" data="@firsthalf" tree="@Tree.t:tree">
<distribution id="treeLikelihood.firsthalf" spec="ThreadedTreeLikelihood" data="@firsthalf" tree="@Tree.t:tree">
<siteModel id="SiteModel.s:firsthalf" spec="SiteModel" gammaCategoryCount="4" shape="@gammaShape.s:firsthalf">
<mutationRate idref="mutationRate.s:firsthalf"/>
<parameter id="proportionInvariant.s:firsthalf" spec="parameter.RealParameter" estimate="false" lower="0.0" name="proportionInvariant" upper="1.0">0.0</parameter>
Expand Down
12 changes: 10 additions & 2 deletions src/beastlabs/evolution/likelihood/BeagleDebugger.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,19 @@ private void print(String str, double v) {
}

private void print(String str, int[] v) {
out.println(" /*" + str + " = */" + (v == null ? "null" : "new int[] {" + Arrays.toString(v).replaceAll("[\\[\\]]","") + "},"));
String values = v == null ? "null" : Arrays.toString(v).replaceAll("[\\[\\]]","");
if (values.length() > 100) {
values = values.substring(0, 100) + "...";
}
out.println(" /*" + str + " = */" + (v == null ? "null" : "new int[] {" + values + "},"));
}

private void print(String str, double[] v) {
out.println(" /*" + str + " = */" + (v == null ? "null" : "new double[] {" + Arrays.toString(v).replaceAll("[\\[\\]]","") + "},"));
String values = v == null ? "null" : Arrays.toString(v).replaceAll("[\\[\\]]","");
if (values.length() > 100) {
values = values.substring(0, 100) + "...";
}
out.println(" /*" + str + " = */" + (v == null ? "null" : "new double[] {" + values + "},"));
}

public void setCPUThreadCount(int threadCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import beast.base.evolution.likelihood.BeagleTreeLikelihood.PartialsRescalingScheme;
import beast.base.evolution.likelihood.TreeLikelihood.Scaling;
import beast.base.evolution.likelihood.GenericTreeLikelihood;
import beast.base.evolution.likelihood.ThreadedTreeLikelihood;
import beast.base.evolution.sitemodel.SiteModel;
import beast.base.evolution.substitutionmodel.EigenDecomposition;
import beast.base.evolution.substitutionmodel.SubstitutionModel;
Expand Down Expand Up @@ -205,7 +206,7 @@ public void initAndValidate() {
tree = tl0.treeInput.get();
branchRateModel = tl0.branchRateModelInput.get();
boolean useAmbiguities = (boolean) tl0.getInput("useAmbiguities").get();
boolean useTipLikelihoods = (boolean) tl0.getInput("useTipLikelihoods").get();
boolean useTipLikelihoods = tl0 instanceof ThreadedTreeLikelihood ? false : (boolean) tl0.getInput("useTipLikelihoods").get();
rescalingScheme = getRescalingScheme(tl0);

for (GenericTreeLikelihood tl : likelihoodsInput.get()) {
Expand All @@ -223,7 +224,9 @@ public void initAndValidate() {
throw new IllegalArgumentException("All partitions must use ambiguities, or ignore ambiguities, but found a difference between " +
tl.getID() + " and " + likelihoodsInput.get().get(0).getID());
}
if (useTipLikelihoods != (boolean)tl.getInput("useTipLikelihoods").get()) {

boolean b = tl instanceof ThreadedTreeLikelihood ? false : (boolean)tl.getInput("useTipLikelihoods").get();
if (useTipLikelihoods != b) {
throw new IllegalArgumentException("All partitions must use tip likelihoods, or ignore tip likelihoods, but found a difference between " +
tl.getID() + " and " + likelihoodsInput.get().get(0).getID());
}
Expand Down

0 comments on commit f431489

Please sign in to comment.