diff --git a/src/mcmc.c b/src/mcmc.c index d78db4d..51f53fd 100644 --- a/src/mcmc.c +++ b/src/mcmc.c @@ -2584,6 +2584,10 @@ int DoMcmc (void) goto errorExit; } + /* Check again that the model is consistent after potentially resetting starting values (co-dependencies etc) */ + if (CheckModel() == ERROR) + goto errorExit; + #ifndef NDEBUG /* checking tree consistency for debug purposes */ for (i=0; iisClock == YES && t->isCalibrated == YES) + for (ch=0; chrelParts[0]].clockRate, 0, 0); - treeAge = t->root->left->nodeDepth / clockRate; - if (!AreDoublesEqual(treeAge, t->root->left->age, 0.000001)) - { - MrBayesPrint("%s ERROR: The tree age setting is inconsistent with the specified tree age prior.\n", spacer); - return (ERROR); - } - if (modelParams[t->relParts[0]].treeAgePr.prior == fixed) + t = GetTreeFromIndex(i,ch,0); + if (t->isClock == YES && t->isCalibrated == YES) { - if (!AreDoublesEqual(treeAge, modelParams[t->relParts[0]].treeAgePr.priorParams[0], 0.000001)) + clockRate = *GetParamVals(modelSettings[t->relParts[0]].clockRate, ch, 0); + treeAge = t->root->left->nodeDepth / clockRate; + if (!AreDoublesEqual(treeAge, t->root->left->age, 0.000001)) { - MrBayesPrint("%s ERROR: The clock rate is inconsistent with the specified tree age prior.\n", spacer); + MrBayesPrint("%s ERROR: The tree age setting is inconsistent with the specified tree age prior.\n", spacer); return (ERROR); } - } - else if (modelParams[t->relParts[0]].treeAgePr.prior == uniform) - { - if (treeAge < modelParams[t->relParts[0]].treeAgePr.priorParams[0] || treeAge > modelParams[t->relParts[0]].treeAgePr.priorParams[1]) - { - MrBayesPrint("%s ERROR: The clock rate is inconsistent with the specified tree age prior.\n", spacer); - return (ERROR); + if (modelParams[t->relParts[0]].treeAgePr.prior == fixed) + { + if (!AreDoublesEqual(treeAge, modelParams[t->relParts[0]].treeAgePr.priorParams[0], 0.000001)) + { + MrBayesPrint("%s ERROR: The clock rate is inconsistent with the specified tree age prior.\n", spacer); + return (ERROR); + } } - } - else if (modelParams[t->relParts[0]].treeAgePr.prior == offsetExponential || - modelParams[t->relParts[0]].treeAgePr.prior == offsetGamma || - modelParams[t->relParts[0]].treeAgePr.prior == truncatedNormal || - modelParams[t->relParts[0]].treeAgePr.prior == offsetLogNormal) - { - if (treeAge < modelParams[t->relParts[0]].treeAgePr.priorParams[0]) - { - MrBayesPrint("%s ERROR: The clock rate is inconsistent with the specified tree age prior.\n", spacer); - return (ERROR); + else if (modelParams[t->relParts[0]].treeAgePr.prior == uniform) + { + if (treeAge < modelParams[t->relParts[0]].treeAgePr.priorParams[0] || treeAge > modelParams[t->relParts[0]].treeAgePr.priorParams[1]) + { + MrBayesPrint("%s ERROR: The clock rate is inconsistent with the specified tree age prior.\n", spacer); + return (ERROR); + } + } + else if (modelParams[t->relParts[0]].treeAgePr.prior == offsetExponential || + modelParams[t->relParts[0]].treeAgePr.prior == offsetGamma || + modelParams[t->relParts[0]].treeAgePr.prior == truncatedNormal || + modelParams[t->relParts[0]].treeAgePr.prior == offsetLogNormal) + { + if (treeAge < modelParams[t->relParts[0]].treeAgePr.priorParams[0]) + { + MrBayesPrint("%s ERROR: The clock rate is inconsistent with the specified tree age prior.\n", spacer); + return (ERROR); + } } } }