Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/BEAST2-Dev/bdsky
Browse files Browse the repository at this point in the history
  • Loading branch information
denisekuehnert committed Apr 20, 2016
2 parents 6f92f35 + 9090d68 commit c8f7da0
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/beast/evolution/speciation/BirthDeathSkylineModel.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package beast.evolution.speciation;


import beast.core.BEASTInterface;
import beast.core.Citation;
import beast.core.Description;
import beast.core.Input;
import beast.core.MCMC;
import beast.core.Operator;
import beast.core.parameter.BooleanParameter;
import beast.core.parameter.RealParameter;
import beast.core.util.Log;
import beast.evolution.alignment.Taxon;
import beast.evolution.operators.Exchange;
import beast.evolution.operators.SubtreeSlide;
import beast.evolution.operators.TipDatesRandomWalker;
import beast.evolution.operators.WilsonBalding;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeInterface;
import beast.math.distributions.Uniform;

import java.util.*;

Expand Down Expand Up @@ -303,8 +312,55 @@ public void initAndValidate() {
}

printTempResults = false;

// sanity check for sampled ancestor analysis
// make sure that operators are valid for such an analysis
boolean isSAAnalysis = false;
if (removalProbability.get().getValue() >= 1.0 && removalProbability.get().isEstimatedInput.get()) {
// default parameters have estimated=true by default.
// check there is an operator on this parameter
for (BEASTInterface o : removalProbability.get().getOutputs()) {
if (o instanceof Operator) {
isSAAnalysis = true;
}
}
}
if (removalProbability.get().getValue() < 1.0 || isSAAnalysis) {
// this is a sampled ancestor analysis
// check that there are no invalid operators in this analysis
List<Operator> operators = getOperators(this);
if (operators != null) {
for (Operator op : operators) {
if (op.getClass().isAssignableFrom(TipDatesRandomWalker.class) ||
op.getClass().isAssignableFrom(SubtreeSlide.class) ||
op.getClass().isAssignableFrom(WilsonBalding.class) ||
op.getClass().isAssignableFrom(Uniform.class) ||
op.getClass().isAssignableFrom(Exchange.class)) {
Log.err.println("ERROR: " + op.getClass().getSimpleName() +
" is not a valid operator for a sampled ancestor analysis.\n" +
"Either remove the operator (id=" + op.getID() + ") or fix the " +
"removal probability to 1.0 so this is not a sampled ancestor " +
"analysis any more. The current analysis is not valid.");
}
}
}
}
}

private List<Operator> getOperators(BEASTInterface o) {
for (BEASTInterface out : o.getOutputs()) {
if (out instanceof MCMC) {
return ((MCMC)out).operatorsInput.get();
} else {
List<Operator> list = getOperators(out);
if (list != null) {
return list;
}
}
}
return null;
}

/**
* checks if r is zero, all elements of rho except the last one are
* zero and the last one is not zero
Expand Down

0 comments on commit c8f7da0

Please sign in to comment.