Skip to content

Commit

Permalink
update sanity check for sampled ancestor analysis operators
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Apr 22, 2016
1 parent c8f7da0 commit 52e591d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/beast/evolution/speciation/BirthDeathSkylineModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import beast.core.Input;
import beast.core.MCMC;
import beast.core.Operator;
import beast.core.StateNode;
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.ScaleOperator;
import beast.evolution.operators.SubtreeSlide;
import beast.evolution.operators.TipDatesRandomWalker;
import beast.evolution.operators.WilsonBalding;
Expand Down Expand Up @@ -316,7 +318,7 @@ public void initAndValidate() {
// 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()) {
if (removalProbability.get() != null && 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()) {
Expand All @@ -325,17 +327,28 @@ public void initAndValidate() {
}
}
}
if (removalProbability.get().getValue() < 1.0 || isSAAnalysis) {
if (removalProbability.get() != null && 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) {
boolean isOK = true;
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)) {
isOK = false;
} else if (op.getClass().isAssignableFrom(ScaleOperator.class)) {
// scale operators on Trees shouldbe replaced with SAScaleOperator
for (StateNode o : op.listStateNodes()) {
if (o instanceof Tree) {
isOK = false;
}
}
}
if (!isOK) {
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 " +
Expand Down

0 comments on commit 52e591d

Please sign in to comment.