/* * MrBayes 3.1.2 * * copyright 2002-2005 * * John P. Huelsenbeck * Section of Ecology, Behavior and Evolution * Division of Biological Sciences * University of California, San Diego * La Jolla, CA 92093-0116 * * johnh@biomail.ucsd.edu * * Fredrik Ronquist * School of Computational Science * Florida State University * Tallahassee, FL 32306-4120 * * ronquist@csit.fsu.edu * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details (www.gnu.org). * */ #include #include #include #include #include #include "mb.h" #include "globals.h" #include "bayes.h" #include "model.h" #include "command.h" #if defined(__MWERKS__) #include "SIOUX.h" #endif /* local prototypes */ int IsModelSame (int whichParam, int part1, int part2, int *isApplic1, int *isApplic2); int NumActiveParts (void); /* globals */ Model modelParams[MAX_NUM_DIVS]; /* holds model params for up to MAX_NUM_DIVS partitions */ int numCurrentDivisions; /* number of partitions of data */ int activeParams[NUM_LINKED][MAX_NUM_DIVS]; /* a table holding the parameter link status */ /* local */ static int numVars[MAX_NUM_DIVS], activeParts[MAX_NUM_DIVS], fromI, toJ, foundDash, foundComma, foundEqual, foundBeta, foundAaSetting, foundExp, modelIsFixed, linkNum, linkTable[NUM_LINKED][MAX_NUM_DIVS], tempLinkUnlink[NUM_LINKED][MAX_NUM_DIVS], tempLinkUnlinkVec[MAX_NUM_DIVS], tempNumStates, isNegative; static MrBFlt tempStateFreqs[200], tempAaModelPrs[10], tempNum[MAX_NUM_DIVS]; static char colonPr[100]; int AreDoublesEqual (MrBFlt x, MrBFlt y, MrBFlt tol) { if ((x - y) < -tol || (x - y) > tol) return (NO); else return (YES); } int CheckModel (void) { int a, b, d, i, j, k, m, n, ns, paramCount, nOfParam, isFirst, shouldPrint, isSame; char tempName[100]; /* set up table of linkages */ if (SetUpModel () == ERROR) { MrBayesPrint ("%s Problem setting up default links\n", spacer); return (ERROR); } MrBayesPrint ("%s Model settings:\n\n", spacer); for (i=0; i 1) MrBayesPrint ("%s Settings for partition %d --\n", spacer, i+1); if (modelParams[i].dataType == DNA) { MrBayesPrint ("%s Datatype = DNA\n", spacer); ns = 4; } else if (modelParams[i].dataType == RNA) { MrBayesPrint ("%s Datatype = RNA\n", spacer); ns = 4; } else if (modelParams[i].dataType == PROTEIN) { MrBayesPrint ("%s Datatype = Protein\n", spacer); ns = 20; } else if (modelParams[i].dataType == RESTRICTION) { MrBayesPrint ("%s Datatype = Restriction\n", spacer); ns = 2; } else if (modelParams[i].dataType == STANDARD) { MrBayesPrint ("%s Datatype = Standard\n", spacer); ns = 10; } else if (modelParams[i].dataType == CONTINUOUS) { MrBayesPrint ("%s Datatype = Continuous\n", spacer); } if (modelParams[i].dataType == CONTINUOUS) { /* begin description of continuous models */ if (!strcmp(modelParams[i].brownCorPr, "Fixed") && AreDoublesEqual(modelParams[i].brownCorrFix, 0.0, ETA)==YES) MrBayesPrint ("%s Model = Independent Brownian motion\n", spacer); else MrBayesPrint ("%s Model = Correlated Brownian motion\n", spacer); /* end description of continuous models */ } else { /* begin description of discrete models */ if (!strcmp(modelParams[i].parsModel, "Yes")) { MrBayesPrint ("%s Parsmodel = %s\n", spacer, modelParams[i].parsModel); } else { /* dna characters in this partition */ if (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA) { /* general form of the rate matrix */ MrBayesPrint ("%s Nucmodel = %s\n", spacer, modelParams[i].nucModel); /* constraints on rates of substitution */ MrBayesPrint ("%s Nst = %s\n", spacer, modelParams[i].nst); if (!strcmp(modelParams[i].nst, "2")) { if (!strcmp(modelParams[i].tRatioPr,"Beta")) { MrBayesPrint ("%s Transition and transversion rates, expressed\n", spacer); MrBayesPrint ("%s as proportions of the rate sum, have a\n", spacer); MrBayesPrint ("%s Beta(%1.2lf,%1.2lf) prior\n", spacer, modelParams[i].tRatioDir[0], modelParams[i].tRatioDir[1]); } else { MrBayesPrint ("%s Transition/transversion rate ratio is fixed to %1.2lf.\n", spacer, modelParams[i].tRatioFix); } } else if (!strcmp(modelParams[i].nst, "6")) { if (!strcmp(modelParams[i].revMatPr,"Dirichlet")) { MrBayesPrint ("%s Substitution rates, expressed as proportions\n", spacer); MrBayesPrint ("%s of the rate sum, have a Dirichlet prior\n", spacer); MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].revMatDir[0], modelParams[i].revMatDir[1], modelParams[i].revMatDir[2], modelParams[i].revMatDir[3], modelParams[i].revMatDir[4], modelParams[i].revMatDir[5]); } else { MrBayesPrint ("%s Substitution rates are fixed to be \n", spacer); MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf).\n", spacer, modelParams[i].revMatFix[0], modelParams[i].revMatFix[1], modelParams[i].revMatFix[2], modelParams[i].revMatFix[3], modelParams[i].revMatFix[4], modelParams[i].revMatFix[5]); } } else if (!strcmp(modelParams[i].nst, "Mixed")) { if (!strcmp(modelParams[i].revMatPr,"Dirichlet")) { MrBayesPrint ("%s Substitution rates, expressed as proportions\n", spacer); MrBayesPrint ("%s of the rate sum, have a Dirichlet prior\n", spacer); MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].revMatDir[0], modelParams[i].revMatDir[1], modelParams[i].revMatDir[2], modelParams[i].revMatDir[3], modelParams[i].revMatDir[4], modelParams[i].revMatDir[5]); } else { MrBayesPrint ("%s Substitution rates are fixed to be \n", spacer); MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf).\n", spacer, modelParams[i].revMatFix[0], modelParams[i].revMatFix[1], modelParams[i].revMatFix[2], modelParams[i].revMatFix[3], modelParams[i].revMatFix[4], modelParams[i].revMatFix[5]); } } if (!strcmp(modelParams[i].nucModel,"Codon")) { /* what is the distribution on the nonsyn./syn. rate ratio */ if (!strcmp(modelParams[i].omegaVar, "Equal")) { if (!strcmp(modelParams[i].omegaPr,"Dirichlet")) { MrBayesPrint ("%s Nonsynonymous and synonymous rates, expressed\n", spacer); MrBayesPrint ("%s as proportions of the rate sum, have a\n", spacer); MrBayesPrint ("%s Dirichlet(%1.2lf,%1.2lf) prior\n", spacer, modelParams[i].omegaDir[0], modelParams[i].omegaDir[1]); } else { MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio is fixed to %1.2lf.\n", spacer, modelParams[i].omegaFix); } } else if (!strcmp(modelParams[i].omegaVar, "Ny98")) { if (!strcmp(modelParams[i].ny98omega1pr, "Beta")) { MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for purifying selection\n", spacer); MrBayesPrint ("%s (class 1) has a Beta(%1.2lf,%1.2lf) on the interval (0,1).\n", spacer, modelParams[i].ny98omega1Beta[0], modelParams[i].ny98omega1Beta[1]); } else { MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for purifying selection\n", spacer); MrBayesPrint ("%s (class 1) is fixed to %1.2lf.\n", spacer, modelParams[i].ny98omega1Fixed); } MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for neutral selection\n", spacer); MrBayesPrint ("%s (class 2) is fixed to 1.0.\n", spacer); if (!strcmp(modelParams[i].ny98omega3pr, "Uniform")) { MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for positive selection\n", spacer); MrBayesPrint ("%s is uniformly distributed on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].ny98omega3Uni[0], modelParams[i].ny98omega3Uni[1]); } else if (!strcmp(modelParams[i].ny98omega3pr, "Exponential")) { MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for positive selection\n", spacer); MrBayesPrint ("%s is exponentially distributed with parameter (%1.2lf).\n", spacer, modelParams[i].ny98omega3Exp); } else { MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for positive \n", spacer); MrBayesPrint ("%s selection is fixed to %1.2lf.\n", spacer, modelParams[i].ny98omega3Fixed); } } else if (!strcmp(modelParams[i].omegaVar, "M3")) { if (!strcmp(modelParams[i].m3omegapr, "Exponential")) { MrBayesPrint ("%s Nonsynonymous and synonymous rates for the tree classes of\n", spacer); MrBayesPrint ("%s omega are exponentially distributed random variables.\n", spacer); } else if (!strcmp(modelParams[i].m3omegapr, "Fixed")) { MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for the three omega\n", spacer); MrBayesPrint ("%s are fixed to %1.2lf, %1.2lf, and %1.2lf.\n", spacer, modelParams[i].m3omegaFixed[0], modelParams[i].m3omegaFixed[1], modelParams[i].m3omegaFixed[2]); } } else if (!strcmp(modelParams[i].omegaVar, "M10")) { MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for purifying \n", spacer); MrBayesPrint ("%s selection (class 1) has a Beta(alpha1,beta1) on the \n", spacer); MrBayesPrint ("%s interval (0,1). Nonsynonymous/synonymous rate ratio \n", spacer); MrBayesPrint ("%s for positive selection (class 2) has an offset \n", spacer); MrBayesPrint ("%s Gamma(alpha2,beta2) on the interval (1,Infinity).\n", spacer); } /* genetic code that is used (if nucmodel=codon) */ MrBayesPrint ("%s Code = %s\n", spacer, modelParams[i].geneticCode); } } /* amino acid characters in this partition */ else if (modelParams[i].dataType == PROTEIN) { /* constraints on rates of substitution in 20 X 20 matrix */ if (!strcmp(modelParams[i].aaModelPr, "Mixed")) MrBayesPrint ("%s Aamodel = Mixture of models with fixed rate matrices\n", spacer); else MrBayesPrint ("%s Aamodel = %s\n", spacer, modelParams[i].aaModel); /* revmat rates */ if (!strcmp(modelParams[i].aaModelPr, "Fixed") && !strcmp(modelParams[i].aaModel, "Gtr")) { if (!strcmp(modelParams[i].aaRevMatPr,"Dirichlet")) { for (j=0; j<190; j++) if (AreDoublesEqual(modelParams[i].aaRevMatDir[0], modelParams[i].aaRevMatDir[j], 0.00001) == NO) break; if (j == 190) { MrBayesPrint ("%s Substitution rates have a Dirichlet(%1.2lf,%1.2lf,...) prior\n", spacer, modelParams[i].aaRevMatDir[0], modelParams[i].aaRevMatDir[0]); } else { MrBayesPrint ("%s Substitution rates have a Dirichlet(\n", spacer); for (j=0; j<190; j++) { if (j % 10 == 0) MrBayesPrint ("%s ", spacer); MrBayesPrint ("%1.2lf", modelParams[i].aaRevMatDir[j]); if (j == 189) MrBayesPrint (") prior\n"); else if ((j+1) % 10 == 0) MrBayesPrint (",\n"); else MrBayesPrint (","); } } } else /* if (!strcmp(modelParams[i].aaRevMatPr,"Fixed")) */ { for (j=0; j<190; j++) if (AreDoublesEqual(modelParams[i].aaRevMatFix[0], modelParams[i].aaRevMatFix[j], 0.00001) == NO) break; if (j == 190) { MrBayesPrint ("%s Substitution rates are fixed to (%1.1lf,%1.1lf,...)\n", spacer, modelParams[i].aaRevMatFix[0], modelParams[i].aaRevMatFix[0]); } else { MrBayesPrint ("%s Substitution rates are fixed to (\n", spacer); for (j=0; j<190; j++) { if (j % 10 == 0) MrBayesPrint ("%s ", spacer); MrBayesPrint ("%1.1lf", modelParams[i].aaRevMatFix[j]); if (j == 189) MrBayesPrint (") prior\n"); else if ((j+1) % 10 == 0) MrBayesPrint (",\n"); else MrBayesPrint (","); } } } } } /* restriction site or morphological characters in this partition */ else if (modelParams[i].dataType == RESTRICTION || modelParams[i].dataType == STANDARD) { /* what type of characters are sampled? */ MrBayesPrint ("%s Coding = %s\n", spacer, modelParams[i].coding); } /* is there rate variation in a single site across the tree? */ if (((modelParams[i].dataType == DNA || modelParams[i].dataType == RNA) && !strcmp(modelParams[i].nucModel, "4by4")) || modelParams[i].dataType == PROTEIN) { /* do rates change on tree accoding to covarion model? */ MrBayesPrint ("%s Covarion = %s\n", spacer, modelParams[i].covarionModel); if (!strcmp(modelParams[i].covarionModel, "Yes")) { /* distribution on switching parameters, if appropriate */ if (!strcmp(modelParams[i].covSwitchPr,"Uniform")) { MrBayesPrint ("%s Switching rates have independent uniform dist-\n", spacer); MrBayesPrint ("%s ributions on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].covswitchUni[0], modelParams[i].covswitchUni[1]); } else if (!strcmp(modelParams[i].covSwitchPr,"Exponential")) { MrBayesPrint ("%s Switching rates have independent exponential\n", spacer); MrBayesPrint ("%s distributions with parameters (%1.2lf).\n", spacer, modelParams[i].covswitchExp); } else { MrBayesPrint ("%s Switching rates are fixed to %1.2lf and %1.2lf.\n", spacer, modelParams[i].covswitchFix[0], modelParams[i].covswitchFix[0]); } ns *= 2; } } /* now, let's deal with variation in omega */ if ((modelParams[i].dataType == DNA || modelParams[i].dataType == RNA) && !strcmp(modelParams[i].nucModel,"Codon")) { MrBayesPrint ("%s Omegavar = %s\n", spacer, modelParams[i].omegaVar); if (!strcmp(modelParams[i].geneticCode, "Universal")) ns = 61; else if (!strcmp(modelParams[i].geneticCode, "Vertmt")) ns = 60; else if (!strcmp(modelParams[i].geneticCode, "Mycoplasma")) ns = 62; else if (!strcmp(modelParams[i].geneticCode, "Yeast")) ns = 62; else if (!strcmp(modelParams[i].geneticCode, "Ciliates")) ns = 63; else if (!strcmp(modelParams[i].geneticCode, "Metmt")) ns = 62; } /* what assumptions are made about the state frequencies? */ if (modelParams[i].dataType != CONTINUOUS) { if (modelParams[i].dataType == STANDARD) MrBayesPrint ("%s # States = Variable, up to 10\n", spacer); else if (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA) { if (!strcmp(modelParams[i].nucModel, "Doublet")) MrBayesPrint ("%s # States = %d\n", spacer, 16); else if (!strcmp(modelParams[i].nucModel, "Codon")) MrBayesPrint ("%s # States = %d\n", spacer, 61); else MrBayesPrint ("%s # States = %d\n", spacer, 4); } else MrBayesPrint ("%s # States = %d\n", spacer, ns); if (modelParams[i].dataType == STANDARD) { if (!strcmp(modelParams[i].symPiPr,"Fixed")) { if (AreDoublesEqual(modelParams[i].symBetaFix, -1.0,ETA)==YES) MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer); else MrBayesPrint ("%s Symmetric Dirichlet is fixed to %1.2lf\n", spacer, modelParams[i].symBetaFix); } else if (!strcmp(modelParams[i].symPiPr,"Uniform")) { MrBayesPrint ("%s Symmetric Dirichlet has a Uniform(%1.2lf,%1.2lf) prior\n", spacer, modelParams[i].symBetaUni[0], modelParams[i].symBetaUni[1]); } else { MrBayesPrint ("%s Symmetric Dirichlet has a Exponential(%1.2lf) prior\n", spacer, modelParams[i].symBetaExp); } } else if (modelParams[i].dataType == RESTRICTION) { /* distribution on state frequencies for restriction site model */ if (!strcmp(modelParams[i].stateFreqPr,"Dirichlet")) { MrBayesPrint ("%s State frequencies have a Dirichlet (%1.2lf,%1.2lf) prior\n", spacer, modelParams[i].stateFreqsDir[0], modelParams[i].stateFreqsDir[1]); } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Equal")) { MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer); } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"User")) { MrBayesPrint ("%s State frequencies have been fixed by the user\n", spacer); } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Empirical")) { MrBayesPrint ("%s State frequencies have been fixed to the empirical frequencies in the data\n", spacer); } } else if (modelParams[i].dataType == PROTEIN) { /* distribution on state frequencies for aminoacid model */ if (!strcmp(modelParams[i].aaModelPr, "Fixed") && (strcmp(modelParams[i].aaModel, "Equalin")==0 || strcmp(modelParams[i].aaModel, "Gtr")==0)) { if (!strcmp(modelParams[i].stateFreqPr,"Dirichlet")) { MrBayesPrint ("%s State frequencies have a Dirichlet prior\n", spacer); MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,", spacer, modelParams[i].stateFreqsDir[0], modelParams[i].stateFreqsDir[1], modelParams[i].stateFreqsDir[2], modelParams[i].stateFreqsDir[3], modelParams[i].stateFreqsDir[4]); MrBayesPrint ("%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,\n", modelParams[i].stateFreqsDir[5], modelParams[i].stateFreqsDir[6], modelParams[i].stateFreqsDir[7], modelParams[i].stateFreqsDir[8], modelParams[i].stateFreqsDir[9]); MrBayesPrint ("%s %1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,", spacer, modelParams[i].stateFreqsDir[10], modelParams[i].stateFreqsDir[11], modelParams[i].stateFreqsDir[12], modelParams[i].stateFreqsDir[13], modelParams[i].stateFreqsDir[14]); MrBayesPrint ("%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", modelParams[i].stateFreqsDir[15], modelParams[i].stateFreqsDir[16], modelParams[i].stateFreqsDir[17], modelParams[i].stateFreqsDir[18], modelParams[i].stateFreqsDir[19]); } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Equal")) { MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer); } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"User")) { MrBayesPrint ("%s State frequencies have been fixed by the user\n", spacer); } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Empirical")) { MrBayesPrint ("%s State frequencies have been fixed to the empirical frequencies in the data\n", spacer); } } else if (!strcmp(modelParams[i].aaModelPr, "Fixed") && !strcmp(modelParams[i].aaModel, "Poisson")) { MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer); } else if (!strcmp(modelParams[i].aaModelPr, "Fixed") && strcmp(modelParams[i].aaModel, "Equalin") && strcmp(modelParams[i].aaModel, "Poisson")) { MrBayesPrint ("%s State frequencies are fixed to the %s frequencies\n", spacer, modelParams[i].aaModel); } else { MrBayesPrint ("%s State frequencies come from the mixture of models\n", spacer); } } else { /* distribution on state frequencies for all other models */ if (!strcmp(modelParams[i].stateFreqPr,"Dirichlet")) { MrBayesPrint ("%s State frequencies have a Dirichlet prior\n", spacer); if (!strcmp(modelParams[i].nucModel, "Doublet")) { MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,\n", spacer, modelParams[i].stateFreqsDir[0], modelParams[i].stateFreqsDir[1], modelParams[i].stateFreqsDir[2], modelParams[i].stateFreqsDir[3]); MrBayesPrint ("%s %1.2lf,%1.2lf,%1.2lf,%1.2lf,\n", spacer, modelParams[i].stateFreqsDir[4], modelParams[i].stateFreqsDir[5], modelParams[i].stateFreqsDir[6], modelParams[i].stateFreqsDir[7]); MrBayesPrint ("%s %1.2lf,%1.2lf,%1.2lf,%1.2lf,\n", spacer, modelParams[i].stateFreqsDir[8], modelParams[i].stateFreqsDir[9], modelParams[i].stateFreqsDir[10], modelParams[i].stateFreqsDir[11]); MrBayesPrint ("%s %1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].stateFreqsDir[12], modelParams[i].stateFreqsDir[13], modelParams[i].stateFreqsDir[14], modelParams[i].stateFreqsDir[15]); } else if (!strcmp(modelParams[i].nucModel, "4by4")) { MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].stateFreqsDir[0], modelParams[i].stateFreqsDir[1], modelParams[i].stateFreqsDir[2], modelParams[i].stateFreqsDir[3]); } } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Equal")) { MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer); } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"User")) { MrBayesPrint ("%s State frequencies have been fixed by the user\n", spacer); } else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Empirical")) { MrBayesPrint ("%s State frequencies have been fixed to the empirical frequencies in the data\n", spacer); } } } else MrBayesPrint ("%s # States = Infinity\n", spacer); /* now, let's deal with rate variation across sites */ if (modelParams[i].dataType != CONTINUOUS) { if (((modelParams[i].dataType == DNA || modelParams[i].dataType == RNA) && strcmp(modelParams[i].nucModel,"Codon")) || modelParams[i].dataType == PROTEIN || modelParams[i].dataType == RESTRICTION || modelParams[i].dataType == STANDARD) { if (!strcmp(modelParams[i].covarionModel, "No")) MrBayesPrint ("%s Rates = %s\n", spacer, modelParams[i].ratesModel); else { if (!strcmp(modelParams[i].ratesModel, "Propinv")) MrBayesPrint ("%s Rates = Equal ", spacer); else if (!strcmp(modelParams[i].ratesModel, "Invgamma")) MrBayesPrint ("%s Rates = Gamma ", spacer); else MrBayesPrint ("%s Rates = %s ", spacer, modelParams[i].ratesModel); MrBayesPrint ("(+ Propinv induced by covarion model)\n"); } if ((modelParams[i].dataType == RESTRICTION || modelParams[i].dataType == STANDARD) && !strcmp(modelParams[i].ratesModel, "Adgamma")) { } else { if ((!strcmp(modelParams[i].ratesModel, "Invgamma") || !strcmp(modelParams[i].ratesModel, "Gamma") || !strcmp(modelParams[i].ratesModel, "Adgamma"))) { /* distribution on shape parameter, if appropriate */ if (!strcmp(modelParams[i].shapePr,"Uniform")) { MrBayesPrint ("%s Gamma shape parameter is uniformly dist-\n", spacer); MrBayesPrint ("%s ributed on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].shapeUni[0], modelParams[i].shapeUni[1]); } else if (!strcmp(modelParams[i].shapePr,"Exponential")) { MrBayesPrint ("%s Gamma shape parameter is exponentially\n", spacer); MrBayesPrint ("%s distributed with parameter (%1.2lf).\n", spacer, modelParams[i].shapeExp); } else { MrBayesPrint ("%s Gamma shape parameter is fixed to %1.2lf.\n", spacer, modelParams[i].shapeFix); } } if ((!strcmp(modelParams[i].ratesModel, "Propinv") || !strcmp(modelParams[i].ratesModel, "Invgamma")) && !strcmp(modelParams[i].covarionModel, "No")) { /* distribution on pInvar parameter, if appropriate */ if (!strcmp(modelParams[i].pInvarPr,"Uniform")) { MrBayesPrint ("%s Proportion of invariable sites is uniformly dist-\n", spacer); MrBayesPrint ("%s ributed on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].pInvarUni[0], modelParams[i].pInvarUni[1]); } else { MrBayesPrint ("%s Proportion of invariable sites is fixed to %1.2lf.\n", spacer, modelParams[i].pInvarFix); } } if (!strcmp(modelParams[i].ratesModel, "Adgamma")) { /* distribution on correlation parameter, if appropriate */ if (!strcmp(modelParams[i].adGammaCorPr,"Uniform")) { MrBayesPrint ("%s Rate correlation parameter is uniformly dist-\n", spacer); MrBayesPrint ("%s ributed on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].corrUni[0], modelParams[i].corrUni[1]); } else { MrBayesPrint ("%s Rate correlation parameter is fixed to %1.2lf.\n", spacer, modelParams[i].corrFix); } } if (!strcmp(modelParams[i].ratesModel, "Gamma") || !strcmp(modelParams[i].ratesModel, "Invgamma") || !strcmp(modelParams[i].ratesModel, "Adgamma")) { /* how many categories is the continuous gamma approximated by? */ MrBayesPrint ("%s Gamma distribution is approximated using %d categories.\n", spacer, modelParams[i].numGammaCats); } } } } } /* end description of discrete models */ } if (i != numCurrentDivisions - 1) MrBayesPrint ("\n"); } # if 1 MrBayesPrint ("\n"); MrBayesPrint ("%s Active parameters: \n\n", spacer); if (numCurrentDivisions > 1) { MrBayesPrint ("%s Partition(s)\n", spacer); MrBayesPrint ("%s Parameters ", spacer); for (i=0; i 1) { MrBayesPrint ("%s ---------------", spacer); for (i=0; i 1) MrBayesPrint ("%s All parameters can be linked or unlinked across partitions\n\n", spacer); nOfParam = 0; for (j=0; j nOfParam) nOfParam = activeParams[j][i]; nOfParam++; for (k=0; k 0) { MrBayesPrint ("%s Branch lengths are constrained by the following age constraint%s:\n", spacer, b > 1 ? "s" : ""); for (a=0; a Var=%1.2lf\n", spacer, modelParams[i].brownScalesGammaMean); else if (!strcmp(modelParams[i].brownScalesPr,"Gamma")) MrBayesPrint ("%s Prior = Gamma Mean=%lf Var=%1.2lf\n", spacer, modelParams[i].brownScalesGamma[0], modelParams[i].brownScalesGamma[1]); else MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, modelParams[i].brownScalesFix); } if (numCurrentDivisions > 1) { n = 0; for (m=0; m 2) { if (paramCount == n) MrBayesPrint (", and "); else if (paramCount != 1) MrBayesPrint (", "); } MrBayesPrint ("%d", m+1); } } MrBayesPrint ("\n"); } } } } } # endif return (NO_ERROR); } int DoLink (void) { int i, j, newLine; MrBayesPrint ("%s Linking\n", spacer); /* update status of linkTable */ for (j=0; j numCurrentDivisions) { MrBayesPrint ("%s Partition delimiter is too large\n", spacer); return (ERROR); } if (fromI == -1) fromI = tempInt; else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO) { toJ = tempInt; for (i=fromI-1; i=0; i--) { if (activeParts[i] == YES) { lastActive = i; break; } } /* MrBayesPrint ("\n"); */ if (numCurrentDivisions == 1) MrBayesPrint ("%s Successfully set likelihood model parameters\n", spacer); else { if (nApplied == numCurrentDivisions || nApplied == 0) { MrBayesPrint ("%s Successfully set likelihood model parameters to all\n", spacer); MrBayesPrint ("%s applicable data partitions \n", spacer); } else { MrBayesPrint ("%s Successfully set likelihood model parameters to\n", spacer); if (nApplied == 1) MrBayesPrint ("%s partition", spacer); else MrBayesPrint ("%s partitions", spacer); for (i=0; i 1) MrBayesPrint (" and %d", i+1); else MrBayesPrint (" %d", i+1); if (nApplied > 2 && i != lastActive) MrBayesPrint (","); } } MrBayesPrint (" (if applicable)\n"); } } return (NO_ERROR); } int DoLsetParm (char *parmName, char *tkn) { int i, j, tempInt, nApplied; char tempStr[100]; if (defMatrix == NO) { MrBayesPrint ("%s A matrix must be specified before the model can be defined\n", spacer); return (ERROR); } if (inValidCommand == YES) { for (i=0; i numCurrentDivisions) { MrBayesPrint ("%s Partition delimiter is too large\n", spacer); return (ERROR); } if (fromI == -1) fromI = tempInt; else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO) { toJ = tempInt; for (i=fromI-1; i= 2 && tempInt < MAX_GAMMA_CATS) { nApplied = NumActiveParts (); for (i=0; i= 2 && tempInt < MAX_GAMMA_CATS) { nApplied = NumActiveParts (); for (i=0; i= 2 && tempInt < MAX_GAMMA_CATS) { nApplied = NumActiveParts (); for (i=0; i= 2 && tempInt < MAX_GAMMA_CATS) { nApplied = NumActiveParts (); for (i=0; i)' instead.\n", spacer); return (ERROR); } /* set Parsmodel (useParsModel) *******************************************************/ else if (!strcmp(parmName, "Parsmodel")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i=0; i--) { if (activeParts[i] == YES) { lastActive = i; break; } } if (numCurrentDivisions == 1) MrBayesPrint ("%s Successfully set prior model parameters\n", spacer); else { if (nApplied == numCurrentDivisions || nApplied == 0) { MrBayesPrint ("%s Successfully set prior model parameters to all\n", spacer); MrBayesPrint ("%s applicable data partitions \n", spacer); } else { MrBayesPrint ("%s Successfully set prior model parameters to\n", spacer); if (nApplied == 1) MrBayesPrint ("%s partition", spacer); else MrBayesPrint ("%s partitions", spacer); for (i=0; i 1) MrBayesPrint (" and %d", i+1); else MrBayesPrint (" %d", i+1); if (nApplied > 2 && i != lastActive) MrBayesPrint (","); } } MrBayesPrint (" (if applicable)\n"); } } return (NO_ERROR); } int DoPrsetParm (char *parmName, char *tkn) { int i, j, k, tempInt, nApplied, howMany, ns; MrBFlt tempD, sum; char tempStr[100]; if (defMatrix == NO) { MrBayesPrint ("%s A matrix must be specified before the model can be defined\n", spacer); return (ERROR); } if (inValidCommand == YES) { for (i=0; i numCurrentDivisions) { MrBayesPrint ("%s Partition delimiter is too large\n", spacer); return (ERROR); } if (fromI == -1) fromI = tempInt; else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO) { toJ = tempInt; for (i=fromI-1; i ALPHA_MAX) { MrBayesPrint ("%s Beta parameter cannot be greater than %1.2lf\n", spacer, ALPHA_MAX); return (ERROR); } if (tempD < ALPHA_MIN) { MrBayesPrint ("%s Beta parameter cannot be less than %1.2lf\n", spacer, ALPHA_MIN); return (ERROR); } modelParams[i].tRatioDir[numVars[i]++] = tempD; if (numVars[i] < 2) expecting = Expecting(COMMA); else { if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Tratiopr to Beta(%1.2lf,%1.2lf)\n", spacer, modelParams[i].tRatioDir[0], modelParams[i].tRatioDir[1]); else MrBayesPrint ("%s Setting Tratiopr to Beta(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].tRatioDir[0], modelParams[i].tRatioDir[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].tRatioPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].tRatioFix = tempD; if (modelParams[i].tRatioFix > KAPPA_MAX) { MrBayesPrint ("%s Tratio cannot be greater than %1.2lf\n", spacer, KAPPA_MAX); return (ERROR); } if (modelParams[i].tRatioFix < 0.0) { MrBayesPrint ("%s Tratio cannot be less than %1.2lf\n", spacer, 0.0); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Tratiopr to Fixed(%1.2lf)\n", spacer, modelParams[i].tRatioFix); else MrBayesPrint ("%s Setting Tratiopr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].tRatioFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Revmatpr (revMatPr) ************************************************************/ else if (!strcmp(parmName, "Revmatpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i ALPHA_MAX) { MrBayesPrint ("%s Dirichlet parameter cannot be greater than %1.2lf\n", spacer, ALPHA_MAX); return (ERROR); } if (tempD < ALPHA_MIN) { MrBayesPrint ("%s Dirichlet parameter cannot be less than %1.2lf\n", spacer, ALPHA_MIN); return (ERROR); } } else if (!strcmp(tempStr,"Fixed")) { if (tempD > KAPPA_MAX) { MrBayesPrint ("%s Rate value cannot be greater than %1.2lf\n", spacer, KAPPA_MAX); return (ERROR); } if (tempD < 0.01) { MrBayesPrint ("%s Rate value cannot be less than %1.2lf\n", spacer, 0.01); return (ERROR); } } tempNum[tempNumStates++] = tempD; if (tempNumStates == 1 && !strcmp(tempStr,"Dirichlet")) expecting = Expecting(COMMA) | Expecting(RIGHTPAR); else if (tempNumStates < 6) expecting = Expecting(COMMA); else expecting = Expecting(RIGHTPAR); } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { nApplied = NumActiveParts (); for (i=0; i ALPHA_MAX) { MrBayesPrint ("%s Dirichlet parameter cannot be greater than %1.2lf\n", spacer, ALPHA_MAX); return (ERROR); } if (tempD < ALPHA_MIN) { MrBayesPrint ("%s Dirichlet parameter cannot be less than %1.2lf\n", spacer, ALPHA_MIN); return (ERROR); } } else if (!strcmp(tempStr,"Fixed")) { if (tempD > KAPPA_MAX) { MrBayesPrint ("%s Rate value cannot be greater than %1.2lf\n", spacer, KAPPA_MAX); return (ERROR); } if (tempD < 0.01) { MrBayesPrint ("%s Rate value cannot be less than %1.2lf\n", spacer, 0.01); return (ERROR); } } tempStateFreqs[tempNumStates++] = tempD; if (tempNumStates == 1 && !strcmp(tempStr,"Dirichlet")) expecting = Expecting(COMMA) | Expecting(RIGHTPAR); else if (tempNumStates < 190) expecting = Expecting(COMMA); else expecting = Expecting(RIGHTPAR); } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { nApplied = NumActiveParts (); for (i=0; i ALPHA_MAX) { MrBayesPrint ("%s Dirichlet parameter cannot be greater than %1.2lf\n", spacer, ALPHA_MAX); return (ERROR); } if (tempD < ALPHA_MIN) { MrBayesPrint ("%s Dirichlet parameter cannot be less than %1.2lf\n", spacer, ALPHA_MIN); return (ERROR); } modelParams[i].omegaDir[numVars[i]++] = tempD; if (numVars[i] < 1) expecting = Expecting(COMMA); else { if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Omegapr to Dirichlet(%1.2lf,%1.2lf)\n", spacer, modelParams[i].omegaDir[0], modelParams[i].omegaDir[1]); else MrBayesPrint ("%s Setting Omegapr to Dirichlet(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].omegaDir[0], modelParams[i].omegaDir[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].omegaPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].omegaFix = tempD; if (modelParams[i].omegaFix > KAPPA_MAX) { MrBayesPrint ("%s Omega ratio cannot be greater than %1.2lf\n", spacer, KAPPA_MAX); return (ERROR); } if (modelParams[i].omegaFix < 0.0) { MrBayesPrint ("%s Omega ratio cannot be less than %1.2lf\n", spacer, 0.0); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Omegapr to Fixed(%1.2lf)\n", spacer, modelParams[i].omegaFix); else MrBayesPrint ("%s Setting Omegapr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].omegaFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Ny98omega1pr (ny98omega1pr) ********************************************************/ else if (!strcmp(parmName, "Ny98omega1pr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].ny98omega3Uni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Ny98omega3pr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].ny98omega3Uni[0], modelParams[i].ny98omega3Uni[1]); else MrBayesPrint ("%s Setting Ny98omega3pr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].ny98omega3Uni[0], modelParams[i].ny98omega3Uni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].ny98omega3pr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].ny98omega3Exp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Ny98omega3pr to Exponential(%1.2lf)\n", spacer, modelParams[i].ny98omega3Exp); else MrBayesPrint ("%s Setting Ny98omega3pr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].ny98omega3Exp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].ny98omega3pr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].ny98omega3Fixed = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Ny98omega3pr to Fixed(%1.2lf)\n", spacer, modelParams[i].ny98omega3Fixed); else MrBayesPrint ("%s Setting Ny98omega3pr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].ny98omega3Fixed, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set M3omegapr (m3omegapr) ********************************************************/ else if (!strcmp(parmName, "M3omegapr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].m3omegaFixed[1] || modelParams[i].m3omegaFixed[0] >= modelParams[i].m3omegaFixed[2] || modelParams[i].m3omegaFixed[1] >= modelParams[i].m3omegaFixed[2]) { MrBayesPrint ("%s The three omega values must be ordered, such that omega1 < omega2 < omega3\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting M3omegapr to Fixed(%1.2lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].m3omegaFixed[0], modelParams[i].m3omegaFixed[1], modelParams[i].m3omegaFixed[2]); else MrBayesPrint ("%s Setting M3omegapr to Fixed(%1.2lf,%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].m3omegaFixed[0], modelParams[i].m3omegaFixed[1], modelParams[i].m3omegaFixed[2], i+1); expecting = Expecting(RIGHTPAR); } } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Codoncatfreqs (codonCatFreqPr) ********************************************************/ else if (!strcmp(parmName, "Codoncatfreqs")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].shapeUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (modelParams[i].shapeUni[1] > MAX_SHAPE_PARAM) { MrBayesPrint ("%s Upper value for uniform cannot be greater than %1.2lf\n", spacer, MAX_SHAPE_PARAM); return (ERROR); } if (modelParams[i].shapeUni[0] < MIN_SHAPE_PARAM) { MrBayesPrint ("%s Lower value for uniform cannot be less than %1.2lf\n", spacer, MIN_SHAPE_PARAM); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Shapepr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].shapeUni[0], modelParams[i].shapeUni[1]); else MrBayesPrint ("%s Setting Shapepr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].shapeUni[0], modelParams[i].shapeUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].shapePr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].shapeExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Shapepr to Exponential(%1.2lf)\n", spacer, modelParams[i].shapeExp); else MrBayesPrint ("%s Setting Shapepr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].shapeExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].shapePr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].shapeFix = tempD; if (modelParams[i].shapeFix > MAX_SHAPE_PARAM) { MrBayesPrint ("%s Shape parameter cannot be greater than %1.2lf\n", spacer, MAX_SHAPE_PARAM); return (ERROR); } if (modelParams[i].shapeFix < MIN_SHAPE_PARAM) { MrBayesPrint ("%s Shape parameter cannot be less than %1.2lf\n", spacer, MIN_SHAPE_PARAM); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Shapepr to Fixed(%1.2lf)\n", spacer, modelParams[i].shapeFix); else MrBayesPrint ("%s Setting Shapepr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].shapeFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Pinvarpr (pInvarPr) ************************************************************/ else if (!strcmp(parmName, "Pinvarpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].pInvarUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (modelParams[i].pInvarUni[1] > 1.0) { MrBayesPrint ("%s Upper value for uniform should be less than or equal to 1.0\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Pinvarpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].pInvarUni[0], modelParams[i].pInvarUni[1]); else MrBayesPrint ("%s Setting Pinvarpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].pInvarUni[0], modelParams[i].pInvarUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].pInvarPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); if (tempD > 1.0) { MrBayesPrint ("%s Value for Pinvar should be in the interval (0, 1)\n", spacer); return (ERROR); } modelParams[i].pInvarFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Pinvarpr to Fixed(%1.2lf)\n", spacer, modelParams[i].pInvarFix); else MrBayesPrint ("%s Setting Pinvarpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].pInvarFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Ratecorrpr (adGammaCorPr) ******************************************************/ else if (!strcmp(parmName, "Ratecorrpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].corrUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (modelParams[i].corrUni[1] > 1.0) { MrBayesPrint ("%s Upper value for uniform should be less than or equal to 1.0\n", spacer); return (ERROR); } if (modelParams[i].corrUni[0] < -1.0) { MrBayesPrint ("%s Lower value for uniform should be greater than or equal to -1.0\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Ratecorrpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].corrUni[0], modelParams[i].corrUni[1]); else MrBayesPrint ("%s Setting Ratecorrpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].corrUni[0], modelParams[i].corrUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].adGammaCorPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); if (foundDash == YES) tempD *= -1.0; if (tempD > 1.0 || tempD < -1.0) { MrBayesPrint ("%s Value for Ratecorrpr should be in the interval (-1, +1)\n", spacer); return (ERROR); } modelParams[i].corrFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Ratecorrpr to Fixed(%1.2lf)\n", spacer, modelParams[i].corrFix); else MrBayesPrint ("%s Setting Ratecorrpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].corrFix, i+1); expecting = Expecting(RIGHTPAR); } } } foundDash = NO; } else if (expecting == Expecting(DASH)) { foundDash = YES; expecting = Expecting(NUMBER); } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER) | Expecting(DASH); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Browncorrpr (brownCorPr) ******************************************************/ else if (!strcmp(parmName, "Browncorrpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].brownCorrUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (modelParams[i].brownCorrUni[1] > 1.0) { MrBayesPrint ("%s Upper value for uniform should be less than or equal to 1.0\n", spacer); return (ERROR); } if (modelParams[i].brownCorrUni[0] < -1.0) { MrBayesPrint ("%s Lower value for uniform should be greater than or equal to -1.0\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Browncorrpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].brownCorrUni[0], modelParams[i].brownCorrUni[1]); else MrBayesPrint ("%s Setting Browncorrpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].brownCorrUni[0], modelParams[i].brownCorrUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].brownCorPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); if (foundDash == YES) tempD *= -1.0; if (tempD > 1.0 || tempD < -1.0) { MrBayesPrint ("%s Value for Browncorrpr should be in the interval (-1, +1)\n", spacer); return (ERROR); } modelParams[i].brownCorrFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Browncorrpr to Fixed(%1.2lf)\n", spacer, modelParams[i].brownCorrFix); else MrBayesPrint ("%s Setting Browncorrpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].brownCorrFix, i+1); expecting = Expecting(RIGHTPAR); } } } foundDash = NO; } else if (expecting == Expecting(DASH)) { foundDash = YES; expecting = Expecting(NUMBER); } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER) | Expecting(DASH); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Ratepr (ratePr) *****************************************************************/ else if (!strcmp(parmName, "Ratepr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i ALPHA_MAX) { MrBayesPrint ("%s Ratemultiplier Dirichlet parameter %lf out of range\n", spacer, tempD); return (ERROR); } /* set the parameter */ modelParams[i].ratePrDir = tempD; /* check if all partitions have been filled in */ for (i=0; i 1) MrBayesPrint ("s"); for (i=k=0; i 1) MrBayesPrint (", and %d", i+1); else if (k == 1) MrBayesPrint (" %d", i+1); else MrBayesPrint (", %d", i+1); } } MrBayesPrint ("\n"); } expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Covswitchpr (covSwitchPr) ******************************************************/ else if (!strcmp(parmName, "Covswitchpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].covswitchUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Covswitchpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].covswitchUni[0], modelParams[i].covswitchUni[1]); else MrBayesPrint ("%s Setting Covswitchpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].covswitchUni[0], modelParams[i].covswitchUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].covSwitchPr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].covswitchExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Covswitchpr to Exponential(%1.2lf)\n", spacer, modelParams[i].covswitchExp); else MrBayesPrint ("%s Setting Covswitchpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].covswitchExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].covSwitchPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].covswitchFix[numVars[i]++] = tempD; if (numVars[i] == 1) expecting = Expecting(COMMA); else { if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Covswitchpr to Fixed(%1.4lf,%1.4lf)\n", spacer, modelParams[i].covswitchFix[0], modelParams[i].covswitchFix[1]); else MrBayesPrint ("%s Setting Covswitchpr to Fixed(%1.4lf,%1.4lf) for partition %d\n", spacer, modelParams[i].covswitchFix[0], modelParams[i].covswitchFix[1], i+1); expecting = Expecting(RIGHTPAR); } } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Symdirihyperpr (symPiPr) ******************************************************/ else if (!strcmp(parmName, "Symdirihyperpr")) { if (expecting == Expecting(EQUALSIGN)) { foundBeta = NO; expecting = Expecting(ALPHA); } else if (expecting == Expecting(ALPHA)) { if (foundBeta == NO) { /* expecting to see Uniform, Exponential, or Fixed */ if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].symBetaUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Symdirihyperpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].symBetaUni[0], modelParams[i].symBetaUni[1]); else MrBayesPrint ("%s Setting Symdirihyperpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].symBetaUni[0], modelParams[i].symBetaUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else { MrBayesPrint ("%s Problem setting Symdirihyperpr\n", spacer); return (ERROR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Statefreqpr (stateFreqPr) ******************************************************/ else if (!strcmp(parmName, "Statefreqpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsSame ("Equal", tkn) == DIFFERENT && IsSame ("Empirical", tkn) == DIFFERENT) { /* the user wants to specify a dirichlet or fixed prior */ if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i numDefinedConstraints) { MrBayesPrint ("%s Constraint number is too large\n", spacer); return (ERROR); } if (fromI == -1) fromI = tempInt; else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO) { toJ = tempInt; for (i=fromI-1; i 0.000001) { MrBayesPrint ("%s Lower value for uniform must equal 0.0\n", spacer); return (ERROR); } if (modelParams[i].brlensUni[0] >= modelParams[i].brlensUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Brlenspr to Unconstrained:Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].brlensUni[0], modelParams[i].brlensUni[1]); else MrBayesPrint ("%s Setting Brlenspr to Unconstrained:Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].brlensUni[0], modelParams[i].brlensUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].unconstrainedPr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].brlensExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Brlenspr to Unconstrained:Exponential(%1.2lf)\n", spacer, modelParams[i].brlensExp); else MrBayesPrint ("%s Setting Brlenspr to Unconstrained:Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].brlensExp, i+1); expecting = Expecting(RIGHTPAR); } } } } else { } } else if (expecting == Expecting(COLON)) { expecting = Expecting(ALPHA); } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Speciationpr (speciationPr) ****************************************************/ else if (!strcmp(parmName, "Speciationpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].speciationUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Speciationpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].speciationUni[0], modelParams[i].speciationUni[1]); else MrBayesPrint ("%s Setting Speciationpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].speciationUni[0], modelParams[i].speciationUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].speciationPr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].speciationExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Speciationpr to Exponential(%1.2lf)\n", spacer, modelParams[i].speciationExp); else MrBayesPrint ("%s Setting Speciationpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].speciationExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].speciationPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); if (AreDoublesEqual(tempD, 0.0, ETA)==YES) { MrBayesPrint ("%s Speciation rate cannot be fixed to 0.0\n", spacer); return (ERROR); } modelParams[i].speciationFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Speciationpr to Fixed(%1.2lf)\n", spacer, modelParams[i].speciationFix); else MrBayesPrint ("%s Setting Speciationpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].speciationFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Extinctionpr (extinctionPr) ****************************************************/ else if (!strcmp(parmName, "Extinctionpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].extinctionUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Extinctionpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].extinctionUni[0], modelParams[i].extinctionUni[1]); else MrBayesPrint ("%s Setting Extinctionpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].extinctionUni[0], modelParams[i].extinctionUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].extinctionPr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].extinctionExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Extinctionpr to Exponential(%1.2lf)\n", spacer, modelParams[i].extinctionExp); else MrBayesPrint ("%s Setting Extinctionpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].extinctionExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].extinctionPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].extinctionFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Extinctionpr to Fixed(%1.2lf)\n", spacer, modelParams[i].extinctionFix); else MrBayesPrint ("%s Setting Extinctionpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].extinctionFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Sampleprob (sampleProb) *****************************************************/ else if (!strcmp(parmName, "Sampleprob")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(NUMBER); else if (expecting == Expecting(NUMBER)) { sscanf (tkn, "%lf", &tempD); if (tempD <= 1.0 && tempD > 0.0) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].thetaUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Thetapr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].thetaUni[0], modelParams[i].thetaUni[1]); else MrBayesPrint ("%s Setting Thetapr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].thetaUni[0], modelParams[i].thetaUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].thetaPr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].thetaExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Thetapr to Exponential(%1.2lf)\n", spacer, modelParams[i].thetaExp); else MrBayesPrint ("%s Setting Thetapr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].thetaExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].thetaPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); if (AreDoublesEqual(tempD, 0.0, ETA)==YES) { MrBayesPrint ("%s Theta cannot be fixed to 0.0\n", spacer); return (ERROR); } modelParams[i].thetaFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Thetapr to Fixed(%1.2lf)\n", spacer, modelParams[i].thetaFix); else MrBayesPrint ("%s Setting Thetapr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].thetaFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set clock waiting time prior (calWaitPr) *********************************************************/ else if (!strcmp(parmName, "Calwaitpr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].calWaitUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Calwaitpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].thetaUni[0], modelParams[i].thetaUni[1]); else MrBayesPrint ("%s Setting Calwaitpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].thetaUni[0], modelParams[i].thetaUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].calWaitPr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].calWaitExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Calwaitpr to Exponential(%1.2lf)\n", spacer, modelParams[i].calWaitExp); else MrBayesPrint ("%s Setting Calwaitpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].calWaitExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].calWaitPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); if (AreDoublesEqual(tempD, 0.0,ETA)==YES) { MrBayesPrint ("%s Clock waiting time cannot be fixed to 0.0\n", spacer); return (ERROR); } modelParams[i].calWaitFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Calwaitpr to Fixed(%1.2lf)\n", spacer, modelParams[i].thetaFix); else MrBayesPrint ("%s Setting Calwaitpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].thetaFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Growthpr (growthPr) **************************************************************/ else if (!strcmp(parmName, "Growthpr")) { if (expecting == Expecting(EQUALSIGN)) { expecting = Expecting(ALPHA); isNegative = NO; } else if (expecting == Expecting(ALPHA)) { isNegative = NO; if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].growthUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Growthpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].growthUni[0], modelParams[i].growthUni[1]); else MrBayesPrint ("%s Setting Growthpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].growthUni[0], modelParams[i].growthUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].growthPr,"Normal")) { sscanf (tkn, "%lf", &tempD); if (isNegative == YES) tempD *= -1.0; modelParams[i].growthNorm[numVars[i]++] = tempD; if (numVars[i] == 1) expecting = Expecting(COMMA); else { if (modelParams[i].growthNorm[1] < 0.0) { MrBayesPrint ("%s Variance for normal distribution should be greater than zero\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Growthpr to Normal(%1.2lf,%1.2lf)\n", spacer, modelParams[i].growthNorm[0], modelParams[i].growthNorm[1]); else MrBayesPrint ("%s Setting Growthpr to Normal(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].growthNorm[0], modelParams[i].growthNorm[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].growthPr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].growthExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Growthpr to Exponential(%1.2lf)\n", spacer, modelParams[i].growthExp); else MrBayesPrint ("%s Setting Growthpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].growthExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].thetaPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); if (isNegative == YES) tempD *= -1.0; modelParams[i].growthFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Growthpr to Fixed(%1.2lf)\n", spacer, modelParams[i].growthFix); else MrBayesPrint ("%s Setting Growthpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].growthFix, i+1); expecting = Expecting(RIGHTPAR); } } } isNegative = NO; } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set Aamodelpr (aaModelPr) **************************************************************/ else if (!strcmp(parmName, "Aamodelpr")) { if (expecting == Expecting(EQUALSIGN)) { expecting = Expecting(ALPHA); foundAaSetting = foundExp = modelIsFixed = foundDash = NO; fromI = 0; for (i=0; i<10; i++) tempAaModelPrs[i] = 0.0; } else if (expecting == Expecting(ALPHA)) { if (foundAaSetting == NO) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= 10) { MrBayesPrint ("%s Too many arguments in Aamodelpr\n", spacer); return (ERROR); } if (modelIsFixed == NO) { if (foundExp == YES) { if (foundDash == YES) tempAaModelPrs[fromI++] = -tempD; else tempAaModelPrs[fromI++] = tempD; expecting = Expecting(RIGHTPAR); } else { if (foundDash == YES) { MrBayesPrint ("%s Unexpected \"-\" in Aamodelpr\n", spacer); return (ERROR); } else { if (tempD <= 0.000000000001) tempAaModelPrs[fromI++] = -1000000000; else tempAaModelPrs[fromI++] = (MrBFlt) log(tempD); } expecting = Expecting(COMMA) | Expecting(RIGHTPAR); } foundDash = NO; } else { MrBayesPrint ("%s Not expecting a number\n", spacer); return (ERROR); } } else if (expecting == Expecting(LEFTPAR)) { if (modelIsFixed == YES) expecting = Expecting(ALPHA); else { if (foundExp == YES) expecting = Expecting(NUMBER) | Expecting(DASH); else expecting = Expecting(NUMBER) | Expecting(ALPHA); } } else if (expecting == Expecting(RIGHTPAR)) { if (modelIsFixed == YES) expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); else { if (foundExp == YES) { foundExp = NO; expecting = Expecting(COMMA) | Expecting(RIGHTPAR); } else { if (fromI < 10) { MrBayesPrint ("%s Too few arguments in Aamodelpr\n", spacer); return (ERROR); } nApplied = NumActiveParts (); for (i=0; i= modelParams[i].brownScalesUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Brownscalepr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].brownScalesUni[0], modelParams[i].brownScalesUni[1]); else MrBayesPrint ("%s Setting Brownscalepr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].brownScalesUni[0], modelParams[i].brownScalesUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].brownScalesPr,"Gamma")) { sscanf (tkn, "%lf", &tempD); modelParams[i].brownScalesGamma[numVars[i]++] = tempD; if (numVars[i] == 1) expecting = Expecting(COMMA); else { if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Brownscalepr to Gamma Mean=%1.2lf Var=%1.2lf\n", spacer, modelParams[i].brownScalesGamma[0], modelParams[i].brownScalesGamma[1]); else MrBayesPrint ("%s Setting Brownscalepr to Gamma Mean=%1.2lf Var=%1.2lf for partition %d\n", spacer, modelParams[i].brownScalesGamma[0], modelParams[i].brownScalesGamma[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].brownScalesPr,"Gammamean")) { sscanf (tkn, "%lf", &tempD); modelParams[i].brownScalesGammaMean = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Brownscalepr to Gamma Mean= Var=%1.2lf\n", spacer, modelParams[i].brownScalesGammaMean); else MrBayesPrint ("%s Setting Brownscalepr to Gamma Mean= Var=%1.2lf for partition %d\n", spacer, modelParams[i].brownScalesGammaMean, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].brownScalesPr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].brownScalesFix = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting Brownscalepr to Fixed(%1.2lf)\n", spacer, modelParams[i].brownScalesFix); else MrBayesPrint ("%s Setting Brownscalepr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].brownScalesFix, i+1); expecting = Expecting(RIGHTPAR); } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set M10betapr (m10betapr) ********************************************************/ else if (!strcmp(parmName, "M10betapr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].m10betaUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting M10betapr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].m10betaUni[0], modelParams[i].m10betaUni[1]); else MrBayesPrint ("%s Setting M10betapr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].m10betaUni[0], modelParams[i].m10betaUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].m10betapr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].m10betaExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting M10betapr to Exponential(%1.2lf)\n", spacer, modelParams[i].m10betaExp); else MrBayesPrint ("%s Setting M10betapr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].m10betaExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].m10betapr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].m10betaFix[numVars[i]++] = tempD; if (numVars[i] == 1) expecting = Expecting(COMMA); else { if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting M10betapr to Fixed(%1.2lf,%1.2lf)\n", spacer, modelParams[i].m10betaFix[0], modelParams[i].m10betaFix[1]); else MrBayesPrint ("%s Setting M10betapr to Fixed(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].m10betaFix[0], modelParams[i].m10betaFix[1], i+1); expecting = Expecting(RIGHTPAR); } } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set M10gammapr (m10gammapr) ********************************************************/ else if (!strcmp(parmName, "M10gammapr")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting(ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i= modelParams[i].m10gammaUni[1]) { MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer); return (ERROR); } if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting M10gammapr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].m10gammaUni[0], modelParams[i].m10gammaUni[1]); else MrBayesPrint ("%s Setting M10gammapr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].m10gammaUni[0], modelParams[i].m10gammaUni[1], i+1); expecting = Expecting(RIGHTPAR); } } else if (!strcmp(modelParams[i].m10gammapr,"Exponential")) { sscanf (tkn, "%lf", &tempD); modelParams[i].m10gammaExp = tempD; if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting M10gammapr to Exponential(%1.2lf)\n", spacer, modelParams[i].m10gammaExp); else MrBayesPrint ("%s Setting M10gammapr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].m10gammaExp, i+1); expecting = Expecting(RIGHTPAR); } else if (!strcmp(modelParams[i].m10gammapr,"Fixed")) { sscanf (tkn, "%lf", &tempD); modelParams[i].m10gammaFix[numVars[i]++] = tempD; if (numVars[i] == 1) expecting = Expecting(COMMA); else { if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting M10gammapr to Fixed(%1.2lf,%1.2lf)\n", spacer, modelParams[i].m10gammaFix[0], modelParams[i].m10gammaFix[1]); else MrBayesPrint ("%s Setting M10gammapr to Fixed(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].m10gammaFix[0], modelParams[i].m10gammaFix[1], i+1); expecting = Expecting(RIGHTPAR); } } } } } else if (expecting == Expecting(COMMA)) { expecting = Expecting(NUMBER); } else if (expecting == Expecting(RIGHTPAR)) { expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } else return (ERROR); } return (NO_ERROR); } int DoReport (void) { return (NO_ERROR); } int DoReportParm (char *parmName, char *tkn) { int i, tempInt, nApplied; char tempStr[100]; if (defMatrix == NO) { MrBayesPrint ("%s A matrix must be specified before the report settings can be altered\n", spacer); return (ERROR); } if (inValidCommand == YES) { for (i=0; i numCurrentDivisions) { MrBayesPrint ("%s Partition delimiter is too large\n", spacer); return (ERROR); } if (fromI == -1) fromI = tempInt; else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO) { toJ = tempInt; for (i=fromI-1; i 1) { strcpy(modelParams[i].ratemultFormat, tempStr); if (nApplied == 0 && numCurrentDivisions == 1) MrBayesPrint ("%s Setting rate multiplier (ratemult) format to %s\n", spacer, modelParams[i].ratemultFormat); else MrBayesPrint ("%s Setting rate multiplier (ratemult) format to %s for partition %d\n", spacer, modelParams[i].ratemultFormat, i+1); } } } else { MrBayesPrint ("%s Invalid rate multiplier (ratemult) format \n", spacer); return (ERROR); } expecting = Expecting(PARAMETER) | Expecting(SEMICOLON); } else return (ERROR); } /* set inferancstates ***********************************************************/ else if (!strcmp(parmName, "Ancstates")) { if (expecting == Expecting(EQUALSIGN)) expecting = Expecting (ALPHA); else if (expecting == Expecting(ALPHA)) { if (IsArgValid(tkn, tempStr) == NO_ERROR) { nApplied = NumActiveParts (); for (i=0; i 1) { paramCount = 0; for (j=0; j 0) { m = activeParams[j][i]; paramCount++; for (k=i; k