7 * Dept. Integrative Biology
8 * University of California, Berkeley
9 * Berkeley, CA 94720-3140
13 * Swedish Museum of Natural History
15 * SE-10405 Stockholm, SWEDEN
16 * fredrik.ronquist@nrm.se
18 * With important contributions by
20 * Paul van der Mark (paulvdm@sc.fsu.edu)
21 * Maxim Teslenko (maxim.teslenko@nrm.se)
23 * and by many users (run 'acknowledgments' to see more info)
25 * This program is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU General Public License
27 * as published by the Free Software Foundation; either version 2
28 * of the License, or (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details (www.gnu.org).
45 #if defined(__MWERKS__)
49 const char* const svnRevisionModelC = "$Rev: 1067 $"; /* Revision keyword which is expended/updated by svn on each commit/update */
51 #undef DEBUG_ADDDUMMYCHARS
52 #undef DEBUG_CONSTRAINTS
53 #undef DEBUG_COMPRESSDATA
56 /* local prototypes */
57 int AddDummyChars (void);
58 void AllocateCppEvents (Param *p);
59 MCMCMove *AllocateMove (MoveType *moveType, Param *param);
60 int AllocateNormalParams (void);
61 int AllocateTreeParams (void);
62 void CheckCharCodingType (Matrix *m, CharInfo *ci);
63 int CheckExpandedModels (void);
64 int CompressData (void);
65 int InitializeChainTrees (Param *p, int from, int to, int isRooted);
66 int FillBrlensSubParams (Param *param, int chn, int state);
67 void FreeCppEvents (Param *p);
68 void FreeMove (MCMCMove *mv);
69 void GetPossibleAAs (int aaCode, int aa[]);
70 void GetPossibleNucs (int nucCode, int nuc[]);
71 void GetPossibleRestrictionSites (int resSiteCode, int *sites);
72 int GetUserTreeFromName (int *index, char *treeName);
73 void InitializeMcmcTrees (Param *p);
74 int IsApplicable (Param *param);
75 int IsApplicable_FiveTaxaOrMore (Param *param);
76 int IsApplicable_FourTaxaOrMore (Param *param);
77 int IsApplicable_ThreeTaxaOrMore (Param *param);
78 int IsApplicableTreeAgeMove (Param *param);
79 int IsModelSame (int whichParam, int part1, int part2, int *isApplic1, int *isApplic2);
80 int LargestMovableSubtree(Param *treeParam);
81 int NumActiveParts (void);
82 int NumInformativeHardConstraints (ModelParams *mp);
83 int NumNonExcludedChar (void);
84 int NumStates (int part);
85 int PrintCompMatrix (void);
86 int PrintMatrix (void);
87 int ProcessStdChars (RandLong *seed);
88 void SetCode (int part);
89 int SetModelParams (void);
90 int SetPopSizeParam (Param *param, int chn, int state, PolyTree *pt);
91 int SetRelaxedClockParam (Param *param, int chn, int state, PolyTree *pt);
92 int SetUpLinkTable (void);
93 int ShowMoves (int used);
94 int ShowParameters (int showStartVals, int showMoves, int showAllAvailable);
95 int UpdateCppEvolLength (int *nEvents, MrBFlt **pos, MrBFlt **rateMult, MrBFlt *evolLength, TreeNode *p, MrBFlt baseRate);
98 int *activeParams[NUM_LINKED]; /* a table holding the parameter link status */
99 int localOutGroup; /* outgroup for non-excluded taxa */
100 Calibration **localTaxonCalibration = NULL; /* stores local taxon calibrations (ages) */
101 char **localTaxonNames = NULL; /* points to names of non-excluded taxa */
102 Model *modelParams; /* holds model params */
103 ModelInfo *modelSettings; /* stores important info on model params */
104 MCMCMove **moves; /* vector of pointers to applicable moves */
105 int numApplicableMoves; /* number of moves applicable to model parameters */
106 int numCurrentDivisions; /* number of partitions of data */
107 int numGlobalChains; /* number of global chains */
108 int numLocalTaxa; /* number of non-excluded taxa */
109 int numLocalChar; /* number of non-excluded characters */
110 int numParams; /* number of parameters in model */
111 int numTopologies; /* number of topologies for one chain and state */
112 int numTrees; /* number of trees for one chain and state */
113 Param *params; /* vector of parameters */
114 Param *printParams; /* vector of subst model parameters to print */
115 ShowmovesParams showmovesParams; /* holds parameters for Showmoves command */
116 Param *treePrintparams; /* vector of tree parameters to print */
117 int setUpAnalysisSuccess; /* Set to YES if analysis is set without error */
119 /* globals used to describe and change the current model; allocated in AllocCharacters and SetPartition */
120 int *numVars; /* number of variables in setting arrays */
121 int *activeParts; /* partitions changes should apply to */
122 int *linkTable[NUM_LINKED]; /* how parameters are linked across parts */
123 int *tempLinkUnlink[NUM_LINKED]; /* for changing parameter linkage */
124 int *tempLinkUnlinkVec; /* for changing parameter linkage */
125 MrBFlt *tempNum; /* vector of numbers used for setting arrays */
127 /* Aamodel parameters */
128 MrBFlt aaJones[20][20]; /* rates for Jones model */
129 MrBFlt aaDayhoff[20][20]; /* rates for Dayhoff model */
130 MrBFlt aaMtrev24[20][20]; /* rates for mtrev24 model */
131 MrBFlt aaMtmam[20][20]; /* rates for mtmam model */
132 MrBFlt aartREV[20][20]; /* rates for rtREV model */
133 MrBFlt aaWAG[20][20]; /* rates for WAG model */
134 MrBFlt aacpREV[20][20]; /* rates for aacpREV model */
135 MrBFlt aaVt[20][20]; /* rates for VT model */
136 MrBFlt aaBlosum[20][20]; /* rates for Blosum62 model */
137 MrBFlt aaLG[20][20]; /* rates for LG model */
138 MrBFlt jonesPi[20]; /* stationary frequencies for Jones model */
139 MrBFlt dayhoffPi[20]; /* stationary frequencies for Dayhoff model */
140 MrBFlt mtrev24Pi[20]; /* stationary frequencies for mtrev24 model */
141 MrBFlt mtmamPi[20]; /* stationary frequencies for mtmam model */
142 MrBFlt rtrevPi[20]; /* stationary frequencies for rtREV model */
143 MrBFlt wagPi[20]; /* stationary frequencies for WAG model */
144 MrBFlt cprevPi[20]; /* stationary frequencies for aacpREV model */
145 MrBFlt vtPi[20]; /* stationary frequencies for VT model */
146 MrBFlt blosPi[20]; /* stationary frequencies for Blosum62 model */
147 MrBFlt lgPi[20]; /* stationary frequencies for LG model */
149 /* parser flags and variables */
150 int fromI, toJ, foundDash, foundComma, foundEqual, foundBeta,
151 foundAaSetting, foundExp, modelIsFixed, linkNum, foundLeftPar,
152 foundFSNum[999], foundFSTime[999], tempNumStates, isNegative;
153 MrBFlt tempStateFreqs[200], tempAaModelPrs[10];
154 char colonPr[100], clockPr[30];
156 /* other local variables (this file) */
157 MrBFlt empiricalFreqs[200]; /* emprical base frequencies for partition */
158 int intValsRowSize = 0; /* row size of intValues matrix */
159 int *intValues = NULL; /* stores int values of chain parameters */
160 Tree **mcmcTree; /* pointers to trees for mcmc */
161 int paramValsRowSize = 0; /* row size of paramValues matrix */
162 MrBFlt *paramValues = NULL; /* stores actual values and subvalues of chain parameters */
163 int *relevantParts = NULL; /* partitions that are affected by this move */
164 Param **subParamPtrs; /* pointer to subparams for topology params */
165 int *stateSize; /* # states for each compressed char */
167 // char *plotTokenP; /* plotToken[CMD_STRING_LENGTH];*/
170 /*-----------------------------------------------------------------------
172 | AddDummyChars: Add dummy characters to relevant partitions
174 ------------------------------------------------------------------------*/
175 int AddDummyChars (void)
177 int i, j, k, d, numIncompatible, numDeleted, numStdChars, oldRowSize,
178 newRowSize, numDummyChars, newColumn, newChar, oldColumn, oldChar,
179 isCompat, *tempChar, numIncompatibleChars;
180 BitsLong *tempMatrix, bitsLongOne = 1;
181 CLFlt *tempSitesOfPat;
187 /* set pointers to NULL */
189 tempSitesOfPat = NULL;
192 /* check how many dummy characters needed in total */
195 for (d=0; d<numCurrentDivisions; d++)
197 m = &modelSettings[d];
198 mp = &modelParams[d];
200 m->numDummyChars = 0;
202 if (mp->dataType == RESTRICTION && !strcmp(mp->parsModel,"No"))
204 if (mp->coding & NOABSENCESITES)
206 if (mp->coding & NOPRESENCESITES)
208 if (mp->coding & NOSINGLETONABSENCE)
209 m->numDummyChars += numLocalTaxa;
210 if (mp->coding & NOSINGLETONPRESENCE)
211 m->numDummyChars += numLocalTaxa;
214 if (mp->dataType == STANDARD && !strcmp(mp->parsModel,"No"))
216 if (mp->coding & VARIABLE)
217 m->numDummyChars += 2;
218 if (mp->coding & NOSINGLETONS)
219 m->numDummyChars += 2*numLocalTaxa;
220 numStdChars += (m->numChars + m->numDummyChars);
223 numDummyChars += m->numDummyChars;
224 m->numChars += m->numDummyChars;
227 /* exit if dummy characters not needed */
228 if (numDummyChars == 0)
231 /* print original compressed matrix */
232 # if defined (DEBUG_ADDDUMMYCHARS)
233 MrBayesPrint ("Compressed matrix before adding dummy characters...\n");
237 /* set row sizes for old and new matrices */
238 oldRowSize = compMatrixRowSize;
239 compMatrixRowSize += numDummyChars;
240 newRowSize = compMatrixRowSize;
241 numCompressedChars += numDummyChars;
243 /* allocate space for new data */
244 tempMatrix = (BitsLong *) SafeCalloc (numLocalTaxa * newRowSize, sizeof(BitsLong));
245 tempSitesOfPat = (CLFlt *) SafeCalloc (numCompressedChars, sizeof(CLFlt));
246 tempChar = (int *) SafeCalloc (compMatrixRowSize, sizeof(int));
247 if (!tempMatrix || !tempSitesOfPat || !tempChar)
249 MrBayesPrint ("%s Problem allocating temporary variables in AddDummyChars\n", spacer);
253 /* initialize indices */
254 oldChar = newChar = newColumn = numDeleted = 0;
256 /* set up matrix struct */
257 matrix.origin = compMatrix;
258 matrix.nRows = numLocalTaxa;
259 matrix.rowSize = oldRowSize;
261 /* loop over divisions */
262 for (d=0; d<numCurrentDivisions; d++)
264 m = &modelSettings[d];
265 mp = &modelParams[d];
267 /* insert the dummy characters first for each division */
268 if (m->numDummyChars > 0)
270 // MrBayesPrint("%s Adding dummy characters (unobserved site patterns) for division %d\n", spacer, d+1);
271 // do not print this every time
275 if (((mp->coding & NOSINGLETONPRESENCE) && k == 0) || ((mp->coding & NOSINGLETONABSENCE) && k == 1))
277 for (i=0; i< numLocalTaxa; i++)
279 for (j=0; j<numLocalTaxa; j++)
282 tempMatrix[pos(j,newColumn,newRowSize)] = (bitsLongOne << k) ^ 3;
284 tempMatrix[pos(j,newColumn,newRowSize)] = bitsLongOne << k;
286 tempSitesOfPat[newChar] = 0;
287 tempChar[newColumn] = -1;
294 if (mp->coding & NOABSENCESITES)
296 for (i=0; i<numLocalTaxa; i++)
297 tempMatrix[pos(i,newColumn,newRowSize)] = 1;
298 tempSitesOfPat[newChar] = 0;
299 tempChar[newColumn] = -1;
304 if (mp->coding & NOPRESENCESITES)
306 for (i=0; i<numLocalTaxa; i++)
307 tempMatrix[pos(i,newColumn,newRowSize)] = 2;
308 tempSitesOfPat[newChar] = 0;
309 tempChar[newColumn] = -1;
315 /* add the normal characters */
316 numIncompatible = numIncompatibleChars = 0;
317 for (oldColumn=m->compMatrixStart; oldColumn<m->compMatrixStop; oldColumn++)
320 /* first check if the character is supposed to be present */
321 if (m->numDummyChars > 0)
323 /* set up matrix struct */
324 matrix.column = oldColumn;
325 /* set up charinfo struct */
326 cinfo.dType = mp->dataType;
327 cinfo.cType = charInfo[origChar[oldChar]].ctype;
328 cinfo.nStates = charInfo[origChar[oldChar]].numStates;
329 CheckCharCodingType(&matrix, &cinfo);
331 if (mp->coding & VARIABLE)
333 if((mp->coding & VARIABLE) == VARIABLE && cinfo.variable == NO)
337 else if((mp->coding & NOABSENCESITES) && cinfo.constant[0] == YES)
341 else if((mp->coding & NOPRESENCESITES) && cinfo.constant[1] == YES)
346 if (mp->coding & NOSINGLETONS)
348 if((mp->coding & NOSINGLETONS) == NOSINGLETONS && cinfo.informative == NO && cinfo.variable == YES)
352 else if((mp->coding & NOSINGLETONABSENCE) && cinfo.singleton[0] == YES && cinfo.informative == NO)
356 else if((mp->coding & NOSINGLETONPRESENCE) && cinfo.singleton[1] == YES && cinfo.informative == NO)
366 numIncompatibleChars += (int) numSitesOfPat[oldChar];
372 for (i=0; i<numLocalTaxa; i++)
373 tempMatrix[pos(i,newColumn,newRowSize)] = compMatrix[pos(i,oldColumn,oldRowSize)];
375 compCharPos[origChar[oldColumn]] = newChar;
376 compColPos[origChar[oldColumn]] = newColumn;
377 tempSitesOfPat[newChar] = numSitesOfPat[oldChar];
378 tempChar[newColumn] = origChar[oldColumn];
380 if ((oldColumn-m->compMatrixStart+1) % m->nCharsPerSite == 0)
388 /* print a warning if there are incompatible characters */
389 if (numIncompatible > 0)
391 m->numChars -= numIncompatible;
392 m->numUncompressedChars -= numIncompatibleChars;
393 numDeleted += numIncompatible;
394 if (numIncompatibleChars > 1)
396 MrBayesPrint ("%s WARNING: There are %d characters incompatible with the specified\n", spacer, numIncompatibleChars);
397 MrBayesPrint ("%s coding bias. These characters will be excluded.\n", spacer);
401 MrBayesPrint ("%s WARNING: There is one character incompatible with the specified\n", spacer);
402 MrBayesPrint ("%s coding bias. This character will be excluded.\n", spacer);
406 /* update division comp matrix and comp char pointers */
407 m->compCharStop = newChar;
408 m->compMatrixStop = newColumn;
409 m->compCharStart = newChar - m->numChars;
410 m->compMatrixStart = newColumn - m->nCharsPerSite * m->numChars;
412 } /* next division */
414 /* compress matrix if necessary */
417 for (i=k=0; i<numLocalTaxa; i++)
419 for (j=0; j<newRowSize-numDeleted; j++)
421 tempMatrix[k++] = tempMatrix[j+i*newRowSize];
424 numCompressedChars -= numDeleted;
425 compMatrixRowSize -= numDeleted;
428 /* free old data, set pointers to new data */
430 free (numSitesOfPat);
433 compMatrix = tempMatrix;
434 numSitesOfPat = tempSitesOfPat;
438 tempSitesOfPat = NULL;
441 /* print new compressed matrix */
442 # if defined (DEBUG_ADDDUMMYCHARS)
443 MrBayesPrint ("After adding dummy characters...\n");
453 free (tempSitesOfPat);
461 /* Allocate space for cpp events */
462 void AllocateCppEvents (Param *p)
466 p->nEvents = (int **) SafeCalloc (2*numGlobalChains, sizeof (int *));
467 p->nEvents[0] = (int *) SafeCalloc (2*numGlobalChains*(2*numLocalTaxa), sizeof (int));
468 for (i=1; i<2*numGlobalChains; i++)
469 p->nEvents[i] = p->nEvents[i-1] + (2*numLocalTaxa);
470 p->position = (MrBFlt ***) SafeCalloc (2*numGlobalChains, sizeof (MrBFlt **));
471 p->position[0] = (MrBFlt **) SafeCalloc (2*numGlobalChains*(2*numLocalTaxa), sizeof (MrBFlt *));
472 for (i=1; i<2*numGlobalChains; i++)
473 p->position[i] = p->position[i-1] + (2*numLocalTaxa);
474 p->rateMult = (MrBFlt ***) SafeCalloc (2*numGlobalChains, sizeof (MrBFlt **));
475 p->rateMult[0] = (MrBFlt **) SafeCalloc (2*numGlobalChains*(2*numLocalTaxa), sizeof (MrBFlt *));
476 for (i=1; i<2*numGlobalChains; i++)
477 p->rateMult[i] = p->rateMult[i-1] + (2*numLocalTaxa);
482 /*----------------------------------------------------------------------------
484 | AllocateMove: Allocate space for and initialize one applicable move
486 -----------------------------------------------------------------------------*/
487 MCMCMove *AllocateMove (MoveType *moveType, Param *param)
489 int i, j, nameLength;
490 char *partitionDescriptor = "";
493 if ((temp = (MCMCMove *) SafeCalloc (1, sizeof (MCMCMove))) == NULL)
496 /* calculate length */
497 if (strcmp (moveType->paramName, "") == 0)
498 nameLength = (int) (strlen (moveType->shortName) + strlen (param->name)) + 10;
501 partitionDescriptor = param->name;
502 while (*partitionDescriptor != '\0')
504 if (*partitionDescriptor == '{')
506 partitionDescriptor++;
508 nameLength = (int) (strlen (moveType->shortName) + strlen (moveType->paramName) + strlen (partitionDescriptor)) + 10;
510 /* add length of names of subparams */
511 if (moveType->subParams == YES)
513 for (i=0; i<param->nSubParams; i++)
514 nameLength += (int)(strlen(param->subParams[i]->name)) + 1;
517 if ((temp->name = (char *) SafeCalloc (nameLength, sizeof (char))) == NULL)
523 if ((temp->nAccepted = (int *) SafeCalloc (5*numGlobalChains, sizeof (int))) == NULL)
529 temp->nTried = temp->nAccepted + numGlobalChains;
530 temp->nBatches = temp->nAccepted + 2*numGlobalChains;
531 temp->nTotAccepted = temp->nAccepted + 3*numGlobalChains;
532 temp->nTotTried = temp->nAccepted + 4*numGlobalChains;
534 if ((temp->relProposalProb = (MrBFlt *) SafeCalloc (4*numGlobalChains, sizeof (MrBFlt))) == NULL)
536 free (temp->nAccepted);
541 temp->cumProposalProb = temp->relProposalProb + numGlobalChains;
542 temp->targetRate = temp->relProposalProb + 2*numGlobalChains;
543 temp->lastAcceptanceRate = temp->relProposalProb + 3*numGlobalChains;
545 if ((temp->tuningParam = (MrBFlt **) SafeCalloc (numGlobalChains, sizeof (MrBFlt *))) == NULL)
547 free (temp->relProposalProb);
548 free (temp->nAccepted);
553 if ((temp->tuningParam[0] = (MrBFlt *) SafeCalloc (moveType->numTuningParams*numGlobalChains, sizeof (MrBFlt))) == NULL)
555 free (temp->tuningParam);
556 free (temp->relProposalProb);
557 free (temp->nAccepted);
562 for (i=1; i<numGlobalChains; i++)
563 temp->tuningParam[i] = temp->tuningParam[0] + (i * moveType->numTuningParams);
565 /* set default values */
566 if (strcmp(moveType->paramName, "") != 0)
567 sprintf (temp->name, "%s(%s%s)", moveType->shortName, moveType->paramName, partitionDescriptor);
570 sprintf (temp->name, "%s(%s", moveType->shortName, param->name);
571 if (moveType->subParams == YES)
573 for (i=0; i<param->nSubParams; i++)
575 strcat(temp->name,",");
576 strcat(temp->name,param->subParams[i]->name);
579 strcat (temp->name,")");
582 temp->moveType = moveType;
583 temp->moveFxn = moveType->moveFxn;
584 for (i=0; i<numGlobalChains; i++)
586 temp->relProposalProb[i] = moveType->relProposalProb;
587 temp->cumProposalProb[i] = 0.0;
588 temp->nAccepted[i] = 0;
590 temp->nBatches[i] = 0;
591 temp->nTotAccepted[i] = 0;
592 temp->nTotTried[i] = 0;
593 temp->targetRate[i] = moveType->targetRate;
594 temp->lastAcceptanceRate[i] = 0.0;
595 for (j=0; j<moveType->numTuningParams; j++)
596 temp->tuningParam[i][j] = moveType->tuningParam[j];
602 /*----------------------------------------------------------------------
604 | AllocateNormalParams: Allocate space for normal parameters
606 -----------------------------------------------------------------------*/
607 int AllocateNormalParams (void)
609 int i, k, nOfParams, nOfIntParams;
612 /* Count the number of param values and subvalues */
615 for (k=0; k<numParams; k++)
617 nOfParams += params[k].nValues;
618 nOfParams += params[k].nSubValues;
619 nOfIntParams += params[k].nIntValues;
622 /* Set row size and find total number of values */
623 paramValsRowSize = nOfParams;
624 intValsRowSize = nOfIntParams;
625 nOfParams *= (2 * numGlobalChains);
626 nOfIntParams *= (2 * numGlobalChains);
628 if (memAllocs[ALLOC_PARAMVALUES] == YES)
630 paramValues = (MrBFlt *) SafeRealloc ((void *) paramValues, nOfParams * sizeof (MrBFlt));
631 for (i=0; i<nOfParams; i++)
632 paramValues[i] = 0.0;
633 if (nOfIntParams > 0)
634 intValues = (int *) SafeRealloc ((void *) intValues, nOfIntParams * sizeof(int));
638 paramValues = (MrBFlt *) SafeCalloc (nOfParams, sizeof(MrBFlt));
639 if (nOfIntParams > 0)
640 intValues = (int *) SafeCalloc (nOfIntParams, sizeof(int));
644 if (!paramValues || (nOfIntParams > 0 && !intValues))
646 MrBayesPrint ("%s Problem allocating paramValues\n", spacer);
654 memAllocs[ALLOC_PARAMVALUES] = YES;
656 /* set pointers to values for chain 1 state 0 */
657 /* this scheme keeps the chain and state values together */
660 for (k=0; k<numParams; k++)
664 p->values = paramValues + nOfParams;
667 nOfParams += p->nValues;
668 if (p->nSubValues > 0)
669 p->subValues = paramValues + nOfParams;
672 nOfParams += p->nSubValues;
673 if (p->nIntValues > 0)
674 p->intValues = intValues + nOfIntParams;
677 nOfIntParams += p->nIntValues;
680 /* allocate space for cpp events */
681 for (k=0; k<numParams; k++)
684 if (p->paramType == P_CPPEVENTS)
685 AllocateCppEvents(p);
692 /*----------------------------------------------------------------------
694 | AllocateTreeParams: Allocate space for tree parameters
696 -----------------------------------------------------------------------*/
697 int AllocateTreeParams (void)
699 int i, j, k, n, nOfParams, nOfTrees, isRooted, numSubParamPtrs;
702 /* Count the number of trees and dated trees */
703 /* based on branch length parameters */
704 /* One tree is needed for each brlen parameter.
705 A topology may apply to several trees; a topology parameter
706 contains pointers to all trees it applies to */
709 for (k=0; k<numParams; k++)
711 if (params[k].paramType == P_BRLENS)
713 else if (params[k].paramType == P_TOPOLOGY)
717 /* We need to add the trees that do not have any branch lengths */
718 /* that is, the pure parsimony model trees, and the species trees */
719 for (k=0; k<numParams; k++)
721 if (params[k].paramType == P_TOPOLOGY)
723 if (!strcmp(modelParams[params[k].relParts[0]].parsModel, "Yes"))
726 else if (params[k].paramType == P_SPECIESTREE)
733 /* Finally add subparam pointers for relaxed clock parameters and species trees */
735 for (k=0; k<numParams; k++)
737 if (params[k].paramType == P_TOPOLOGY && params[k].paramId == TOPOLOGY_SPECIESTREE)
738 numSubParamPtrs += 1;
739 else if (params[k].paramType == P_BRLENS)
740 numSubParamPtrs += 1;
741 else if (params[k].paramType == P_CPPEVENTS)
742 numSubParamPtrs += 3;
743 else if (params[k].paramType == P_TK02BRANCHRATES)
744 numSubParamPtrs += 2;
745 else if (params[k].paramType == P_IGRBRANCHRATES)
746 numSubParamPtrs += 2;
747 else if (params[k].paramType == P_MIXEDBRCHRATES)
748 numSubParamPtrs += 2;
751 /* Allocate space for trees and subparam pointers */
752 if (memAllocs[ALLOC_MCMCTREES] == YES)
758 memAllocs[ALLOC_MCMCTREES] = NO;
760 subParamPtrs = (Param **) SafeCalloc (numSubParamPtrs, sizeof (Param *));
761 mcmcTree = (Tree **) SafeCalloc (numTrees * 2 * numGlobalChains, sizeof (Tree *));
762 if (!subParamPtrs || !mcmcTree)
764 if (subParamPtrs) free (subParamPtrs);
765 if (mcmcTree) free (mcmcTree);
768 MrBayesPrint ("%s Problem allocating mcmc trees\n", spacer);
772 memAllocs[ALLOC_MCMCTREES] = YES;
774 /* Initialize number of subparams, just in case */
775 for (k=0; k<numParams; k++)
776 params[k].nSubParams = 0;
778 /* Count number of trees (brlens) for each topology or species tree */
779 for (k=0; k<numParams; k++)
782 if (params[k].paramType == P_BRLENS)
784 q = modelSettings[p->relParts[0]].topology;
786 if (p->printParam == YES)
787 q->nPrintSubParams++;
789 else if (params[k].paramType == P_TOPOLOGY)
791 q = modelSettings[p->relParts[0]].speciesTree;
797 /* Make sure there is also one subparam for a parsimony tree */
798 for (k=0; k<numParams; k++)
799 if (params[k].paramType == P_TOPOLOGY)
802 if (p->nSubParams == 0)
806 /* Count subparams for relaxed clock parameters */
807 for (k=0; k<numParams; k++)
810 if (p->paramType == P_CPPEVENTS)
812 q = modelSettings[p->relParts[0]].cppRate;
814 q = modelSettings[p->relParts[0]].cppMultDev;
816 q = modelSettings[p->relParts[0]].brlens;
819 else if (p->paramType == P_TK02BRANCHRATES)
821 q = modelSettings[p->relParts[0]].tk02var;
823 q = modelSettings[p->relParts[0]].brlens;
826 else if (p->paramType == P_IGRBRANCHRATES)
828 q = modelSettings[p->relParts[0]].igrvar;
830 q = modelSettings[p->relParts[0]].brlens;
833 else if (p->paramType == P_MIXEDBRCHRATES)
835 q = modelSettings[p->relParts[0]].mixedvar;
837 q = modelSettings[p->relParts[0]].brlens;
842 /* set pointers to subparams */
844 for (k=0; k<numParams; k++)
847 if (p->nSubParams > 0)
849 p->subParams = subParamPtrs + nOfParams;
850 nOfParams += p->nSubParams;
853 assert (nOfParams == numSubParamPtrs);
855 /* Set brlens param pointers and tree values */
856 /* the scheme below keeps trees for the same state and chain together */
858 for (k=0; k<numParams; k++)
861 if ((p->paramType == P_BRLENS) ||
862 (p->paramType == P_TOPOLOGY && p->paramId == TOPOLOGY_PARSIMONY_UNIFORM) ||
863 (p->paramType == P_TOPOLOGY && p->paramId == TOPOLOGY_PARSIMONY_CONSTRAINED) ||
864 (p->paramType == P_SPECIESTREE))
866 /* allocate space for trees and initialize trees */
867 p->treeIndex = nOfTrees;
868 p->tree = mcmcTree + nOfTrees;
873 /* Set topology params and associated brlen subparams */
874 for (k=0; k<numParams; k++)
877 if (p->paramType == P_TOPOLOGY)
879 if (p->paramId == TOPOLOGY_PARSIMONY_UNIFORM ||
880 p->paramId == TOPOLOGY_PARSIMONY_CONSTRAINED)
881 /* pure parsimony topology case */
883 /* there is no brlen subparam */
884 /* so let subparam point to the param itself */
885 q = p->subParams[0] = p;
886 /* p->tree and p->treeIndex have been set above */
890 /* first set brlens pointers for any parsimony partitions */
891 for (i=j=0; i<p->nRelParts; i++)
893 if (modelSettings[p->relParts[i]].parsModelId == YES)
895 modelSettings[p->relParts[i]].brlens = p;
899 /* now proceed with pointer assignment */
900 q = modelSettings[p->relParts[0]].brlens;
901 n = 0; /* number of stored subParams */
902 i = 0; /* relevant partition number */
903 while (i < p->nRelParts)
906 if (q == p->subParams[j])
909 if (j == n && q != p) /* a new tree (brlens) for this topology */
911 p->subParams[n++] = q;
913 q = modelSettings[p->relParts[++i]].brlens;
916 p->tree = p->subParams[0]->tree;
917 p->treeIndex = p->subParams[0]->treeIndex;
920 else if (p->paramType == P_SPECIESTREE)
922 /* now proceed with pointer assignment */
923 q = modelSettings[p->relParts[0]].topology;
924 n = 0; /* number of stored subParams */
925 i = 0; /* relevant partition number */
926 while (i < p->nRelParts)
929 if (q == p->subParams[j])
932 if (j == n && q != p) /* a new topology for this species tree */
934 p->subParams[n++] = q;
936 q = modelSettings[p->relParts[++i]].topology;
941 /* Check for constraints */
942 for (k=0; k<numParams; k++)
945 if (p->paramType == P_TOPOLOGY)
947 if (!strcmp(modelParams[p->relParts[0]].topologyPr, "Constraints"))
949 for (i=0; i<p->nSubParams; i++)
952 q->checkConstraints = YES;
957 for (i=0; i<p->nSubParams; i++)
960 q->checkConstraints = NO;
967 for (k=0; k<numParams; k++)
970 if (p->paramType == P_TOPOLOGY)
972 if (p->nSubParams > 1)
974 if (p->paramId == TOPOLOGY_NCL_UNIFORM_HOMO)
975 p->paramId = TOPOLOGY_NCL_UNIFORM_HETERO;
976 else if (p->paramId == TOPOLOGY_NCL_CONSTRAINED_HOMO)
977 p->paramId = TOPOLOGY_NCL_CONSTRAINED_HETERO;
978 else if (p->paramId == TOPOLOGY_NCL_FIXED_HOMO)
979 p->paramId = TOPOLOGY_NCL_FIXED_HETERO;
982 MrBayesPrint ("%s A clock tree cannot have more than one set of branch lengths\n", spacer);
983 printf ("nparam:%d paramid:%d",p->nSubParams,p->paramId);
990 /* finally initialize trees */
991 for (k=0; k<numParams; k++)
994 if (p->paramType == P_BRLENS)
996 /* find type of tree */
997 if (!strcmp(modelParams[p->relParts[0]].brlensPr,"Clock"))
1002 if (InitializeChainTrees (p, 0, numGlobalChains, isRooted) == ERROR)
1005 else if (p->paramType == P_SPECIESTREE)
1007 if (InitializeChainTrees (p, 0, numGlobalChains, YES) == ERROR)
1012 /* now initialize subparam pointers for relaxed clock models */
1013 /* use nSubParams to point to the next available subParam by first
1014 resetting all nSubParams to 0 */
1015 for (k=0; k<numParams; k++)
1018 if (p->paramType == P_CPPRATE ||
1019 p->paramType == P_CPPMULTDEV ||
1020 p->paramType == P_BRLENS ||
1021 p->paramType == P_TK02VAR ||
1022 p->paramType == P_IGRVAR ||
1023 p->paramType == P_MIXEDVAR)
1026 for (k=0; k<numParams; k++)
1029 if (p->paramType == P_CPPEVENTS)
1031 q = modelSettings[p->relParts[0]].cppRate;
1032 q->subParams[q->nSubParams++] = p;
1033 q = modelSettings[p->relParts[0]].cppMultDev;
1034 q->subParams[q->nSubParams++] = p;
1035 q = modelSettings[p->relParts[0]].brlens;
1036 q->subParams[q->nSubParams++] = p;
1037 p->treeIndex = q->treeIndex;
1039 if (p->printParam == YES)
1040 q->nPrintSubParams++;
1042 else if (p->paramType == P_TK02BRANCHRATES)
1044 q = modelSettings[p->relParts[0]].tk02var;
1045 q->subParams[q->nSubParams++] = p;
1046 q = modelSettings[p->relParts[0]].brlens;
1047 q->subParams[q->nSubParams++] = p;
1048 p->treeIndex = q->treeIndex;
1050 if (p->printParam == YES)
1051 q->nPrintSubParams++;
1053 else if (p->paramType == P_IGRBRANCHRATES)
1055 q = modelSettings[p->relParts[0]].igrvar;
1056 q->subParams[q->nSubParams++] = p;
1057 q = modelSettings[p->relParts[0]].brlens;
1058 q->subParams[q->nSubParams++] = p;
1059 p->treeIndex = q->treeIndex;
1061 if (p->printParam == YES)
1062 q->nPrintSubParams++;
1064 else if (p->paramType == P_MIXEDBRCHRATES)
1066 q = modelSettings[p->relParts[0]].mixedvar;
1067 q->subParams[q->nSubParams++] = p;
1068 q = modelSettings[p->relParts[0]].brlens;
1069 q->subParams[q->nSubParams++] = p;
1070 p->treeIndex = q->treeIndex;
1072 if (p->printParam == YES)
1073 q->nPrintSubParams++;
1081 int AreDoublesEqual (MrBFlt x, MrBFlt y, MrBFlt tol)
1083 if ((x - y) < -tol || (x - y) > tol)
1090 int ChangeNumChains (int from, int to)
1092 int i, i1, j, k, m, st, nRuns, fromIndex, toIndex, run, chn, *tempIntVals, nCppEventParams, *toEvents, *fromEvents;
1093 MCMCMove **tempMoves, *fromMove, *toMove;
1095 MrBFlt *tempVals, **toRateMult, **toPosition, **fromRateMult, **fromPosition, *stdStateFreqsOld;
1096 Param *p, *q, *cppEventParams = NULL;
1097 Tree **oldMcmcTree, *tree;
1102 /* set new number of chains */
1103 chainParams.numChains = to;
1104 nRuns = chainParams.numRuns;
1105 numGlobalChains = chainParams.numRuns * chainParams.numChains;
1107 /* Do the normal parameters */
1108 /* first save old values */
1109 tempVals = paramValues;
1111 tempIntVals = intValues;
1113 memAllocs[ALLOC_PARAMS] = NO;
1114 /* .. and old cpp events parameters */
1115 nCppEventParams = 0;
1116 for (i=0; i<numParams; i++)
1119 if (p->paramType == P_CPPEVENTS)
1122 cppEventParams = (Param *) SafeCalloc (nCppEventParams, sizeof(Param));
1123 for (i=0; i<nCppEventParams; i++)
1125 cppEventParams[i].paramType = P_CPPEVENTS;
1126 AllocateCppEvents (&cppEventParams[i]);
1128 for (i=j=0; i<numParams; i++)
1131 if (p->paramType == P_CPPEVENTS)
1133 cppEventParams[j].nEvents = p->nEvents;
1135 cppEventParams[j].position = p->position;
1137 cppEventParams[j].rateMult = p->rateMult;
1142 if (AllocateNormalParams () == ERROR)
1145 /* then fill all params */
1146 FillNormalParams (&globalSeed, 0, numGlobalChains);
1148 /* finally overwrite with old values if present */
1149 for (run=0; run<nRuns; run++)
1151 for (chn=0; chn<from; chn++)
1155 fromIndex = (run*from + chn)*2*paramValsRowSize;
1156 toIndex = (run*to + chn)*2*paramValsRowSize;
1157 for (i=0; i<2*paramValsRowSize; i++)
1158 paramValues[toIndex++] = tempVals[fromIndex++];
1159 fromIndex = (run*from + chn)*2*intValsRowSize;
1160 toIndex = (run*to + chn)*2*intValsRowSize;
1161 for (i=0; i<2*intValsRowSize; i++)
1162 intValues[toIndex++] = tempIntVals[fromIndex++];
1163 for (i=i1=0; i<numParams; i++)
1166 if (p->paramType == P_CPPEVENTS)
1168 fromIndex = 2*(run*from + chn);
1169 toIndex = 2*(run*to + chn);
1170 fromEvents = cppEventParams[i1].nEvents[fromIndex];
1171 toEvents = p->nEvents[toIndex];
1172 fromPosition = cppEventParams[i1].position[fromIndex];
1173 toPosition = p->position[toIndex];
1174 fromRateMult = cppEventParams[i1].rateMult[fromIndex];
1175 toRateMult = p->rateMult[toIndex];
1176 for (j=0; j<2*numLocalTaxa; j++)
1178 toEvents[j] = fromEvents[j];
1179 toPosition[j] = (MrBFlt *) SafeRealloc ((void *)toPosition[j], toEvents[j]*sizeof(MrBFlt));
1180 toRateMult[j] = (MrBFlt *) SafeRealloc ((void *)toRateMult[j], toEvents[j]*sizeof(MrBFlt));
1181 for (k=0; k<toEvents[j]; k++)
1183 toPosition[j][k] = fromPosition[j][k];
1184 toRateMult[j][k] = fromRateMult[j][k];
1190 assert (nCppEventParams==i1);
1195 /* and free up space */
1197 if (intValsRowSize > 0)
1199 for (i=0; i<nCppEventParams; i++)
1201 numGlobalChains = chainParams.numRuns * from; /* Revert to the old value to clean old Cpp events in FreeCppEvents() */
1202 FreeCppEvents(&cppEventParams[i]);
1203 numGlobalChains = chainParams.numRuns * chainParams.numChains; /*Set to proper value again*/
1205 if (nCppEventParams > 0)
1206 free (cppEventParams);
1208 /* then do the trees (they cannot be done before the parameters because otherwise FillTreeParams will overwrite
1209 relaxed clock parameters that need to be saved) */
1211 /* reallocate trees */
1212 tempTrees = (Tree **) SafeCalloc (2*nRuns*from*numTrees, sizeof(Tree *));
1213 for (i=0; i<2*nRuns*from*numTrees; i++)
1214 tempTrees[i] = mcmcTree[i];
1215 oldMcmcTree = mcmcTree;
1216 mcmcTree = (Tree **) SafeRealloc ((void *)(mcmcTree), 2 * (size_t)numGlobalChains * (size_t)numTrees * sizeof(Tree*));
1217 for (i=0; i<2*nRuns*to*numTrees; i++)
1220 /* move the old trees over */
1221 for (run=0; run<nRuns; run++)
1223 for (chn=0; chn<from; chn++)
1227 /*Here we move only one tree per chain/state?! Should not we move numTrees??*/
1228 fromIndex = 2*(run*from + chn) * numTrees;
1229 toIndex = 2*(run*to + chn) * numTrees;
1230 for (k=0;k<2*numTrees;k++)
1232 mcmcTree[toIndex+k] = tempTrees[fromIndex+k];
1233 tempTrees[fromIndex+k] = NULL;
1238 /* remove any remaining old trees */
1239 for (i=0; i<2*nRuns*from*numTrees; i++)
1240 if (tempTrees[i] != NULL)
1241 FreeTree (tempTrees[i]);
1244 /* now fill in the tree parameters */
1245 for (i=0; i<numParams; i++)
1248 if (p->paramType == P_TOPOLOGY)
1250 p->tree += (mcmcTree - oldMcmcTree); /* calculate new address */
1251 for (j=0; j<p->nSubParams; j++)
1253 q = p->subParams[j];
1254 assert (q->paramType==P_BRLENS);
1255 q->tree += (mcmcTree - oldMcmcTree); /* calculate new address */
1257 for (run=0; run<nRuns; run++)
1259 /*rename old trees because each run has more chains*/
1260 for (m=0; m<from; m++)
1262 for (st=0; st<2; st++)
1264 tree = GetTree (q,run*to + m, st);
1266 sprintf (tree->name, "mcmc.tree%d_%d", p->treeIndex+1, run*to + m +1);
1267 else /* if (numTrees == 1) */
1268 sprintf (tree->name, "mcmc.tree_%d", run*to + m +1);
1271 InitializeChainTrees (q, run*to + from, run*to + to , GetTree (q, 0, 0)->isRooted);
1275 else if (p->paramType == P_CPPEVENTS || p->paramType == P_TK02BRANCHRATES || p->paramType == P_IGRBRANCHRATES || p->paramType == P_MIXEDBRCHRATES)
1276 p->tree += (mcmcTree - oldMcmcTree);
1278 assert (p->paramType==P_BRLENS || p->tree==NULL);
1282 /* fill new tree parameters */
1285 for (run=0; run<nRuns; run++)
1287 for (chn=from; chn<to; chn++)
1289 toIndex = run*to + chn;
1290 FillTreeParams (&globalSeed, toIndex, toIndex+1);
1295 /* fix stationary frequencies for standard data */
1296 if (stdStateFreqsRowSize > 0)
1298 assert (memAllocs[ALLOC_STDSTATEFREQS] == YES);
1299 stdStateFreqsOld=stdStateFreqs;
1300 stdStateFreqs = (MrBFlt *) SafeMalloc (2 * (size_t)stdStateFreqsRowSize * (size_t)numGlobalChains * sizeof (MrBFlt));
1303 MrBayesPrint ("%s Problem reallocating stdStateFreqs\n", spacer);
1308 for (k=0; k<numParams; k++)
1311 if (p->paramType != P_PI || modelParams[p->relParts[0]].dataType != STANDARD)
1313 p->stdStateFreqs += stdStateFreqs-stdStateFreqsOld;
1316 for (run=0; run<nRuns; run++)
1318 /* copy old chains values*/
1319 for (chn=0; chn<from; chn++)
1324 fromIndex = 2*(run*from + chn)*stdStateFreqsRowSize;
1325 toIndex = 2*(run*to + chn)*stdStateFreqsRowSize;
1326 for (k=0;k<2*stdStateFreqsRowSize;k++)
1328 stdStateFreqs[toIndex+k]=stdStateFreqsOld[fromIndex+k];
1331 /* set new chains */
1332 FillStdStateFreqs (run*to+from, run*to+to, &globalSeed);
1334 free(stdStateFreqsOld);
1338 /* first allocate space and set up default moves */
1341 memAllocs[ALLOC_MOVES] = NO;
1344 /* then overwrite with old values if present */
1345 for (i=0; i<numApplicableMoves; i++)
1348 fromMove = tempMoves[i];
1349 for (run=0; run<nRuns; run++)
1351 for (chn=0; chn<from; chn++)
1355 fromIndex = run*from + chn;
1356 toIndex = run*to + chn;
1357 toMove->relProposalProb[toIndex] = fromMove->relProposalProb[fromIndex];
1358 for (j=0; j<toMove->moveType->numTuningParams; j++)
1360 toMove->tuningParam[toIndex][j] = fromMove->tuningParam[fromIndex][j];
1367 /* and free up space */
1368 for (i=0; i<numApplicableMoves; i++)
1369 FreeMove (tempMoves[i]);
1376 int ChangeNumRuns (int from, int to)
1378 int i, i1, j, k, n, nChains;
1382 MrBFlt *oldParamValues;
1383 MrBFlt *stdStateFreqsOld;
1390 for (i=0; i<numParams; i++)
1393 if (p->paramType == P_CPPEVENTS)
1395 printf ("Trees before changing number of runs\n");
1396 for (j=0; j<numGlobalChains; j++)
1398 printf ("Event tree for chain %d\n", j+1);
1399 for (k=0; k<2*numLocalTaxa; k++)
1401 printf ("%d -- %d:", k, p->nEvents[2*j][k]);
1402 for (i1=0; i1<p->nEvents[2*j][k]; i1++)
1405 printf (" (%lf %lf,", p->position[2*j][k], p->rateMult[2*j][k]);
1406 else if (i1 == p->nEvents[2*j][k]-1)
1407 printf (" %lf %lf)", p->position[2*j][k], p->rateMult[2*j][k]);
1409 printf (" %lf %lf,", p->position[2*j][k], p->rateMult[2*j][k]);
1413 for (k=0; k<2*numLocalTaxa; k++)
1415 printf ("%d -- %d:", k, p->nEvents[2*j][k]);
1416 for (i1=0; i1<p->nEvents[2*j+1][k]; i1++)
1419 printf (" (%lf %lf,", p->position[2*j+1][k], p->rateMult[2*j+1][k]);
1420 else if (i1 == p->nEvents[2*j][k]-1)
1421 printf (" %lf %lf)", p->position[2*j+1][k], p->rateMult[2*j+1][k]);
1423 printf (" %lf %lf,", p->position[2*j+1][k], p->rateMult[2*j+1][k]);
1432 /* set new number of runs */
1433 chainParams.numRuns = to;
1434 nChains = chainParams.numChains;
1435 numGlobalChains = chainParams.numRuns * chainParams.numChains;
1437 /* do the trees, free tree's memory if we reduce number of trees. */
1438 for (i=to*2*nChains*numTrees; i<from*2*nChains*numTrees; i++)
1440 FreeTree (mcmcTree[i]);
1442 oldMcmcTree = mcmcTree;
1443 mcmcTree = (Tree **) SafeRealloc ((void *) mcmcTree, numTrees * 2 * numGlobalChains * sizeof (Tree *));
1444 if (mcmcTree == NULL)
1446 memAllocs[ALLOC_MCMCTREES] = NO;
1447 MrBayesPrint ("%s Problem reallocating mcmcTree\n", spacer);
1451 for (i=from*2*nChains*numTrees; i<to*2*nChains*numTrees; i++)
1455 /* then the cppevents parameters */
1456 for (i1=0; i1<numParams; i1++)
1459 if (p->paramType == P_CPPEVENTS)
1461 p->nEvents = (int **) SafeRealloc ((void *)p->nEvents, 2*numGlobalChains*sizeof (int *));
1462 p->nEvents[0] = (int *) SafeRealloc ((void *)p->nEvents[0], 2*numGlobalChains*(2*numLocalTaxa)*sizeof (int));
1463 for (i=1; i<2*numGlobalChains; i++)
1464 p->nEvents[i] = p->nEvents[i-1] + (2*numLocalTaxa);
1467 for (j=numGlobalChains; j<from*nChains; j++)
1469 for (k=0; k<2*numLocalTaxa; k++)
1471 free (p->position[2*j+0][k]);
1472 p->position[2*j+0][k] = NULL;
1473 free (p->rateMult[2*j+0][k]);
1474 p->rateMult[2*j+0][k] = NULL;
1478 p->position = (MrBFlt ***) SafeRealloc ((void *)p->position, 2*numGlobalChains*sizeof (MrBFlt **));
1479 p->position[0] = (MrBFlt **) SafeRealloc ((void *)p->position[0], 2*numGlobalChains*(2*numLocalTaxa)*sizeof (MrBFlt *));
1480 for (i=1; i<2*numGlobalChains; i++)
1481 p->position[i] = p->position[i-1] + (2*numLocalTaxa);
1482 p->rateMult = (MrBFlt ***) SafeRealloc ((void *)p->rateMult, 2*numGlobalChains*sizeof (MrBFlt **));
1483 p->rateMult[0] = (MrBFlt **) SafeRealloc ((void *)p->rateMult[0], 2*numGlobalChains*(2*numLocalTaxa)*sizeof (MrBFlt *));
1484 for (i=1; i<2*numGlobalChains; i++)
1485 p->rateMult[i] = p->rateMult[i-1] + (2*numLocalTaxa);
1488 for (j=from*nChains; j<numGlobalChains; j++)
1490 for (k=0; k<2*numLocalTaxa; k++)
1492 p->nEvents[2*j+0][k] = 0;
1493 p->position[2*j+0][k] = NULL;
1494 p->rateMult[2*j+0][k] = NULL;
1495 p->nEvents[2*j+1][k] = 0;
1496 p->position[2*j+1][k] = NULL;
1497 p->rateMult[2*j+1][k] = NULL;
1503 /* and finally the normal parameters */
1504 oldParamValues = paramValues;
1505 paramValues = (MrBFlt *) SafeRealloc ((void *) paramValues, paramValsRowSize * 2 * numGlobalChains * sizeof (MrBFlt));
1506 oldintValues = intValues;
1507 intValues = (int *) SafeRealloc ((void *) intValues, intValsRowSize * 2 * numGlobalChains * sizeof (int));
1508 if (paramValues == NULL)
1510 memAllocs[ALLOC_PARAMVALUES] = NO;
1511 MrBayesPrint ("%s Problem reallocating paramValues\n", spacer);
1514 for (i=0; i<numParams; i++)
1516 params[i].values += (paramValues - oldParamValues);
1517 params[i].subValues += (paramValues - oldParamValues);
1518 params[i].intValues += (intValues - oldintValues);
1521 /* fill new chains paramiters with appropriate values */
1523 FillNormalParams (&globalSeed, from*nChains, to*nChains);
1525 /* now fill in the tree parameters */
1526 for (i=0; i<numParams; i++)
1529 if (p->paramType == P_TOPOLOGY)
1531 p->tree += (mcmcTree - oldMcmcTree); /* calculate new address */
1532 for (j=0; j<p->nSubParams; j++)
1534 q = p->subParams[j];
1535 assert (q->paramType==P_BRLENS);
1536 q->tree += (mcmcTree - oldMcmcTree); /* calculate new address */
1537 InitializeChainTrees (q, from*nChains, to*nChains, GetTree (q, 0, 0)->isRooted);
1540 else if (p->paramType == P_CPPEVENTS || p->paramType == P_TK02BRANCHRATES || p->paramType == P_IGRBRANCHRATES || p->paramType == P_MIXEDBRCHRATES)
1541 p->tree += (mcmcTree - oldMcmcTree);
1544 FillTreeParams (&globalSeed, from*nChains, to*nChains);
1546 /* fix stationary frequencies for standard data */
1547 if (stdStateFreqsRowSize > 0)
1549 assert (memAllocs[ALLOC_STDSTATEFREQS] == YES);
1550 stdStateFreqsOld=stdStateFreqs;
1551 stdStateFreqs = (MrBFlt *) SafeRealloc ((void *) stdStateFreqs, stdStateFreqsRowSize * 2 * numGlobalChains * sizeof (MrBFlt));
1554 MrBayesPrint ("%s Problem reallocating stdStateFreqs\n", spacer);
1559 for (k=n=0; k<numParams; k++)
1562 if (p->paramType != P_PI || modelParams[p->relParts[0]].dataType != STANDARD)
1564 p->stdStateFreqs += stdStateFreqs-stdStateFreqsOld;
1567 FillStdStateFreqs (from*nChains, to*nChains, &globalSeed);
1571 for (i=0; i<numApplicableMoves; i++)
1573 mvt = moves[i]->moveType;
1574 moves[i]->tuningParam = (MrBFlt **) SafeRealloc ((void *) moves[i]->tuningParam, (size_t)numGlobalChains * sizeof (MrBFlt *));
1575 moves[i]->tuningParam[0] = (MrBFlt *) SafeRealloc ((void *) moves[i]->tuningParam[0], (size_t)numGlobalChains * (size_t)(mvt->numTuningParams) * sizeof (MrBFlt));
1576 for (j=1; j<numGlobalChains; j++)
1577 moves[i]->tuningParam[j] = moves[i]->tuningParam[0] + j * mvt->numTuningParams;
1578 moves[i]->relProposalProb = (MrBFlt *) SafeRealloc ((void *) moves[i]->relProposalProb, 4 * (size_t)numGlobalChains * sizeof (MrBFlt));
1579 moves[i]->cumProposalProb = moves[i]->relProposalProb + numGlobalChains;
1580 moves[i]->targetRate = moves[i]->relProposalProb + 2*numGlobalChains;
1581 moves[i]->lastAcceptanceRate = moves[i]->relProposalProb + 3*numGlobalChains;
1582 moves[i]->nAccepted = (int *) SafeRealloc ((void *) moves[i]->nAccepted, 5* (size_t)numGlobalChains * sizeof (int));
1583 moves[i]->nTried = moves[i]->nAccepted + numGlobalChains;
1584 moves[i]->nBatches = moves[i]->nAccepted + 2*numGlobalChains;
1585 moves[i]->nTotAccepted = moves[i]->nAccepted + 3*numGlobalChains;
1586 moves[i]->nTotTried = moves[i]->nAccepted + 4*numGlobalChains;
1587 /* initialize all values to default */
1588 for (j=0; j<numGlobalChains; j++)
1590 moves[i]->nAccepted[j] = 0;
1591 moves[i]->nTried[j] = 0;
1592 moves[i]->nBatches[j] = 0;
1593 moves[i]->nTotAccepted[j] = 0;
1594 moves[i]->nTotTried[j] = 0;
1595 moves[i]->relProposalProb[j] = mvt->relProposalProb;
1596 moves[i]->cumProposalProb[j] = 0.0;
1597 moves[i]->lastAcceptanceRate[j] = 0.0;
1598 for (k=0; k<mvt->numTuningParams; k++)
1599 moves[i]->tuningParam[j][k] = mvt->tuningParam[k];
1600 moves[i]->targetRate[j] = mvt->targetRate;
1605 for (i=0; i<numParams; i++)
1608 if (p->paramType == P_CPPEVENTS)
1610 printf ("Trees after changing number of runs\n");
1611 for (j=0; j<numGlobalChains; j++)
1613 printf ("Event tree for chain %d\n", j+1);
1614 for (k=0; k<2*numLocalTaxa; k++)
1616 printf ("%d -- %d:", k, p->nEvents[2*j][k]);
1617 assert (p->nEvents[2*j] >= 0);
1618 for (i1=0; i1<p->nEvents[2*j][k]; i1++)
1621 printf (" (%lf %lf,", p->position[2*j][k], p->rateMult[2*j][k]);
1622 else if (i1 == p->nEvents[2*j][k]-1)
1623 printf (" %lf %lf)", p->position[2*j][k], p->rateMult[2*j][k]);
1625 printf (" %lf %lf,", p->position[2*j][k], p->rateMult[2*j][k]);
1629 for (k=0; k<2*numLocalTaxa; k++)
1631 printf ("%d -- %d:", k, p->nEvents[2*j+1][k]);
1632 assert (p->nEvents[2*j+1] >= 0);
1633 for (i1=0; i1<p->nEvents[2*j+1][k]; i1++)
1636 printf (" (%lf %lf,", p->position[2*j+1][k], p->rateMult[2*j+1][k]);
1637 else if (i1 == p->nEvents[2*j][k]-1)
1638 printf (" %lf %lf)", p->position[2*j+1][k], p->rateMult[2*j+1][k]);
1640 printf (" %lf %lf,", p->position[2*j+1][k], p->rateMult[2*j+1][k]);
1653 /*-----------------------------------------------------------
1655 | CheckCharCodingType: check if character is parsimony-
1656 | informative, variable, or constant
1658 -----------------------------------------------------------*/
1659 void CheckCharCodingType (Matrix *m, CharInfo *ci)
1661 int i, j, k, x, n1[10], n2[10], largest, smallest, numPartAmbig,
1662 numConsidered, numInformative, lastInformative=0, uniqueBits,
1664 BitsLong combinations[2048], *tempComb, *newComb, *oldComb, bitsLongOne=1;
1666 /* set up comb pointers */
1667 oldComb = combinations;
1668 newComb = oldComb + 1024;
1670 /* set counters to 0 */
1671 numPartAmbig = numConsidered = 0;
1673 /* set variable and informative to yes */
1674 ci->variable = ci->informative = YES;
1676 /* set constant to no and state counters to 0 for all states */
1677 for (i=0; i<10; i++)
1679 ci->constant[i] = ci->singleton[i] = NO;
1683 for (i=0; i<m->nRows; i++)
1685 /* retrieve character */
1686 x = (int) m->origin[m->column + i*m->rowSize];
1688 /* add it to counters if not all ambiguous */
1689 if (NBits(x) < ci->nStates)
1694 for (j=0; j<10; j++)
1696 if (((bitsLongOne<<j) & x) != 0)
1706 /* if the ambig counter for any state is equal to the number of considered
1707 states, then set constant for that state and set variable and informative to no */
1708 for (i=0; i<10; i++)
1710 if (n1[i] == numConsidered)
1712 ci->constant[i] = YES;
1713 ci->variable = ci->informative = NO;
1715 else if (n1[i] == 1)
1717 ci->singleton[i] = YES;
1721 /* return if variable is no */
1722 if (ci->variable == NO)
1725 /* the character is either (variable and uninformative) or informative */
1727 /* first consider unambiguous characters */
1728 /* find smallest and largest unambiguous state for this character */
1731 for (i=0; i<10; i++)
1742 /* count the number of informative states in the unambiguous codings */
1743 for (i=numInformative=0; i<10; i++)
1745 if (ci->cType == ORD && n2[i] > 0 && i != smallest && i != largest)
1748 lastInformative = i;
1753 lastInformative = i;
1757 /* set informative */
1758 if (numInformative > 1)
1759 ci->informative = YES;
1761 ci->informative = NO;
1764 /* we can return now unless informative is no and numPartAmbig is not 0 */
1765 if (!(numPartAmbig > 0 && ci->informative == NO))
1768 /* check if partially ambiguous observations make this character informative
1771 /* first set the bits for the taken states */
1773 for (i=0; i<10; i++)
1775 if (n2[i] > 0 && i != lastInformative)
1776 x |= (bitsLongOne<<i);
1781 /* now go through all partambig chars and see if we can add them without
1782 making the character informative */
1783 for (i=0; i<m->nRows; i++)
1785 x = (int) m->origin[m->column + i*m->rowSize];
1787 if (NBits(x) > 1 && NBits(x) < ci->nStates)
1789 /* remove lastInformative */
1790 x &= !(bitsLongOne<<lastInformative);
1793 /* see if we can add it, store all possible combinations */
1794 for (j=0; j<oldPoss; j++)
1796 uniqueBits = x & (!oldComb[j]);
1797 for (k=0; k<10; k++)
1799 if (((bitsLongOne<<k) & uniqueBits) != 0)
1800 newComb[newPoss++] = oldComb[j] | (bitsLongOne<<k);
1803 /* break out if we could not add it */
1807 /* prepare for next partAmbig */
1816 ci->informative = YES;
1822 /*-----------------------------------------------------------
1824 | CheckModel: check model and warn user if strange things
1827 -------------------------------------------------------------*/
1828 int CheckModel (void)
1830 int i, j, k, answer;
1834 /* there should only be one calibrated tree */
1835 for (i=0; i<numTrees; i++)
1837 t = GetTreeFromIndex(i,0,0);
1838 if (t->isCalibrated == YES)
1844 if (!strcmp(modelParams[t->relParts[0]].clockRatePr, "Fixed") && AreDoublesEqual(modelParams[t->relParts[0]].clockRateFix, 1.0, 1E-6) == YES)
1846 MrBayesPrint("%s WARNING: You have calibrated the tree but the clock rate is fixed to 1.0.\n", spacer);
1847 MrBayesPrint("%s This means that time is measured in expected changes per time unit. If\n", spacer);
1848 MrBayesPrint("%s the calibrations use a different time scale, you need to modify the model\n", spacer);
1849 MrBayesPrint("%s by introducing a prior for the clock rate ('prset clockratepr').\n", spacer);
1853 answer = WantTo("Do you want to continue with the run regardless");
1856 MrBayesPrint("%s Continuing with the run...\n\n", spacer);
1860 MrBayesPrint("%s Stopping the run...\n\n", spacer);
1867 /* check coalescence model */
1868 for (i=0; i<numTrees; i++)
1870 t = GetTreeFromIndex(i, 0, 0);
1871 if ((!strcmp(modelParams[t->relParts[0]].clockPr,"Coalescence") || !strcmp(modelParams[t->relParts[0]].clockPr,"Speciestreecoalescence"))
1872 && !strcmp(modelParams[t->relParts[0]].clockRatePr, "Fixed") && AreDoublesEqual(modelParams[t->relParts[0]].clockRateFix, 1.0, 1E-6) == YES)
1874 MrBayesPrint("%s WARNING: You are using a coalescent model but the clock rate is fixed to 1.0.\n", spacer);
1875 MrBayesPrint("%s This is likely to be incorrect unless you have set the population size prior\n", spacer);
1876 MrBayesPrint("%s ('prset popsizepr') to reflect an appropriate prior on theta. \n", spacer);
1880 answer = WantTo("Do you want to continue with the run regardless");
1883 MrBayesPrint("%s Continuing with the run...\n\n", spacer);
1887 MrBayesPrint("%s Stopping the run...\n\n", spacer);
1894 /* Check consistency of best model. First we guarantee that if one topology has
1895 a species tree prior, then all topologies have the same prior. Then we make
1896 sure that all clock trees have a coalescence prior. */
1899 for (i=0; i<numCurrentDivisions; i++)
1901 if (!strcmp(modelParams[i].topologyPr, "Speciestree"))
1907 if (j != numCurrentDivisions)
1909 MrBayesPrint("%s ERROR: If one gene tree has a speciestree prior then all\n", spacer);
1910 MrBayesPrint("%s gene trees must have the same prior.\n", spacer);
1913 for (i=0; i<numTrees-1; i++)
1915 t = GetTreeFromIndex(i,0,0);
1916 if (strcmp(modelParams[t->relParts[0]].clockPr,"Speciestreecoalescence") != 0)
1918 MrBayesPrint("%s ERROR: All gene trees must have a speciestreecoalescence prior\n", spacer);
1919 MrBayesPrint("%s if they fold into a species tree.\n", spacer);
1922 if (t->isCalibrated == YES)
1924 for (k=0; k<t->nNodes-1; k++)
1926 p = t->allDownPass[k];
1927 if (p->calibration != NULL)
1929 MrBayesPrint("%s ERROR: Gene trees cannot be individually calibrated\n", spacer);
1930 MrBayesPrint("%s if they fold into a species tree.\n", spacer);
1942 /*-----------------------------------------------------------
1944 | CheckExpandedModels: check data partitions that have
1945 | the codon or doublet model specified
1947 -------------------------------------------------------------*/
1948 int CheckExpandedModels (void)
1950 int c, d, i, t, s, s1, s2, s3, whichNuc, uniqueId, numCharsInPart,
1951 firstChar, lastChar, contiguousPart, badBreak, badExclusion,
1952 nGone, nuc1, nuc2, nuc3, foundStopCodon, posNucs1[4], posNucs2[4], posNucs3[4],
1953 oneGoodCodon, foundUnpaired, nPair, allCheckedOut;
1955 int tempStrSize=100;
1958 tempStr = (char *) SafeMalloc((size_t)tempStrSize * sizeof(char));
1961 MrBayesPrint ("%s Problem allocating tempString (%d)\n", spacer, tempStrSize * sizeof(char));
1965 /* first, set charId to 0 for all characters */
1966 for (i=0; i<numChar; i++)
1967 charInfo[i].charId = 0;
1969 /* loop over partitions */
1972 for (d=0; d<numCurrentDivisions; d++)
1974 mp = &modelParams[d];
1976 if (mp->dataType == DNA || mp->dataType == RNA)
1978 if (!strcmp(mp->nucModel,"Codon") || !strcmp(mp->nucModel,"Protein"))
1980 /* start check that the codon model is appropriate for this partition */
1982 /* find first character in this partition */
1983 for (c=0; c<numChar; c++)
1985 if (partitionId[c][partitionNum] == d+1)
1989 /*printf (" first character = %d\n", firstChar);*/
1991 /* find last character in this partition */
1992 for (c=numChar-1; c>=0; c--)
1994 if (partitionId[c][partitionNum] == d+1)
1998 /*printf (" last character = %d\n", lastChar);*/
2000 /* check that the number of characters in partition is divisible by 3 */
2002 for (c=firstChar; c<=lastChar; c++)
2004 if (charInfo[c].isExcluded == YES || partitionId[c][partitionNum] != d+1)
2008 /*printf (" numCharsInPart = %d\n", numCharsInPart);*/
2009 if (numCharsInPart % 3 != 0)
2011 if (numCurrentDivisions == 1)
2013 MrBayesPrint ("%s The number of characters is not divisible by three.\n", spacer);
2014 MrBayesPrint ("%s You specified a %s model which requires triplets\n", spacer, mp->nucModel);
2015 MrBayesPrint ("%s However, you have %d characters.\n", spacer, numCharsInPart);
2019 MrBayesPrint ("%s The number of characters in partition %d is not\n", spacer, d+1);
2020 MrBayesPrint ("%s divisible by three. You specified a %s model\n", spacer, mp->nucModel);
2021 MrBayesPrint ("%s which requires triplets. \n", spacer);
2022 MrBayesPrint ("%s However, you have %d characters in this partition\n", spacer, numCharsInPart);
2028 /* check that all of the characters in the partition are contiguous */
2029 contiguousPart = YES;
2030 for (c=firstChar; c<=lastChar; c++)
2032 if (charInfo[c].isExcluded == NO && partitionId[c][partitionNum] != d+1)
2033 contiguousPart = NO;
2035 if (contiguousPart == NO)
2037 MrBayesPrint ("%s Partition %d is not contiguous. You specified that\n", spacer, d+1);
2038 MrBayesPrint ("%s a %s model be used for this partition. However, there\n", spacer, mp->nucModel);
2039 MrBayesPrint ("%s is another partition that is between some of the characters\n", spacer);
2040 MrBayesPrint ("%s in this partition. \n", spacer);
2045 /* check that there is not a break inside a triplet of characters */
2048 for (c=firstChar; c<=lastChar; c++)
2050 if (charInfo[c].isExcluded == NO)
2053 if (charInfo[c].bigBreakAfter == YES && whichNuc != 3)
2058 if (badBreak == YES)
2060 MrBayesPrint ("%s You specified a databreak inside of a coding triplet.\n", spacer);
2061 MrBayesPrint ("%s This is a problem, as you imply that part of the codon\n", spacer);
2062 MrBayesPrint ("%s lies in one gene and the remainder in another gene. \n", spacer);
2067 /* make certain excluded characters are in triplets but allow frameshift exclusions first in sequence */
2069 whichNuc = nGone = 0;
2070 for (c=firstChar; c<=lastChar; c++)
2071 if (charInfo[c].isExcluded == NO)
2073 for (; c<=lastChar; c++)
2076 if (charInfo[c].isExcluded == YES)
2080 if (nGone == 1 || nGone == 2)
2082 whichNuc = nGone = 0;
2085 if (badExclusion == YES)
2087 MrBayesPrint ("%s In excluding characters, you failed to remove all of the\n", spacer);
2088 MrBayesPrint ("%s sites of at least one codon. If you exclude sites, make \n", spacer);
2089 MrBayesPrint ("%s certain to exclude all of the sites in the codon(s). \n", spacer);
2094 /* check that there are no stop codons */
2095 foundStopCodon = NO;
2096 /* allow frameshifting exclusions in the beginning */
2097 for (c=firstChar; c<=lastChar; c++)
2098 if (charInfo[c].isExcluded == NO)
2100 for (; c<=lastChar; c+=3)
2102 if (charInfo[c].isExcluded == NO)
2104 for (t=0; t<numTaxa; t++)
2106 if (taxaInfo[t].isDeleted == YES)
2108 nuc1 = matrix[pos(t,c+0,numChar)];
2109 nuc2 = matrix[pos(t,c+1,numChar)];
2110 nuc3 = matrix[pos(t,c+2,numChar)];
2111 /*nucX is in range 0-15 to represent any possible set of states that nucleatide could be in*/
2112 GetPossibleNucs (nuc1, posNucs1);
2113 GetPossibleNucs (nuc2, posNucs2);
2114 GetPossibleNucs (nuc3, posNucs3);
2118 for (s1=0; s1<4; s1++)
2120 for (s2=0; s2<4; s2++)
2122 for (s3=0; s3<4; s3++)
2124 if (posNucs1[s1] == 1 && posNucs2[s2] == 1 && posNucs3[s3] == 1)
2126 if (mp->codon[s1*16 + s2*4 + s3] != 21)
2133 if (oneGoodCodon == NO)
2135 foundStopCodon = YES;
2136 MrBayesPrint ("%s Stop codon: taxon %s, sites %d to %d (%c%c%c, %s code)\n", spacer,
2137 taxaNames[t], c+1, c+3, WhichNuc (nuc1), WhichNuc (nuc2), WhichNuc (nuc3), mp->geneticCode);
2142 if (foundStopCodon == YES)
2144 MrBayesPrint ("%s At least one stop codon was found. Stop codons are not\n", spacer);
2145 MrBayesPrint ("%s allowed under the codon models. \n", spacer);
2150 /* everything checks out. Now we can initialize charId */
2152 for (c=firstChar; c<=lastChar; c++)
2155 charInfo[c].charId = uniqueId;
2164 /* end check that the codon model is appropriate for this partition */
2166 else if (!strcmp(mp->nucModel,"Doublet"))
2168 /* start check that the doublet model is appropriate for this partition */
2170 /* Check that pairsId does not equal 0 for any of the characters in
2171 the partition. If it does, then this means that at least one
2172 site was not appropriately paired. Remember, that pairsId is
2173 initialized 1, 2, 3, ... for the first pair, second pair, etc.
2174 Also, check that every pair is only represented two times. */
2176 for (c=0; c<numChar; c++)
2178 if (partitionId[c][partitionNum] == d+1 && charInfo[c].pairsId == 0 && charInfo[c].isExcluded == NO)
2179 foundUnpaired = YES;
2182 for (c=0; c<numChar; c++)
2184 if (partitionId[c][partitionNum] == d+1 && charInfo[c].isExcluded == NO)
2187 for (i=0; i<numChar; i++)
2189 if (i != c && partitionId[i][partitionNum] == d+1 && charInfo[i].isExcluded == NO && charInfo[c].pairsId == charInfo[i].pairsId)
2193 foundUnpaired = YES;
2196 if (foundUnpaired == YES)
2198 if (numCurrentDivisions == 1)
2200 MrBayesPrint ("%s Found unpaired nucleotide sites. The doublet model\n", spacer);
2201 MrBayesPrint ("%s requires that all sites are paired. \n", spacer);
2205 MrBayesPrint ("%s Found unpaired nucleotide sites in partition %d.\n", spacer, d+1);
2206 MrBayesPrint ("%s The doublet model requires that all sites are paired. \n", spacer);
2212 /* everything checks out. Now we can initialize charId */
2213 for (c=0; c<numChar; c++)
2216 if (partitionId[c][partitionNum] == d+1 && charInfo[c].charId == 0)
2219 for (i=0; i<numChar; i++)
2221 if (i != c && charInfo[i].charId == 0 && charInfo[c].pairsId == charInfo[i].pairsId)
2224 if (nuc1 >= 0 && nuc2 >= 0)
2226 charInfo[nuc1].charId = charInfo[nuc2].charId = uniqueId;
2231 MrBayesPrint ("%s Weird doublet problem in partition %d.\n", spacer, d+1);
2239 /* end check that the doublet model is appropriate for this partition */
2245 if (allCheckedOut > 0)
2246 MrBayesPrint ("%s Codon/Doublet models successfully checked\n", spacer);
2250 for (c=0; c<numChar; c++)
2251 printf (" %d", charId[c]);
2259 void CodingToString(int coding, char* string)
2262 strcpy(string, "All");
2263 else if(coding == INFORMATIVE)
2264 strcpy(string, "Informative");
2265 else if((coding & VARIABLE) == VARIABLE)
2267 if (coding == VARIABLE)
2269 strcpy(string, "Variable");
2271 else if (coding & NOSINGLETONABSENCE)
2273 strcpy(string, "Variable|Nosingletonabsence");
2275 else if (coding & NOSINGLETONPRESENCE)
2277 strcpy(string, "Variable|Nosingletonpresence");
2280 else if((coding & NOSINGLETONS) == NOSINGLETONS)
2282 if (coding == NOSINGLETONS)
2284 strcpy(string, "Nosingletons");
2286 else if (coding & NOABSENCESITES)
2288 strcpy(string, "Noabsencesites|Nosingletons");
2290 else if (coding & NOPRESENCESITES)
2292 strcpy(string, "Nopresencesites|Nosingletons");
2295 else if(coding == NOABSENCESITES)
2297 strcpy(string, "Noabsencesites");
2299 else if(coding == NOPRESENCESITES)
2301 strcpy(string, "Nopresencesites");
2303 else if(coding == NOSINGLETONABSENCE)
2305 strcpy(string, "Nosingletonabsence");
2307 else if(coding == NOSINGLETONPRESENCE)
2309 strcpy(string, "Nosingletonpresence");
2311 else if(coding == (NOABSENCESITES | NOSINGLETONABSENCE))
2313 strcpy(string, "Noabsencesites|Nosingletonabsence");
2315 else if(coding == (NOABSENCESITES | NOSINGLETONPRESENCE))
2317 strcpy(string, "Noabsencesites|Nosingletonpresence");
2319 else if(coding == (NOPRESENCESITES | NOSINGLETONABSENCE))
2321 strcpy(string, "Nopresencesites|Nosingletonabsence");
2323 else if(coding == (NOPRESENCESITES | NOSINGLETONPRESENCE))
2325 strcpy(string, "Nopresencesites|Nosingletonpresence");
2330 /*-----------------------------------------------------------
2332 | CompressData: compress original data matrix
2334 -------------------------------------------------------------*/
2335 int CompressData (void)
2337 int a, c, d, i, j, k, t, col[3], isSame, newRow, newColumn,
2338 *isTaken, *tempSitesOfPat, *tempChar;
2339 BitsLong *tempMatrix;
2343 # if defined DEBUG_COMPRESSDATA
2344 if (PrintMatrix() == ERROR)
2349 /* set all pointers that will be allocated locally to NULL */
2352 tempSitesOfPat = NULL;
2355 /* allocate indices pointing from original to compressed matrix */
2356 if (memAllocs[ALLOC_COMPCOLPOS] == YES)
2360 memAllocs[ALLOC_COMPCOLPOS] = NO;
2362 compColPos = (int *)SafeMalloc((size_t)numChar * sizeof(int));
2365 MrBayesPrint ("%s Problem allocating compColPos (%d)\n", spacer, numChar * sizeof(int));
2368 for (i=0; i<numChar; i++)
2370 memAllocs[ALLOC_COMPCOLPOS] = YES;
2372 if (memAllocs[ALLOC_COMPCHARPOS] == YES)
2376 memAllocs[ALLOC_COMPCHARPOS] = NO;
2378 compCharPos = (int *)SafeMalloc((size_t)numChar * sizeof(int));
2381 MrBayesPrint ("%s Problem allocating compCharPos (%d)\n", spacer, numChar * sizeof(int));
2384 for (i=0; i<numChar; i++)
2386 memAllocs[ALLOC_COMPCHARPOS] = YES;
2388 /* allocate space for temporary matrix, tempSitesOfPat, */
2389 /* vector keeping track of whether a character has been compressed, */
2390 /* and vector indexing first original char for each compressed char */
2391 tempMatrix = (BitsLong *) SafeCalloc (numLocalTaxa * numLocalChar, sizeof(BitsLong));
2392 tempSitesOfPat = (int *) SafeCalloc (numLocalChar, sizeof(int));
2393 isTaken = (int *) SafeCalloc (numChar, sizeof(int));
2394 tempChar = (int *) SafeCalloc (numLocalChar, sizeof(int));
2395 if (!tempMatrix || !tempSitesOfPat || !isTaken || !tempChar)
2397 MrBayesPrint ("%s Problem allocating temporary variables in CompressData\n", spacer);
2401 /* initialize isTaken */
2402 for (c=0; c<numChar; c++)
2405 /* set index to first empty column in temporary matrix */
2408 /* initialize number of compressed characters */
2409 numCompressedChars = 0;
2411 /* sort and compress data */
2412 for (d=0; d<numCurrentDivisions; d++)
2414 /* set pointers to the model params and settings for this division */
2415 m = &modelSettings[d];
2416 mp = &modelParams[d];
2418 /* set column offset for this division in compressed matrix */
2419 m->compMatrixStart = newColumn;
2421 /* set compressed character offset for this division */
2422 m->compCharStart = numCompressedChars;
2424 /* set number of compressed characters to 0 for this division */
2427 /* find the number of original characters per model site */
2428 m->nCharsPerSite = 1;
2429 if (mp->dataType == DNA || mp->dataType == RNA)
2431 if (!strcmp(mp->nucModel, "Doublet"))
2432 m->nCharsPerSite = 2;
2433 if (!strcmp(mp->nucModel, "Codon") || !strcmp(mp->nucModel, "Protein"))
2434 m->nCharsPerSite = 3;
2437 /* sort and compress the characters for this division */
2438 for (c=0; c<numChar; c++)
2440 if (charInfo[c].isExcluded == YES || partitionId[c][partitionNum] != d+1 || isTaken[c] == YES)
2446 /* find additional columns if more than one character per model site */
2447 /* return error if the number of matching characters is smaller or larger */
2448 /* than the actual number of characters per model site */
2449 if (m->nCharsPerSite > 1)
2452 if (charInfo[c].charId == 0)
2454 MrBayesPrint("%s Character %d is not properly defined\n", spacer, c+1);
2457 for (i=c+1; i<numChar; i++)
2459 if (charInfo[i].charId == charInfo[c].charId)
2461 if (j >= m->nCharsPerSite)
2463 MrBayesPrint("%s Too many matches in charId (division %d char %d)\n", spacer, d, numCompressedChars);
2473 if (j != m->nCharsPerSite)
2475 MrBayesPrint ("%s Too few matches in charId (division %d char %d)\n", spacer, d, numCompressedChars);
2480 /* add character to temporary matrix in column(s) at newColumn */
2481 for (t=newRow=0; t<numTaxa; t++)
2483 if (taxaInfo[t].isDeleted == YES)
2486 for (k=0; k<m->nCharsPerSite; k++)
2488 tempMatrix[pos(newRow,newColumn+k,numLocalChar)] = matrix[pos(t,col[k],numChar)];
2495 if (mp->dataType != CONTINUOUS)
2497 for (i=m->compMatrixStart; i<newColumn; i+=m->nCharsPerSite)
2500 for (j=0; j<numLocalTaxa; j++)
2502 for (k=0; k<m->nCharsPerSite; k++)
2503 if (tempMatrix[pos(j,newColumn+k,numLocalChar)] != tempMatrix[pos(j,i+k,numLocalChar)])
2516 /* if subject to data augmentation, it is always unique */
2517 if (!strcmp(mp->augmentData, "Yes"))
2519 for (k=0; k<m->nCharsPerSite; k++)
2521 if (charInfo[col[k]].isMissAmbig == YES)
2528 /* if it is unique then it should be added */
2529 tempSitesOfPat[numCompressedChars] = 1;
2530 for (k=0; k<m->nCharsPerSite; k++)
2532 compColPos[col[k]] = newColumn + k;
2533 compCharPos[col[k]] = numCompressedChars;
2534 tempChar[newColumn + k] = col[k];
2536 newColumn+=m->nCharsPerSite;
2538 numCompressedChars++;
2542 /* if it is not unique then simply update tempSitesOfPat */
2543 /* calculate compressed character position and put it into a */
2544 /* (i points to compressed column position) */
2545 a = m->compCharStart + ((i - m->compMatrixStart) / m->nCharsPerSite);
2546 tempSitesOfPat[a]++;
2547 for (k=0; k<m->nCharsPerSite; k++)
2549 compColPos[col[k]] = i;
2550 compCharPos[col[k]] = a;
2551 /* tempChar (pointing from compressed to uncompresed) */
2552 /* can only be set for first pattern */
2555 } /* next character */
2557 /* check that the partition has at least a single character */
2558 if (m->numChars <= 0)
2560 MrBayesPrint ("%s You must have at least one site in a partition. Partition %d\n", spacer, d+1);
2561 MrBayesPrint ("%s has %d site patterns.\n", spacer, m->numChars);
2565 m->compCharStop = m->compCharStart + m->numChars;
2566 m->compMatrixStop = newColumn;
2568 } /* next division */
2570 compMatrixRowSize = newColumn;
2572 /* now we know the size, so we can allocate space for the compressed matrix ... */
2573 if (memAllocs[ALLOC_COMPMATRIX] == YES)
2577 memAllocs[ALLOC_COMPMATRIX] = NO;
2579 compMatrix = (BitsLong *) SafeCalloc (compMatrixRowSize * numLocalTaxa, sizeof(BitsLong));
2582 MrBayesPrint ("%s Problem allocating compMatrix (%d)\n", spacer, compMatrixRowSize * numLocalTaxa * sizeof(BitsLong));
2585 memAllocs[ALLOC_COMPMATRIX] = YES;
2587 if (memAllocs[ALLOC_NUMSITESOFPAT] == YES)
2589 free (numSitesOfPat);
2590 numSitesOfPat = NULL;
2591 memAllocs[ALLOC_NUMSITESOFPAT] = NO;
2593 numSitesOfPat = (CLFlt *) SafeCalloc (numCompressedChars, sizeof(CLFlt));
2596 MrBayesPrint ("%s Problem allocating numSitesOfPat (%d)\n", spacer, numCompressedChars * sizeof(MrBFlt));
2599 memAllocs[ALLOC_NUMSITESOFPAT] = YES;
2601 if (memAllocs[ALLOC_ORIGCHAR] == YES)
2605 memAllocs[ALLOC_ORIGCHAR] = NO;
2607 origChar = (int *)SafeMalloc((size_t)compMatrixRowSize * sizeof(int));
2610 MrBayesPrint ("%s Problem allocating origChar (%d)\n", spacer, numCompressedChars * sizeof(int));
2613 memAllocs[ALLOC_ORIGCHAR] = YES;
2615 /* ... and copy the data there */
2616 for (i=0; i<numLocalTaxa; i++)
2617 for (j=0; j<compMatrixRowSize; j++)
2618 compMatrix[pos(i,j,compMatrixRowSize)] = tempMatrix[pos(i,j,numLocalChar)];
2620 for (i=0; i<numCompressedChars; i++)
2621 numSitesOfPat[i] = (CLFlt) tempSitesOfPat[i];
2623 for (i=0; i<compMatrixRowSize; i++)
2624 origChar[i] = tempChar[i];
2626 # if defined (DEBUG_COMPRESSDATA)
2627 if (PrintCompMatrix() == ERROR)
2632 /* free the temporary variables */
2633 free (tempSitesOfPat);
2644 free (tempSitesOfPat);
2654 int DataType (int part)
2658 for (i=0; i<numChar; i++)
2660 if (partitionId[i][partitionNum] == part + 1)
2664 return (charInfo[i].charType);
2672 MrBayesPrint ("%s Linking\n", spacer);
2674 /* update status of linkTable */
2675 for (j=0; j<NUM_LINKED; j++)
2678 for (i=0; i<numCurrentDivisions; i++)
2680 if (tempLinkUnlink[j][i] == YES)
2687 linkTable[j][i] = linkNum;
2693 for (j=0; j<NUM_LINKED; j++)
2695 MrBayesPrint ("%s ", spacer);
2696 for (i=0; i<numCurrentDivisions; i++)
2697 MrBayesPrint ("%d", linkTable[j][i]);
2698 MrBayesPrint ("\n");
2702 /* reinitialize the temporary table */
2703 for (j=0; j<NUM_LINKED; j++)
2704 for (i=0; i<numCurrentDivisions; i++)
2705 tempLinkUnlink[j][i] = NO;
2707 /* set up parameters and moves */
2708 if (SetUpAnalysis (&globalSeed) == ERROR)
2715 int DoLinkParm (char *parmName, char *tkn)
2719 if (defMatrix == NO)
2721 MrBayesPrint ("%s A matrix must be specified before the model can be defined\n", spacer);
2725 if (inValidCommand == YES)
2727 for (j=0; j<NUM_LINKED; j++)
2728 for (i=0; i<numCurrentDivisions; i++)
2729 tempLinkUnlink[j][i] = NO;
2730 inValidCommand = NO;
2733 if (expecting == Expecting(PARAMETER))
2735 expecting = Expecting(EQUALSIGN);
2737 else if (expecting == Expecting(EQUALSIGN))
2739 expecting = Expecting(LEFTPAR);
2741 else if (expecting == Expecting(LEFTPAR))
2743 /* initialize tempLinkUnlinkVec to no */
2744 for (i=0; i<numCurrentDivisions; i++)
2745 tempLinkUnlinkVec[i] = NO;
2748 expecting = Expecting(NUMBER) | Expecting(ALPHA);
2750 else if (expecting == Expecting(RIGHTPAR))
2753 tempLinkUnlinkVec[fromI-1] = YES;
2754 /* now copy tempLinkUnlinkVec to appropriate row of tempLinkUnlink */
2755 if (!strcmp(parmName, "Tratio"))
2757 for (i=0; i<numCurrentDivisions; i++)
2758 tempLinkUnlink[P_TRATIO][i] = tempLinkUnlinkVec[i];
2760 else if (!strcmp(parmName, "Revmat"))
2762 for (i=0; i<numCurrentDivisions; i++)
2763 tempLinkUnlink[P_REVMAT][i] = tempLinkUnlinkVec[i];
2765 else if (!strcmp(parmName, "Omega"))
2767 for (i=0; i<numCurrentDivisions; i++)
2768 tempLinkUnlink[P_OMEGA][i] = tempLinkUnlinkVec[i];
2770 else if (!strcmp(parmName, "Statefreq"))
2772 for (i=0; i<numCurrentDivisions; i++)
2773 tempLinkUnlink[P_PI][i] = tempLinkUnlinkVec[i];
2775 else if (!strcmp(parmName, "Shape"))
2777 for (i=0; i<numCurrentDivisions; i++)
2778 tempLinkUnlink[P_SHAPE][i] = tempLinkUnlinkVec[i];
2780 else if (!strcmp(parmName, "Pinvar"))
2782 for (i=0; i<numCurrentDivisions; i++)
2783 tempLinkUnlink[P_PINVAR][i] = tempLinkUnlinkVec[i];
2785 else if (!strcmp(parmName, "Correlation"))
2787 for (i=0; i<numCurrentDivisions; i++)
2788 tempLinkUnlink[P_CORREL][i] = tempLinkUnlinkVec[i];
2790 else if (!strcmp(parmName, "Ratemultiplier"))
2792 for (i=0; i<numCurrentDivisions; i++)
2793 tempLinkUnlink[P_RATEMULT][i] = tempLinkUnlinkVec[i];
2795 else if (!strcmp(parmName, "Switchrates"))
2797 for (i=0; i<numCurrentDivisions; i++)
2798 tempLinkUnlink[P_SWITCH][i] = tempLinkUnlinkVec[i];
2800 else if (!strcmp(parmName, "Topology"))
2802 for (i=0; i<numCurrentDivisions; i++)
2803 tempLinkUnlink[P_TOPOLOGY][i] = tempLinkUnlinkVec[i];
2805 else if (!strcmp(parmName, "Brlens"))
2807 for (i=0; i<numCurrentDivisions; i++)
2808 tempLinkUnlink[P_BRLENS][i] = tempLinkUnlinkVec[i];
2810 else if (!strcmp(parmName, "Speciationrate"))
2812 for (i=0; i<numCurrentDivisions; i++)
2813 tempLinkUnlink[P_SPECRATE][i] = tempLinkUnlinkVec[i];
2815 else if (!strcmp(parmName, "Extinctionrate"))
2817 for (i=0; i<numCurrentDivisions; i++)
2818 tempLinkUnlink[P_EXTRATE][i] = tempLinkUnlinkVec[i];
2820 else if (!strcmp(parmName, "Fossilizationrate"))
2822 for (i=0; i<numCurrentDivisions; i++)
2823 tempLinkUnlink[P_FOSLRATE][i] = tempLinkUnlinkVec[i];
2825 else if (!strcmp(parmName, "Popsize"))
2827 for (i=0; i<numCurrentDivisions; i++)
2828 tempLinkUnlink[P_POPSIZE][i] = tempLinkUnlinkVec[i];
2830 else if (!strcmp(parmName, "Growthrate"))
2832 for (i=0; i<numCurrentDivisions; i++)
2833 tempLinkUnlink[P_GROWTH][i] = tempLinkUnlinkVec[i];
2835 else if (!strcmp(parmName, "Aamodel"))
2837 for (i=0; i<numCurrentDivisions; i++)
2838 tempLinkUnlink[P_AAMODEL][i] = tempLinkUnlinkVec[i];
2840 else if (!strcmp(parmName, "Cpprate"))
2842 for (i=0; i<numCurrentDivisions; i++)
2843 tempLinkUnlink[P_CPPRATE][i] = tempLinkUnlinkVec[i];
2845 else if (!strcmp(parmName, "Cppmultdev"))
2847 for (i=0; i<numCurrentDivisions; i++)
2848 tempLinkUnlink[P_CPPMULTDEV][i] = tempLinkUnlinkVec[i];
2850 else if (!strcmp(parmName, "Cppevents"))
2852 for (i=0; i<numCurrentDivisions; i++)
2853 tempLinkUnlink[P_CPPEVENTS][i] = tempLinkUnlinkVec[i];
2855 else if (!strcmp(parmName, "TK02var") || !strcmp(parmName, "Bmvar"))
2857 for (i=0; i<numCurrentDivisions; i++)
2858 tempLinkUnlink[P_TK02VAR][i] = tempLinkUnlinkVec[i];
2860 else if (!strcmp(parmName, "TK02branchrates") || !strcmp(parmName, "Bmbranchrates"))
2862 for (i=0; i<numCurrentDivisions; i++)
2863 tempLinkUnlink[P_TK02BRANCHRATES][i] = tempLinkUnlinkVec[i];
2865 else if (!strcmp(parmName, "Igrvar") || !strcmp(parmName, "Ibrvar"))
2867 for (i=0; i<numCurrentDivisions; i++)
2868 tempLinkUnlink[P_IGRVAR][i] = tempLinkUnlinkVec[i];
2870 else if (!strcmp(parmName, "Igrbranchrates") || !strcmp(parmName, "Ibrbranchlens"))
2872 for (i=0; i<numCurrentDivisions; i++)
2873 tempLinkUnlink[P_IGRBRANCHRATES][i] = tempLinkUnlinkVec[i];
2875 else if (!strcmp(parmName, "Mixedvar"))
2877 for (i=0; i<numCurrentDivisions; i++)
2878 tempLinkUnlink[P_MIXEDVAR][i] = tempLinkUnlinkVec[i];
2880 else if (!strcmp(parmName, "Mixedbrchrates"))
2882 for (i=0; i<numCurrentDivisions; i++)
2883 tempLinkUnlink[P_MIXEDBRCHRATES][i] = tempLinkUnlinkVec[i];
2887 MrBayesPrint ("%s Couldn't find parameter %s to link\n", spacer, parmName);
2890 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
2892 else if (expecting == Expecting(COMMA))
2895 expecting = Expecting(NUMBER);
2897 else if (expecting == Expecting(ALPHA))
2899 if (IsSame ("All", tkn) == DIFFERENT)
2901 MrBayesPrint ("%s Do not understand delimiter \"%s\"\n", spacer, tkn);
2904 for (i=0; i<numCurrentDivisions; i++)
2905 tempLinkUnlinkVec[i] = YES;
2906 expecting = Expecting(RIGHTPAR);
2908 else if (expecting == Expecting(NUMBER))
2910 sscanf (tkn, "%d", &tempInt);
2911 if (tempInt > numCurrentDivisions)
2913 MrBayesPrint ("%s Partition delimiter is too large\n", spacer);
2918 else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO)
2921 for (i=fromI-1; i<toJ; i++)
2922 tempLinkUnlinkVec[i] = YES;
2926 else if (fromI != -1 && toJ == -1 && foundDash == NO && foundComma == YES)
2928 tempLinkUnlinkVec[fromI-1] = YES;
2932 expecting = Expecting(COMMA);
2933 expecting |= Expecting(DASH);
2934 expecting |= Expecting(RIGHTPAR);
2936 else if (expecting == Expecting(DASH))
2939 expecting = Expecting(NUMBER);
2950 int i, nApplied, lastActive=0;
2952 nApplied = NumActiveParts ();
2953 for (i=numCurrentDivisions-1; i>=0; i--)
2955 if (activeParts[i] == YES)
2962 /* MrBayesPrint ("\n"); */
2963 if (numCurrentDivisions == 1)
2964 MrBayesPrint ("%s Successfully set likelihood model parameters\n", spacer);
2967 if (nApplied == numCurrentDivisions || nApplied == 0)
2969 MrBayesPrint ("%s Successfully set likelihood model parameters to all\n", spacer);
2970 MrBayesPrint ("%s applicable data partitions \n", spacer);
2974 MrBayesPrint ("%s Successfully set likelihood model parameters to\n", spacer);
2976 MrBayesPrint ("%s partition", spacer);
2978 MrBayesPrint ("%s partitions", spacer);
2979 for (i=0; i<numCurrentDivisions; i++)
2981 if (activeParts[i] == YES)
2983 if (i == lastActive && nApplied > 1)
2984 MrBayesPrint (" and %d", i+1);
2986 MrBayesPrint (" %d", i+1);
2987 if (nApplied > 2 && i != lastActive)
2991 MrBayesPrint (" (if applicable)\n");
2995 if (SetUpAnalysis (&globalSeed) == ERROR)
3002 int DoLsetParm (char *parmName, char *tkn)
3004 int i, j, tempInt, nApplied;
3007 if (defMatrix == NO)
3009 MrBayesPrint ("%s A matrix must be specified before the model can be defined\n", spacer);
3012 if (inValidCommand == YES)
3014 for (i=0; i<numCurrentDivisions; i++)
3015 activeParts[i] = NO;
3016 inValidCommand = NO;
3019 if (expecting == Expecting(PARAMETER))
3021 expecting = Expecting(EQUALSIGN);
3025 /* set Applyto (Applyto) *************************************************************/
3026 if (!strcmp(parmName, "Applyto"))
3028 if (expecting == Expecting(EQUALSIGN))
3029 expecting = Expecting(LEFTPAR);
3030 else if (expecting == Expecting(LEFTPAR))
3032 for (i=0; i<numCurrentDivisions; i++)
3033 activeParts[i] = NO;
3036 expecting = Expecting(NUMBER) | Expecting(ALPHA);
3038 else if (expecting == Expecting(RIGHTPAR))
3041 activeParts[fromI-1] = YES;
3042 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3044 else if (expecting == Expecting(COMMA))
3047 expecting = Expecting(NUMBER);
3049 else if (expecting == Expecting(ALPHA))
3051 if (IsSame ("All", tkn) == DIFFERENT)
3053 MrBayesPrint ("%s Do not understand delimiter \"%s\"\n", spacer, tkn);
3056 for (i=0; i<numCurrentDivisions; i++)
3057 activeParts[i] = YES;
3058 expecting = Expecting(RIGHTPAR);
3060 else if (expecting == Expecting(NUMBER))
3062 sscanf (tkn, "%d", &tempInt);
3063 if (tempInt > numCurrentDivisions)
3065 MrBayesPrint ("%s Partition delimiter is too large\n", spacer);
3070 else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO)
3073 for (i=fromI-1; i<toJ; i++)
3074 activeParts[i] = YES;
3078 else if (fromI != -1 && toJ == -1 && foundDash == NO && foundComma == YES)
3080 activeParts[fromI-1] = YES;
3085 expecting = Expecting(COMMA);
3086 expecting |= Expecting(DASH);
3087 expecting |= Expecting(RIGHTPAR);
3089 else if (expecting == Expecting(DASH))
3092 expecting = Expecting(NUMBER);
3097 /* set Nucmodel (nucModel) ************************************************************/
3098 else if (!strcmp(parmName, "Nucmodel"))
3100 if (expecting == Expecting(EQUALSIGN))
3101 expecting = Expecting(ALPHA);
3102 else if (expecting == Expecting(ALPHA))
3104 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3106 nApplied = NumActiveParts ();
3108 for (i=0; i<numCurrentDivisions; i++)
3110 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
3112 strcpy(modelParams[i].nucModel, tempStr);
3113 modelParams[i].nStates = NumStates (i);
3115 /* set state frequencies back to default */
3116 strcpy(modelParams[i].stateFreqPr, "Dirichlet");
3117 strcpy(modelParams[i].stateFreqsFixType, "Equal");
3118 for (j=0; j<200; j++)
3120 modelParams[i].stateFreqsFix[j] = 0.0;
3121 modelParams[i].stateFreqsDir[j] = 1.0;
3124 if (nApplied == 0 && numCurrentDivisions == 1)
3125 MrBayesPrint ("%s Setting Nucmodel to %s\n", spacer, modelParams[i].nucModel);
3127 MrBayesPrint ("%s Setting Nucmodel to %s for partition %d\n", spacer, modelParams[i].nucModel, i+1);
3131 MrBayesPrint ("%s Set state frequency prior to default\n", spacer);
3135 MrBayesPrint ("%s Invalid DNA substitution model\n", spacer);
3138 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3143 /* set Nst (nst) **********************************************************************/
3144 else if (!strcmp(parmName, "Nst"))
3146 if (expecting == Expecting(EQUALSIGN))
3147 expecting = Expecting(NUMBER) | Expecting(ALPHA);
3148 else if (expecting == Expecting(NUMBER) || expecting == Expecting(ALPHA))
3150 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3152 nApplied = NumActiveParts ();
3153 for (i=0; i<numCurrentDivisions; i++)
3155 if (activeParts[i] == YES || nApplied == 0)
3157 if (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA)
3159 strcpy(modelParams[i].nst, tempStr);
3160 if (nApplied == 0 && numCurrentDivisions == 1)
3161 MrBayesPrint ("%s Setting Nst to %s\n", spacer, modelParams[i].nst);
3163 MrBayesPrint ("%s Setting Nst to %s for partition %d\n", spacer, modelParams[i].nst, i+1);
3166 if (nApplied == 0 && numCurrentDivisions == 1)
3167 MrBayesPrint ("%s Nst =%s unchanged ", spacer, modelParams[i].nst);
3169 MrBayesPrint ("%s Nst =%s unchanged for partition %d ", spacer, modelParams[i].nst, i+1);
3170 MrBayesPrint ("because dataType is not DNA or RNA\n");
3177 MrBayesPrint ("%s Invalid Nst argument\n", spacer);
3180 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3185 /* set Ncat (numGammaCats) ************************************************************/
3186 else if (!strcmp(parmName, "Ngammacat"))
3188 if (expecting == Expecting(EQUALSIGN))
3189 expecting = Expecting(NUMBER);
3190 else if (expecting == Expecting(NUMBER))
3192 sscanf (tkn, "%d", &tempInt);
3193 if (tempInt >= 2 && tempInt < MAX_GAMMA_CATS)
3195 nApplied = NumActiveParts ();
3196 for (i=0; i<numCurrentDivisions; i++)
3198 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType != CONTINUOUS))
3200 modelParams[i].numGammaCats = tempInt;
3201 if (nApplied == 0 && numCurrentDivisions == 1)
3202 MrBayesPrint ("%s Setting Ngammacat to %d\n", spacer, modelParams[i].numGammaCats);
3204 MrBayesPrint ("%s Setting Ngammacat to %d for partition %d\n", spacer, modelParams[i].numGammaCats, i+1);
3210 MrBayesPrint ("%s Invalid Ngammacat argument (should be between 2 and %d)\n", spacer, MAX_GAMMA_CATS);
3213 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3218 /* set Usegibbs (useGibbs) *************************************************************/
3219 else if (!strcmp(parmName, "Usegibbs"))
3221 if (expecting == Expecting(EQUALSIGN))
3222 expecting = Expecting(ALPHA);
3223 else if (expecting == Expecting(ALPHA))
3225 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3227 nApplied = NumActiveParts ();
3228 for (i=0; i<numCurrentDivisions; i++)
3230 if (activeParts[i] == YES || nApplied == 0)
3232 if (!strcmp(tempStr, "Yes"))
3234 MrBayesPrint ("%s Downsampling of site rates ('usegibbs = yes') disabled temporarily because of conflict with likelihood calculators\n", spacer);
3236 strcpy(modelParams[i].useGibbs, "Yes");
3240 strcpy(modelParams[i].useGibbs, "No");
3243 if (nApplied == 0 && numCurrentDivisions == 1)
3244 MrBayesPrint ("%s Setting Usegibbs to %s (if applicable)\n", spacer, modelParams[i].useGibbs);
3246 MrBayesPrint ("%s Setting Usegibbs to %s (if applicable) for partition %d\n", spacer, modelParams[i].useGibbs, i+1);
3252 MrBayesPrint ("%s Invalid argument for Usegibbs (using Gibbs sampling of discrete gamma)\n", spacer);
3255 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3260 /* set Gibbsfreq (gibbsFreq) ************************************************************/
3261 else if (!strcmp(parmName, "Gibbsfreq"))
3263 if (expecting == Expecting(EQUALSIGN))
3264 expecting = Expecting(NUMBER);
3265 else if (expecting == Expecting(NUMBER))
3267 sscanf (tkn, "%d", &tempInt);
3268 if (tempInt >= 1 && tempInt <= 1000)
3270 nApplied = NumActiveParts ();
3271 for (i=0; i<numCurrentDivisions; i++)
3273 if (activeParts[i] == YES || nApplied == 0)
3275 modelParams[i].gibbsFreq = tempInt;
3276 if (nApplied == 0 && numCurrentDivisions == 1)
3277 MrBayesPrint ("%s Setting Gibbsfreq to %d\n", spacer, modelParams[i].gibbsFreq);
3279 MrBayesPrint ("%s Setting Gibbsfreq to %d for partition %d\n", spacer, modelParams[i].gibbsFreq, i+1);
3285 MrBayesPrint ("%s Invalid Gibbsgammafreq argument (should be between 1 and 1000)\n", spacer);
3288 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3293 /* set NumM10GammaCats (numM10GammaCats) ************************************************************/
3294 else if (!strcmp(parmName, "NumM10GammaCats"))
3296 if (expecting == Expecting(EQUALSIGN))
3297 expecting = Expecting(NUMBER);
3298 else if (expecting == Expecting(NUMBER))
3300 sscanf (tkn, "%d", &tempInt);
3301 if (tempInt >= 2 && tempInt < MAX_GAMMA_CATS)
3303 nApplied = NumActiveParts ();
3304 for (i=0; i<numCurrentDivisions; i++)
3306 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType != CONTINUOUS))
3308 modelParams[i].numM10GammaCats = tempInt;
3309 if (nApplied == 0 && numCurrentDivisions == 1)
3310 MrBayesPrint ("%s Setting NumM10GammaCats to %d\n", spacer, modelParams[i].numM10GammaCats);
3312 MrBayesPrint ("%s Setting NumM10GammaCats to %d for partition %d\n", spacer, modelParams[i].numM10GammaCats, i+1);
3318 MrBayesPrint ("%s Invalid NumM10GammaCats argument (should be between 2 and %d)\n", spacer, MAX_GAMMA_CATS);
3321 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3326 /* set NumM10BetaCats (numM10BetaCats) ************************************************************/
3327 else if (!strcmp(parmName, "NumM10BetaCats"))
3329 if (expecting == Expecting(EQUALSIGN))
3330 expecting = Expecting(NUMBER);
3331 else if (expecting == Expecting(NUMBER))
3333 sscanf (tkn, "%d", &tempInt);
3334 if (tempInt >= 2 && tempInt < MAX_GAMMA_CATS)
3336 nApplied = NumActiveParts ();
3337 for (i=0; i<numCurrentDivisions; i++)
3339 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType != CONTINUOUS))
3341 modelParams[i].numM10BetaCats = tempInt;
3342 if (nApplied == 0 && numCurrentDivisions == 1)
3343 MrBayesPrint ("%s Setting NumM10BetaCats to %d\n", spacer, modelParams[i].numM10BetaCats);
3345 MrBayesPrint ("%s Setting NumM10BetaCats to %d for partition %d\n", spacer, modelParams[i].numM10BetaCats, i+1);
3351 MrBayesPrint ("%s Invalid NumM10GammaCats argument (should be between 2 and %d)\n", spacer, MAX_GAMMA_CATS);
3354 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3359 /* set Nbetacat (numBetaCats) *****************************************************/
3360 else if (!strcmp(parmName, "Nbetacat"))
3362 if (expecting == Expecting(EQUALSIGN))
3363 expecting = Expecting(NUMBER);
3364 else if (expecting == Expecting(NUMBER))
3366 sscanf (tkn, "%d", &tempInt);
3367 if (tempInt >= 2 && tempInt < MAX_GAMMA_CATS)
3369 nApplied = NumActiveParts ();
3370 for (i=0; i<numCurrentDivisions; i++)
3372 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == STANDARD || modelParams[i].dataType == RESTRICTION))
3374 modelParams[i].numBetaCats = tempInt;
3375 if (nApplied == 0 && numCurrentDivisions == 1)
3376 MrBayesPrint ("%s Setting Nbetacat to %d\n", spacer, modelParams[i].numBetaCats);
3378 MrBayesPrint ("%s Setting Nbetacat to %d for partition %d\n", spacer, modelParams[i].numBetaCats, i+1);
3384 MrBayesPrint ("%s Invalid Nbetacat argument (should be between 2 and %d)\n", spacer, MAX_GAMMA_CATS);
3387 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3392 /* set Aamodel (aaModel) **************************************************************/
3393 else if (!strcmp(parmName, "Aamodel"))
3395 MrBayesPrint ("%s Aamodel argument for lset deprecated.\n", spacer);
3396 MrBayesPrint ("%s Use 'prset aamodelpr=fixed(<aamodel>)' instead.\n", spacer);
3399 /* set Parsmodel (useParsModel) *******************************************************/
3400 else if (!strcmp(parmName, "Parsmodel"))
3402 if (expecting == Expecting(EQUALSIGN))
3403 expecting = Expecting(ALPHA);
3404 else if (expecting == Expecting(ALPHA))
3406 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3408 nApplied = NumActiveParts ();
3409 for (i=0; i<numCurrentDivisions; i++)
3411 if (activeParts[i] == YES || nApplied == 0)
3413 if (!strcmp(tempStr, "Yes"))
3414 strcpy(modelParams[i].parsModel, "Yes");
3416 strcpy(modelParams[i].parsModel, "No");
3418 if (nApplied == 0 && numCurrentDivisions == 1)
3419 MrBayesPrint ("%s Setting Parsmodel to %s\n", spacer, modelParams[i].parsModel);
3421 MrBayesPrint ("%s Setting Parsmodel to %s for partition %d\n", spacer, modelParams[i].parsModel, i+1);
3427 MrBayesPrint ("%s Invalid argument for using (so-called) parsimony model\n", spacer);
3430 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3435 /* set Augment (augmentData) **********************************************************/
3436 else if (!strcmp(parmName, "Augment"))
3438 if (expecting == Expecting(EQUALSIGN))
3439 expecting = Expecting(ALPHA);
3440 else if (expecting == Expecting(ALPHA))
3442 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3444 nApplied = NumActiveParts ();
3445 for (i=0; i<numCurrentDivisions; i++)
3447 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
3449 if (!strcmp(tempStr, "Yes"))
3450 strcpy(modelParams[i].augmentData, "Yes");
3452 strcpy(modelParams[i].augmentData, "No");
3454 if (nApplied == 0 && numCurrentDivisions == 1)
3455 MrBayesPrint ("%s Setting Augmentdata to %s\n", spacer, modelParams[i].augmentData);
3457 MrBayesPrint ("%s Setting Augmentdata to %s for partition %d\n", spacer, modelParams[i].augmentData, i+1);
3463 MrBayesPrint ("%s Invalid argument for data augmentation\n", spacer);
3466 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3471 /* set Omegavar (wVarModel) ***********************************************************/
3472 else if (!strcmp(parmName, "Omegavar"))
3474 if (expecting == Expecting(EQUALSIGN))
3475 expecting = Expecting(ALPHA);
3476 else if (expecting == Expecting(ALPHA))
3478 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3480 nApplied = NumActiveParts ();
3481 for (i=0; i<numCurrentDivisions; i++)
3483 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
3485 strcpy(modelParams[i].omegaVar, tempStr);
3486 if (nApplied == 0 && numCurrentDivisions == 1)
3487 MrBayesPrint ("%s Setting Omegavar to %s\n", spacer, modelParams[i].omegaVar);
3489 MrBayesPrint ("%s Setting Omegavar to %s for partition %d\n", spacer, modelParams[i].omegaVar, i+1);
3495 MrBayesPrint ("%s Invalid omega variation argument\n", spacer);
3498 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3503 /* set Code (codeModel) ***************************************************************/
3504 else if (!strcmp(parmName, "Code"))
3506 if (expecting == Expecting(EQUALSIGN))
3507 expecting = Expecting(ALPHA);
3508 else if (expecting == Expecting(ALPHA))
3510 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3512 nApplied = NumActiveParts ();
3513 for (i=0; i<numCurrentDivisions; i++)
3515 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
3517 strcpy(modelParams[i].geneticCode, tempStr);
3519 modelParams[i].nStates = NumStates (i);
3520 if (nApplied == 0 && numCurrentDivisions == 1)
3521 MrBayesPrint ("%s Setting Code to %s\n", spacer, modelParams[i].geneticCode);
3523 MrBayesPrint ("%s Setting Code to %s for partition %d\n", spacer, modelParams[i].geneticCode, i+1);
3529 MrBayesPrint ("%s Invalid genetic code argument\n", spacer);
3532 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3537 /* set Ploidy (ploidy) ***************************************************************/
3538 else if (!strcmp(parmName, "Ploidy"))
3540 if (expecting == Expecting(EQUALSIGN))
3541 expecting = Expecting(ALPHA);
3542 else if (expecting == Expecting(ALPHA))
3544 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3546 nApplied = NumActiveParts ();
3547 for (i=0; i<numCurrentDivisions; i++)
3549 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
3551 strcpy(modelParams[i].ploidy, tempStr);
3552 if (nApplied == 0 && numCurrentDivisions == 1)
3553 MrBayesPrint ("%s Setting ploidy level to %s\n", spacer, modelParams[i].ploidy);
3555 MrBayesPrint ("%s Setting ploidy level to %s for partition %d\n", spacer, modelParams[i].ploidy, i+1);
3561 MrBayesPrint ("%s Invalid ploidy level argument\n", spacer);
3564 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3569 /* set Rates (ratesModel) *************************************************************/
3570 else if (!strcmp(parmName, "Rates"))
3572 if (expecting == Expecting(EQUALSIGN))
3573 expecting = Expecting(ALPHA);
3574 else if (expecting == Expecting(ALPHA))
3576 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3578 nApplied = NumActiveParts ();
3579 for (i=0; i<numCurrentDivisions; i++)
3581 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
3583 if (!strcmp(tempStr, "Adgamma") && (modelParams[i].dataType != DNA && modelParams[i].dataType != RNA && modelParams[i].dataType != PROTEIN))
3585 /* we won't apply an adgamma model to anything but DNA, RNA, or PROTEIN data */
3587 else if ((!strcmp(tempStr, "Propinv") || !strcmp(tempStr, "Invgamma")) && (modelParams[i].dataType == STANDARD || modelParams[i].dataType == RESTRICTION))
3589 /* we will not apply pinvar to standard or restriction site data */
3593 strcpy(modelParams[i].ratesModel, tempStr);
3594 if (nApplied == 0 && numCurrentDivisions == 1)
3595 MrBayesPrint ("%s Setting Rates to %s\n", spacer, modelParams[i].ratesModel);
3597 MrBayesPrint ("%s Setting Rates to %s for partition %d\n", spacer, modelParams[i].ratesModel, i+1);
3604 MrBayesPrint ("%s Invalid Rates argument\n", spacer);
3607 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3612 /* set Covarion (covarionModel) *******************************************************/
3613 else if (!strcmp(parmName, "Covarion"))
3615 if (expecting == Expecting(EQUALSIGN))
3616 expecting = Expecting(ALPHA);
3617 else if (expecting == Expecting(ALPHA))
3619 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3621 nApplied = NumActiveParts ();
3622 for (i=0; i<numCurrentDivisions; i++)
3624 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA || modelParams[i].dataType == PROTEIN))
3626 strcpy(modelParams[i].covarionModel, tempStr);
3627 if (nApplied == 0 && numCurrentDivisions == 1)
3628 MrBayesPrint ("%s Setting Covarion to %s\n", spacer, modelParams[i].covarionModel);
3630 MrBayesPrint ("%s Setting Covarion to %s for partition %d\n", spacer, modelParams[i].covarionModel, i+1);
3636 MrBayesPrint ("%s Invalid Rates argument\n", spacer);
3639 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3644 /* set Coding (missingType) ***********************************************************/
3645 else if (!strcmp(parmName, "Coding"))
3647 if (expecting == Expecting(EQUALSIGN))
3649 for (i=0; i<numCurrentDivisions; i++)
3650 modelParams[i].coding = ALL;
3652 expecting = Expecting(ALPHA);
3654 else if (expecting == Expecting(VERTICALBAR))
3655 expecting = Expecting(ALPHA);
3656 else if (expecting == Expecting(ALPHA))
3658 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3660 nApplied = NumActiveParts ();
3661 for (i=0; i<numCurrentDivisions; i++)
3663 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == RESTRICTION || modelParams[i].dataType == STANDARD))
3665 if(!strcmp(tempStr, "Nosingletons"))
3667 modelParams[i].coding |= NOSINGLETONS;
3669 else if(!strcmp(tempStr, "Variable"))
3671 modelParams[i].coding |= VARIABLE;
3673 else if(!strcmp(tempStr, "Informative"))
3675 modelParams[i].coding |= INFORMATIVE;
3679 if(modelParams[i].dataType != RESTRICTION)
3681 MrBayesPrint ("%s Invalid coding for standard characters: %s\n", spacer, tempStr);
3685 if(!strcmp(tempStr, "Noabsencesites"))
3687 modelParams[i].coding |= NOABSENCESITES;
3689 else if(!strcmp(tempStr, "Nopresencesites"))
3691 modelParams[i].coding |= NOPRESENCESITES;
3693 else if(!strcmp(tempStr, "Nosingletonpresence"))
3695 modelParams[i].coding |= NOSINGLETONPRESENCE;
3697 else if(!strcmp(tempStr, "Nosingletonabsence"))
3699 modelParams[i].coding |= NOSINGLETONABSENCE;
3703 CodingToString(modelParams[i].coding, modelParams[i].codingString);
3705 if (nApplied == 0 && numCurrentDivisions == 1)
3706 MrBayesPrint ("%s Enabling Coding %s\n", spacer, tempStr);
3708 MrBayesPrint ("%s Enabling Coding %s for partition %d\n", spacer, tempStr, i+1);
3714 MrBayesPrint ("%s Invalid argument for missing patterns\n", spacer);
3717 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON) | Expecting(VERTICALBAR);
3736 int i, n, nHeaders, burnin, len, longestHeader, whichIsX, whichIsY, numPlotted;
3737 char temp[100], **headerNames = NULL;
3738 SumpFileInfo fileInfo;
3739 ParameterSample *parameterSamples;
3741 # if defined (MPI_ENABLED)
3746 /* initialize values */
3749 parameterSamples = NULL;
3751 /* tell user we are ready to go */
3752 MrBayesPrint ("%s Plotting parameters in file %s ...\n", spacer, plotParams.plotFileName);
3754 /* examine plot file */
3755 if (ExamineSumpFile (plotParams.plotFileName, &fileInfo, &headerNames, &nHeaders) == ERROR)
3758 /* Calculate burn in */
3759 burnin = fileInfo.firstParamLine - fileInfo.headerLine - 1;
3761 /* tell the user that everything is fine */
3762 MrBayesPrint ("%s Found %d parameter lines in file \"%s\"\n", spacer, fileInfo.numRows + burnin, plotParams.plotFileName);
3764 MrBayesPrint ("%s Of the %d lines, %d of them will be summarized (starting at line %d)\n", spacer, fileInfo.numRows+burnin, fileInfo.numRows, fileInfo.firstParamLine);
3766 MrBayesPrint ("%s All %d lines will be summarized (starting at line %d)\n", spacer, fileInfo.numRows, fileInfo.firstParamLine);
3767 MrBayesPrint ("%s (Only the last set of lines will be read, in case multiple\n", spacer);
3768 MrBayesPrint ("%s parameter blocks are present in the same file.)\n", spacer);
3770 /* allocate space to hold parameter information */
3771 if (AllocateParameterSamples (¶meterSamples, 1, fileInfo.numRows, fileInfo.numColumns) == ERROR)
3774 /* Now we read the file for real. First, rewind file pointer to beginning of file... */
3775 if (ReadParamSamples (plotParams.plotFileName, &fileInfo, parameterSamples, 0) == ERROR)
3778 /* get length of longest header */
3779 longestHeader = 9; /* 9 is the length of the word "parameter" (for printing table) */
3780 for (i=0; i<nHeaders; i++)
3782 len = (int) strlen(headerNames[i]);
3783 if (len > longestHeader)
3784 longestHeader = len;
3787 /* print x-y plot of parameter vs. generation */
3789 for (i=0; i<nHeaders; i++)
3791 if (IsSame (headerNames[i], "Gen") == SAME)
3797 MrBayesPrint ("%s Could not find a column labelled \"Gen\" \n", spacer);
3802 for (n=0; n<nHeaders; n++)
3804 strcpy (temp, headerNames[n]);
3806 if (!strcmp(plotParams.match, "Perfect"))
3808 if (IsSame (temp, plotParams.parameter) == SAME)
3811 else if (!strcmp(plotParams.match, "All"))
3817 if (IsSame (temp, plotParams.parameter) == CONSISTENT_WITH)
3821 if (whichIsY >= 0 && whichIsX != whichIsY)
3823 MrBayesPrint ("\n%s Rough trace plot of parameter %s:\n", spacer, headerNames[whichIsY]);
3824 if (PrintPlot (parameterSamples[whichIsX].values[0], parameterSamples[whichIsY].values[0], fileInfo.numRows) == ERROR)
3830 if (numPlotted == 0)
3832 MrBayesPrint ("%s Did not find any parameters matching \"%s\" to plot\n", spacer, plotParams.parameter);
3836 for (i=0; i<nHeaders; i++)
3837 free (headerNames[i]);
3839 FreeParameterSamples(parameterSamples);
3841 expecting = Expecting(COMMAND);
3848 for (i=0; i<nHeaders; i++)
3849 free (headerNames[i]);
3851 FreeParameterSamples(parameterSamples);
3853 expecting = Expecting(COMMAND);
3859 int DoPlotParm (char *parmName, char *tkn)
3865 if (defMatrix == NO)
3867 MrBayesPrint ("%s A matrix must be specified before sumt can be used\n", spacer);
3871 if (expecting == Expecting(PARAMETER))
3873 expecting = Expecting(EQUALSIGN);
3877 if (!strcmp(parmName, "Xxxxxxxxxx"))
3879 expecting = Expecting(PARAMETER);
3880 expecting |= Expecting(SEMICOLON);
3882 /* set Filename (plotParams.plotFileName) ***************************************************/
3883 else if (!strcmp(parmName, "Filename"))
3885 if (expecting == Expecting(EQUALSIGN))
3887 expecting = Expecting(ALPHA);
3890 else if (expecting == Expecting(ALPHA))
3892 strcpy (plotParams.plotFileName, tkn);
3893 MrBayesPrint ("%s Setting plot filename to %s\n", spacer, plotParams.plotFileName);
3894 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3899 /* set Relburnin (chainParams.relativeBurnin) ********************************************************/
3900 else if (!strcmp(parmName, "Relburnin"))
3902 if (expecting == Expecting(EQUALSIGN))
3903 expecting = Expecting(ALPHA);
3904 else if (expecting == Expecting(ALPHA))
3906 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3908 if (!strcmp(tempStr, "Yes"))
3909 chainParams.relativeBurnin = YES;
3911 chainParams.relativeBurnin = NO;
3915 MrBayesPrint ("%s Invalid argument for Relburnin\n", spacer);
3918 if (chainParams.relativeBurnin == YES)
3919 MrBayesPrint ("%s Using relative burnin (a fraction of samples discarded).\n", spacer);
3921 MrBayesPrint ("%s Using absolute burnin (a fixed number of samples discarded).\n", spacer);
3922 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3929 /* set Burnin (chainParams.chainBurnIn) *******************************************************/
3930 else if (!strcmp(parmName, "Burnin"))
3932 if (expecting == Expecting(EQUALSIGN))
3933 expecting = Expecting(NUMBER);
3934 else if (expecting == Expecting(NUMBER))
3936 sscanf (tkn, "%d", &tempI);
3937 chainParams.chainBurnIn = tempI;
3938 MrBayesPrint ("%s Setting burnin to %d\n", spacer, chainParams.chainBurnIn);
3939 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3944 /* set Burninfrac (chainParams.burninFraction) ************************************************************/
3945 else if (!strcmp(parmName, "Burninfrac"))
3947 if (expecting == Expecting(EQUALSIGN))
3948 expecting = Expecting(NUMBER);
3949 else if (expecting == Expecting(NUMBER))
3951 sscanf (tkn, "%lf", &tempD);
3954 MrBayesPrint ("%s Burnin fraction too low (< 0.01)\n", spacer);
3959 MrBayesPrint ("%s Burnin fraction too high (> 0.50)\n", spacer);
3962 chainParams.burninFraction = tempD;
3963 MrBayesPrint ("%s Setting burnin fraction to %.2f\n", spacer, chainParams.burninFraction);
3964 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3971 /* set Parameter (plotParams.parameter) *******************************************************/
3972 else if (!strcmp(parmName, "Parameter"))
3974 if (expecting == Expecting(EQUALSIGN))
3976 expecting = Expecting(ALPHA);
3979 else if (expecting == Expecting(ALPHA))
3981 strcpy (plotParams.parameter, tkn);
3982 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
3987 /* set Parameter (plotParams.match) *******************************************************/
3988 else if (!strcmp(parmName, "Match"))
3990 if (expecting == Expecting(EQUALSIGN))
3991 expecting = Expecting(ALPHA);
3992 else if (expecting == Expecting(ALPHA))
3994 if (IsArgValid(tkn, tempStr) == NO_ERROR)
3995 strcpy (plotParams.match, tempStr);
3999 MrBayesPrint ("%s Setting plot matching to %s\n", spacer, plotParams.match);
4000 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
4014 int DoPropset (void)
4016 MrBayesPrint ("%s Successfully set proposal parameters\n", spacer);
4022 int DoPropsetParm (char *parmName, char *tkn)
4024 int i, j, k, nMatches, tempInt;
4026 static MCMCMove *mv = NULL;
4027 static MrBFlt *theValue, theValueMin, theValueMax;
4028 static int jump, runIndex, chainIndex;
4029 static char *temp=NULL, *localTkn=NULL; /*freed at the end of the call*/
4030 static char *tempName=NULL; /*not freed at the end of the call*/
4032 if (defMatrix == NO)
4034 MrBayesPrint ("%s A matrix must be specified before proposal parameters can be changed\n", spacer);
4038 if (expecting == Expecting(PARAMETER))
4040 if (!strcmp(parmName, "Xxxxxxxxxx"))
4042 /* we expect a move name with possible run and chain specification as follows:
4043 <move_name>$<tuning_param_name>(<run>,<chain>)=<number> -- apply to run <run> and chain <chain>
4044 <move_name>$<tuning_param_name>(,<chain>)=<number> -- apply to chain <chain> for all runs
4045 <move_name>$<tuning_param_name>(<run>,)=<number> -- apply to all chains of run <run>
4046 <move_name>$prob(<run>,<chain>)=<number> -- change relative proposal probability
4047 <move_name>$targetrate(<run>,<chain>)=<number> -- change target acc rate for autotuning
4049 the parsing is complicated by the fact that the move name can look something like:
4052 so we need to assemble the move name from several tokens that are parsed out separately;
4053 here we receive only the first part (before the left parenthesis)
4056 /* copy to local move name */
4057 SafeStrcpy(&tempName, tkn);
4059 foundComma = foundEqual = NO;
4060 expecting = Expecting(LEFTCURL) | Expecting(RIGHTCURL) | Expecting(COMMA) |
4061 Expecting(LEFTPAR) | Expecting(RIGHTPAR) | Expecting(NUMBER) | Expecting(ALPHA) |
4067 else if (expecting == Expecting(ALPHA))
4071 /* we are still assembling the move name */
4072 SafeStrcat(&tempName, tkn);
4073 expecting = Expecting(LEFTCURL) | Expecting(RIGHTCURL) | Expecting(COMMA) |
4074 Expecting(LEFTPAR) | Expecting(RIGHTPAR) | Expecting(NUMBER) | Expecting(ALPHA) |
4079 /* we have a parameter name; now find the parameter name, case insensitive */
4080 SafeStrcpy(&localTkn, tkn);
4081 for (i=0; i<(int)strlen(localTkn); i++)
4082 localTkn[i] = tolower(localTkn[i]);
4084 for (i=0; i<mv->moveType->numTuningParams; i++)
4086 SafeStrcpy(&temp, mv->moveType->shortTuningName[i]);
4087 for (k=0; k<(int)strlen(temp); k++)
4088 temp[k] = tolower(temp[k]);
4089 if (strncmp(localTkn,temp,strlen(localTkn)) == 0)
4095 if (strncmp(localTkn,"prob",strlen(localTkn)) == 0)
4100 else if (strncmp(localTkn,"targetrate",strlen(localTkn)) == 0)
4107 MrBayesPrint ("%s Could not find move parameter to change '%s'\n", spacer, localTkn);
4110 else if (nMatches > 1)
4112 MrBayesPrint ("%s Several move parameters matched the abbreviated name '%s'\n", spacer, localTkn);
4118 theValue = mv->relProposalProb;
4120 theValueMax = 1000.0;
4125 theValue = mv->targetRate;
4132 theValue = &mv->tuningParam[0][j];
4133 theValueMin = mv->moveType->minimum[j];
4134 theValueMax = mv->moveType->maximum[j];
4135 jump = mv->moveType->numTuningParams;
4139 expecting = Expecting(LEFTPAR) | Expecting(EQUALSIGN);
4142 else if (expecting == Expecting(LEFTCURL) || expecting == Expecting(RIGHTCURL))
4144 /* we are still assembling the move name */
4145 SafeStrcat (&tempName, tkn);
4146 expecting = Expecting(LEFTCURL) | Expecting(RIGHTCURL) | Expecting(COMMA) |
4147 Expecting(LEFTPAR) | Expecting(RIGHTPAR) | Expecting(NUMBER) | Expecting(ALPHA) |
4150 else if (expecting == Expecting(DOLLAR))
4152 /* we know that the name is complete now; find the move by its name,
4154 SafeStrcpy(&localTkn, tempName);
4155 j=(int)strlen(localTkn);
4157 localTkn[i] = tolower(localTkn[i]);
4161 for (i=0; i<numApplicableMoves; i++)
4164 SafeStrcpy(&temp,mv->name);
4165 for (k=0; k<(int)strlen(temp); k++)
4166 temp[k] = tolower(temp[k]);
4167 if (strncmp(temp,localTkn,strlen(localTkn)) == 0)
4175 MrBayesPrint ("%s Could not find move '%s'\n", spacer, localTkn);
4178 else if (nMatches > 1)
4180 MrBayesPrint ("%s Several moves matched the abbreviated name '%s'\n", spacer, localTkn);
4186 foundComma = foundEqual = NO;
4187 expecting = Expecting(ALPHA);
4189 else if (expecting == Expecting(LEFTPAR))
4193 /* we are still assembling the move name */
4194 SafeStrcat (&tempName, tkn);
4195 expecting = Expecting(LEFTCURL) | Expecting(RIGHTCURL) | Expecting(COMMA) |
4196 Expecting(LEFTPAR) | Expecting(RIGHTPAR) | Expecting(NUMBER) | Expecting(ALPHA) |
4199 else /* if (mv != NULL) */
4201 /* we will be reading in run and chain indices */
4202 expecting = Expecting(NUMBER) | Expecting(COMMA);
4205 else if (expecting == Expecting(NUMBER))
4209 /* we are still assembling the move name */
4210 SafeStrcat (&tempName, tkn);
4211 expecting = Expecting(LEFTCURL) | Expecting(RIGHTCURL) | Expecting(COMMA) |
4212 Expecting(LEFTPAR) | Expecting(RIGHTPAR) | Expecting(NUMBER) | Expecting(ALPHA) |
4215 else if (foundEqual == YES)
4217 sscanf (tkn, "%lf", &tempFloat);
4218 if (tempFloat < theValueMin || tempFloat > theValueMax)
4220 MrBayesPrint ("%s The value is out of range (min = %lf; max = %lf)\n", spacer, theValueMin, theValueMax);
4223 if (runIndex == -1 && chainIndex == -1)
4225 for (i=0; i<chainParams.numRuns; i++)
4227 for (j=0; j<chainParams.numChains; j++)
4229 *theValue = tempFloat;
4234 else if (runIndex == -1 && chainIndex >= 0)
4236 theValue += chainIndex*jump;
4237 for (i=0; i<chainParams.numRuns; i++)
4239 *theValue = tempFloat;
4240 theValue += chainParams.numChains*jump;
4243 else if (runIndex >= 0 && chainIndex == -1)
4245 theValue += runIndex*chainParams.numChains*jump;
4246 for (i=0; i<chainParams.numChains; i++)
4248 *theValue = tempFloat;
4252 else /* if (runIndex >= 0 && chainIndex >= 0) */
4254 theValue[runIndex*chainParams.numChains*jump+chainIndex*jump] = tempFloat;
4256 expecting = Expecting (PARAMETER) | Expecting(SEMICOLON);
4258 else /* if (foundEqual == NO) */
4260 sscanf (tkn, "%d", &tempInt);
4261 if (foundComma == NO)
4263 if (tempInt <= 0 || tempInt > chainParams.numRuns)
4265 MrBayesPrint ("%s Run index is out of range (min=1; max=%d)\n", spacer, chainParams.numRuns);
4268 runIndex = tempInt - 1;
4269 expecting = Expecting(COMMA);
4273 if (tempInt <= 0 || tempInt > chainParams.numChains)
4275 MrBayesPrint ("%s Chain index is out of range (min=1; max=%d)\n", spacer, chainParams.numChains);
4278 chainIndex = tempInt - 1;
4279 expecting = Expecting(RIGHTPAR);
4283 else if (expecting == Expecting(COMMA))
4287 /* we are still assembling the move name */
4288 SafeStrcat (&tempName, tkn);
4289 expecting = Expecting(LEFTCURL) | Expecting(RIGHTCURL) | Expecting(COMMA) |
4290 Expecting(LEFTPAR) | Expecting(RIGHTPAR) | Expecting(NUMBER) | Expecting(ALPHA) |
4295 /* we will be reading in chain index, if present */
4297 expecting = Expecting(RIGHTPAR) | Expecting(NUMBER);
4300 else if (expecting == Expecting(RIGHTPAR))
4304 /* we are still assembling the move name */
4305 SafeStrcat (&tempName, tkn);
4306 expecting = Expecting(LEFTCURL) | Expecting(RIGHTCURL) | Expecting(COMMA) |
4307 Expecting(LEFTPAR) | Expecting(RIGHTPAR) | Expecting(NUMBER) | Expecting(ALPHA) |
4311 expecting = Expecting(EQUALSIGN);
4313 else if (expecting == Expecting(EQUALSIGN))
4316 expecting = Expecting(NUMBER);
4321 SafeFree ((void **)&temp);
4322 SafeFree ((void **)&localTkn);
4329 int i, nApplied, lastActive=0;
4331 nApplied = NumActiveParts ();
4332 for (i=numCurrentDivisions-1; i>=0; i--)
4334 if (activeParts[i] == YES)
4341 if (numCurrentDivisions == 1)
4342 MrBayesPrint ("%s Successfully set prior model parameters\n", spacer);
4345 if (nApplied == numCurrentDivisions || nApplied == 0)
4347 MrBayesPrint ("%s Successfully set prior model parameters to all\n", spacer);
4348 MrBayesPrint ("%s applicable data partitions \n", spacer);
4352 MrBayesPrint ("%s Successfully set prior model parameters to\n", spacer);
4354 MrBayesPrint ("%s partition", spacer);
4356 MrBayesPrint ("%s partitions", spacer);
4357 for (i=0; i<numCurrentDivisions; i++)
4359 if (activeParts[i] == YES)
4361 if (i == lastActive && nApplied > 1)
4362 MrBayesPrint (" and %d", i+1);
4364 MrBayesPrint (" %d", i+1);
4365 if (nApplied > 2 && i != lastActive)
4369 MrBayesPrint (" (if applicable)\n");
4373 if (SetUpAnalysis (&globalSeed) == ERROR)
4380 int DoPrsetParm (char *parmName, char *tkn)
4382 int i, j, k, tempInt, nApplied, index, ns, flag=0;
4386 if (defMatrix == NO)
4388 MrBayesPrint ("%s A matrix must be specified before the model can be defined\n", spacer);
4391 if (inValidCommand == YES)
4393 for (i=0; i<numCurrentDivisions; i++)
4394 activeParts[i] = NO;
4395 inValidCommand = NO;
4398 if (expecting == Expecting(PARAMETER))
4400 expecting = Expecting(EQUALSIGN);
4404 /* set Applyto (Applyto) *************************************************************/
4405 if (!strcmp(parmName, "Applyto"))
4407 if (expecting == Expecting(EQUALSIGN))
4408 expecting = Expecting(LEFTPAR);
4409 else if (expecting == Expecting(LEFTPAR))
4411 for (i=0; i<numCurrentDivisions; i++)
4412 activeParts[i] = NO;
4415 expecting = Expecting(NUMBER) | Expecting(ALPHA);
4417 else if (expecting == Expecting(RIGHTPAR))
4420 activeParts[fromI-1] = YES;
4422 for (i=0; i<numCurrentDivisions; i++)
4423 MrBayesPrint("%d ", activeParts[i]);
4424 MrBayesPrint ("\n");
4426 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
4428 else if (expecting == Expecting(COMMA))
4431 expecting = Expecting(NUMBER);
4433 else if (expecting == Expecting(ALPHA))
4435 if (IsSame ("All", tkn) == DIFFERENT)
4437 MrBayesPrint ("%s Do not understand delimiter \"%s\"\n", spacer, tkn);
4440 for (i=0; i<numCurrentDivisions; i++)
4441 activeParts[i] = YES;
4442 expecting = Expecting(RIGHTPAR);
4444 else if (expecting == Expecting(NUMBER))
4446 sscanf (tkn, "%d", &tempInt);
4447 if (tempInt > numCurrentDivisions)
4449 MrBayesPrint ("%s Partition delimiter is too large\n", spacer);
4454 else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO)
4457 for (i=fromI-1; i<toJ; i++)
4458 activeParts[i] = YES;
4462 else if (fromI != -1 && toJ == -1 && foundDash == NO && foundComma == YES)
4464 activeParts[fromI-1] = YES;
4469 expecting = Expecting(COMMA);
4470 expecting |= Expecting(DASH);
4471 expecting |= Expecting(RIGHTPAR);
4473 else if (expecting == Expecting(DASH))
4476 expecting = Expecting(NUMBER);
4481 /* set Tratiopr (tRatioPr) ************************************************************/
4482 else if (!strcmp(parmName, "Tratiopr"))
4484 if (expecting == Expecting(EQUALSIGN))
4485 expecting = Expecting(ALPHA);
4486 else if (expecting == Expecting(ALPHA))
4488 if (IsArgValid(tkn, tempStr) == NO_ERROR)
4490 nApplied = NumActiveParts ();
4492 for (i=0; i<numCurrentDivisions; i++)
4494 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
4496 strcpy(modelParams[i].tRatioPr, tempStr);
4497 modelParams[i].tRatioDir[0] = modelParams[i].tRatioDir[1] = 1.0;
4498 modelParams[i].tRatioFix = 1.0;
4504 MrBayesPrint ("%s Warning: %s can be set only for partition containing either DNA or RNA data.\
4505 Currently there is no active partition with such data.\n", spacer, parmName);
4511 MrBayesPrint ("%s Invalid Tratiopr argument \n", spacer);
4514 expecting = Expecting(LEFTPAR);
4515 for (i=0; i<numCurrentDivisions; i++)
4518 else if (expecting == Expecting(LEFTPAR))
4520 expecting = Expecting(NUMBER);
4522 else if (expecting == Expecting(NUMBER))
4524 nApplied = NumActiveParts ();
4525 for (i=0; i<numCurrentDivisions; i++)
4527 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
4529 if (!strcmp(modelParams[i].tRatioPr,"Beta"))
4531 sscanf (tkn, "%lf", &tempD);
4532 if (tempD > ALPHA_MAX)
4534 MrBayesPrint ("%s Beta parameter cannot be greater than %1.2lf\n", spacer, ALPHA_MAX);
4537 if (tempD < ALPHA_MIN)
4539 MrBayesPrint ("%s Beta parameter cannot be less than %1.2lf\n", spacer, ALPHA_MIN);
4542 modelParams[i].tRatioDir[numVars[i]++] = tempD;
4544 expecting = Expecting(COMMA);
4547 if (nApplied == 0 && numCurrentDivisions == 1)
4548 MrBayesPrint ("%s Setting Tratiopr to Beta(%1.2lf,%1.2lf)\n", spacer, modelParams[i].tRatioDir[0], modelParams[i].tRatioDir[1]);
4550 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);
4551 expecting = Expecting(RIGHTPAR);
4554 else if (!strcmp(modelParams[i].tRatioPr,"Fixed"))
4556 sscanf (tkn, "%lf", &tempD);
4557 modelParams[i].tRatioFix = tempD;
4558 if (modelParams[i].tRatioFix > KAPPA_MAX)
4560 MrBayesPrint ("%s Tratio cannot be greater than %1.2lf\n", spacer, KAPPA_MAX);
4563 if (modelParams[i].tRatioFix < 0.0)
4565 MrBayesPrint ("%s Tratio cannot be less than %1.2lf\n", spacer, 0.0);
4568 if (nApplied == 0 && numCurrentDivisions == 1)
4569 MrBayesPrint ("%s Setting Tratiopr to Fixed(%1.2lf)\n", spacer, modelParams[i].tRatioFix);
4571 MrBayesPrint ("%s Setting Tratiopr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].tRatioFix, i+1);
4572 expecting = Expecting(RIGHTPAR);
4577 else if (expecting == Expecting(COMMA))
4579 expecting = Expecting(NUMBER);
4581 else if (expecting == Expecting(RIGHTPAR))
4583 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
4588 /* set Revmatpr (revMatPr) ************************************************************/
4589 else if (!strcmp(parmName, "Revmatpr"))
4591 if (expecting == Expecting(EQUALSIGN))
4592 expecting = Expecting(ALPHA);
4593 else if (expecting == Expecting(ALPHA))
4595 if (IsArgValid(tkn, tempStr) == NO_ERROR)
4597 nApplied = NumActiveParts ();
4599 for (i=0; i<numCurrentDivisions; i++)
4601 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
4603 strcpy(modelParams[i].revMatPr, tempStr);
4604 modelParams[i].revMatDir[0] = modelParams[i].revMatDir[1] = 1.0;
4605 modelParams[i].revMatDir[2] = modelParams[i].revMatDir[3] = 1.0;
4606 modelParams[i].revMatDir[4] = modelParams[i].revMatDir[5] = 1.0;
4612 MrBayesPrint ("%s Warning: %s can be set only for partition containing either DNA or RNA data.\
4613 Currently there is no active partition with such data.\n", spacer, parmName);
4619 MrBayesPrint ("%s Invalid Revmatpr argument\n", spacer);
4622 expecting = Expecting(LEFTPAR);
4625 else if (expecting == Expecting(LEFTPAR))
4627 expecting = Expecting(NUMBER);
4629 else if (expecting == Expecting(NUMBER))
4631 /* find out what type of prior is being set */
4632 nApplied = NumActiveParts ();
4633 for (i=0; i<numCurrentDivisions; i++)
4635 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
4636 strcpy (tempStr,modelParams[i].revMatPr);
4638 /* find and store the number */
4639 sscanf (tkn, "%lf", &tempD);
4640 if (!strcmp(tempStr,"Dirichlet"))
4642 if (tempD > ALPHA_MAX)
4644 MrBayesPrint ("%s Dirichlet parameter cannot be greater than %1.2lf\n", spacer, ALPHA_MAX);
4647 if (tempD < ALPHA_MIN)
4649 MrBayesPrint ("%s Dirichlet parameter cannot be less than %1.2lf\n", spacer, ALPHA_MIN);
4653 else if (!strcmp(tempStr,"Fixed"))
4655 if (tempD > KAPPA_MAX)
4657 MrBayesPrint ("%s Rate value cannot be greater than %1.2lf\n", spacer, KAPPA_MAX);
4662 MrBayesPrint ("%s Rate value cannot be less than %1.2lf\n", spacer, 0.0001);
4666 tempNum[tempNumStates++] = tempD;
4667 if (tempNumStates == 1 && !strcmp(tempStr,"Dirichlet"))
4668 expecting = Expecting(COMMA) | Expecting(RIGHTPAR);
4669 else if (tempNumStates < 6)
4670 expecting = Expecting(COMMA);
4672 expecting = Expecting(RIGHTPAR);
4674 else if (expecting == Expecting(COMMA))
4676 expecting = Expecting(NUMBER);
4678 else if (expecting == Expecting(RIGHTPAR))
4680 nApplied = NumActiveParts ();
4681 for (i=0; i<numCurrentDivisions; i++)
4683 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
4685 if (!strcmp(modelParams[i].revMatPr,"Dirichlet"))
4689 if (tempNumStates == 1)
4690 modelParams[i].revMatDir[j] = tempNum[0] / (MrBFlt) 6.0;
4692 modelParams[i].revMatDir[j] = tempNum[j];
4695 if (nApplied == 0 && numCurrentDivisions == 1)
4696 MrBayesPrint ("%s Setting Revmatpr to Dirichlet(%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer,
4697 modelParams[i].revMatDir[0], modelParams[i].revMatDir[1], modelParams[i].revMatDir[2],
4698 modelParams[i].revMatDir[3], modelParams[i].revMatDir[4], modelParams[i].revMatDir[5]);
4700 MrBayesPrint ("%s Setting Revmatpr to Dirichlet(%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf) for partition %d\n", spacer,
4701 modelParams[i].revMatDir[0], modelParams[i].revMatDir[1], modelParams[i].revMatDir[2],
4702 modelParams[i].revMatDir[3], modelParams[i].revMatDir[4], modelParams[i].revMatDir[5], i+1);
4704 else if (!strcmp(modelParams[i].revMatPr,"Fixed"))
4707 modelParams[i].revMatFix[j] = tempNum[j];
4708 if (nApplied == 0 && numCurrentDivisions == 1)
4709 MrBayesPrint ("%s Setting Revmatpr to Fixed(%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer,
4710 modelParams[i].revMatFix[0], modelParams[i].revMatFix[1], modelParams[i].revMatFix[2],
4711 modelParams[i].revMatFix[3], modelParams[i].revMatFix[4], modelParams[i].revMatFix[5]);
4713 MrBayesPrint ("%s Setting Revmatpr to Fixed(%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf) for partition %d\n", spacer,
4714 modelParams[i].revMatFix[0], modelParams[i].revMatFix[1], modelParams[i].revMatFix[2],
4715 modelParams[i].revMatFix[3], modelParams[i].revMatFix[4], modelParams[i].revMatFix[5], i+1);
4719 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
4724 /* set Aarevmatpr (aaRevMatPr) ********************************************************/
4725 else if (!strcmp(parmName, "Aarevmatpr"))
4727 if (expecting == Expecting(EQUALSIGN))
4728 expecting = Expecting(ALPHA);
4729 else if (expecting == Expecting(ALPHA))
4731 if (IsArgValid(tkn, tempStr) == NO_ERROR)
4733 nApplied = NumActiveParts ();
4735 for (i=0; i<numCurrentDivisions; i++)
4737 if ((activeParts[i] == YES || nApplied == 0) && modelSettings[i].dataType == PROTEIN)
4739 strcpy(modelParams[i].aaRevMatPr, tempStr);
4740 for (j=0; j<190; j++)
4741 modelParams[i].aaRevMatDir[j] = 1.0;
4747 MrBayesPrint ("%s Warning: %s can be set only for partition containing PROTEIN.\
4748 Currently there is no active partition with such data.\n", spacer, parmName);
4754 MrBayesPrint ("%s Invalid Aarevmatpr argument\n", spacer);
4757 expecting = Expecting(LEFTPAR);
4760 else if (expecting == Expecting(LEFTPAR))
4762 expecting = Expecting(NUMBER);
4764 else if (expecting == Expecting(NUMBER))
4766 /* find out what type of prior is being set */
4767 nApplied = NumActiveParts ();
4768 for (i=0; i<numCurrentDivisions; i++)
4770 if ((activeParts[i] == YES || nApplied == 0) && modelSettings[i].dataType == PROTEIN)
4771 strcpy (tempStr,modelParams[i].aaRevMatPr);
4773 /* find and store the number */
4774 sscanf (tkn, "%lf", &tempD);
4775 if (!strcmp(tempStr,"Dirichlet"))
4777 if (tempD > ALPHA_MAX)
4779 MrBayesPrint ("%s Dirichlet parameter cannot be greater than %1.2lf\n", spacer, ALPHA_MAX);
4782 if (tempD < ALPHA_MIN)
4784 MrBayesPrint ("%s Dirichlet parameter cannot be less than %1.2lf\n", spacer, ALPHA_MIN);
4788 else if (!strcmp(tempStr,"Fixed"))
4790 if (tempD > KAPPA_MAX)
4792 MrBayesPrint ("%s Rate value cannot be greater than %1.2lf\n", spacer, KAPPA_MAX);
4797 MrBayesPrint ("%s Rate value cannot be less than %1.2lf\n", spacer, 0.0001);
4801 tempStateFreqs[tempNumStates++] = tempD;
4802 if (tempNumStates == 1 && !strcmp(tempStr,"Dirichlet"))
4803 expecting = Expecting(COMMA) | Expecting(RIGHTPAR);
4804 else if (tempNumStates < 190)
4805 expecting = Expecting(COMMA);
4807 expecting = Expecting(RIGHTPAR);
4809 else if (expecting == Expecting(COMMA))
4811 expecting = Expecting(NUMBER);
4813 else if (expecting == Expecting(RIGHTPAR))
4815 nApplied = NumActiveParts ();
4816 for (i=0; i<numCurrentDivisions; i++)
4818 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType == PROTEIN)
4820 if (!strcmp(modelParams[i].aaRevMatPr,"Dirichlet"))
4822 for (j=0; j<190; j++)
4824 if (tempNumStates == 1)
4825 modelParams[i].aaRevMatDir[j] = tempStateFreqs[0] / (MrBFlt) 190.0;
4827 modelParams[i].aaRevMatDir[j] = tempStateFreqs[j];
4829 if (nApplied == 0 && numCurrentDivisions == 1)
4831 for (j=0; j<190; j++)
4832 if (AreDoublesEqual(modelParams[i].aaRevMatDir[0], modelParams[i].aaRevMatDir[j], 0.00001) == NO)
4835 MrBayesPrint ("%s Setting Aarevmatpr to Dirichlet(%1.2lf,%1.2lf,...)\n", spacer,
4836 modelParams[i].aaRevMatDir[0], modelParams[i].aaRevMatDir[0]);
4839 MrBayesPrint ("%s Setting Aarevmatpr to Dirichlet(\n", spacer);
4840 for (j=0; j<190; j++)
4843 MrBayesPrint ("%s ", spacer);
4844 MrBayesPrint ("%1.2lf", modelParams[i].aaRevMatDir[j]);
4846 MrBayesPrint (")\n");
4847 else if ((j+1) % 10 == 0)
4848 MrBayesPrint (",\n");
4856 for (j=0; j<190; j++)
4857 if (AreDoublesEqual(modelParams[i].aaRevMatDir[0], modelParams[i].aaRevMatDir[j], 0.00001) == NO)
4860 MrBayesPrint ("%s Setting Aarevmatpr to Dirichlet(%1.2lf,%1.2lf,...) for partition %d\n",
4861 spacer, modelParams[i].aaRevMatDir[0], modelParams[i].aaRevMatDir[0], i+1);
4864 MrBayesPrint ("%s Setting Aarevmatpr to Dirichlet(\n", spacer);
4865 for (j=0; j<190; j++)
4868 MrBayesPrint ("%s ", spacer);
4869 MrBayesPrint ("%1.2lf", modelParams[i].aaRevMatDir[j]);
4871 MrBayesPrint (")\n");
4872 else if ((j+1) % 10 == 0)
4873 MrBayesPrint (",\n");
4878 MrBayesPrint ("%s for partition %d\n", spacer, i+1);
4881 else if (!strcmp(modelParams[i].aaRevMatPr,"Fixed"))
4883 for (j=0; j<190; j++)
4884 modelParams[i].aaRevMatFix[j] = tempStateFreqs[j];
4885 if (nApplied == 0 && numCurrentDivisions == 1)
4887 for (j=0; j<190; j++)
4888 if (AreDoublesEqual(modelParams[i].aaRevMatFix[0], modelParams[i].aaRevMatFix[j], 0.00001) == NO)
4891 MrBayesPrint ("%s Setting Aarevmatpr to Fixed(%1.2lf,%1.2lf,...)\n", spacer, modelParams[i].aaRevMatFix[0],
4892 modelParams[i].aaRevMatFix[0]);
4895 MrBayesPrint ("%s Setting Aarevmatpr to Fixed(\n", spacer);
4896 for (j=0; j<190; j++)
4899 MrBayesPrint ("%s ", spacer);
4900 MrBayesPrint ("%1.2lf", modelParams[i].aaRevMatFix[j]);
4902 MrBayesPrint (")\n");
4903 else if ((j+1) % 10 == 0)
4904 MrBayesPrint (",\n");
4912 for (j=0; j<190; j++)
4913 if (AreDoublesEqual(modelParams[i].aaRevMatFix[0], modelParams[i].aaRevMatFix[j], 0.00001) == NO)
4916 MrBayesPrint ("%s Setting Aarevmatpr to Fixed(%1.2lf,%1.2lf,...) for partition %d\n", spacer,
4917 modelParams[i].aaRevMatFix[0], modelParams[i].aaRevMatFix[0], i+1);
4920 MrBayesPrint ("%s Setting Aarevmatpr to Fixed(\n", spacer);
4921 for (j=0; j<190; j++)
4924 MrBayesPrint ("%s ", spacer);
4925 MrBayesPrint ("%1.2lf", modelParams[i].aaRevMatFix[j]);
4927 MrBayesPrint (")\n");
4928 else if ((j+1) % 10 == 0)
4929 MrBayesPrint (",\n");
4934 MrBayesPrint ("%s for partition %d\n", spacer, i+1);
4939 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
4944 /* set Revratepr (revSymDirPr) ****************************************************/
4945 else if (!strcmp(parmName, "Revratepr"))
4947 if (expecting == Expecting(EQUALSIGN))
4948 expecting = Expecting(ALPHA);
4949 else if (expecting == Expecting(ALPHA))
4951 if (IsArgValid(tkn, tempStr) == ERROR) /* we only allow symmetric dirichlet prior, so no need to store the value */
4953 MrBayesPrint ("%s Invalid Revratepr argument\n", spacer);
4956 expecting = Expecting(LEFTPAR);
4957 for (i=0; i<numCurrentDivisions; i++)
4960 else if (expecting == Expecting(LEFTPAR))
4962 expecting = Expecting(NUMBER);
4964 else if (expecting == Expecting(NUMBER))
4966 nApplied = NumActiveParts ();
4967 for (i=0; i<numCurrentDivisions; i++)
4969 if (activeParts[i] == YES || nApplied == 0)
4971 sscanf (tkn, "%lf", &tempD);
4974 MrBayesPrint ("%s Symmetric Dirichlet parameter must be positive\n", spacer);
4977 modelParams[i].revMatSymDir = tempD;
4978 if (nApplied == 0 && numCurrentDivisions == 1)
4979 MrBayesPrint ("%s Setting Revratepr to Symmetric Dirichlet(%1.2lf)\n", spacer, modelParams[i].revMatSymDir);
4981 MrBayesPrint ("%s Setting Revratepr to Symmetric Dirichlet(%1.2lf) for partition %d\n", spacer, modelParams[i].revMatSymDir, i+1);
4982 expecting = Expecting(RIGHTPAR);
4986 else if (expecting == Expecting(RIGHTPAR))
4988 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
4993 /* set Omegapr (omegaPr) **************************************************************/
4994 else if (!strcmp(parmName, "Omegapr"))
4996 if (expecting == Expecting(EQUALSIGN))
4997 expecting = Expecting(ALPHA);
4998 else if (expecting == Expecting(ALPHA))
5000 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5002 nApplied = NumActiveParts ();
5004 for (i=0; i<numCurrentDivisions; i++)
5006 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5008 strcpy(modelParams[i].omegaPr, tempStr);
5009 modelParams[i].omegaDir[0] = modelParams[i].omegaDir[1] = 1.0;
5010 modelParams[i].omegaFix = 1.0;
5016 MrBayesPrint ("%s Warning: %s can be set only for partition containing either DNA or RNA data.\
5017 Currently there is no active partition with such data.\n", spacer, parmName);
5023 MrBayesPrint ("%s Invalid Omegapr argument\n", spacer);
5026 expecting = Expecting(LEFTPAR);
5027 for (i=0; i<numCurrentDivisions; i++)
5030 else if (expecting == Expecting(LEFTPAR))
5032 expecting = Expecting(NUMBER);
5034 else if (expecting == Expecting(NUMBER))
5036 nApplied = NumActiveParts ();
5037 for (i=0; i<numCurrentDivisions; i++)
5039 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5041 if (!strcmp(modelParams[i].omegaPr,"Dirichlet"))
5043 sscanf (tkn, "%lf", &tempD);
5044 if (tempD > ALPHA_MAX)
5046 MrBayesPrint ("%s Dirichlet parameter cannot be greater than %1.2lf\n", spacer, ALPHA_MAX);
5049 if (tempD < ALPHA_MIN)
5051 MrBayesPrint ("%s Dirichlet parameter cannot be less than %1.2lf\n", spacer, ALPHA_MIN);
5054 modelParams[i].omegaDir[numVars[i]++] = tempD;
5055 if (numVars[i] == 1)
5056 expecting = Expecting(COMMA);
5059 if (nApplied == 0 && numCurrentDivisions == 1)
5060 MrBayesPrint ("%s Setting Omegapr to Dirichlet(%1.2lf,%1.2lf)\n", spacer, modelParams[i].omegaDir[0], modelParams[i].omegaDir[1]);
5062 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);
5063 expecting = Expecting(RIGHTPAR);
5066 else if (!strcmp(modelParams[i].omegaPr,"Fixed"))
5068 sscanf (tkn, "%lf", &tempD);
5069 modelParams[i].omegaFix = tempD;
5070 if (modelParams[i].omegaFix > KAPPA_MAX)
5072 MrBayesPrint ("%s Omega ratio cannot be greater than %1.2lf\n", spacer, KAPPA_MAX);
5075 if (modelParams[i].omegaFix < 0.0)
5077 MrBayesPrint ("%s Omega ratio cannot be less than %1.2lf\n", spacer, 0.0);
5080 if (nApplied == 0 && numCurrentDivisions == 1)
5081 MrBayesPrint ("%s Setting Omegapr to Fixed(%1.2lf)\n", spacer, modelParams[i].omegaFix);
5083 MrBayesPrint ("%s Setting Omegapr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].omegaFix, i+1);
5084 expecting = Expecting(RIGHTPAR);
5089 else if (expecting == Expecting(COMMA))
5091 expecting = Expecting(NUMBER);
5093 else if (expecting == Expecting(RIGHTPAR))
5095 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5100 /* set Ny98omega1pr (ny98omega1pr) ********************************************************/
5101 else if (!strcmp(parmName, "Ny98omega1pr"))
5103 if (expecting == Expecting(EQUALSIGN))
5104 expecting = Expecting(ALPHA);
5105 else if (expecting == Expecting(ALPHA))
5107 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5109 nApplied = NumActiveParts ();
5111 for (i=0; i<numCurrentDivisions; i++)
5113 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5115 strcpy(modelParams[i].ny98omega1pr, tempStr);
5121 MrBayesPrint ("%s Warning: %s can be set only for partition containing either DNA or RNA data.\
5122 Currently there is no active partition with such data. The setting is ignored.\n", spacer, parmName);
5128 MrBayesPrint ("%s Invalid Ny98omega1pr argument\n", spacer);
5131 expecting = Expecting(LEFTPAR);
5132 for (i=0; i<numCurrentDivisions; i++)
5135 else if (expecting == Expecting(LEFTPAR))
5137 expecting = Expecting(NUMBER);
5139 else if (expecting == Expecting(NUMBER))
5141 nApplied = NumActiveParts ();
5142 for (i=0; i<numCurrentDivisions; i++)
5144 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5146 if (!strcmp(modelParams[i].ny98omega1pr,"Beta"))
5148 sscanf (tkn, "%lf", &tempD);
5149 modelParams[i].ny98omega1Beta[numVars[i]++] = tempD;
5150 if (numVars[i] == 1)
5151 expecting = Expecting(COMMA);
5154 if (modelParams[i].ny98omega1Beta[0] < 0 || modelParams[i].ny98omega1Beta[1] < 0)
5156 MrBayesPrint ("%s Beta parameter should be greater than 0\n", spacer);
5159 if (nApplied == 0 && numCurrentDivisions == 1)
5160 MrBayesPrint ("%s Setting Ny98omega1pr to Beta(%1.2lf,%1.2lf)\n", spacer, modelParams[i].ny98omega1Beta[0], modelParams[i].ny98omega1Beta[1]);
5162 MrBayesPrint ("%s Setting Ny98omega1pr to Beta(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].ny98omega1Beta[0], modelParams[i].ny98omega1Beta[1], i+1);
5163 expecting = Expecting(RIGHTPAR);
5166 else if (!strcmp(modelParams[i].ny98omega1pr,"Fixed"))
5168 sscanf (tkn, "%lf", &tempD);
5169 modelParams[i].ny98omega1Fixed = tempD;
5170 if (nApplied == 0 && numCurrentDivisions == 1)
5171 MrBayesPrint ("%s Setting Ny98omega1pr to Fixed(%1.2lf)\n", spacer, modelParams[i].ny98omega1Fixed);
5173 MrBayesPrint ("%s Setting Ny98omega1pr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].ny98omega1Fixed, i+1);
5174 expecting = Expecting(RIGHTPAR);
5179 else if (expecting == Expecting(COMMA))
5181 expecting = Expecting(NUMBER);
5183 else if (expecting == Expecting(RIGHTPAR))
5185 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5190 /* set Ny98omega3pr (ny98omega3pr) ********************************************************/
5191 else if (!strcmp(parmName, "Ny98omega3pr"))
5193 if (expecting == Expecting(EQUALSIGN))
5194 expecting = Expecting(ALPHA);
5195 else if (expecting == Expecting(ALPHA))
5197 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5199 nApplied = NumActiveParts ();
5201 for (i=0; i<numCurrentDivisions; i++)
5203 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5205 strcpy(modelParams[i].ny98omega3pr, tempStr);
5211 MrBayesPrint ("%s Warning: %s can be set only for partition containing either DNA or RNA data.\
5212 Currently there is no active partition with such data. The setting is ignored.\n", spacer, parmName);
5218 MrBayesPrint ("%s Invalid Ny98omega3pr argument\n", spacer);
5221 expecting = Expecting(LEFTPAR);
5222 for (i=0; i<numCurrentDivisions; i++)
5225 else if (expecting == Expecting(LEFTPAR))
5227 expecting = Expecting(NUMBER);
5229 else if (expecting == Expecting(NUMBER))
5231 nApplied = NumActiveParts ();
5232 for (i=0; i<numCurrentDivisions; i++)
5234 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5236 if (!strcmp(modelParams[i].ny98omega3pr,"Uniform"))
5238 sscanf (tkn, "%lf", &tempD);
5239 modelParams[i].ny98omega3Uni[numVars[i]++] = tempD;
5240 if (numVars[i] == 1)
5241 expecting = Expecting(COMMA);
5244 if (modelParams[i].ny98omega3Uni[0] >= modelParams[i].ny98omega3Uni[1])
5246 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
5249 if (nApplied == 0 && numCurrentDivisions == 1)
5250 MrBayesPrint ("%s Setting Ny98omega3pr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].ny98omega3Uni[0], modelParams[i].ny98omega3Uni[1]);
5252 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);
5253 expecting = Expecting(RIGHTPAR);
5256 else if (!strcmp(modelParams[i].ny98omega3pr,"Exponential"))
5258 sscanf (tkn, "%lf", &tempD);
5259 modelParams[i].ny98omega3Exp = tempD;
5260 if (nApplied == 0 && numCurrentDivisions == 1)
5261 MrBayesPrint ("%s Setting Ny98omega3pr to Exponential(%1.2lf)\n", spacer, modelParams[i].ny98omega3Exp);
5263 MrBayesPrint ("%s Setting Ny98omega3pr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].ny98omega3Exp, i+1);
5264 expecting = Expecting(RIGHTPAR);
5266 else if (!strcmp(modelParams[i].ny98omega3pr,"Fixed"))
5268 sscanf (tkn, "%lf", &tempD);
5269 modelParams[i].ny98omega3Fixed = tempD;
5270 if (nApplied == 0 && numCurrentDivisions == 1)
5271 MrBayesPrint ("%s Setting Ny98omega3pr to Fixed(%1.2lf)\n", spacer, modelParams[i].ny98omega3Fixed);
5273 MrBayesPrint ("%s Setting Ny98omega3pr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].ny98omega3Fixed, i+1);
5274 expecting = Expecting(RIGHTPAR);
5279 else if (expecting == Expecting(COMMA))
5281 expecting = Expecting(NUMBER);
5283 else if (expecting == Expecting(RIGHTPAR))
5285 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5290 /* set M3omegapr (m3omegapr) ********************************************************/
5291 else if (!strcmp(parmName, "M3omegapr"))
5293 if (expecting == Expecting(EQUALSIGN))
5294 expecting = Expecting(ALPHA);
5295 else if (expecting == Expecting(ALPHA))
5297 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5299 nApplied = NumActiveParts ();
5301 for (i=0; i<numCurrentDivisions; i++)
5303 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5305 strcpy(modelParams[i].m3omegapr, tempStr);
5311 MrBayesPrint ("%s Warning: %s can be set only for partition containing either DNA or RNA data.\
5312 Currently there is no active partition with such data. The setting is ignored.\n", spacer, parmName);
5318 MrBayesPrint ("%s Invalid M3omegapr argument\n", spacer);
5321 for (i=0; i<numCurrentDivisions; i++)
5323 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5325 if (!strcmp(modelParams[i].m3omegapr,"Exponential"))
5327 if (nApplied == 0 && numCurrentDivisions == 1)
5328 MrBayesPrint ("%s Setting M3omegapr to Exponential\n", spacer);
5330 MrBayesPrint ("%s Setting M3omegapr to Exponential for partition %d\n", spacer, i+1);
5331 expecting = Expecting(RIGHTPAR);
5335 if (!strcmp(tempStr,"Exponential"))
5336 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5338 expecting = Expecting(LEFTPAR);
5339 for (i=0; i<numCurrentDivisions; i++)
5342 else if (expecting == Expecting(LEFTPAR))
5344 expecting = Expecting(NUMBER);
5346 else if (expecting == Expecting(NUMBER))
5348 nApplied = NumActiveParts ();
5349 for (i=0; i<numCurrentDivisions; i++)
5351 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5353 if (!strcmp(modelParams[i].m3omegapr,"Fixed"))
5355 sscanf (tkn, "%lf", &tempD);
5356 modelParams[i].m3omegaFixed[numVars[i]++] = tempD;
5357 if (numVars[i] == 1 || numVars[i] == 2)
5358 expecting = Expecting(COMMA);
5361 if (modelParams[i].m3omegaFixed[0] >= modelParams[i].m3omegaFixed[1] || modelParams[i].m3omegaFixed[0] >= modelParams[i].m3omegaFixed[2] || modelParams[i].m3omegaFixed[1] >= modelParams[i].m3omegaFixed[2])
5363 MrBayesPrint ("%s The three omega values must be ordered, such that omega1 < omega2 < omega3\n", spacer);
5366 if (nApplied == 0 && numCurrentDivisions == 1)
5367 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]);
5369 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);
5370 expecting = Expecting(RIGHTPAR);
5376 else if (expecting == Expecting(COMMA))
5378 expecting = Expecting(NUMBER);
5380 else if (expecting == Expecting(RIGHTPAR))
5382 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5387 /* set Codoncatfreqs (codonCatFreqPr) ********************************************************/
5388 else if (!strcmp(parmName, "Codoncatfreqs"))
5390 if (expecting == Expecting(EQUALSIGN))
5391 expecting = Expecting(ALPHA);
5392 else if (expecting == Expecting(ALPHA))
5394 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5396 nApplied = NumActiveParts ();
5398 for (i=0; i<numCurrentDivisions; i++)
5400 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5402 strcpy(modelParams[i].codonCatFreqPr, tempStr);
5408 MrBayesPrint ("%s Warning: %s can be set only for partition containing either DNA or RNA data.\
5409 Currently there is no active partition with such data. The setting is ignored.\n", spacer, parmName);
5415 MrBayesPrint ("%s Invalid Omegapurpr argument\n", spacer);
5418 expecting = Expecting(LEFTPAR);
5419 for (i=0; i<numCurrentDivisions; i++)
5422 else if (expecting == Expecting(LEFTPAR))
5424 expecting = Expecting(NUMBER);
5426 else if (expecting == Expecting(NUMBER))
5428 nApplied = NumActiveParts ();
5429 for (i=0; i<numCurrentDivisions; i++)
5431 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5433 if (!strcmp(modelParams[i].codonCatFreqPr,"Dirichlet"))
5435 sscanf (tkn, "%lf", &tempD);
5436 modelParams[i].codonCatDir[numVars[i]++] = tempD;
5437 if (numVars[i] == 1 || numVars[i] == 2)
5438 expecting = Expecting(COMMA);
5441 if (nApplied == 0 && numCurrentDivisions == 1)
5442 MrBayesPrint ("%s Setting Codoncatfreqs prior to Dirichlet(%1.2lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].codonCatDir[0], modelParams[i].codonCatDir[1], modelParams[i].codonCatDir[2]);
5444 MrBayesPrint ("%s Setting Codoncatfreqs prior to Dirichlet(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].codonCatDir[0], modelParams[i].codonCatDir[1], modelParams[i].codonCatDir[2], i+1);
5445 expecting = Expecting(RIGHTPAR);
5448 else if (!strcmp(modelParams[i].codonCatFreqPr,"Fixed"))
5450 sscanf (tkn, "%lf", &tempD);
5451 modelParams[i].codonCatFreqFix[numVars[i]++] = tempD;
5452 if (numVars[i] == 1 || numVars[i] == 2)
5453 expecting = Expecting(COMMA);
5456 if (AreDoublesEqual (modelParams[i].codonCatFreqFix[0] + modelParams[i].codonCatFreqFix[1] + modelParams[i].codonCatFreqFix[2], (MrBFlt) 1.0, (MrBFlt) 0.001) == NO)
5458 MrBayesPrint ("%s Codon category frequencies must sum to 1\n", spacer);
5462 if (nApplied == 0 && numCurrentDivisions == 1)
5463 MrBayesPrint ("%s Setting Codoncatfreqs prior to Fixed(%1.2lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].codonCatFreqFix[0], modelParams[i].codonCatFreqFix[1], modelParams[i].codonCatFreqFix[2]);
5465 MrBayesPrint ("%s Setting Codoncatfreqs prior to Fixed(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].codonCatFreqFix[0], modelParams[i].codonCatFreqFix[1], modelParams[i].codonCatFreqFix[2], i+1);
5466 expecting = Expecting(RIGHTPAR);
5472 else if (expecting == Expecting(COMMA))
5474 expecting = Expecting(NUMBER);
5476 else if (expecting == Expecting(RIGHTPAR))
5478 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5484 /* set Shapepr (shapePr) **************************************************************/
5485 else if (!strcmp(parmName, "Shapepr"))
5487 if (expecting == Expecting(EQUALSIGN))
5488 expecting = Expecting(ALPHA);
5489 else if (expecting == Expecting(ALPHA))
5491 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5493 nApplied = NumActiveParts ();
5495 for (i=0; i<numCurrentDivisions; i++)
5497 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA || modelParams[i].dataType == PROTEIN || modelParams[i].dataType == RESTRICTION || modelParams[i].dataType == STANDARD))
5499 strcpy(modelParams[i].shapePr, tempStr);
5505 MrBayesPrint ("%s Warning: %s can be set only for partition containing data of at least one of following type: DNA, RNA, PROTEIN, RESTRICTION, STANDARD.\
5506 Currently there is no active partition with such data.\n", spacer, parmName);
5512 MrBayesPrint ("%s Invalid Shapepr argument\n", spacer);
5515 expecting = Expecting(LEFTPAR);
5516 for (i=0; i<numCurrentDivisions; i++)
5519 else if (expecting == Expecting(LEFTPAR))
5521 expecting = Expecting(NUMBER);
5523 else if (expecting == Expecting(NUMBER))
5525 nApplied = NumActiveParts ();
5526 for (i=0; i<numCurrentDivisions; i++)
5528 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA || modelParams[i].dataType == PROTEIN || modelParams[i].dataType == RESTRICTION || modelParams[i].dataType == STANDARD))
5530 if (!strcmp(modelParams[i].shapePr,"Uniform"))
5532 sscanf (tkn, "%lf", &tempD);
5533 modelParams[i].shapeUni[numVars[i]++] = tempD;
5534 if (numVars[i] == 1)
5535 expecting = Expecting(COMMA);
5538 if (modelParams[i].shapeUni[0] >= modelParams[i].shapeUni[1])
5540 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
5543 if (modelParams[i].shapeUni[1] > MAX_SHAPE_PARAM)
5545 MrBayesPrint ("%s Upper value for uniform cannot be greater than %1.2lf\n", spacer, MAX_SHAPE_PARAM);
5548 if (modelParams[i].shapeUni[0] < MIN_SHAPE_PARAM)
5550 MrBayesPrint ("%s Lower value for uniform cannot be less than %1.2lf\n", spacer, MIN_SHAPE_PARAM);
5553 if (nApplied == 0 && numCurrentDivisions == 1)
5554 MrBayesPrint ("%s Setting Shapepr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].shapeUni[0], modelParams[i].shapeUni[1]);
5556 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);
5557 expecting = Expecting(RIGHTPAR);
5560 else if (!strcmp(modelParams[i].shapePr,"Exponential"))
5562 sscanf (tkn, "%lf", &tempD);
5563 modelParams[i].shapeExp = tempD;
5564 if (nApplied == 0 && numCurrentDivisions == 1)
5565 MrBayesPrint ("%s Setting Shapepr to Exponential(%1.2lf)\n", spacer, modelParams[i].shapeExp);
5567 MrBayesPrint ("%s Setting Shapepr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].shapeExp, i+1);
5568 expecting = Expecting(RIGHTPAR);
5570 else if (!strcmp(modelParams[i].shapePr,"Fixed"))
5572 sscanf (tkn, "%lf", &tempD);
5573 modelParams[i].shapeFix = tempD;
5574 if (modelParams[i].shapeFix > MAX_SHAPE_PARAM)
5576 MrBayesPrint ("%s Shape parameter cannot be greater than %1.2lf\n", spacer, MAX_SHAPE_PARAM);
5579 if (modelParams[i].shapeFix < MIN_SHAPE_PARAM)
5581 MrBayesPrint ("%s Shape parameter cannot be less than %1.2lf\n", spacer, MIN_SHAPE_PARAM);
5584 if (nApplied == 0 && numCurrentDivisions == 1)
5585 MrBayesPrint ("%s Setting Shapepr to Fixed(%1.2lf)\n", spacer, modelParams[i].shapeFix);
5587 MrBayesPrint ("%s Setting Shapepr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].shapeFix, i+1);
5588 expecting = Expecting(RIGHTPAR);
5593 else if (expecting == Expecting(COMMA))
5595 expecting = Expecting(NUMBER);
5597 else if (expecting == Expecting(RIGHTPAR))
5599 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5604 /* set Pinvarpr (pInvarPr) ************************************************************/
5605 else if (!strcmp(parmName, "Pinvarpr"))
5607 if (expecting == Expecting(EQUALSIGN))
5608 expecting = Expecting(ALPHA);
5609 else if (expecting == Expecting(ALPHA))
5611 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5613 nApplied = NumActiveParts ();
5615 for (i=0; i<numCurrentDivisions; i++)
5617 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA || modelParams[i].dataType == PROTEIN))
5619 strcpy(modelParams[i].pInvarPr, tempStr);
5625 MrBayesPrint ("%s Warning: %s can be set only for partition containing data of at least one of the following type: DNA, RNA, PROTEIN.\
5626 Currently there is no active partition with such data.\n", spacer, parmName);
5632 MrBayesPrint ("%s Invalid Pinvarpr argument\n", spacer);
5635 expecting = Expecting(LEFTPAR);
5636 for (i=0; i<numCurrentDivisions; i++)
5639 else if (expecting == Expecting(LEFTPAR))
5641 expecting = Expecting(NUMBER);
5643 else if (expecting == Expecting(NUMBER))
5645 nApplied = NumActiveParts ();
5646 for (i=0; i<numCurrentDivisions; i++)
5648 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA || modelParams[i].dataType == PROTEIN))
5650 if (!strcmp(modelParams[i].pInvarPr,"Uniform"))
5652 sscanf (tkn, "%lf", &tempD);
5653 modelParams[i].pInvarUni[numVars[i]++] = tempD;
5654 if (numVars[i] == 1)
5655 expecting = Expecting(COMMA);
5658 if (modelParams[i].pInvarUni[0] >= modelParams[i].pInvarUni[1])
5660 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
5663 if (modelParams[i].pInvarUni[1] > 1.0)
5665 MrBayesPrint ("%s Upper value for uniform should be less than or equal to 1.0\n", spacer);
5668 if (nApplied == 0 && numCurrentDivisions == 1)
5669 MrBayesPrint ("%s Setting Pinvarpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].pInvarUni[0], modelParams[i].pInvarUni[1]);
5671 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);
5672 expecting = Expecting(RIGHTPAR);
5675 else if (!strcmp(modelParams[i].pInvarPr,"Fixed"))
5677 sscanf (tkn, "%lf", &tempD);
5680 MrBayesPrint ("%s Value for Pinvar should be in the interval (0, 1)\n", spacer);
5683 modelParams[i].pInvarFix = tempD;
5684 if (nApplied == 0 && numCurrentDivisions == 1)
5685 MrBayesPrint ("%s Setting Pinvarpr to Fixed(%1.2lf)\n", spacer, modelParams[i].pInvarFix);
5687 MrBayesPrint ("%s Setting Pinvarpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].pInvarFix, i+1);
5688 expecting = Expecting(RIGHTPAR);
5693 else if (expecting == Expecting(COMMA))
5695 expecting = Expecting(NUMBER);
5697 else if (expecting == Expecting(RIGHTPAR))
5699 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5704 /* set Ratecorrpr (adGammaCorPr) ******************************************************/
5705 else if (!strcmp(parmName, "Ratecorrpr"))
5707 if (expecting == Expecting(EQUALSIGN))
5708 expecting = Expecting(ALPHA);
5709 else if (expecting == Expecting(ALPHA))
5711 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5713 nApplied = NumActiveParts ();
5715 for (i=0; i<numCurrentDivisions; i++)
5717 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5719 strcpy(modelParams[i].adGammaCorPr, tempStr);
5725 MrBayesPrint ("%s Warning: %s can be set only for partition containing data of at least one of the following type: DNA, RNA.\
5726 Currently there is no active partition with such data.\n", spacer, parmName);
5732 MrBayesPrint ("%s Invalid Ratecorrpr argument\n", spacer);
5735 expecting = Expecting(LEFTPAR);
5736 for (i=0; i<numCurrentDivisions; i++)
5740 else if (expecting == Expecting(LEFTPAR))
5742 expecting = Expecting(NUMBER) | Expecting(DASH);
5744 else if (expecting == Expecting(NUMBER))
5746 nApplied = NumActiveParts ();
5747 for (i=0; i<numCurrentDivisions; i++)
5749 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
5751 if (!strcmp(modelParams[i].adGammaCorPr,"Uniform"))
5753 sscanf (tkn, "%lf", &tempD);
5754 if (foundDash == YES)
5756 modelParams[i].corrUni[numVars[i]++] = tempD;
5757 if (numVars[i] == 1)
5758 expecting = Expecting(COMMA);
5761 if (modelParams[i].corrUni[0] >= modelParams[i].corrUni[1])
5763 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
5766 if (modelParams[i].corrUni[1] > 1.0)
5768 MrBayesPrint ("%s Upper value for uniform should be less than or equal to 1.0\n", spacer);
5771 if (modelParams[i].corrUni[0] < -1.0)
5773 MrBayesPrint ("%s Lower value for uniform should be greater than or equal to -1.0\n", spacer);
5776 if (nApplied == 0 && numCurrentDivisions == 1)
5777 MrBayesPrint ("%s Setting Ratecorrpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].corrUni[0], modelParams[i].corrUni[1]);
5779 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);
5780 expecting = Expecting(RIGHTPAR);
5783 else if (!strcmp(modelParams[i].adGammaCorPr,"Fixed"))
5785 sscanf (tkn, "%lf", &tempD);
5786 if (foundDash == YES)
5788 if (tempD > 1.0 || tempD < -1.0)
5790 MrBayesPrint ("%s Value for Ratecorrpr should be in the interval (-1, +1)\n", spacer);
5793 modelParams[i].corrFix = tempD;
5794 if (nApplied == 0 && numCurrentDivisions == 1)
5795 MrBayesPrint ("%s Setting Ratecorrpr to Fixed(%1.2lf)\n", spacer, modelParams[i].corrFix);
5797 MrBayesPrint ("%s Setting Ratecorrpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].corrFix, i+1);
5798 expecting = Expecting(RIGHTPAR);
5804 else if (expecting == Expecting(DASH))
5807 expecting = Expecting(NUMBER);
5809 else if (expecting == Expecting(COMMA))
5811 expecting = Expecting(NUMBER) | Expecting(DASH);
5813 else if (expecting == Expecting(RIGHTPAR))
5815 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5820 /* set Browncorrpr (brownCorPr) ******************************************************/
5821 else if (!strcmp(parmName, "Browncorrpr"))
5823 if (expecting == Expecting(EQUALSIGN))
5824 expecting = Expecting(ALPHA);
5825 else if (expecting == Expecting(ALPHA))
5827 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5829 nApplied = NumActiveParts ();
5831 for (i=0; i<numCurrentDivisions; i++)
5833 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType == CONTINUOUS)
5835 strcpy(modelParams[i].brownCorPr, tempStr);
5841 MrBayesPrint ("%s Warning: %s can be set only for partition containing CONTINUOUS data.\
5842 Currently there is no active partition with such data.\n", spacer, parmName);
5848 MrBayesPrint ("%s Invalid Browncorrpr argument\n", spacer);
5851 expecting = Expecting(LEFTPAR);
5852 for (i=0; i<numCurrentDivisions; i++)
5856 else if (expecting == Expecting(LEFTPAR))
5858 expecting = Expecting(NUMBER) | Expecting(DASH);
5860 else if (expecting == Expecting(NUMBER))
5862 nApplied = NumActiveParts ();
5863 for (i=0; i<numCurrentDivisions; i++)
5865 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType == CONTINUOUS)
5867 if (!strcmp(modelParams[i].brownCorPr,"Uniform"))
5869 sscanf (tkn, "%lf", &tempD);
5870 if (foundDash == YES)
5872 modelParams[i].brownCorrUni[numVars[i]++] = tempD;
5873 if (numVars[i] == 1)
5874 expecting = Expecting(COMMA);
5877 if (modelParams[i].brownCorrUni[0] >= modelParams[i].brownCorrUni[1])
5879 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
5882 if (modelParams[i].brownCorrUni[1] > 1.0)
5884 MrBayesPrint ("%s Upper value for uniform should be less than or equal to 1.0\n", spacer);
5887 if (modelParams[i].brownCorrUni[0] < -1.0)
5889 MrBayesPrint ("%s Lower value for uniform should be greater than or equal to -1.0\n", spacer);
5892 if (nApplied == 0 && numCurrentDivisions == 1)
5893 MrBayesPrint ("%s Setting Browncorrpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].brownCorrUni[0], modelParams[i].brownCorrUni[1]);
5895 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);
5896 expecting = Expecting(RIGHTPAR);
5899 else if (!strcmp(modelParams[i].brownCorPr,"Fixed"))
5901 sscanf (tkn, "%lf", &tempD);
5902 if (foundDash == YES)
5904 if (tempD > 1.0 || tempD < -1.0)
5906 MrBayesPrint ("%s Value for Browncorrpr should be in the interval (-1, +1)\n", spacer);
5909 modelParams[i].brownCorrFix = tempD;
5910 if (nApplied == 0 && numCurrentDivisions == 1)
5911 MrBayesPrint ("%s Setting Browncorrpr to Fixed(%1.2lf)\n", spacer, modelParams[i].brownCorrFix);
5913 MrBayesPrint ("%s Setting Browncorrpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].brownCorrFix, i+1);
5914 expecting = Expecting(RIGHTPAR);
5920 else if (expecting == Expecting(DASH))
5923 expecting = Expecting(NUMBER);
5925 else if (expecting == Expecting(COMMA))
5927 expecting = Expecting(NUMBER) | Expecting(DASH);
5929 else if (expecting == Expecting(RIGHTPAR))
5931 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5936 /* set Ratepr (ratePr) *****************************************************************/
5937 else if (!strcmp(parmName, "Ratepr"))
5939 if (expecting == Expecting(EQUALSIGN))
5940 expecting = Expecting(ALPHA);
5941 else if (expecting == Expecting(ALPHA))
5943 if (IsArgValid(tkn, tempStr) == NO_ERROR)
5945 nApplied = NumActiveParts ();
5946 for (i=0; i<numCurrentDivisions; i++)
5948 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
5950 if (!strcmp(tempStr,"Variable"))
5951 strcpy(modelParams[i].ratePr, "Dirichlet");
5953 strcpy(modelParams[i].ratePr, tempStr);
5954 modelParams[i].ratePrDir = 1.0;
5955 if (!strcmp(tempStr,"Variable") || !strcmp(tempStr,"Fixed"))
5957 if (tempStr[0]=='V')
5958 strcat (tempStr," [Dirichlet(..,1,..)]");
5959 if (nApplied == 0 && numCurrentDivisions == 1)
5960 MrBayesPrint ("%s Setting Ratepr to %s\n", spacer, tempStr);
5962 MrBayesPrint ("%s Setting Ratepr to %s for partition %d\n", spacer, tempStr, i+1);
5963 if (tempStr[0]=='V')
5964 strcpy (tempStr,"Variable");
5971 MrBayesPrint ("%s Invalid Ratepr argument\n", spacer);
5974 if (!strcmp(tempStr,"Fixed") || !strcmp(tempStr,"Variable"))
5975 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
5977 expecting = Expecting(LEFTPAR);
5978 for (i=0; i<numCurrentDivisions; i++)
5981 else if (expecting == Expecting(LEFTPAR))
5983 expecting = Expecting (NUMBER);
5985 else if (expecting == Expecting(NUMBER))
5987 /* find next partition to fill in */
5988 nApplied = NumActiveParts ();
5989 for (i=0; i<numCurrentDivisions; i++)
5990 if ((activeParts[i] == YES || nApplied == 0) && numVars[i] == 0)
5992 if (i == numCurrentDivisions)
5994 MrBayesPrint ("%s Could not find first ratemultiplier partition\n", spacer);
5998 /* read in the parameter */
5999 sscanf (tkn, "%lf", &tempD);
6000 if (tempD < ALPHA_MIN || tempD > ALPHA_MAX)
6002 MrBayesPrint ("%s Ratemultiplier Dirichlet parameter %lf out of range\n", spacer, tempD);
6005 /* set the parameter */
6006 modelParams[i].ratePrDir = tempD;
6007 /* check if all partitions have been filled in */
6008 for (i=0; i<numCurrentDivisions; i++)
6010 if ((activeParts[i] == YES || nApplied == 0) && numVars[i] == 0)
6013 /* set expecting accordingly so that we know what should be coming next */
6014 if (i == numCurrentDivisions)
6015 expecting = Expecting (RIGHTPAR);
6017 expecting = Expecting (COMMA);
6019 else if (expecting == Expecting (COMMA))
6020 expecting = Expecting (NUMBER);
6021 else if (expecting == Expecting (RIGHTPAR))
6024 for (i=j=0; i<numCurrentDivisions; i++)
6026 if (numVars[i] == 1)
6031 MrBayesPrint ("%s Setting Ratepr to Dirichlet(%1.2f",
6032 spacer, modelParams[i].ratePrDir);
6035 MrBayesPrint(",%1.2f", modelParams[i].ratePrDir);
6038 if (numCurrentDivisions == 1)
6039 MrBayesPrint (")\n");
6042 MrBayesPrint (") for partition");
6045 for (i=k=0; i<numCurrentDivisions; i++)
6047 if (numVars[i] == 1)
6050 if (k == j && j > 1)
6051 MrBayesPrint (", and %d", i+1);
6053 MrBayesPrint (" %d", i+1);
6055 MrBayesPrint (", %d", i+1);
6058 MrBayesPrint ("\n");
6060 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6065 /* set Generatepr (generatePr) *****************************************************************/
6066 else if (!strcmp(parmName, "Generatepr"))
6068 if (expecting == Expecting(EQUALSIGN))
6069 expecting = Expecting(ALPHA);
6070 else if (expecting == Expecting(ALPHA))
6072 if (IsArgValid(tkn, tempStr) == NO_ERROR)
6074 nApplied = NumActiveParts ();
6075 for (i=0; i<numCurrentDivisions; i++)
6077 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
6079 if (!strcmp(tempStr,"Variable"))
6080 strcpy(modelParams[i].generatePr, "Dirichlet");
6082 strcpy(modelParams[i].generatePr, tempStr);
6083 modelParams[i].generatePrDir = 1.0;
6084 if (!strcmp(tempStr,"Variable") || !strcmp(tempStr,"Fixed"))
6086 if (tempStr[0]=='V')
6087 strcat (tempStr," [Dirichlet(..,1,..)]");
6088 if (nApplied == 0 && numCurrentDivisions == 1)
6089 MrBayesPrint ("%s Setting Generatepr to %s\n", spacer, tempStr);
6091 MrBayesPrint ("%s Setting Generatepr to %s for partition %d\n", spacer, tempStr, i+1);
6092 if (tempStr[0]=='V')
6093 strcpy (tempStr,"Variable");
6100 MrBayesPrint ("%s Invalid Generatepr argument\n", spacer);
6103 if (!strcmp(tempStr,"Fixed") || !strcmp(tempStr,"Variable"))
6104 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6106 expecting = Expecting(LEFTPAR);
6107 for (i=0; i<numCurrentDivisions; i++)
6110 else if (expecting == Expecting(LEFTPAR))
6112 expecting = Expecting (NUMBER);
6114 else if (expecting == Expecting(NUMBER))
6116 /* find next partition to fill in */
6117 nApplied = NumActiveParts ();
6118 for (i=0; i<numCurrentDivisions; i++)
6119 if ((activeParts[i] == YES || nApplied == 0) && numVars[i] == 0)
6121 if (i == numCurrentDivisions)
6123 MrBayesPrint ("%s Could not find first generate multiplier partition\n", spacer);
6127 /* read in the parameter */
6128 sscanf (tkn, "%lf", &tempD);
6129 if (tempD < ALPHA_MIN || tempD > ALPHA_MAX)
6131 MrBayesPrint ("%s Generate multiplier Dirichlet parameter %lf out of range\n", spacer, tempD);
6134 /* set the parameter */
6135 modelParams[i].generatePrDir = tempD;
6136 /* check if all partitions have been filled in */
6137 for (i=0; i<numCurrentDivisions; i++)
6139 if ((activeParts[i] == YES || nApplied == 0) && numVars[i] == 0)
6142 /* set expecting accordingly so that we know what should be coming next */
6143 if (i == numCurrentDivisions)
6144 expecting = Expecting (RIGHTPAR);
6146 expecting = Expecting (COMMA);
6148 else if (expecting == Expecting (COMMA))
6149 expecting = Expecting (NUMBER);
6150 else if (expecting == Expecting (RIGHTPAR))
6153 for (i=j=0; i<numCurrentDivisions; i++)
6155 if (numVars[i] == 1)
6160 MrBayesPrint ("%s Setting Generatepr to Dirichlet(%1.2f",
6161 spacer, modelParams[i].generatePrDir);
6164 MrBayesPrint(",%1.2f", modelParams[i].generatePrDir);
6167 if (numCurrentDivisions == 1)
6168 MrBayesPrint (")\n");
6171 MrBayesPrint (") for partition");
6174 for (i=k=0; i<numCurrentDivisions; i++)
6176 if (numVars[i] == 1)
6179 if (k == j && j > 1)
6180 MrBayesPrint (", and %d", i+1);
6182 MrBayesPrint (" %d", i+1);
6184 MrBayesPrint (", %d", i+1);
6187 MrBayesPrint ("\n");
6189 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6194 /* set Covswitchpr (covSwitchPr) ******************************************************/
6195 else if (!strcmp(parmName, "Covswitchpr"))
6197 if (expecting == Expecting(EQUALSIGN))
6198 expecting = Expecting(ALPHA);
6199 else if (expecting == Expecting(ALPHA))
6201 if (IsArgValid(tkn, tempStr) == NO_ERROR)
6203 nApplied = NumActiveParts ();
6205 for (i=0; i<numCurrentDivisions; i++)
6207 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA || modelParams[i].dataType == PROTEIN))
6209 strcpy(modelParams[i].covSwitchPr, tempStr);
6215 MrBayesPrint ("%s Warning: %s can be set only for partition containing data of at least one of the following type: DNA, RNA, PROTEIN.\
6216 Currently there is no active partition with such data. ", spacer, parmName);
6222 MrBayesPrint ("%s Invalid Covswitchpr argument\n", spacer);
6225 expecting = Expecting(LEFTPAR);
6226 for (i=0; i<numCurrentDivisions; i++)
6229 else if (expecting == Expecting(LEFTPAR))
6231 expecting = Expecting(NUMBER);
6233 else if (expecting == Expecting(NUMBER))
6235 nApplied = NumActiveParts ();
6236 for (i=0; i<numCurrentDivisions; i++)
6238 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA || modelParams[i].dataType == PROTEIN))
6240 if (!strcmp(modelParams[i].covSwitchPr,"Uniform"))
6242 sscanf (tkn, "%lf", &tempD);
6243 modelParams[i].covswitchUni[numVars[i]++] = tempD;
6244 if (numVars[i] == 1)
6245 expecting = Expecting(COMMA);
6248 if (modelParams[i].covswitchUni[0] >= modelParams[i].covswitchUni[1])
6250 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
6253 if (nApplied == 0 && numCurrentDivisions == 1)
6254 MrBayesPrint ("%s Setting Covswitchpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].covswitchUni[0], modelParams[i].covswitchUni[1]);
6256 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);
6257 expecting = Expecting(RIGHTPAR);
6260 else if (!strcmp(modelParams[i].covSwitchPr,"Exponential"))
6262 sscanf (tkn, "%lf", &tempD);
6263 modelParams[i].covswitchExp = tempD;
6264 if (nApplied == 0 && numCurrentDivisions == 1)
6265 MrBayesPrint ("%s Setting Covswitchpr to Exponential(%1.2lf)\n", spacer, modelParams[i].covswitchExp);
6267 MrBayesPrint ("%s Setting Covswitchpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].covswitchExp, i+1);
6268 expecting = Expecting(RIGHTPAR);
6270 else if (!strcmp(modelParams[i].covSwitchPr,"Fixed"))
6272 sscanf (tkn, "%lf", &tempD);
6273 modelParams[i].covswitchFix[numVars[i]++] = tempD;
6274 if (numVars[i] == 1)
6275 expecting = Expecting(COMMA);
6278 if (nApplied == 0 && numCurrentDivisions == 1)
6279 MrBayesPrint ("%s Setting Covswitchpr to Fixed(%1.4lf,%1.4lf)\n", spacer, modelParams[i].covswitchFix[0], modelParams[i].covswitchFix[1]);
6281 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);
6282 expecting = Expecting(RIGHTPAR);
6288 else if (expecting == Expecting(COMMA))
6290 expecting = Expecting(NUMBER);
6292 else if (expecting == Expecting(RIGHTPAR))
6294 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6299 /* set Symdirihyperpr (symPiPr) ******************************************************/
6300 else if (!strcmp(parmName, "Symdirihyperpr"))
6302 if (expecting == Expecting(EQUALSIGN))
6305 expecting = Expecting(ALPHA);
6307 else if (expecting == Expecting(ALPHA))
6309 if (foundBeta == NO)
6311 /* expecting to see Uniform, Exponential, or Fixed */
6312 if (IsArgValid(tkn, tempStr) == NO_ERROR)
6314 nApplied = NumActiveParts ();
6316 for (i=0; i<numCurrentDivisions; i++)
6318 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == STANDARD || modelParams[i].dataType == RESTRICTION))
6320 strcpy(modelParams[i].symPiPr, tempStr);
6326 MrBayesPrint ("%s Warning: %s can be set only for partition containing data", spacer, parmName);
6327 MrBayesPrint (" of at least one of the following type: STANDARD, RESTRICTION.");
6328 MrBayesPrint ("Currently there is no active partition with such data. ");
6334 MrBayesPrint ("%s Invalid Symdirihyperpr argument\n", spacer);
6337 expecting = Expecting(LEFTPAR);
6338 for (i=0; i<numCurrentDivisions; i++)
6344 /* expecting infinity */
6345 if (IsSame("Infinity", tkn) == SAME || IsSame("Infinity", tkn) == CONSISTENT_WITH)
6347 nApplied = NumActiveParts ();
6348 for (i=0; i<numCurrentDivisions; i++)
6350 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == STANDARD || modelParams[i].dataType == RESTRICTION))
6352 if (!strcmp(modelParams[i].symPiPr, "Fixed"))
6354 modelParams[i].symBetaFix = -1;
6355 if (nApplied == 0 && numCurrentDivisions == 1)
6356 MrBayesPrint ("%s Setting Symdirihyperpr to Beta(Infinity)\n", spacer);
6358 MrBayesPrint ("%s Setting Symdirihyperpr to Beta(Infinity) for partition %d\n", spacer, i+1);
6359 expecting = Expecting(RIGHTPAR);
6363 MrBayesPrint ("%s Problem setting Symdirihyperpr\n", spacer);
6368 expecting = Expecting(RIGHTPAR);
6372 else if (expecting == Expecting(LEFTPAR))
6374 expecting = Expecting(NUMBER) | Expecting(ALPHA);
6376 else if (expecting == Expecting(NUMBER))
6378 nApplied = NumActiveParts ();
6379 for (i=0; i<numCurrentDivisions; i++)
6381 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == STANDARD || modelParams[i].dataType == RESTRICTION))
6383 if (!strcmp(modelParams[i].symPiPr,"Fixed"))
6385 sscanf (tkn, "%lf", &tempD);
6386 modelParams[i].symBetaFix = tempD;
6387 if (nApplied == 0 && numCurrentDivisions == 1)
6388 MrBayesPrint ("%s Setting Symdirihyperpr to Fixed(%1.2lf)\n", spacer, modelParams[i].symBetaFix);
6390 MrBayesPrint ("%s Setting Symdirihyperpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].symBetaFix, i+1);
6391 expecting = Expecting(RIGHTPAR);
6393 else if (!strcmp(modelParams[i].symPiPr,"Exponential"))
6395 sscanf (tkn, "%lf", &tempD);
6396 modelParams[i].symBetaExp = tempD;
6397 if (nApplied == 0 && numCurrentDivisions == 1)
6398 MrBayesPrint ("%s Setting Symdirihyperpr to Exponential(%1.2lf)\n", spacer, modelParams[i].symBetaExp);
6400 MrBayesPrint ("%s Setting Symdirihyperpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].symBetaExp, i+1);
6401 expecting = Expecting(RIGHTPAR);
6403 else if (!strcmp(modelParams[i].symPiPr,"Uniform"))
6405 sscanf (tkn, "%lf", &tempD);
6406 modelParams[i].symBetaUni[numVars[i]++] = tempD;
6407 if (numVars[i] == 1)
6408 expecting = Expecting(COMMA);
6411 if (modelParams[i].symBetaUni[0] >= modelParams[i].symBetaUni[1])
6413 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
6416 if (nApplied == 0 && numCurrentDivisions == 1)
6417 MrBayesPrint ("%s Setting Symdirihyperpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].symBetaUni[0], modelParams[i].symBetaUni[1]);
6419 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);
6420 expecting = Expecting(RIGHTPAR);
6425 MrBayesPrint ("%s Problem setting Symdirihyperpr\n", spacer);
6431 else if (expecting == Expecting(COMMA))
6433 expecting = Expecting(NUMBER);
6435 else if (expecting == Expecting(RIGHTPAR))
6437 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6442 /* set Statefreqpr (stateFreqPr) ******************************************************/
6443 else if (!strcmp(parmName, "Statefreqpr"))
6445 if (expecting == Expecting(EQUALSIGN))
6446 expecting = Expecting(ALPHA);
6447 else if (expecting == Expecting(ALPHA))
6449 if (IsSame ("Equal", tkn) == DIFFERENT && IsSame ("Empirical", tkn) == DIFFERENT)
6451 /* the user wants to specify a dirichlet or fixed prior */
6452 if (IsArgValid(tkn, tempStr) == NO_ERROR)
6454 nApplied = NumActiveParts ();
6455 for (i=0; i<numCurrentDivisions; i++)
6457 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
6458 strcpy(modelParams[i].stateFreqPr, tempStr);
6462 MrBayesPrint ("%s Warning: %s can be set only for partition containing CONTINUOUS data.\
6463 Currently there is no active partition with such data. ", spacer, parmName);
6469 MrBayesPrint ("%s Invalid Statefreqpr argument\n", spacer);
6472 /* TODO: Here we set flat dirichlet parameters */
6473 expecting = Expecting(LEFTPAR);
6477 /* the user wants equal or empirical state frequencies */
6478 nApplied = NumActiveParts ();
6479 if (IsSame ("Equal", tkn) == SAME || IsSame ("Equal", tkn) == CONSISTENT_WITH)
6481 for (i=0; i<numCurrentDivisions; i++)
6483 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
6484 strcpy(modelParams[i].stateFreqsFixType, "Equal");
6487 else if (IsSame ("Empirical", tkn) == SAME || IsSame ("Empirical", tkn) == CONSISTENT_WITH)
6489 for (i=0; i<numCurrentDivisions; i++)
6491 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
6492 strcpy(modelParams[i].stateFreqsFixType, "Empirical");
6497 MrBayesPrint ("%s Invalid Statefreqpr delimiter\n", spacer);
6500 expecting = Expecting(RIGHTPAR);
6503 else if (expecting == Expecting(LEFTPAR))
6506 expecting = Expecting(NUMBER) | Expecting(ALPHA);
6508 else if (expecting == Expecting(NUMBER))
6510 nApplied = NumActiveParts ();
6511 sscanf (tkn, "%lf", &tempD);
6512 tempStateFreqs[tempNumStates++] = tempD;
6513 for (i=0; i<numCurrentDivisions; i++)
6515 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
6516 if (!strcmp(modelParams[i].stateFreqPr,"Fixed"))
6517 strcpy(modelParams[i].stateFreqsFixType, "User");
6519 expecting = Expecting(COMMA) | Expecting(RIGHTPAR);
6521 else if (expecting == Expecting(COMMA))
6523 expecting = Expecting(NUMBER);
6525 else if (expecting == Expecting(RIGHTPAR))
6527 nApplied = NumActiveParts ();
6528 for (i=0; i<numCurrentDivisions; i++)
6530 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType != CONTINUOUS)
6533 if (!strcmp(modelParams[i].stateFreqPr,"Dirichlet"))
6535 if (tempNumStates == 1)
6537 for (j=0; j<ns; j++)
6538 modelParams[i].stateFreqsDir[j] = tempStateFreqs[0] / ns;
6539 MrBayesPrint ("%s Setting Statefreqpr to Dirichlet(", spacer);
6540 for (j=0; j<ns; j++)
6542 MrBayesPrint("%1.2lf", modelParams[i].stateFreqsDir[j]);
6548 if (nApplied == 0 && numCurrentDivisions == 1)
6549 MrBayesPrint ("\n");
6551 MrBayesPrint (" for partition %d\n", i+1);
6552 modelParams[i].numDirParams = ns;
6556 if (tempNumStates != ns)
6558 MrBayesPrint ("%s Found %d dirichlet parameters but expecting %d\n", spacer, tempNumStates, modelParams[i].nStates);
6563 modelParams[i].numDirParams = ns;
6564 for (j=0; j<ns; j++)
6565 modelParams[i].stateFreqsDir[j] = tempStateFreqs[j];
6566 MrBayesPrint ("%s Setting Statefreqpr to Dirichlet(", spacer);
6567 for (j=0; j<ns; j++)
6569 MrBayesPrint("%1.2lf", modelParams[i].stateFreqsDir[j]);
6575 if (nApplied == 0 && numCurrentDivisions == 1)
6576 MrBayesPrint ("\n");
6578 MrBayesPrint (" for partition %d\n", i+1);
6582 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed"))
6584 if (tempNumStates == 0)
6586 if (!strcmp(modelParams[i].stateFreqsFixType, "Equal"))
6587 MrBayesPrint ("%s Setting Statefreqpr to Fixed(Equal)", spacer);
6588 else if (!strcmp(modelParams[i].stateFreqsFixType, "Empirical"))
6589 MrBayesPrint ("%s Setting Statefreqpr to Fixed(Empirical)", spacer);
6590 if (nApplied == 0 && numCurrentDivisions == 1)
6591 MrBayesPrint ("\n");
6593 MrBayesPrint (" for partition %d\n", i+1);
6597 if (tempNumStates == ns)
6600 for (j=0; j<ns; j++)
6601 sum += tempStateFreqs[j];
6602 if (AreDoublesEqual (sum, (MrBFlt) 1.0, (MrBFlt) 0.001) == NO)
6604 MrBayesPrint ("%s State frequencies do not sum to 1.0\n", spacer);
6607 strcpy(modelParams[i].stateFreqsFixType, "User");
6608 for (j=0; j<ns; j++)
6609 modelParams[i].stateFreqsFix[j] = tempStateFreqs[j];
6610 MrBayesPrint ("%s Setting Statefreqpr to Fixed(", spacer);
6611 for (j=0; j<ns; j++)
6613 MrBayesPrint("%1.2lf", modelParams[i].stateFreqsFix[j]);
6619 if (nApplied == 0 && numCurrentDivisions == 1)
6620 MrBayesPrint ("\n");
6622 MrBayesPrint (" for partition %d\n", i+1);
6626 MrBayesPrint ("%s Found %d state frequencies but expecting %d\n", spacer, tempNumStates, modelParams[i].nStates);
6634 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6639 /* set Topologypr (topologyPr) ********************************************************/
6640 else if (!strcmp(parmName, "Topologypr"))
6642 if (expecting == Expecting(EQUALSIGN))
6645 expecting = Expecting(ALPHA);
6647 else if (expecting == Expecting(ALPHA))
6649 if (foundEqual == YES)
6651 if (IsArgValid(tkn, tempStr) == NO_ERROR)
6653 /* set topology prior */
6654 nApplied = NumActiveParts ();
6655 for (i=0; i<numCurrentDivisions; i++)
6657 if (activeParts[i] == YES || nApplied == 0)
6659 strcpy(modelParams[i].topologyPr, tempStr);
6660 /* erase previous constraints, if any */
6661 for (j=0; j<numDefinedConstraints; j++)
6662 modelParams[i].activeConstraints[j] = NO;
6663 if (nApplied == 0 && numCurrentDivisions == 1)
6664 MrBayesPrint ("%s Setting Topologypr to %s\n", spacer, modelParams[i].topologyPr);
6666 MrBayesPrint ("%s Setting Topologypr to %s for partition %d\n", spacer, modelParams[i].topologyPr, i+1);
6667 /* adjust branch length prior if necessary */
6668 if (strcmp(modelParams[i].topologyPr,"Fixed") != 0 && strcmp(modelParams[i].brlensPr,"Fixed") == 0)
6670 MrBayesPrint ("%s Resetting Brlenspr to default\n", spacer);
6671 if (strcmp(modelParams[i].clockPr,"Clock") == 0)
6672 strcpy(modelParams[i].brlensPr, "Uniform");
6674 strcpy(modelParams[i].brlensPr, defaultModel.brlensPr);
6681 MrBayesPrint ("%s Invalid Topologypr argument\n", spacer);
6684 /* make sure we know what to do next */
6685 if (!strcmp(tempStr, "Uniform") || !strcmp(tempStr, "Speciestree"))
6686 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6688 expecting = Expecting(LEFTPAR);
6693 /* find out whether we need a tree name or constraint name */
6694 nApplied = NumActiveParts ();
6695 for (i=0; i<numCurrentDivisions; i++)
6696 if (activeParts[i] == YES || nApplied == 0)
6699 if (foundDash == YES) /* we must be collecting constraint numbers */
6701 MrBayesPrint ("%s Expecting a number\n", spacer);
6704 if (!strcmp(modelParams[i].topologyPr,"Constraints"))
6706 /* find constraint number */
6707 if (CheckString (constraintNames, numDefinedConstraints, tkn, &index) == ERROR)
6709 MrBayesPrint ("%s Could not find constraint named %s\n", spacer, tkn);
6712 tempActiveConstraints[index] = YES;
6713 expecting = Expecting(RIGHTPAR);
6714 expecting |= Expecting(COMMA);
6718 /* find tree number */
6719 if (GetUserTreeFromName (&index, tkn) == ERROR)
6721 MrBayesPrint ("%s Could not set fixed topology from user tree '%s'\n", spacer, tkn);
6724 fromI = index + 1; /* fromI is used to hold the index of the user tree, 1-based */
6725 expecting = Expecting(RIGHTPAR);
6729 else if (expecting == Expecting(LEFTPAR))
6731 for (i=0; i<numDefinedConstraints; i++)
6732 tempActiveConstraints[i] = NO;
6734 foundDash = foundComma = NO;
6735 expecting = Expecting(NUMBER) | Expecting(ALPHA);
6737 else if (expecting == Expecting(NUMBER))
6739 /* find out whether we need a tree number or constraint number */
6740 nApplied = NumActiveParts ();
6741 for (i=0; i<numCurrentDivisions; i++)
6742 if (activeParts[i] == YES || nApplied == 0)
6745 if (!strcmp(modelParams[i].topologyPr,"Constraints"))
6747 if (numDefinedConstraints == 0)
6749 MrBayesPrint ("%s No constraints have been defined\n", spacer);
6752 sscanf (tkn, "%d", &tempInt);
6753 if (tempInt > numDefinedConstraints)
6755 MrBayesPrint ("%s Constraint number is too large\n", spacer);
6760 if (foundDash == YES)
6762 MrBayesPrint ("%s Unexpected dash\n", spacer);
6766 tempActiveConstraints[fromI-1] = YES;
6768 else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO)
6771 //for (i=fromI-1; i<toJ; i++)
6772 for (i=fromI; i<toJ; i++)
6773 tempActiveConstraints[i] = YES;
6777 else if (fromI != -1 && toJ == -1 && foundDash == NO && foundComma == YES)
6780 tempActiveConstraints[fromI-1] = YES;
6783 expecting = Expecting(COMMA);
6784 expecting |= Expecting(DASH);
6785 expecting |= Expecting(RIGHTPAR);
6787 else /* if (!strcmp(modelParams[i].topologyPr,"Fixed")) */
6789 if (numUserTrees == 0)
6791 MrBayesPrint ("%s No user trees have been defined\n", spacer);
6794 sscanf (tkn, "%d", &tempInt);
6795 if (tempInt > numUserTrees)
6797 MrBayesPrint ("%s Tree number is too large\n", spacer);
6802 MrBayesPrint ("%s Tree number is too small\n", spacer);
6806 expecting = Expecting(RIGHTPAR); /* only one tree number acceptable */
6809 else if (expecting == Expecting(COMMA))
6812 expecting = Expecting(NUMBER) | Expecting(ALPHA);
6814 else if (expecting == Expecting(DASH))
6817 expecting = Expecting(NUMBER);
6819 else if (expecting == Expecting(RIGHTPAR))
6821 /* find out whether we need a tree number or constraint number(s) */
6822 nApplied = NumActiveParts ();
6823 for (i=0; i<numCurrentDivisions; i++)
6824 if (activeParts[i] == YES || nApplied == 0)
6827 if (!strcmp(modelParams[i].topologyPr,"Constraints"))
6829 /* set constraints */
6830 for (i=0; i<numCurrentDivisions; i++)
6832 if (activeParts[i] == YES || nApplied == 0)
6834 modelParams[i].numActiveConstraints = 0;
6835 for (j=0; j<numDefinedConstraints; j++)
6837 if (tempActiveConstraints[j] == YES)
6839 modelParams[i].activeConstraints[j] = YES;
6840 modelParams[i].numActiveConstraints++;
6843 modelParams[i].activeConstraints[j] = NO;
6845 if (modelParams[i].numActiveConstraints == 0)
6847 MrBayesPrint ("%s No constraints have been defined\n", spacer);
6853 else /* if (!strcmp(modelParams[i].topologyPr,"Constraints")) */
6855 /* set start tree index */
6856 for (i=0; i<numCurrentDivisions; i++)
6858 if (activeParts[i] == YES || nApplied == 0)
6859 modelParams[i].topologyFix = fromI-1;
6863 for (i=0; i<numCurrentDivisions; i++)
6865 MrBayesPrint ("%4d -- ", i+1);
6866 for (j=0; j<numDefinedConstraints; j++)
6867 MrBayesPrint (" %d", modelParams[i].activeConstraints[j]);
6868 MrBayesPrint ("\n");
6871 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6876 /* set Nodeagepr (nodeAgePr) ********************************************************/
6877 else if (!strcmp(parmName, "Nodeagepr"))
6879 if (expecting == Expecting(EQUALSIGN))
6880 expecting = Expecting(ALPHA);
6881 else if (expecting == Expecting(ALPHA))
6883 if (IsArgValid(tkn, tempStr) == NO_ERROR)
6885 nApplied = NumActiveParts ();
6886 for (i=0; i<numCurrentDivisions; i++)
6888 if (activeParts[i] == YES || nApplied == 0)
6890 strcpy(modelParams[i].nodeAgePr, tempStr);
6891 if (nApplied == 0 && numCurrentDivisions == 1)
6892 MrBayesPrint ("%s Setting Nodeagepr to %s\n", spacer, modelParams[i].nodeAgePr);
6894 MrBayesPrint ("%s Setting Nodeagepr to %s for partition %d\n", spacer, modelParams[i].nodeAgePr, i+1);
6900 MrBayesPrint ("%s Invalid Nodeagepr argument\n", spacer);
6903 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6908 /* set Clockvarpr (clockVarPr) ********************************************************/
6909 else if (!strcmp(parmName, "Clockvarpr"))
6911 if (expecting == Expecting(EQUALSIGN))
6912 expecting = Expecting(ALPHA);
6913 else if (expecting == Expecting(ALPHA))
6915 if (IsArgValid(tkn, tempStr) == NO_ERROR)
6917 if (strcmp(tempStr, "Bm") == 0)
6918 strcpy(tempStr, "TK02");
6919 else if (strcmp(tempStr, "Ibr") == 0)
6920 strcpy(tempStr, "Igr");
6921 nApplied = NumActiveParts ();
6922 for (i=0; i<numCurrentDivisions; i++)
6924 if (activeParts[i] == YES || nApplied == 0)
6926 strcpy(modelParams[i].clockVarPr, tempStr);
6927 if (nApplied == 0 && numCurrentDivisions == 1)
6928 MrBayesPrint ("%s Setting Clockvarpr to %s\n", spacer, modelParams[i].clockVarPr);
6930 MrBayesPrint ("%s Setting Clockvarpr to %s for partition %d\n", spacer, modelParams[i].clockVarPr, i+1);
6936 MrBayesPrint ("%s Invalid Clockvarpr argument\n", spacer);
6939 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
6944 /* set Brlenspr (brlensPr) ************************************************************/
6945 else if (!strcmp(parmName, "Brlenspr"))
6947 if (expecting == Expecting(EQUALSIGN))
6949 for (i=0; i<numCurrentDivisions; i++)
6953 expecting = Expecting(ALPHA);
6955 else if (expecting == Expecting(ALPHA))
6957 if (foundEqual == YES)
6959 if (IsArgValid(tkn, tempStr) == NO_ERROR)
6961 strcpy (colonPr, tempStr);
6962 nApplied = NumActiveParts ();
6963 for (i=0; i<numCurrentDivisions; i++)
6964 if (activeParts[i] == YES || nApplied == 0)
6965 strcpy(modelParams[i].brlensPr, tempStr);
6969 MrBayesPrint ("%s Invalid Brlenspr argument\n", spacer);
6973 if (!strcmp(colonPr,"Fixed"))
6974 expecting = Expecting(LEFTPAR);
6976 expecting = Expecting(COLON);
6978 else if (foundLeftPar == YES)
6980 /*process argument of fixed() prior*/
6981 /* find tree number */
6982 if (GetUserTreeFromName (&tempInt, tkn) == ERROR)
6984 MrBayesPrint ("%s Could not set fixed branch lengths from the user tree '%s'\n", spacer, tkn);
6987 fromI = tempInt + 1; /* fromI is used to hold the index of the user tree, 1-based */
6988 expecting = Expecting(RIGHTPAR);
6993 if (!strcmp(colonPr, "Unconstrained"))
6995 /* have unconstrained branch lengths, which we expect to have a uniform or exponential distribution */
6996 nApplied = NumActiveParts ();
6997 if (IsSame ("Uniform", tkn) == SAME || IsSame ("Uniform", tkn) == CONSISTENT_WITH)
6999 for (i=0; i<numCurrentDivisions; i++)
7000 if (activeParts[i] == YES || nApplied == 0)
7001 strcpy(modelParams[i].unconstrainedPr, "Uniform");
7003 else if (IsSame ("Exponential", tkn) == SAME || IsSame ("Exponential", tkn) == CONSISTENT_WITH)
7005 for (i=0; i<numCurrentDivisions; i++)
7006 if (activeParts[i] == YES || nApplied == 0)
7007 strcpy(modelParams[i].unconstrainedPr, "Exponential");
7009 else if (IsSame ("GammaDirichlet", tkn) == SAME || IsSame ("GammaDirichlet", tkn) == CONSISTENT_WITH)
7011 for (i=0; i<numCurrentDivisions; i++)
7012 if (activeParts[i] == YES || nApplied == 0)
7013 strcpy(modelParams[i].unconstrainedPr, "GammaDir");
7015 else if (IsSame ("invGamDirichlet", tkn) == SAME || IsSame ("invGamDirichlet", tkn) == CONSISTENT_WITH)
7017 for (i=0; i<numCurrentDivisions; i++)
7018 if (activeParts[i] == YES || nApplied == 0)
7019 strcpy(modelParams[i].unconstrainedPr, "invGamDir");
7021 else if (IsSame ("twoExponential", tkn) == SAME || IsSame ("twoExponential", tkn) == CONSISTENT_WITH)
7023 for (i=0; i<numCurrentDivisions; i++)
7024 if (activeParts[i] == YES || nApplied == 0)
7025 strcpy(modelParams[i].unconstrainedPr, "twoExp");
7029 MrBayesPrint ("%s Do not understand %s\n", spacer, tkn);
7032 expecting = Expecting(LEFTPAR);
7034 else if (!strcmp(colonPr, "Clock"))
7036 /* otherwise we have a clock constraint and expect uniform, birthdeath, coalescence or fixed prior */
7037 nApplied = NumActiveParts ();
7038 if (IsSame ("Uniform", tkn) == SAME || IsSame ("Uniform", tkn) == CONSISTENT_WITH)
7040 strcpy (clockPr, "Uniform");
7041 for (i=0; i<numCurrentDivisions; i++)
7043 if (activeParts[i] == YES || nApplied == 0)
7044 strcpy(modelParams[i].clockPr, "Uniform");
7045 if (nApplied == 0 && numCurrentDivisions == 1)
7046 MrBayesPrint ("%s Setting Brlenspr to Clock:Uniform\n", spacer);
7048 MrBayesPrint ("%s Setting Brlenspr to Clock:Uniform for partition %d\n", spacer, i+1);
7050 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7052 else if (IsSame ("Birthdeath", tkn) == SAME || IsSame ("Birthdeath", tkn) == CONSISTENT_WITH)
7054 strcpy (clockPr, "Birthdeath");
7055 for (i=0; i<numCurrentDivisions; i++)
7057 if (activeParts[i] == YES || nApplied == 0)
7058 strcpy(modelParams[i].clockPr, "Birthdeath");
7059 if (nApplied == 0 && numCurrentDivisions == 1)
7060 MrBayesPrint ("%s Setting Brlenspr to Clock:Birthdeath\n", spacer);
7062 MrBayesPrint ("%s Setting Brlenspr to Clock:Birthdeath for partition %d\n", spacer, i+1);
7064 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7066 else if (IsSame ("Coalescence", tkn) == SAME || IsSame ("Coalescence", tkn) == CONSISTENT_WITH)
7068 strcpy (clockPr, "Coalescence");
7069 for (i=0; i<numCurrentDivisions; i++)
7071 if (activeParts[i] == YES || nApplied == 0)
7072 strcpy(modelParams[i].clockPr, "Coalescence");
7073 if (nApplied == 0 && numCurrentDivisions == 1)
7074 MrBayesPrint ("%s Setting Brlenspr to Clock:Coalescence\n", spacer);
7076 MrBayesPrint ("%s Setting Brlenspr to Clock:Coalescence for partition %d\n", spacer, i+1);
7078 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7080 else if (IsSame ("Speciestreecoalescence", tkn) == SAME || IsSame ("Speciestreecoalescence", tkn) == CONSISTENT_WITH)
7082 strcpy (clockPr, "Speciestreecoalescence");
7083 for (i=0; i<numCurrentDivisions; i++)
7085 if (activeParts[i] == YES || nApplied == 0)
7086 strcpy(modelParams[i].clockPr, "Speciestreecoalescence");
7087 if (nApplied == 0 && numCurrentDivisions == 1)
7088 MrBayesPrint ("%s Setting Brlenspr to Clock:Speciestreecoalescence\n", spacer);
7090 MrBayesPrint ("%s Setting Brlenspr to Clock:Speciestreecoalescence for partition %d\n", spacer, i+1);
7092 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7094 else if (IsSame ("Fossilization", tkn) == SAME || IsSame ("Fossilization", tkn) == CONSISTENT_WITH)
7096 strcpy (clockPr, "Fossilization");
7097 for (i=0; i<numCurrentDivisions; i++)
7099 if (activeParts[i] == YES || nApplied == 0)
7100 strcpy(modelParams[i].clockPr, "Fossilization");
7101 if (nApplied == 0 && numCurrentDivisions == 1)
7102 MrBayesPrint ("%s Setting Brlenspr to Clock:Fossilization\n", spacer);
7104 MrBayesPrint ("%s Setting Brlenspr to Clock:Fossilization for partition %d\n", spacer, i+1);
7106 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7108 else if (IsSame ("Fixed", tkn) == SAME || IsSame ("Fixed", tkn) == CONSISTENT_WITH)
7110 strcpy (clockPr, "Fixed");
7111 for (i=0; i<numCurrentDivisions; i++)
7113 if (activeParts[i] == YES || nApplied == 0)
7114 strcpy(modelParams[i].clockPr, "Fixed");
7116 expecting = Expecting(LEFTPAR); /* Proceed with tree name */
7120 MrBayesPrint ("%s Do not understand %s\n", spacer, tkn);
7126 MrBayesPrint ("%s Do not understand %s\n", spacer, tkn);
7131 else if (expecting == Expecting(LEFTPAR))
7134 expecting = Expecting(NUMBER);
7135 if (!strcmp(colonPr,"Fixed") || (!strcmp(colonPr,"Clock") && !strcmp(clockPr,"Fixed")))
7137 expecting |= Expecting(ALPHA);
7141 for (i=0; i<numCurrentDivisions; i++)
7145 else if (expecting == Expecting(NUMBER))
7147 if (!strcmp(colonPr, "Unconstrained"))
7149 /* have unconstrained branch lengths */
7150 nApplied = NumActiveParts ();
7151 for (i=0; i<numCurrentDivisions; i++)
7153 if (activeParts[i] == YES || nApplied == 0)
7155 if (!strcmp(modelParams[i].unconstrainedPr,"Uniform"))
7157 sscanf (tkn, "%lf", &tempD);
7158 modelParams[i].brlensUni[numVars[i]++] = tempD;
7159 if (numVars[i] == 1)
7160 expecting = Expecting(COMMA);
7163 if (modelParams[i].brlensUni[0] > 0.000001)
7165 MrBayesPrint ("%s Lower value for uniform must equal 0.0\n", spacer);
7168 if (modelParams[i].brlensUni[0] >= modelParams[i].brlensUni[1])
7170 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
7173 if (nApplied == 0 && numCurrentDivisions == 1)
7174 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].brlensUni[0], modelParams[i].brlensUni[1]);
7176 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);
7177 expecting = Expecting(RIGHTPAR);
7180 else if (!strcmp(modelParams[i].unconstrainedPr,"Exponential"))
7182 sscanf (tkn, "%lf", &tempD);
7183 modelParams[i].brlensExp = tempD;
7184 if (modelParams[i].brlensExp <= 0.0)
7186 MrBayesPrint ("%s Value for exponential must > 0.0\n", spacer);
7189 if (nApplied == 0 && numCurrentDivisions == 1)
7190 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:Exponential(%1.2lf)\n", spacer, modelParams[i].brlensExp);
7192 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].brlensExp, i+1);
7193 expecting = Expecting(RIGHTPAR);
7195 else if (!strcmp(modelParams[i].unconstrainedPr,"GammaDir"))
7197 sscanf (tkn, "%lf", &tempD);
7198 modelParams[i].brlensDir[numVars[i]++] = tempD;
7199 if (numVars[i] == 1 || numVars[i] == 2 || numVars[i] == 3)
7200 expecting = Expecting(COMMA);
7203 if (modelParams[i].brlensDir[0] <= 0.0 || modelParams[i].brlensDir[1] <= 0.0 || modelParams[i].brlensDir[2] <= 0.0 || modelParams[i].brlensDir[3] <= 0.0)
7205 MrBayesPrint ("%s alphaT & betaT & a & c for GammaDir prior must > 0.0\n", spacer);
7208 if (nApplied == 0 && numCurrentDivisions == 1)
7209 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:GammaDir(%1.2lf,%1.4lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].brlensDir[0], modelParams[i].brlensDir[1], modelParams[i].brlensDir[2], modelParams[i].brlensDir[3]);
7211 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:GammaDir(%1.2lf,%1.4lf,%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].brlensDir[0], modelParams[i].brlensDir[1], modelParams[i].brlensDir[2], modelParams[i].brlensDir[3], i+1);
7212 expecting = Expecting(RIGHTPAR);
7215 else if (!strcmp(modelParams[i].unconstrainedPr,"invGamDir"))
7217 sscanf (tkn, "%lf", &tempD);
7218 modelParams[i].brlensDir[numVars[i]++] = tempD;
7219 if (numVars[i] == 1 || numVars[i] == 2 || numVars[i] == 3)
7220 expecting = Expecting(COMMA);
7223 if (modelParams[i].brlensDir[0] <= 2.0 || modelParams[i].brlensDir[1] <= 0.0 || modelParams[i].brlensDir[2] <= 0.0 || modelParams[i].brlensDir[3] <= 0.0)
7225 MrBayesPrint ("%s alphaT must > 2.0, betaT & a & c for invGamDir prior must > 0.0\n", spacer);
7228 if (nApplied == 0 && numCurrentDivisions == 1)
7229 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:invGamDir(%1.2lf,%1.4lf,%1.2lf,%1.2lf)\n", spacer, modelParams[i].brlensDir[0], modelParams[i].brlensDir[1], modelParams[i].brlensDir[2], modelParams[i].brlensDir[3]);
7231 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:invGamDir(%1.2lf,%1.4lf,%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].brlensDir[0], modelParams[i].brlensDir[1], modelParams[i].brlensDir[2], modelParams[i].brlensDir[3], i+1);
7232 expecting = Expecting(RIGHTPAR);
7235 else if (!strcmp(modelParams[i].unconstrainedPr,"twoExp"))
7237 sscanf (tkn, "%lf", &tempD);
7238 modelParams[i].brlens2Exp[numVars[i]++] = tempD;
7239 if (numVars[i] == 1)
7240 expecting = Expecting(COMMA);
7243 if (modelParams[i].brlens2Exp[0] <= 0.0 || modelParams[i].brlens2Exp[1] <= 0.0)
7245 MrBayesPrint ("%s Values for the two exponentials must > 0.0\n", spacer);
7248 if (nApplied == 0 && numCurrentDivisions == 1)
7249 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:twoExp(%1.2lf,%1.2lf)\n", spacer, modelParams[i].brlens2Exp[0], modelParams[i].brlens2Exp[1]);
7251 MrBayesPrint ("%s Setting Brlenspr to Unconstrained:twoExp(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].brlens2Exp[0], modelParams[i].brlens2Exp[1], i+1);
7252 expecting = Expecting(RIGHTPAR);
7258 else if (!strcmp(colonPr,"Fixed") || !strcmp(colonPr,"Clock"))
7260 sscanf (tkn, "%d", &tempInt);
7261 if (tempInt < 1 || tempInt > numUserTrees)
7263 MrBayesPrint ("%s Tree needs to be in the range %d to %d\n", spacer, 1, numUserTrees);
7267 expecting = Expecting(RIGHTPAR);
7271 else if (expecting == Expecting(COLON))
7273 expecting = Expecting(ALPHA);
7275 else if (expecting == Expecting(COMMA))
7277 expecting = Expecting(NUMBER);
7279 else if (expecting == Expecting(RIGHTPAR))
7281 if (!strcmp(colonPr,"Fixed") || (!strcmp(colonPr,"Clock") && !strcmp(clockPr,"Fixed")))
7283 /* index of a tree which set up branch lengths*/
7284 nApplied = NumActiveParts ();
7285 for (i=0; i<numCurrentDivisions; i++)
7287 if (activeParts[i] == YES || nApplied == 0)
7288 modelParams[i].brlensFix = fromI-1;
7289 if (!strcmp(colonPr,"Fixed"))
7291 if (nApplied == 0 && numCurrentDivisions == 1)
7292 MrBayesPrint ("%s Setting Brlenspr to Fixed(%s)\n", spacer, userTree[fromI-1]->name);
7294 MrBayesPrint ("%s Setting Brlenspr to Fixed(%s) for partition %d\n", spacer, userTree[fromI-1]->name, i+1);
7298 if (nApplied == 0 && numCurrentDivisions == 1)
7299 MrBayesPrint ("%s Setting Brlenspr to Fixed(%s)\n", spacer, userTree[fromI-1]->name);
7301 MrBayesPrint ("%s Setting Brlenspr to Fixed(%s) for partition %d\n", spacer, userTree[fromI-1]->name, i+1);
7305 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7310 /* set Speciationpr (speciationPr) *************************************************/
7311 else if (!strcmp(parmName, "Speciationpr"))
7313 if (expecting == Expecting(EQUALSIGN))
7314 expecting = Expecting(ALPHA);
7315 else if (expecting == Expecting(ALPHA))
7317 if (IsArgValid(tkn, tempStr) == NO_ERROR)
7319 nApplied = NumActiveParts ();
7320 for (i=0; i<numCurrentDivisions; i++)
7321 if (activeParts[i] == YES || nApplied == 0)
7322 strcpy(modelParams[i].speciationPr, tempStr);
7326 MrBayesPrint ("%s Invalid Speciationpr argument\n", spacer);
7329 expecting = Expecting(LEFTPAR);
7330 for (i=0; i<numCurrentDivisions; i++)
7333 else if (expecting == Expecting(LEFTPAR))
7335 expecting = Expecting(NUMBER);
7337 else if (expecting == Expecting(NUMBER))
7339 nApplied = NumActiveParts ();
7340 for (i=0; i<numCurrentDivisions; i++)
7342 if (activeParts[i] == YES || nApplied == 0)
7344 if (!strcmp(modelParams[i].speciationPr,"Uniform"))
7346 sscanf (tkn, "%lf", &tempD);
7347 modelParams[i].speciationUni[numVars[i]++] = tempD;
7348 if (numVars[i] == 1)
7349 expecting = Expecting(COMMA);
7352 if (modelParams[i].speciationUni[0] >= modelParams[i].speciationUni[1])
7354 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
7357 if (nApplied == 0 && numCurrentDivisions == 1)
7358 MrBayesPrint ("%s Setting Speciationpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].speciationUni[0], modelParams[i].speciationUni[1]);
7360 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);
7361 expecting = Expecting(RIGHTPAR);
7364 else if (!strcmp(modelParams[i].speciationPr,"Exponential"))
7366 sscanf (tkn, "%lf", &tempD);
7369 MrBayesPrint ("%s Exponential parameter must be positive\n", spacer);
7372 modelParams[i].speciationExp = tempD;
7373 if (nApplied == 0 && numCurrentDivisions == 1)
7374 MrBayesPrint ("%s Setting Speciationpr to Exponential(%1.2lf)\n", spacer, modelParams[i].speciationExp);
7376 MrBayesPrint ("%s Setting Speciationpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].speciationExp, i+1);
7377 expecting = Expecting(RIGHTPAR);
7379 else if (!strcmp(modelParams[i].speciationPr,"Fixed"))
7381 sscanf (tkn, "%lf", &tempD);
7384 MrBayesPrint ("%s Net speciation rate must be positive\n", spacer);
7387 modelParams[i].speciationFix = tempD;
7388 if (nApplied == 0 && numCurrentDivisions == 1)
7389 MrBayesPrint ("%s Setting Speciationpr to Fixed(%1.2lf)\n", spacer, modelParams[i].speciationFix);
7391 MrBayesPrint ("%s Setting Speciationpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].speciationFix, i+1);
7392 expecting = Expecting(RIGHTPAR);
7397 else if (expecting == Expecting(COMMA))
7399 expecting = Expecting(NUMBER);
7401 else if (expecting == Expecting(RIGHTPAR))
7403 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7408 /* set Extinctionpr (extinctionPr) *************************************************/
7409 else if (!strcmp(parmName, "Extinctionpr"))
7411 if (expecting == Expecting(EQUALSIGN))
7412 expecting = Expecting(ALPHA);
7413 else if (expecting == Expecting(ALPHA))
7415 if (IsArgValid(tkn, tempStr) == NO_ERROR)
7417 nApplied = NumActiveParts ();
7418 for (i=0; i<numCurrentDivisions; i++)
7419 if (activeParts[i] == YES || nApplied == 0)
7420 strcpy(modelParams[i].extinctionPr, tempStr);
7424 MrBayesPrint ("%s Invalid Extinctionpr argument\n", spacer);
7427 expecting = Expecting(LEFTPAR);
7428 for (i=0; i<numCurrentDivisions; i++)
7431 else if (expecting == Expecting(LEFTPAR))
7433 expecting = Expecting(NUMBER);
7435 else if (expecting == Expecting(NUMBER))
7437 nApplied = NumActiveParts ();
7438 for (i=0; i<numCurrentDivisions; i++)
7440 if (activeParts[i] == YES || nApplied == 0)
7442 if (!strcmp(modelParams[i].extinctionPr,"Beta"))
7444 sscanf (tkn, "%lf", &tempD);
7447 MrBayesPrint ("%s Beta parameter must be positive\n", spacer);
7450 modelParams[i].extinctionBeta[numVars[i]++] = tempD;
7451 if (numVars[i] == 1)
7452 expecting = Expecting(COMMA);
7455 if (nApplied == 0 && numCurrentDivisions == 1)
7456 MrBayesPrint ("%s Setting Extinctionpr to Beta(%1.2lf,%1.2lf)\n", spacer, modelParams[i].extinctionBeta[0], modelParams[i].extinctionBeta[1]);
7458 MrBayesPrint ("%s Setting Extinctionpr to Beta(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].extinctionBeta[0], modelParams[i].extinctionBeta[1], i+1);
7459 expecting = Expecting(RIGHTPAR);
7462 else if (!strcmp(modelParams[i].extinctionPr,"Fixed"))
7464 sscanf (tkn, "%lf", &tempD);
7465 if (tempD < 0.0 || tempD >= 1.0)
7467 MrBayesPrint ("%s Relative extinction rate must be in range [0,1)\n", spacer);
7470 modelParams[i].extinctionFix = tempD;
7471 if (nApplied == 0 && numCurrentDivisions == 1)
7472 MrBayesPrint ("%s Setting Extinctionpr to Fixed(%1.2lf)\n", spacer, modelParams[i].extinctionFix);
7474 MrBayesPrint ("%s Setting Extinctionpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].extinctionFix, i+1);
7475 expecting = Expecting(RIGHTPAR);
7480 else if (expecting == Expecting(COMMA))
7482 expecting = Expecting(NUMBER);
7484 else if (expecting == Expecting(RIGHTPAR))
7486 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7491 /* set Fossilizationpr (fossilizationPr) */
7492 else if (!strcmp(parmName, "Fossilizationpr"))
7494 if (expecting == Expecting(EQUALSIGN))
7495 expecting = Expecting(ALPHA);
7496 else if (expecting == Expecting(ALPHA))
7498 if (IsArgValid(tkn, tempStr) == NO_ERROR)
7500 nApplied = NumActiveParts ();
7501 for (i=0; i<numCurrentDivisions; i++)
7502 if (activeParts[i] == YES || nApplied == 0)
7503 strcpy(modelParams[i].fossilizationPr, tempStr);
7507 MrBayesPrint ("%s Invalid Fossilization argument\n", spacer);
7510 expecting = Expecting(LEFTPAR);
7511 for (i=0; i<numCurrentDivisions; i++)
7514 else if (expecting == Expecting(LEFTPAR))
7516 expecting = Expecting(NUMBER);
7518 else if (expecting == Expecting(NUMBER))
7520 nApplied = NumActiveParts ();
7521 for (i=0; i<numCurrentDivisions; i++)
7523 if (activeParts[i] == YES || nApplied == 0)
7525 if (!strcmp(modelParams[i].fossilizationPr,"Beta"))
7527 sscanf (tkn, "%lf", &tempD);
7530 MrBayesPrint ("%s Beta parameter must be positive\n", spacer);
7533 modelParams[i].fossilizationBeta[numVars[i]++] = tempD;
7534 if (numVars[i] == 1)
7535 expecting = Expecting(COMMA);
7538 if (nApplied == 0 && numCurrentDivisions == 1)
7539 MrBayesPrint ("%s Setting Fossilizationpr to Beta(%1.2lf,%1.2lf)\n", spacer, modelParams[i].fossilizationBeta[0], modelParams[i].fossilizationBeta[1]);
7541 MrBayesPrint ("%s Setting Fossilizationpr to Beta(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].fossilizationBeta[0], modelParams[i].fossilizationBeta[1], i+1);
7542 expecting = Expecting(RIGHTPAR);
7545 else if (!strcmp(modelParams[i].fossilizationPr,"Fixed"))
7547 sscanf (tkn, "%lf", &tempD);
7548 if (tempD < 0.0 || tempD > 1.0)
7550 MrBayesPrint ("%s Relative fossilization rate must be in the range (0,1]\n", spacer);
7553 modelParams[i].fossilizationFix = tempD;
7554 if (nApplied == 0 && numCurrentDivisions == 1)
7555 MrBayesPrint ("%s Setting Fossilizationpr to Fixed(%1.2lf)\n", spacer, modelParams[i].fossilizationFix);
7557 MrBayesPrint ("%s Setting Fossilizationpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].fossilizationFix, i+1);
7558 expecting = Expecting(RIGHTPAR);
7563 else if (expecting == Expecting(COMMA))
7565 expecting = Expecting(NUMBER);
7567 else if (expecting == Expecting(RIGHTPAR))
7569 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7574 /* set SampleStrat (sampleStrat) ***************************************************/
7575 else if (!strcmp(parmName, "Samplestrat"))
7577 if (expecting == Expecting(EQUALSIGN))
7579 expecting = Expecting(ALPHA);
7581 else if (expecting == Expecting(ALPHA))
7583 if (IsArgValid(tkn, tempStr) == NO_ERROR)
7585 nApplied = NumActiveParts ();
7586 for (i=0; i<numCurrentDivisions; i++)
7588 if (activeParts[i] == YES || nApplied == 0)
7590 strcpy(modelParams[i].sampleStrat, tempStr);
7591 if (nApplied == 0 && numCurrentDivisions == 1)
7592 MrBayesPrint ("%s Setting SampleStrat to %s\n", spacer, modelParams[i].sampleStrat);
7594 MrBayesPrint ("%s Setting SampleStrat to %s for partition %d\n", spacer, modelParams[i].sampleStrat, i+1);
7595 if (!strcmp(modelParams[i].sampleStrat,"Random") || !strcmp(modelParams[i].sampleStrat,"Diversity"))
7597 foundFSNum[i] = foundFSTime[i] = NO;
7598 modelParams[i].sampleFSNum = 0;
7600 expecting = Expecting(NUMBER);
7601 expecting |= Expecting(PARAMETER);
7602 expecting |= Expecting(SEMICOLON);
7605 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7611 MrBayesPrint ("%s Invalid Samplestrat argument\n", spacer);
7615 else if (expecting == Expecting(NUMBER))
7617 nApplied = NumActiveParts ();
7618 for (i=0; i<numCurrentDivisions; i++)
7620 if (activeParts[i] == YES || nApplied == 0)
7622 if (foundFSNum[i] == NO)
7624 sscanf (tkn, "%d", &tempInt);
7627 MrBayesPrint ("%s Number of fossil slice sampling events must be > 0\n", spacer);
7630 modelParams[i].sampleFSNum = tempInt;
7631 if (memAllocs[ALLOC_SAMPLEFOSSILSLICE] == YES)
7633 free(modelParams[i].sampleFSProb);
7634 free(modelParams[i].sampleFSTime);
7636 modelParams[i].sampleFSTime = (MrBFlt *) SafeMalloc ((size_t)tempInt * sizeof(MrBFlt));
7637 modelParams[i].sampleFSProb = (MrBFlt *) SafeMalloc ((size_t)tempInt * sizeof(MrBFlt));
7638 memAllocs[ALLOC_SAMPLEFOSSILSLICE] = YES;
7639 foundFSNum[i] = YES;
7640 expecting = Expecting(COLON);
7642 else if (foundFSTime[i] == NO)
7644 sscanf (tkn, "%lf", &tempD);
7647 MrBayesPrint ("%s Time of fossil slice sampling events must be > 0.\n", spacer);
7650 if (numVars[i] > 0 && modelParams[i].sampleFSTime[numVars[i]-1] < tempD)
7652 MrBayesPrint ("%s Time of fossil slice sampling events must be in decreasing order\n", spacer);
7655 modelParams[i].sampleFSTime[numVars[i]] = tempD;
7656 foundFSTime[i] = YES;
7657 expecting = Expecting(NUMBER);
7661 sscanf (tkn, "%lf", &tempD);
7662 if (tempD < 0.0 || tempD > 1.0)
7664 MrBayesPrint ("%s Prob of fossil slice sampling events must be in [0,1]\n", spacer);
7667 modelParams[i].sampleFSProb[numVars[i]] = tempD;
7668 foundFSTime[i] = NO;
7669 expecting = Expecting(COMMA);
7670 if (nApplied == 0 && numCurrentDivisions == 1)
7671 MrBayesPrint ("%s Setting %d FSTime FSProb to %1.2lf %1.6lf\n", spacer, numVars[i]+1,
7672 modelParams[i].sampleFSTime[numVars[i]], modelParams[i].sampleFSProb[numVars[i]]);
7674 MrBayesPrint ("%s Setting %d FSTime FSProb to %1.2lf %1.6lf for partition %d\n", spacer, numVars[i]+1,
7675 modelParams[i].sampleFSTime[numVars[i]], modelParams[i].sampleFSProb[numVars[i]], i+1);
7677 if (numVars[i] == modelParams[i].sampleFSNum)
7678 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7683 else if (expecting == Expecting(COLON) || expecting == Expecting(COMMA))
7685 expecting = Expecting(NUMBER);
7692 /* set Sampleprob (sampleProb) *****************************************************/
7693 else if (!strcmp(parmName, "Sampleprob"))
7695 if (expecting == Expecting(EQUALSIGN))
7696 expecting = Expecting(NUMBER);
7697 else if (expecting == Expecting(NUMBER))
7699 nApplied = NumActiveParts ();
7700 for (i=0; i<numCurrentDivisions; i++)
7702 if ((activeParts[i] == YES || nApplied == 0))
7704 sscanf (tkn, "%lf", &tempD);
7705 if (tempD <= 0.0 || tempD > 1.0)
7707 MrBayesPrint ("%s Sampleprob should be in range (0,1]\n", spacer);
7710 modelParams[i].sampleProb = tempD;
7711 if (nApplied == 0 && numCurrentDivisions == 1)
7712 MrBayesPrint ("%s Setting Sampleprob to %1.8lf\n", spacer, modelParams[i].sampleProb);
7714 MrBayesPrint ("%s Setting Sampleprob to %1.8lf for partition %d\n", spacer, modelParams[i].sampleProb, i+1);
7717 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7722 /* set Treeagepr (treeAgePr) *******************************************************/
7723 else if (!strcmp(parmName, "Treeagepr"))
7725 if (expecting == Expecting(EQUALSIGN))
7726 expecting = Expecting(ALPHA);
7727 else if (expecting == Expecting(ALPHA))
7729 if (IsArgValid(tkn, tempStr) == NO_ERROR)
7731 nApplied = NumActiveParts ();
7732 for (i=0; i<numCurrentDivisions; i++)
7733 if (activeParts[i] == YES || nApplied == 0)
7735 strcpy(modelParams[i].treeAgePr.name, tempStr);
7736 if (!strcmp(tempStr,"Fixed"))
7737 modelParams[i].treeAgePr.prior = fixed;
7738 else if (!strcmp(tempStr,"Uniform"))
7739 modelParams[i].treeAgePr.prior = uniform;
7740 else if (!strcmp(tempStr,"Offsetexponential"))
7741 modelParams[i].treeAgePr.prior = offsetExponential;
7742 else if (!strcmp(tempStr,"Truncatednormal"))
7743 modelParams[i].treeAgePr.prior = truncatedNormal;
7744 else if (!strcmp(tempStr,"Lognormal"))
7745 modelParams[i].treeAgePr.prior = logNormal;
7746 else if (!strcmp(tempStr,"Offsetlognormal"))
7747 modelParams[i].treeAgePr.prior = offsetLogNormal;
7748 else if (!strcmp(tempStr,"Gamma"))
7749 modelParams[i].treeAgePr.prior = standardGamma;
7750 else if (!strcmp(tempStr,"Offsetgamma"))
7751 modelParams[i].treeAgePr.prior = offsetGamma;
7756 MrBayesPrint ("%s Invalid Treeagepr argument\n", spacer);
7759 expecting = Expecting(LEFTPAR);
7760 for (i=0; i<numCurrentDivisions; i++)
7763 else if (expecting == Expecting(LEFTPAR))
7765 nApplied = NumActiveParts ();
7766 for (i=0; i<numCurrentDivisions; i++)
7767 if (activeParts[i] == YES || nApplied == 0)
7768 strcat(modelParams[i].treeAgePr.name, "(");
7769 expecting = Expecting(NUMBER);
7771 else if (expecting == Expecting(NUMBER))
7773 sscanf (tkn, "%lf", &tempD);
7774 sprintf (tempStr, "%1.2lf", tempD);
7775 nApplied = NumActiveParts ();
7776 for (i=0; i<numCurrentDivisions; i++)
7778 if (activeParts[i] == YES || nApplied == 0)
7780 if (numVars[i] == 0 && tempD < 0.0)
7782 if (modelParams[i].treeAgePr.prior == uniform ||
7783 modelParams[i].treeAgePr.prior == offsetExponential ||
7784 modelParams[i].treeAgePr.prior == truncatedNormal ||
7785 modelParams[i].treeAgePr.prior == offsetLogNormal ||
7786 modelParams[i].treeAgePr.prior == offsetGamma)
7787 MrBayesPrint("%s Minimum, offset or truncation point must be nonnegative\n", spacer);
7788 else if (modelParams[i].treeAgePr.prior == fixed)
7789 MrBayesPrint("%s Fixed age must be nonnegative\n", spacer);
7791 MrBayesPrint("%s Mean must be nonnegative\n", spacer);
7794 else if (numVars[i] == 1)
7796 if (modelParams[i].treeAgePr.prior == uniform && tempD <= modelParams[i].treeAgePr.priorParams[0])
7798 MrBayesPrint("%s Max of uniform distribution must be larger than min\n", spacer);
7801 else if ((modelParams[i].treeAgePr.prior == standardGamma || modelParams[i].treeAgePr.prior == logNormal) && tempD <= 0.0)
7803 MrBayesPrint("%s Standard deviation must be positive\n", spacer);
7806 else if ((modelParams[i].treeAgePr.prior == offsetExponential ||
7807 modelParams[i].treeAgePr.prior == offsetGamma ||
7808 modelParams[i].treeAgePr.prior == offsetLogNormal) && tempD <= modelParams[i].treeAgePr.priorParams[0])
7810 MrBayesPrint("%s Mean must be larger than offset\n", spacer);
7814 else if (numVars[i] == 2 && tempD <= 0.0)
7816 MrBayesPrint("%s Standard deviation must be positive\n", spacer);
7819 modelParams[i].treeAgePr.priorParams[numVars[i]++] = tempD;
7820 sprintf (tempStr, "%1.2lf", tempD);
7821 strcat(modelParams[i].treeAgePr.name, tempStr);
7822 if (modelParams[i].treeAgePr.prior == fixed || numVars[i] == 3)
7823 expecting = Expecting(RIGHTPAR);
7824 else if (numVars[i] == 1)
7825 expecting = Expecting(COMMA);
7826 else if (modelParams[i].treeAgePr.prior == standardGamma ||
7827 modelParams[i].treeAgePr.prior == uniform ||
7828 modelParams[i].treeAgePr.prior == offsetExponential ||
7829 modelParams[i].treeAgePr.prior == logNormal)
7830 expecting = Expecting(RIGHTPAR);
7832 expecting = Expecting(COMMA);
7835 if (i < numCurrentDivisions)
7837 /* An error occurred. Reset calibrations and bail out */
7838 nApplied = NumActiveParts ();
7839 for (i=0; i<numCurrentDivisions; i++)
7841 if (activeParts[i] == YES || nApplied == 0)
7843 strcpy(modelParams[i].treeAgePr.name, "Gamma(1.00,1.00)");
7844 modelParams[i].treeAgePr.prior = standardGamma;
7845 modelParams[i].treeAgePr.priorParams[0] = 1.0;
7846 modelParams[i].treeAgePr.priorParams[1] = 1.0;
7847 modelParams[i].treeAgePr.priorParams[2] = -1.0;
7848 modelParams[i].treeAgePr.min = 0.0;
7849 modelParams[i].treeAgePr.max = POS_INFINITY;
7855 else if (expecting == Expecting(COMMA))
7857 nApplied = NumActiveParts ();
7858 for (i=0; i<numCurrentDivisions; i++)
7859 if (activeParts[i] == YES || nApplied == 0)
7860 strcat(modelParams[i].treeAgePr.name, ",");
7861 expecting = Expecting(NUMBER);
7863 else if (expecting == Expecting(RIGHTPAR))
7865 nApplied = NumActiveParts ();
7866 for (i=0; i<numCurrentDivisions; i++)
7868 if (activeParts[i] == YES || nApplied == 0)
7870 strcat(modelParams[i].treeAgePr.name, ")");
7871 MrBayesPrint ("%s Setting Treeagepr to %s\n", spacer, modelParams[i].treeAgePr.name);
7873 if (modelParams[i].treeAgePr.prior == fixed)
7875 modelParams[i].treeAgePr.LnPriorProb = &LnPriorProbFix;
7876 modelParams[i].treeAgePr.LnPriorRatio = &LnProbRatioFix;
7877 modelParams[i].treeAgePr.min = modelParams[i].treeAgePr.priorParams[0];
7878 modelParams[i].treeAgePr.max = modelParams[i].treeAgePr.priorParams[0];
7880 else if (modelParams[i].treeAgePr.prior == uniform)
7882 modelParams[i].treeAgePr.LnPriorProb = &LnPriorProbUniform;
7883 modelParams[i].treeAgePr.LnPriorRatio = &LnProbRatioUniform;
7884 modelParams[i].treeAgePr.min = modelParams[i].treeAgePr.priorParams[0];
7885 modelParams[i].treeAgePr.max = modelParams[i].treeAgePr.priorParams[1];
7887 else if (modelParams[i].treeAgePr.prior == offsetExponential)
7889 modelParams[i].treeAgePr.LnPriorProb = &LnPriorProbOffsetExponential_Param_Offset_Mean;
7890 modelParams[i].treeAgePr.LnPriorRatio = &LnProbRatioOffsetExponential_Param_Offset_Mean;
7891 modelParams[i].treeAgePr.min = modelParams[i].treeAgePr.priorParams[0];
7892 modelParams[i].treeAgePr.max = POS_INFINITY;
7894 else if (modelParams[i].treeAgePr.prior == truncatedNormal)
7896 modelParams[i].treeAgePr.LnPriorProb = &LnPriorProbTruncatedNormal_Param_Trunc_Mean_Sd;
7897 modelParams[i].treeAgePr.LnPriorRatio = &LnProbRatioTruncatedNormal_Param_Trunc_Mean_Sd;
7898 modelParams[i].treeAgePr.min = modelParams[i].treeAgePr.priorParams[0];
7899 modelParams[i].treeAgePr.max = POS_INFINITY;
7901 else if (modelParams[i].treeAgePr.prior == logNormal)
7903 modelParams[i].treeAgePr.LnPriorProb = &LnPriorProbLognormal_Param_Mean_Sd;
7904 modelParams[i].treeAgePr.LnPriorRatio = &LnProbRatioLognormal_Param_Mean_Sd;
7905 modelParams[i].treeAgePr.min = 0.0;
7906 modelParams[i].treeAgePr.max = POS_INFINITY;
7908 else if (modelParams[i].treeAgePr.prior == offsetLogNormal)
7910 modelParams[i].treeAgePr.LnPriorProb = &LnPriorProbOffsetLognormal_Param_Offset_Mean_Sd;
7911 modelParams[i].treeAgePr.LnPriorRatio = &LnProbRatioOffsetLognormal_Param_Offset_Mean_Sd;
7912 modelParams[i].treeAgePr.min = modelParams[i].treeAgePr.priorParams[0];
7913 modelParams[i].treeAgePr.max = POS_INFINITY;
7915 else if (modelParams[i].treeAgePr.prior == standardGamma)
7917 modelParams[i].treeAgePr.LnPriorProb = &LnPriorProbGamma_Param_Mean_Sd;
7918 modelParams[i].treeAgePr.LnPriorRatio = &LnProbRatioGamma_Param_Mean_Sd;
7919 modelParams[i].treeAgePr.min = 0.0;
7920 modelParams[i].treeAgePr.max = POS_INFINITY;
7922 else if (modelParams[i].treeAgePr.prior == offsetGamma)
7924 modelParams[i].treeAgePr.LnPriorProb = &LnPriorProbOffsetGamma_Param_Offset_Mean_Sd;
7925 modelParams[i].treeAgePr.LnPriorRatio = &LnProbRatioOffsetGamma_Param_Offset_Mean_Sd;
7926 modelParams[i].treeAgePr.min = modelParams[i].treeAgePr.priorParams[0];
7927 modelParams[i].treeAgePr.max = POS_INFINITY;
7931 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
7936 /* set Clockratepr (clockRatePr) ****************************************************/
7937 else if (!strcmp(parmName, "Clockratepr"))
7939 if (expecting == Expecting(EQUALSIGN))
7942 expecting = Expecting(ALPHA);
7944 else if (expecting == Expecting(ALPHA))
7946 if (IsArgValid(tkn, tempStr) == NO_ERROR)
7948 nApplied = NumActiveParts ();
7949 for (i=0; i<numCurrentDivisions; i++)
7951 if (activeParts[i] == YES || nApplied == 0)
7952 strcpy(modelParams[i].clockRatePr, tempStr);
7957 MrBayesPrint ("%s Invalid Clockratepr argument\n", spacer);
7960 expecting = Expecting(LEFTPAR);
7961 for (i=0; i<numCurrentDivisions; i++)
7964 else if (expecting == Expecting(LEFTPAR))
7966 expecting = Expecting(NUMBER);
7967 expecting |= Expecting(DASH); /* negative numbers possible */
7969 else if (expecting == Expecting(DASH))
7972 expecting = Expecting(NUMBER);
7974 else if (expecting == Expecting(NUMBER))
7976 sscanf (tkn, "%lf", &tempD);
7977 if (foundDash == YES)
7982 nApplied = NumActiveParts ();
7983 for (i=0; i<numCurrentDivisions; i++)
7985 if (activeParts[i] == YES || nApplied == 0)
7987 if (!strcmp(modelParams[i].clockRatePr,"Normal"))
7991 if (numVars[i] == 0)
7992 MrBayesPrint ("%s Mean of the normal must be positive\n", spacer);
7993 else if (numVars[i] == 1)
7994 MrBayesPrint ("%s Standard deviation of the normal must be positive\n", spacer);
7997 modelParams[i].clockRateNormal[numVars[i]] = tempD;
7999 if (numVars[i] == 1)
8000 expecting = Expecting(COMMA);
8003 if (nApplied == 0 || numCurrentDivisions == 1)
8004 MrBayesPrint ("%s Setting Clockratepr to Normal(%1.6lf,%1.6lf)\n", spacer, modelParams[i].clockRateNormal[0], modelParams[i].clockRateNormal[1]);
8006 MrBayesPrint ("%s Setting Clockratepr to Normal(%1.6lf,%1.6lf) for partition %d\n", spacer, modelParams[i].clockRateNormal[0], modelParams[i].clockRateNormal[1], i+1);
8007 expecting = Expecting(RIGHTPAR);
8010 else if (!strcmp(modelParams[i].clockRatePr,"Lognormal"))
8012 modelParams[i].clockRateLognormal[numVars[i]] = tempD;
8014 if (numVars[i] == 1)
8015 expecting = Expecting(COMMA);
8018 if (nApplied == 0 || numCurrentDivisions == 1)
8019 MrBayesPrint ("%s Setting Clockratepr to Lognormal(%1.2lf,%1.2lf)\n", spacer, modelParams[i].clockRateLognormal[0], modelParams[i].clockRateLognormal[1]);
8021 MrBayesPrint ("%s Setting Clockratepr to Lognormal(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].clockRateLognormal[0], modelParams[i].clockRateLognormal[1], i+1);
8022 expecting = Expecting(RIGHTPAR);
8025 else if (!strcmp(modelParams[i].clockRatePr,"Exponential"))
8029 MrBayesPrint ("%s Rate of the exponential must be positive\n", spacer);
8032 modelParams[i].clockRateExp = tempD;
8034 if (nApplied == 0 || numCurrentDivisions == 1)
8035 MrBayesPrint ("%s Setting Clockratepr to Exponential(%1.2lf)\n", spacer, modelParams[i].clockRateExp);
8037 MrBayesPrint ("%s Setting Clockratepr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].clockRateExp, i+1);
8038 expecting = Expecting(RIGHTPAR);
8040 else if (!strcmp(modelParams[i].clockRatePr,"Gamma"))
8044 if (numVars[i] == 0)
8045 MrBayesPrint ("%s Shape of the gamma must be positive\n", spacer);
8046 else if (numVars[i] == 1)
8047 MrBayesPrint ("%s Rate (inverse scale) of the gamma must be positive\n", spacer);
8050 modelParams[i].clockRateGamma[numVars[i]] = tempD;
8052 if (numVars[i] == 1)
8053 expecting = Expecting(COMMA);
8056 if (nApplied == 0 || numCurrentDivisions == 1)
8057 MrBayesPrint ("%s Setting Clockratepr to Gamma(%1.2lf,%1.2lf)\n", spacer, modelParams[i].clockRateGamma[0], modelParams[i].clockRateGamma[1]);
8059 MrBayesPrint ("%s Setting Clockratepr to Gamma(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].clockRateGamma[0], modelParams[i].clockRateGamma[1], i+1);
8060 expecting = Expecting(RIGHTPAR);
8063 else if (!strcmp(modelParams[i].clockRatePr,"Fixed"))
8067 MrBayesPrint ("%s Fixed clock rate must be positive\n", spacer);
8070 modelParams[i].clockRateFix = tempD;
8072 if (nApplied == 0 || numCurrentDivisions == 1)
8073 MrBayesPrint ("%s Setting Clockratepr to Fixed(%1.6lf)\n", spacer, modelParams[i].clockRateFix);
8075 MrBayesPrint ("%s Setting Clockratepr to Fixed(%1.6lf) for partition %d\n", spacer, modelParams[i].clockRateFix, i+1);
8076 for (k=0; k<numGlobalChains; k++)
8078 if (UpdateClockRate(tempD, k) == ERROR)
8081 expecting = Expecting(RIGHTPAR);
8086 else if (expecting == Expecting(COMMA))
8088 expecting = Expecting(NUMBER);
8090 else if (expecting == Expecting(RIGHTPAR))
8092 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8097 /* set Popsizepr (popSizePr) **************************************************************/
8098 else if (!strcmp(parmName, "Popsizepr"))
8100 if (expecting == Expecting(EQUALSIGN))
8101 expecting = Expecting(ALPHA);
8102 else if (expecting == Expecting(ALPHA))
8104 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8106 nApplied = NumActiveParts ();
8107 for (i=0; i<numCurrentDivisions; i++)
8109 if (activeParts[i] == YES || nApplied == 0)
8110 strcpy(modelParams[i].popSizePr, tempStr);
8115 MrBayesPrint ("%s Invalid Popsizepr argument\n", spacer);
8118 expecting = Expecting(LEFTPAR);
8119 for (i=0; i<numCurrentDivisions; i++)
8122 else if (expecting == Expecting(LEFTPAR))
8124 expecting = Expecting(NUMBER);
8126 else if (expecting == Expecting(NUMBER))
8128 nApplied = NumActiveParts ();
8129 for (i=0; i<numCurrentDivisions; i++)
8131 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
8133 if (!strcmp(modelParams[i].popSizePr,"Uniform"))
8135 sscanf (tkn, "%lf", &tempD);
8136 modelParams[i].popSizeUni[numVars[i]++] = tempD;
8137 if (numVars[i] == 1)
8141 MrBayesPrint ("%s Lower value for Uniform must be a positive number\n", spacer);
8144 expecting = Expecting(COMMA);
8148 if (modelParams[i].popSizeUni[0] >= modelParams[i].popSizeUni[1])
8150 MrBayesPrint ("%s Lower value for Uniform should be greater than upper value\n", spacer);
8153 if (nApplied == 0 && numCurrentDivisions == 1)
8154 MrBayesPrint ("%s Setting Popsizepr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].popSizeUni[0], modelParams[i].popSizeUni[1]);
8156 MrBayesPrint ("%s Setting Popsizepr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].popSizeUni[0], modelParams[i].popSizeUni[1], i+1);
8157 expecting = Expecting(RIGHTPAR);
8160 else if (!strcmp(modelParams[i].popSizePr,"Lognormal"))
8162 sscanf (tkn, "%lf", &tempD);
8163 modelParams[i].popSizeLognormal[numVars[i]++] = tempD;
8164 if (numVars[i] == 1)
8166 expecting = Expecting(COMMA);
8170 if (modelParams[i].popSizeLognormal[1] <= 0.0)
8172 MrBayesPrint ("%s Standard deviation of Lognormal must be a positive number\n", spacer);
8175 if (nApplied == 0 && numCurrentDivisions == 1)
8176 MrBayesPrint ("%s Setting Popsizepr to Lognormal(%1.2lf,%1.2lf)\n", spacer, modelParams[i].popSizeLognormal[0], modelParams[i].popSizeLognormal[1]);
8178 MrBayesPrint ("%s Setting Popsizepr to Lognormal(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].popSizeLognormal[0], modelParams[i].popSizeLognormal[1], i+1);
8179 expecting = Expecting(RIGHTPAR);
8182 else if (!strcmp(modelParams[i].popSizePr,"Normal"))
8184 sscanf (tkn, "%lf", &tempD);
8185 modelParams[i].popSizeNormal[numVars[i]++] = tempD;
8186 if (numVars[i] == 1)
8188 if (modelParams[i].popSizeNormal[0] <= 0.0)
8190 MrBayesPrint ("%s Mean of Truncated Normal must be a positive number\n", spacer);
8193 expecting = Expecting(COMMA);
8197 if (modelParams[i].popSizeNormal[1] <= 0.0)
8199 MrBayesPrint ("%s Standard deviation of Truncated Normal must be a positive number\n", spacer);
8202 if (nApplied == 0 && numCurrentDivisions == 1)
8203 MrBayesPrint ("%s Setting Popsizepr to Truncated Normal(%1.2lf,%1.2lf)\n", spacer, modelParams[i].popSizeNormal[0], modelParams[i].popSizeNormal[1]);
8205 MrBayesPrint ("%s Setting Popsizepr to Truncated Normal(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].popSizeNormal[0], modelParams[i].popSizeNormal[1], i+1);
8206 expecting = Expecting(RIGHTPAR);
8209 else if (!strcmp(modelParams[i].popSizePr,"Gamma"))
8211 sscanf (tkn, "%lf", &tempD);
8212 modelParams[i].popSizeGamma[numVars[i]++] = tempD;
8213 if (numVars[i] == 1)
8215 if (modelParams[i].popSizeGamma[0] <= 0.0)
8217 MrBayesPrint ("%s Shape (alpha) of Gamma must be a positive number\n", spacer);
8220 expecting = Expecting(COMMA);
8224 if (modelParams[i].popSizeGamma[1] <= 0.0)
8226 MrBayesPrint ("%s Rate (beta) of Gamma must be a positive number\n", spacer);
8229 if (nApplied == 0 && numCurrentDivisions == 1)
8230 MrBayesPrint ("%s Setting Popsizepr to Gamma(%1.2lf,%1.2lf)\n", spacer, modelParams[i].popSizeGamma[0], modelParams[i].popSizeGamma[1]);
8232 MrBayesPrint ("%s Setting Popsizepr to Gamma(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].popSizeGamma[0], modelParams[i].popSizeGamma[1], i+1);
8233 expecting = Expecting(RIGHTPAR);
8236 else if (!strcmp(modelParams[i].popSizePr,"Fixed"))
8238 sscanf (tkn, "%lf", &tempD);
8239 if (AreDoublesEqual(tempD, 0.0, ETA)==YES)
8241 MrBayesPrint ("%s Popsizepr cannot be fixed to 0.0\n", spacer);
8244 modelParams[i].popSizeFix = tempD;
8245 if (nApplied == 0 && numCurrentDivisions == 1)
8246 MrBayesPrint ("%s Setting Popsizepr to Fixed(%1.5lf)\n", spacer, modelParams[i].popSizeFix);
8248 MrBayesPrint ("%s Setting Popsizepr to Fixed(%1.5lf) for partition %d\n", spacer, modelParams[i].popSizeFix, i+1);
8249 expecting = Expecting(RIGHTPAR);
8254 else if (expecting == Expecting(COMMA))
8256 expecting = Expecting(NUMBER);
8258 else if (expecting == Expecting(RIGHTPAR))
8260 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8265 /* set Popvarpr (popVarPr) **************************************************************/
8266 else if (!strcmp(parmName, "Popvarpr"))
8268 if (expecting == Expecting(EQUALSIGN))
8269 expecting = Expecting(ALPHA);
8270 else if (expecting == Expecting(ALPHA))
8272 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8274 nApplied = NumActiveParts ();
8275 for (i=0; i<numCurrentDivisions; i++)
8277 if (activeParts[i] == YES || nApplied == 0)
8279 strcpy(modelParams[i].popVarPr, tempStr);
8281 if (nApplied == 0 && numCurrentDivisions == 1)
8282 MrBayesPrint ("%s Setting Popvarpr to %s\n", spacer, modelParams[i].popVarPr);
8284 MrBayesPrint ("%s Setting Popvarpr to %s for partition %d\n", spacer, modelParams[i].popVarPr, i+1);
8287 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8291 MrBayesPrint ("%s Invalid Popvarpr argument\n", spacer);
8298 /* set Compound Poisson Process rate prior (cppRatePr) *********************************************************/
8299 else if (!strcmp(parmName, "Cppratepr"))
8301 if (expecting == Expecting(EQUALSIGN))
8302 expecting = Expecting(ALPHA);
8303 else if (expecting == Expecting(ALPHA))
8305 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8307 nApplied = NumActiveParts ();
8308 for (i=0; i<numCurrentDivisions; i++)
8310 if (activeParts[i] == YES || nApplied == 0)
8311 strcpy(modelParams[i].cppRatePr, tempStr);
8316 MrBayesPrint ("%s Invalid Cppratepr argument\n", spacer);
8319 expecting = Expecting(LEFTPAR);
8320 for (i=0; i<numCurrentDivisions; i++)
8323 else if (expecting == Expecting(LEFTPAR))
8325 expecting = Expecting(NUMBER);
8327 else if (expecting == Expecting(NUMBER))
8329 nApplied = NumActiveParts ();
8330 for (i=0; i<numCurrentDivisions; i++)
8332 if (activeParts[i] == YES || nApplied == 0)
8334 if (!strcmp(modelParams[i].cppRatePr,"Exponential"))
8336 sscanf (tkn, "%lf", &tempD);
8337 modelParams[i].cppRateExp = tempD;
8338 if (nApplied == 0 && numCurrentDivisions == 1)
8339 MrBayesPrint ("%s Setting Cppratepr to Exponential(%1.2lf)\n", spacer, modelParams[i].cppRateExp);
8341 MrBayesPrint ("%s Setting Cppratepr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].cppRateExp, i+1);
8342 expecting = Expecting(RIGHTPAR);
8344 else if (!strcmp(modelParams[i].cppRatePr,"Fixed"))
8346 sscanf (tkn, "%lf", &tempD);
8347 if (tempD < CPPLAMBDA_MIN || tempD > CPPLAMBDA_MAX)
8349 MrBayesPrint ("%s CPP rate must be in the range %f - %f\n", spacer, CPPLAMBDA_MIN, CPPLAMBDA_MAX);
8352 modelParams[i].cppRateFix = tempD;
8353 if (nApplied == 0 && numCurrentDivisions == 1)
8354 MrBayesPrint ("%s Setting Cppratepr to Fixed(%1.2lf)\n", spacer, modelParams[i].cppRateFix);
8356 MrBayesPrint ("%s Setting Cppratepr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].cppRateFix, i+1);
8357 expecting = Expecting(RIGHTPAR);
8362 else if (expecting == Expecting(COMMA))
8364 expecting = Expecting(NUMBER);
8366 else if (expecting == Expecting(RIGHTPAR))
8368 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8373 /* set Compound Poisson Process rate multiplier standard deviation (log scale) ***********************/
8374 else if (!strcmp(parmName, "Cppmultdevpr"))
8376 if (expecting == Expecting(EQUALSIGN))
8377 expecting = Expecting(ALPHA);
8378 else if (expecting == Expecting(ALPHA))
8380 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8382 nApplied = NumActiveParts ();
8383 for (i=0; i<numCurrentDivisions; i++)
8385 if (activeParts[i] == YES || nApplied == 0)
8386 strcpy(modelParams[i].cppMultDevPr, tempStr);
8391 MrBayesPrint ("%s Invalid Cppmultdevpr argument\n", spacer);
8394 expecting = Expecting(LEFTPAR);
8395 for (i=0; i<numCurrentDivisions; i++)
8398 else if (expecting == Expecting(LEFTPAR))
8400 expecting = Expecting(NUMBER);
8402 else if (expecting == Expecting(NUMBER))
8404 nApplied = NumActiveParts ();
8405 for (i=0; i<numCurrentDivisions; i++)
8407 if (activeParts[i] == YES || nApplied == 0)
8409 if (!strcmp(modelParams[i].cppMultDevPr,"Fixed"))
8411 sscanf (tkn, "%lf", &tempD);
8412 if (tempD < POSREAL_MIN || tempD > POSREAL_MAX)
8414 MrBayesPrint ("%s The log standard deviation of rate multipliers must be in the range %f - %f\n", spacer, POSREAL_MIN, POSREAL_MAX);
8417 modelParams[i].cppMultDevFix = tempD;
8418 if (nApplied == 0 && numCurrentDivisions == 1)
8419 MrBayesPrint ("%s Setting Cppmultdevpr to Fixed(%1.2lf)\n", spacer, modelParams[i].cppMultDevFix);
8421 MrBayesPrint ("%s Setting Cppmultdevpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].cppMultDevFix, i+1);
8422 expecting = Expecting(RIGHTPAR);
8427 else if (expecting == Expecting(COMMA))
8429 expecting = Expecting(NUMBER);
8431 else if (expecting == Expecting(RIGHTPAR))
8433 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8438 /* set prior for variance of lognormal of autocorrelated rates (tk02varPr) ***********************/
8439 else if (!strcmp(parmName, "TK02varpr") || !strcmp(parmName,"Bmvarpr"))
8441 if (expecting == Expecting(EQUALSIGN))
8442 expecting = Expecting(ALPHA);
8443 else if (expecting == Expecting(ALPHA))
8445 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8447 nApplied = NumActiveParts ();
8448 for (i=0; i<numCurrentDivisions; i++)
8450 if (activeParts[i] == YES || nApplied == 0)
8451 strcpy(modelParams[i].tk02varPr, tempStr);
8456 MrBayesPrint ("%s Invalid TK02varpr argument\n", spacer);
8459 expecting = Expecting(LEFTPAR);
8460 for (i=0; i<numCurrentDivisions; i++)
8463 else if (expecting == Expecting(LEFTPAR))
8465 expecting = Expecting(NUMBER);
8467 else if (expecting == Expecting(NUMBER))
8469 nApplied = NumActiveParts ();
8470 for (i=0; i<numCurrentDivisions; i++)
8472 if (activeParts[i] == YES || nApplied == 0)
8474 if (!strcmp(modelParams[i].tk02varPr,"Uniform"))
8476 sscanf (tkn, "%lf", &tempD);
8477 modelParams[i].tk02varUni[numVars[i]++] = tempD;
8478 if (numVars[i] == 1)
8479 expecting = Expecting(COMMA);
8482 if (modelParams[i].tk02varUni[0] >= modelParams[i].tk02varUni[1])
8484 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
8487 if (nApplied == 0 && numCurrentDivisions == 1)
8488 MrBayesPrint ("%s Setting TK02varpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].tk02varUni[0], modelParams[i].tk02varUni[1]);
8490 MrBayesPrint ("%s Setting TK02varpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].tk02varUni[0], modelParams[i].tk02varUni[1], i+1);
8491 expecting = Expecting(RIGHTPAR);
8494 else if (!strcmp(modelParams[i].tk02varPr,"Exponential"))
8496 sscanf (tkn, "%lf", &tempD);
8497 modelParams[i].tk02varExp = tempD;
8498 if (nApplied == 0 && numCurrentDivisions == 1)
8499 MrBayesPrint ("%s Setting TK02varpr to Exponential(%1.2lf)\n", spacer, modelParams[i].tk02varExp);
8501 MrBayesPrint ("%s Setting TK02varpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].tk02varExp, i+1);
8502 expecting = Expecting(RIGHTPAR);
8504 else if (!strcmp(modelParams[i].tk02varPr,"Fixed"))
8506 sscanf (tkn, "%lf", &tempD);
8507 if (tempD < TK02VAR_MIN || tempD > TK02VAR_MAX)
8509 MrBayesPrint ("%s Ratevar (nu) must be in the range %f - %f\n", spacer, TK02VAR_MIN, TK02VAR_MAX);
8512 modelParams[i].tk02varFix = tempD;
8513 if (nApplied == 0 && numCurrentDivisions == 1)
8514 MrBayesPrint ("%s Setting TK02varpr to Fixed(%1.2lf)\n", spacer, modelParams[i].tk02varFix);
8516 MrBayesPrint ("%s Setting TK02varpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].tk02varFix, i+1);
8517 expecting = Expecting(RIGHTPAR);
8522 else if (expecting == Expecting(COMMA))
8524 expecting = Expecting(NUMBER);
8526 else if (expecting == Expecting(RIGHTPAR))
8528 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8533 /* set prior for shape of independent branch rate gamma distribution (igrvarPr) ***********************/
8534 else if (!strcmp(parmName, "Igrvarpr") || !strcmp(parmName, "Ibrvarpr"))
8536 if (expecting == Expecting(EQUALSIGN))
8537 expecting = Expecting(ALPHA);
8538 else if (expecting == Expecting(ALPHA))
8540 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8542 nApplied = NumActiveParts ();
8543 for (i=0; i<numCurrentDivisions; i++)
8545 if (activeParts[i] == YES || nApplied == 0)
8546 strcpy(modelParams[i].igrvarPr, tempStr);
8551 MrBayesPrint ("%s Invalid Igrvarpr argument\n", spacer);
8554 expecting = Expecting(LEFTPAR);
8555 for (i=0; i<numCurrentDivisions; i++)
8558 else if (expecting == Expecting(LEFTPAR))
8560 expecting = Expecting(NUMBER);
8562 else if (expecting == Expecting(NUMBER))
8564 nApplied = NumActiveParts ();
8565 for (i=0; i<numCurrentDivisions; i++)
8567 if (activeParts[i] == YES || nApplied == 0)
8569 if (!strcmp(modelParams[i].igrvarPr,"Uniform"))
8571 sscanf (tkn, "%lf", &tempD);
8572 modelParams[i].igrvarUni[numVars[i]++] = tempD;
8573 if (numVars[i] == 1)
8574 expecting = Expecting(COMMA);
8577 if (modelParams[i].igrvarUni[0] >= modelParams[i].igrvarUni[1])
8579 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
8582 if (nApplied == 0 && numCurrentDivisions == 1)
8583 MrBayesPrint ("%s Setting Igrvarpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].igrvarUni[0], modelParams[i].igrvarUni[1]);
8585 MrBayesPrint ("%s Setting Igrvarpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].igrvarUni[0], modelParams[i].igrvarUni[1], i+1);
8586 expecting = Expecting(RIGHTPAR);
8589 else if (!strcmp(modelParams[i].igrvarPr,"Exponential"))
8591 sscanf (tkn, "%lf", &tempD);
8592 modelParams[i].igrvarExp = tempD;
8593 if (nApplied == 0 && numCurrentDivisions == 1)
8594 MrBayesPrint ("%s Setting Igrvarpr to Exponential(%1.2lf)\n", spacer, modelParams[i].igrvarExp);
8596 MrBayesPrint ("%s Setting Igrvarpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].igrvarExp, i+1);
8597 expecting = Expecting(RIGHTPAR);
8599 else if (!strcmp(modelParams[i].igrvarPr,"Fixed"))
8601 sscanf (tkn, "%lf", &tempD);
8602 if (tempD < IGRVAR_MIN || tempD > IGRVAR_MAX)
8604 MrBayesPrint ("%s Igrvar must be in the range %f - %f\n", spacer, IGRVAR_MIN, IGRVAR_MAX);
8607 modelParams[i].igrvarFix = tempD;
8608 if (nApplied == 0 && numCurrentDivisions == 1)
8609 MrBayesPrint ("%s Setting Igrvarpr to Fixed(%1.2lf)\n", spacer, modelParams[i].igrvarFix);
8611 MrBayesPrint ("%s Setting Igrvarpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].igrvarFix, i+1);
8612 expecting = Expecting(RIGHTPAR);
8617 else if (expecting == Expecting(COMMA))
8619 expecting = Expecting(NUMBER);
8621 else if (expecting == Expecting(RIGHTPAR))
8623 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8628 /* set prior for variance of mixed relaxed clock model (mixedvarPr) ***********************/
8629 else if (!strcmp(parmName, "Mixedvarpr"))
8631 if (expecting == Expecting(EQUALSIGN))
8632 expecting = Expecting(ALPHA);
8633 else if (expecting == Expecting(ALPHA))
8635 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8637 nApplied = NumActiveParts ();
8638 for (i=0; i<numCurrentDivisions; i++)
8640 if (activeParts[i] == YES || nApplied == 0)
8641 strcpy(modelParams[i].mixedvarPr, tempStr);
8646 MrBayesPrint ("%s Invalid Mixedvarpr argument\n", spacer);
8649 expecting = Expecting(LEFTPAR);
8650 for (i=0; i<numCurrentDivisions; i++)
8653 else if (expecting == Expecting(LEFTPAR))
8655 expecting = Expecting(NUMBER);
8657 else if (expecting == Expecting(NUMBER))
8659 nApplied = NumActiveParts ();
8660 for (i=0; i<numCurrentDivisions; i++)
8662 if (activeParts[i] == YES || nApplied == 0)
8664 if (!strcmp(modelParams[i].mixedvarPr,"Uniform"))
8666 sscanf (tkn, "%lf", &tempD);
8667 modelParams[i].mixedvarUni[numVars[i]++] = tempD;
8668 if (numVars[i] == 1)
8669 expecting = Expecting(COMMA);
8672 if (modelParams[i].mixedvarUni[0] >= modelParams[i].mixedvarUni[1])
8674 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
8677 if (nApplied == 0 && numCurrentDivisions == 1)
8678 MrBayesPrint ("%s Setting Mixedvarpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].mixedvarUni[0], modelParams[i].mixedvarUni[1]);
8680 MrBayesPrint ("%s Setting Mixedvarpr to Uniform(%1.2lf,%1.2lf) for partition %d\n", spacer, modelParams[i].mixedvarUni[0], modelParams[i].mixedvarUni[1], i+1);
8681 expecting = Expecting(RIGHTPAR);
8684 else if (!strcmp(modelParams[i].mixedvarPr,"Exponential"))
8686 sscanf (tkn, "%lf", &tempD);
8687 modelParams[i].mixedvarExp = tempD;
8688 if (nApplied == 0 && numCurrentDivisions == 1)
8689 MrBayesPrint ("%s Setting Mixedvarpr to Exponential(%1.2lf)\n", spacer, modelParams[i].mixedvarExp);
8691 MrBayesPrint ("%s Setting Mixedvarpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].mixedvarExp, i+1);
8692 expecting = Expecting(RIGHTPAR);
8694 else if (!strcmp(modelParams[i].mixedvarPr,"Fixed"))
8696 sscanf (tkn, "%lf", &tempD);
8697 if (tempD < IGRVAR_MIN || tempD > IGRVAR_MAX || tempD < TK02VAR_MIN || tempD > TK02VAR_MAX)
8699 MrBayesPrint ("%s Mixedvar must be in the range %f - %f\n", spacer, IGRVAR_MIN, IGRVAR_MAX);
8702 modelParams[i].mixedvarFix = tempD;
8703 if (nApplied == 0 && numCurrentDivisions == 1)
8704 MrBayesPrint ("%s Setting Mixedvarpr to Fixed(%1.2lf)\n", spacer, modelParams[i].mixedvarFix);
8706 MrBayesPrint ("%s Setting Mixedvarpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].mixedvarFix, i+1);
8707 expecting = Expecting(RIGHTPAR);
8712 else if (expecting == Expecting(COMMA))
8714 expecting = Expecting(NUMBER);
8716 else if (expecting == Expecting(RIGHTPAR))
8718 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8723 /* set Growthpr (growthPr) **************************************************************/
8724 else if (!strcmp(parmName, "Growthpr"))
8726 if (expecting == Expecting(EQUALSIGN))
8728 expecting = Expecting(ALPHA);
8731 else if (expecting == Expecting(ALPHA))
8734 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8736 nApplied = NumActiveParts ();
8737 for (i=0; i<numCurrentDivisions; i++)
8739 if (activeParts[i] == YES || nApplied == 0)
8740 strcpy(modelParams[i].growthPr, tempStr);
8745 MrBayesPrint ("%s Invalid Growthpr argument\n", spacer);
8748 expecting = Expecting(LEFTPAR);
8749 for (i=0; i<numCurrentDivisions; i++)
8752 else if (expecting == Expecting(LEFTPAR))
8754 expecting = Expecting(NUMBER) | Expecting(DASH);
8756 else if (expecting == Expecting(DASH))
8758 expecting = Expecting(NUMBER);
8761 else if (expecting == Expecting(NUMBER))
8763 nApplied = NumActiveParts ();
8764 for (i=0; i<numCurrentDivisions; i++)
8766 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
8768 if (!strcmp(modelParams[i].growthPr,"Uniform"))
8770 sscanf (tkn, "%lf", &tempD);
8771 if (isNegative == YES)
8773 modelParams[i].growthUni[numVars[i]++] = tempD;
8774 if (numVars[i] == 1)
8775 expecting = Expecting(COMMA);
8778 if (modelParams[i].growthUni[0] >= modelParams[i].growthUni[1])
8780 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
8783 if (nApplied == 0 && numCurrentDivisions == 1)
8784 MrBayesPrint ("%s Setting Growthpr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].growthUni[0], modelParams[i].growthUni[1]);
8786 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);
8787 expecting = Expecting(RIGHTPAR);
8790 else if (!strcmp(modelParams[i].growthPr,"Normal"))
8792 sscanf (tkn, "%lf", &tempD);
8793 if (isNegative == YES)
8795 modelParams[i].growthNorm[numVars[i]++] = tempD;
8796 if (numVars[i] == 1)
8797 expecting = Expecting(COMMA);
8800 if (modelParams[i].growthNorm[1] < 0.0)
8802 MrBayesPrint ("%s Variance for normal distribution should be greater than zero\n", spacer);
8805 if (nApplied == 0 && numCurrentDivisions == 1)
8806 MrBayesPrint ("%s Setting Growthpr to Normal(%1.2lf,%1.2lf)\n", spacer, modelParams[i].growthNorm[0], modelParams[i].growthNorm[1]);
8808 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);
8809 expecting = Expecting(RIGHTPAR);
8812 else if (!strcmp(modelParams[i].growthPr,"Exponential"))
8814 sscanf (tkn, "%lf", &tempD);
8815 modelParams[i].growthExp = tempD;
8816 if (nApplied == 0 && numCurrentDivisions == 1)
8817 MrBayesPrint ("%s Setting Growthpr to Exponential(%1.2lf)\n", spacer, modelParams[i].growthExp);
8819 MrBayesPrint ("%s Setting Growthpr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].growthExp, i+1);
8820 expecting = Expecting(RIGHTPAR);
8822 else if (!strcmp(modelParams[i].growthPr,"Fixed"))
8824 sscanf (tkn, "%lf", &tempD);
8825 if (isNegative == YES)
8827 modelParams[i].growthFix = tempD;
8828 if (nApplied == 0 && numCurrentDivisions == 1)
8829 MrBayesPrint ("%s Setting Growthpr to Fixed(%1.2lf)\n", spacer, modelParams[i].growthFix);
8831 MrBayesPrint ("%s Setting Growthpr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].growthFix, i+1);
8832 expecting = Expecting(RIGHTPAR);
8838 else if (expecting == Expecting(COMMA))
8840 expecting = Expecting(NUMBER);
8842 else if (expecting == Expecting(RIGHTPAR))
8844 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
8849 /* set Aamodelpr (aaModelPr) **************************************************************/
8850 else if (!strcmp(parmName, "Aamodelpr"))
8852 if (expecting == Expecting(EQUALSIGN))
8854 expecting = Expecting(ALPHA);
8855 foundAaSetting = foundExp = modelIsFixed = foundDash = NO;
8857 for (i=0; i<10; i++)
8858 tempAaModelPrs[i] = 0.0;
8860 else if (expecting == Expecting(ALPHA))
8862 if (foundAaSetting == NO)
8864 if (IsArgValid(tkn, tempStr) == NO_ERROR)
8866 nApplied = NumActiveParts ();
8867 for (i=0; i<numCurrentDivisions; i++)
8869 if ((activeParts[i] == YES || nApplied == 0))
8871 strcpy(modelParams[i].aaModelPr, tempStr);
8872 if (!strcmp(modelParams[i].aaModelPr, "Mixed"))
8874 if (nApplied == 0 && numCurrentDivisions == 1)
8875 MrBayesPrint ("%s Setting Aamodelpr to %s\n", spacer, modelParams[i].aaModelPr);
8877 MrBayesPrint ("%s Setting Aamodelpr to %s for partition %d\n", spacer, modelParams[i].aaModelPr, i+1);
8884 MrBayesPrint ("%s Invalid Aamodelpr argument\n", spacer);
8887 foundAaSetting = YES;
8888 if (!strcmp(tempStr, "Fixed"))
8891 expecting = Expecting(LEFTPAR);
8895 expecting = Expecting(LEFTPAR) | Expecting(PARAMETER) | Expecting(SEMICOLON);
8900 if (modelIsFixed == YES)
8902 if (IsSame ("Poisson", tkn) == SAME || IsSame ("Poisson", tkn) == CONSISTENT_WITH)
8903 strcpy (tempStr, "Poisson");
8904 else if (IsSame ("Equalin", tkn) == SAME || IsSame ("Equalin", tkn) == CONSISTENT_WITH)
8905 strcpy (tempStr, "Equalin");
8906 else if (IsSame ("Jones", tkn) == SAME || IsSame ("Jones", tkn) == CONSISTENT_WITH)
8907 strcpy (tempStr, "Jones");
8908 else if (IsSame ("Dayhoff", tkn) == SAME || IsSame ("Dayhoff", tkn) == CONSISTENT_WITH)
8909 strcpy (tempStr, "Dayhoff");
8910 else if (IsSame ("Mtrev", tkn) == SAME || IsSame ("Mtrev", tkn) == CONSISTENT_WITH)
8911 strcpy (tempStr, "Mtrev");
8912 else if (IsSame ("Mtmam", tkn) == SAME || IsSame ("Mtmam", tkn) == CONSISTENT_WITH)
8913 strcpy (tempStr, "Mtmam");
8914 else if (IsSame ("Wag", tkn) == SAME || IsSame ("Wag", tkn) == CONSISTENT_WITH)
8915 strcpy (tempStr, "Wag");
8916 else if (IsSame ("Rtrev", tkn) == SAME || IsSame ("Rtrev", tkn) == CONSISTENT_WITH)
8917 strcpy (tempStr, "Rtrev");
8918 else if (IsSame ("Cprev", tkn) == SAME || IsSame ("Cprev", tkn) == CONSISTENT_WITH)
8919 strcpy (tempStr, "Cprev");
8920 else if (IsSame ("Vt", tkn) == SAME || IsSame ("Vt", tkn) == CONSISTENT_WITH)
8921 strcpy (tempStr, "Vt");
8922 else if (IsSame ("Blosum", tkn) == SAME || IsSame ("Blosum", tkn) == CONSISTENT_WITH)
8923 strcpy (tempStr, "Blosum");
8924 else if (IsSame ("Blossum", tkn) == SAME || IsSame ("Blossum", tkn) == CONSISTENT_WITH)
8925 strcpy (tempStr, "Blosum");
8926 else if (IsSame ("LG", tkn) == SAME || IsSame ("LG", tkn) == CONSISTENT_WITH)
8927 strcpy (tempStr, "LG");
8928 else if (IsSame ("Gtr", tkn) == SAME || IsSame ("Gtr", tkn) == CONSISTENT_WITH)
8929 strcpy (tempStr, "Gtr");
8932 MrBayesPrint ("%s Invalid amino acid model\n", spacer);
8935 nApplied = NumActiveParts ();
8936 for (i=0; i<numCurrentDivisions; i++)
8938 if ((activeParts[i] == YES || nApplied == 0))
8940 if (!strcmp(modelParams[i].aaModelPr, "Fixed"))
8942 strcpy(modelParams[i].aaModel, tempStr);
8943 if (nApplied == 0 && numCurrentDivisions == 1)
8944 MrBayesPrint ("%s Setting Aamodelpr to Fixed(%s)\n", spacer, modelParams[i].aaModel);
8946 MrBayesPrint ("%s Setting Aamodelpr to Fixed(%s) for partition %d\n", spacer, modelParams[i].aaModel, i+1);
8950 MrBayesPrint ("%s You cannot assign an amino acid matrix for mixed models\n", spacer);
8955 expecting = Expecting(RIGHTPAR);
8959 if (IsSame ("Exponential", tkn) == SAME || IsSame ("Exponential", tkn) == CONSISTENT_WITH)
8962 expecting = Expecting(LEFTPAR);
8966 MrBayesPrint ("%s Invalid argument \"%s\"\n", spacer, tkn);
8973 else if (expecting == Expecting(NUMBER))
8975 sscanf (tkn, "%lf", &tempD);
8978 MrBayesPrint ("%s Too many arguments in Aamodelpr\n", spacer);
8981 if (modelIsFixed == NO)
8983 if (foundExp == YES)
8985 if (foundDash == YES)
8986 tempAaModelPrs[fromI++] = -tempD;
8988 tempAaModelPrs[fromI++] = tempD;
8989 expecting = Expecting(RIGHTPAR);
8993 if (foundDash == YES)
8995 MrBayesPrint ("%s Unexpected \"-\" in Aamodelpr\n", spacer);
9000 if (tempD <= 0.000000000001)
9001 tempAaModelPrs[fromI++] = -1000000000;
9003 tempAaModelPrs[fromI++] = (MrBFlt) log(tempD);
9005 expecting = Expecting(COMMA) | Expecting(RIGHTPAR);
9011 MrBayesPrint ("%s Not expecting a number\n", spacer);
9015 else if (expecting == Expecting(LEFTPAR))
9017 if (modelIsFixed == YES)
9018 expecting = Expecting(ALPHA);
9021 if (foundExp == YES)
9022 expecting = Expecting(NUMBER) | Expecting(DASH);
9024 expecting = Expecting(NUMBER) | Expecting(ALPHA);
9027 else if (expecting == Expecting(RIGHTPAR))
9029 if (modelIsFixed == YES)
9030 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9033 if (foundExp == YES)
9036 expecting = Expecting(COMMA) | Expecting(RIGHTPAR);
9042 MrBayesPrint ("%s Too few arguments in Aamodelpr\n", spacer);
9045 nApplied = NumActiveParts ();
9046 for (i=0; i<numCurrentDivisions; i++)
9048 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType == PROTEIN)
9050 if (!strcmp(modelParams[i].aaModelPr, "Fixed"))
9052 MrBayesPrint ("%s You cannot assign model prior probabilities for a fixed amino acid model\n", spacer);
9057 for (j=0; j<10; j++)
9058 modelParams[i].aaModelPrProbs[j] = tempAaModelPrs[j];
9062 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9066 else if (expecting == Expecting(DASH))
9068 if (foundExp == YES)
9071 expecting = Expecting(NUMBER);
9075 MrBayesPrint ("%s Invalid argument \"%s\"\n", spacer, tkn);
9079 else if (expecting == Expecting(COMMA))
9081 if (modelIsFixed == YES)
9083 MrBayesPrint ("%s Not expecting \"%s\"\n", spacer, tkn);
9087 expecting = Expecting(NUMBER) | Expecting(ALPHA);
9092 /* set Brownscalepr (brownScalesPr) ****************************************************/
9093 else if (!strcmp(parmName, "Brownscalepr"))
9095 if (expecting == Expecting(EQUALSIGN))
9096 expecting = Expecting(ALPHA);
9097 else if (expecting == Expecting(ALPHA))
9099 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9101 nApplied = NumActiveParts ();
9103 for (i=0; i<numCurrentDivisions; i++)
9105 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType == CONTINUOUS)
9107 strcpy(modelParams[i].brownScalesPr, tempStr);
9113 MrBayesPrint ("%s Warning: %s can be set only for partition containing CONTINUOUS data.\
9114 Currently there is no active partition with such data. ", spacer, parmName);
9120 MrBayesPrint ("%s Invalid Brownscalepr argument\n", spacer);
9123 expecting = Expecting(LEFTPAR);
9124 for (i=0; i<numCurrentDivisions; i++)
9127 else if (expecting == Expecting(LEFTPAR))
9129 expecting = Expecting(NUMBER);
9131 else if (expecting == Expecting(NUMBER))
9133 nApplied = NumActiveParts ();
9134 for (i=0; i<numCurrentDivisions; i++)
9136 if ((activeParts[i] == YES || nApplied == 0) && modelParams[i].dataType == CONTINUOUS)
9138 if (!strcmp(modelParams[i].brownScalesPr,"Uniform"))
9140 sscanf (tkn, "%lf", &tempD);
9141 modelParams[i].brownScalesUni[numVars[i]++] = tempD;
9142 if (numVars[i] == 1)
9143 expecting = Expecting(COMMA);
9146 if (modelParams[i].brownScalesUni[0] >= modelParams[i].brownScalesUni[1])
9148 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
9151 if (nApplied == 0 && numCurrentDivisions == 1)
9152 MrBayesPrint ("%s Setting Brownscalepr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].brownScalesUni[0], modelParams[i].brownScalesUni[1]);
9154 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);
9155 expecting = Expecting(RIGHTPAR);
9158 else if (!strcmp(modelParams[i].brownScalesPr,"Gamma"))
9160 sscanf (tkn, "%lf", &tempD);
9161 modelParams[i].brownScalesGamma[numVars[i]++] = tempD;
9162 if (numVars[i] == 1)
9163 expecting = Expecting(COMMA);
9166 if (nApplied == 0 && numCurrentDivisions == 1)
9167 MrBayesPrint ("%s Setting Brownscalepr to Gamma Mean=%1.2lf Var=%1.2lf\n", spacer, modelParams[i].brownScalesGamma[0], modelParams[i].brownScalesGamma[1]);
9169 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);
9170 expecting = Expecting(RIGHTPAR);
9173 else if (!strcmp(modelParams[i].brownScalesPr,"Gammamean"))
9175 sscanf (tkn, "%lf", &tempD);
9176 modelParams[i].brownScalesGammaMean = tempD;
9177 if (nApplied == 0 && numCurrentDivisions == 1)
9178 MrBayesPrint ("%s Setting Brownscalepr to Gamma Mean=<char. ave.> Var=%1.2lf\n", spacer, modelParams[i].brownScalesGammaMean);
9180 MrBayesPrint ("%s Setting Brownscalepr to Gamma Mean=<char.ave.> Var=%1.2lf for partition %d\n", spacer, modelParams[i].brownScalesGammaMean, i+1);
9181 expecting = Expecting(RIGHTPAR);
9183 else if (!strcmp(modelParams[i].brownScalesPr,"Fixed"))
9185 sscanf (tkn, "%lf", &tempD);
9186 modelParams[i].brownScalesFix = tempD;
9187 if (nApplied == 0 && numCurrentDivisions == 1)
9188 MrBayesPrint ("%s Setting Brownscalepr to Fixed(%1.2lf)\n", spacer, modelParams[i].brownScalesFix);
9190 MrBayesPrint ("%s Setting Brownscalepr to Fixed(%1.2lf) for partition %d\n", spacer, modelParams[i].brownScalesFix, i+1);
9191 expecting = Expecting(RIGHTPAR);
9196 else if (expecting == Expecting(COMMA))
9198 expecting = Expecting(NUMBER);
9200 else if (expecting == Expecting(RIGHTPAR))
9202 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9207 /* set M10betapr (m10betapr) ********************************************************/
9208 else if (!strcmp(parmName, "M10betapr"))
9210 if (expecting == Expecting(EQUALSIGN))
9211 expecting = Expecting(ALPHA);
9212 else if (expecting == Expecting(ALPHA))
9214 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9216 nApplied = NumActiveParts ();
9218 for (i=0; i<numCurrentDivisions; i++)
9220 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
9222 strcpy(modelParams[i].m10betapr, tempStr);
9228 MrBayesPrint ("%s Warning: %s can be set only for partition containing data of at least one of the following type: DNA, RNA.\
9229 Currently there is no active partition with such data. ", spacer, parmName);
9235 MrBayesPrint ("%s Invalid M10betapr argument\n", spacer);
9238 expecting = Expecting(LEFTPAR);
9239 for (i=0; i<numCurrentDivisions; i++)
9242 else if (expecting == Expecting(LEFTPAR))
9244 expecting = Expecting(NUMBER);
9246 else if (expecting == Expecting(NUMBER))
9248 nApplied = NumActiveParts ();
9249 for (i=0; i<numCurrentDivisions; i++)
9251 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
9253 if (!strcmp(modelParams[i].m10betapr,"Uniform"))
9255 sscanf (tkn, "%lf", &tempD);
9256 modelParams[i].m10betaUni[numVars[i]++] = tempD;
9257 if (numVars[i] == 1)
9258 expecting = Expecting(COMMA);
9261 if (modelParams[i].m10betaUni[0] >= modelParams[i].m10betaUni[1])
9263 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
9266 if (nApplied == 0 && numCurrentDivisions == 1)
9267 MrBayesPrint ("%s Setting M10betapr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].m10betaUni[0], modelParams[i].m10betaUni[1]);
9269 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);
9270 expecting = Expecting(RIGHTPAR);
9273 else if (!strcmp(modelParams[i].m10betapr,"Exponential"))
9275 sscanf (tkn, "%lf", &tempD);
9276 modelParams[i].m10betaExp = tempD;
9277 if (nApplied == 0 && numCurrentDivisions == 1)
9278 MrBayesPrint ("%s Setting M10betapr to Exponential(%1.2lf)\n", spacer, modelParams[i].m10betaExp);
9280 MrBayesPrint ("%s Setting M10betapr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].m10betaExp, i+1);
9281 expecting = Expecting(RIGHTPAR);
9283 else if (!strcmp(modelParams[i].m10betapr,"Fixed"))
9285 sscanf (tkn, "%lf", &tempD);
9286 modelParams[i].m10betaFix[numVars[i]++] = tempD;
9287 if (numVars[i] == 1)
9288 expecting = Expecting(COMMA);
9291 if (nApplied == 0 && numCurrentDivisions == 1)
9292 MrBayesPrint ("%s Setting M10betapr to Fixed(%1.2lf,%1.2lf)\n", spacer, modelParams[i].m10betaFix[0], modelParams[i].m10betaFix[1]);
9294 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);
9295 expecting = Expecting(RIGHTPAR);
9301 else if (expecting == Expecting(COMMA))
9303 expecting = Expecting(NUMBER);
9305 else if (expecting == Expecting(RIGHTPAR))
9307 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9312 /* set M10gammapr (m10gammapr) ********************************************************/
9313 else if (!strcmp(parmName, "M10gammapr"))
9315 if (expecting == Expecting(EQUALSIGN))
9316 expecting = Expecting(ALPHA);
9317 else if (expecting == Expecting(ALPHA))
9319 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9321 nApplied = NumActiveParts ();
9323 for (i=0; i<numCurrentDivisions; i++)
9325 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
9327 strcpy(modelParams[i].m10gammapr, tempStr);
9333 MrBayesPrint ("%s Warning: %s can be set only for partition containing data of at least one of the following type: DNA, RNA.\
9334 Currently there is no active partition with such data. ", spacer, parmName);
9340 MrBayesPrint ("%s Invalid M10gammapr argument\n", spacer);
9343 expecting = Expecting(LEFTPAR);
9344 for (i=0; i<numCurrentDivisions; i++)
9347 else if (expecting == Expecting(LEFTPAR))
9349 expecting = Expecting(NUMBER);
9351 else if (expecting == Expecting(NUMBER))
9353 nApplied = NumActiveParts ();
9354 for (i=0; i<numCurrentDivisions; i++)
9356 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
9358 if (!strcmp(modelParams[i].m10gammapr,"Uniform"))
9360 sscanf (tkn, "%lf", &tempD);
9361 modelParams[i].m10gammaUni[numVars[i]++] = tempD;
9362 if (numVars[i] == 1)
9363 expecting = Expecting(COMMA);
9366 if (modelParams[i].m10gammaUni[0] >= modelParams[i].m10gammaUni[1])
9368 MrBayesPrint ("%s Lower value for uniform should be greater than upper value\n", spacer);
9371 if (nApplied == 0 && numCurrentDivisions == 1)
9372 MrBayesPrint ("%s Setting M10gammapr to Uniform(%1.2lf,%1.2lf)\n", spacer, modelParams[i].m10gammaUni[0], modelParams[i].m10gammaUni[1]);
9374 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);
9375 expecting = Expecting(RIGHTPAR);
9378 else if (!strcmp(modelParams[i].m10gammapr,"Exponential"))
9380 sscanf (tkn, "%lf", &tempD);
9381 modelParams[i].m10gammaExp = tempD;
9382 if (nApplied == 0 && numCurrentDivisions == 1)
9383 MrBayesPrint ("%s Setting M10gammapr to Exponential(%1.2lf)\n", spacer, modelParams[i].m10gammaExp);
9385 MrBayesPrint ("%s Setting M10gammapr to Exponential(%1.2lf) for partition %d\n", spacer, modelParams[i].m10gammaExp, i+1);
9386 expecting = Expecting(RIGHTPAR);
9388 else if (!strcmp(modelParams[i].m10gammapr,"Fixed"))
9390 sscanf (tkn, "%lf", &tempD);
9391 modelParams[i].m10gammaFix[numVars[i]++] = tempD;
9392 if (numVars[i] == 1)
9393 expecting = Expecting(COMMA);
9396 if (nApplied == 0 && numCurrentDivisions == 1)
9397 MrBayesPrint ("%s Setting M10gammapr to Fixed(%1.2lf,%1.2lf)\n", spacer, modelParams[i].m10gammaFix[0], modelParams[i].m10gammaFix[1]);
9399 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);
9400 expecting = Expecting(RIGHTPAR);
9406 else if (expecting == Expecting(COMMA))
9408 expecting = Expecting(NUMBER);
9410 else if (expecting == Expecting(RIGHTPAR))
9412 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9431 /* free information for model and matrix */
9435 SafeFclose (&logFileFp);
9438 /* check to see if any memory has not been freed */
9439 for (i=0; i<NUM_ALLOCS; i++)
9441 if (memAllocs[i] == YES)
9443 MrBayesPrint (" WARNING: Memory (%d) has not been freed\n", i);
9444 if (mode == INTERACTIVE && quitOnError == NO)
9446 MrBayesPrint ("%s Hit return key to continue ", spacer);
9448 if (fgets (tempName, 100, stdin) == NULL)
9450 printf ("Error in function: %s at line: %d in file: %s", __FUNCTION__, __LINE__, __FILE__);
9456 /* free modelIndicatorParams and modelElementNames */
9457 for (i=0; i<203; i++)
9458 free (modelElementNames[1][i]);
9460 free (modelElementNames[i]);
9461 free (modelElementNames);
9462 free (modelIndicatorParams);
9464 MrBayesPrint (" Quitting program\n\n");
9466 /* If we quit while reading a mrbayes block, then we need to make certain
9467 that we return a NO_ERROR_QUIT so we can break out of DoExecute cleanly,
9468 and dealloc "s" there. */
9469 if (inMrbayesBlock == YES)
9471 inMrbayesBlock = NO;
9472 return (NO_ERROR_QUIT);
9481 /* TODO: smart update */
9482 if (SetUpAnalysis (&globalSeed) == ERROR)
9488 int DoReportParm (char *parmName, char *tkn)
9490 int i, tempInt, nApplied;
9493 if (defMatrix == NO)
9495 MrBayesPrint ("%s A matrix must be specified before the report settings can be altered\n", spacer);
9498 if (inValidCommand == YES)
9500 for (i=0; i<numCurrentDivisions; i++)
9501 activeParts[i] = NO;
9502 inValidCommand = NO;
9505 if (expecting == Expecting(PARAMETER))
9507 expecting = Expecting(EQUALSIGN);
9511 /* set Applyto (Applyto) *************************************************************/
9512 if (!strcmp(parmName, "Applyto"))
9514 if (expecting == Expecting(EQUALSIGN))
9515 expecting = Expecting(LEFTPAR);
9516 else if (expecting == Expecting(LEFTPAR))
9518 for (i=0; i<numCurrentDivisions; i++)
9519 activeParts[i] = NO;
9522 expecting = Expecting(NUMBER) | Expecting(ALPHA);
9524 else if (expecting == Expecting(RIGHTPAR))
9527 activeParts[fromI-1] = YES;
9528 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9530 else if (expecting == Expecting(COMMA))
9533 expecting = Expecting(NUMBER);
9535 else if (expecting == Expecting(ALPHA))
9537 if (IsSame ("All", tkn) == DIFFERENT)
9539 MrBayesPrint ("%s Do not understand delimiter \"%s\"\n", spacer, tkn);
9542 for (i=0; i<numCurrentDivisions; i++)
9543 activeParts[i] = YES;
9544 expecting = Expecting(RIGHTPAR);
9546 else if (expecting == Expecting(NUMBER))
9548 sscanf (tkn, "%d", &tempInt);
9549 if (tempInt > numCurrentDivisions)
9551 MrBayesPrint ("%s Partition delimiter is too large\n", spacer);
9556 else if (fromI != -1 && toJ == -1 && foundDash == YES && foundComma == NO)
9559 for (i=fromI-1; i<toJ; i++)
9560 activeParts[i] = YES;
9564 else if (fromI != -1 && toJ == -1 && foundDash == NO && foundComma == YES)
9566 activeParts[fromI-1] = YES;
9571 expecting = Expecting(COMMA);
9572 expecting |= Expecting(DASH);
9573 expecting |= Expecting(RIGHTPAR);
9575 else if (expecting == Expecting(DASH))
9578 expecting = Expecting(NUMBER);
9583 /* set report format of tratio ***************************************************/
9584 else if (!strcmp(parmName, "Tratio"))
9586 if (expecting == Expecting(EQUALSIGN))
9587 expecting = Expecting (ALPHA);
9588 else if (expecting == Expecting(ALPHA))
9590 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9592 nApplied = NumActiveParts ();
9594 for (i=0; i<numCurrentDivisions; i++)
9596 /* check that data type is correct; we do not know yet if the user will specify
9597 a nst=2 model so we cannot check that tratio is an active parameter */
9598 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
9600 strcpy(modelParams[i].tratioFormat, tempStr);
9601 if (nApplied == 0 && numCurrentDivisions == 1)
9602 MrBayesPrint ("%s Setting transition/transversion rate ratio (tratio) format to %s\n", spacer, modelParams[i].tratioFormat);
9604 MrBayesPrint ("%s Setting transition/transversion rate ratio (tratio) format to %s for partition %d\n", spacer, modelParams[i].tratioFormat, i+1);
9610 MrBayesPrint ("%s Invalid transition/transversion rate ratio (tratio) format \n", spacer);
9613 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9618 /* set report format of revmat ***************************************************/
9619 else if (!strcmp(parmName, "Revmat"))
9621 if (expecting == Expecting(EQUALSIGN))
9622 expecting = Expecting (ALPHA);
9623 else if (expecting == Expecting(ALPHA))
9625 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9627 nApplied = NumActiveParts ();
9629 for (i=0; i<numCurrentDivisions; i++)
9631 /* check that data type is correct; we do not know yet if the user will specify
9632 a nst=6 model so we cannot check that revmat is an active parameter */
9633 if ((activeParts[i] == YES || nApplied == 0) && (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA))
9635 strcpy(modelParams[i].revmatFormat, tempStr);
9636 if (nApplied == 0 && numCurrentDivisions == 1)
9637 MrBayesPrint ("%s Setting reversible rate matrix (revmat) format to %s\n", spacer, modelParams[i].revmatFormat);
9639 MrBayesPrint ("%s Setting reversible rate matrix (revmat) format to %s for partition %d\n", spacer, modelParams[i].revmatFormat, i+1);
9645 MrBayesPrint ("%s Invalid reversible rate matrix (revmat) format \n", spacer);
9648 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9653 /* set report format of ratemult *************************************************/
9654 else if (!strcmp(parmName, "Ratemult"))
9656 if (expecting == Expecting(EQUALSIGN))
9657 expecting = Expecting (ALPHA);
9658 else if (expecting == Expecting(ALPHA))
9660 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9662 nApplied = NumActiveParts ();
9664 for (i=0; i<numCurrentDivisions; i++)
9666 /* we do not know yet if the user will specify variable rates across partitions
9667 so only check that we have more than one partition in the model */
9668 if ((activeParts[i] == YES || nApplied == 0) && numCurrentDivisions > 1)
9670 strcpy(modelParams[i].ratemultFormat, tempStr);
9671 if (nApplied == 0 && numCurrentDivisions == 1)
9672 MrBayesPrint ("%s Setting rate multiplier (ratemult) format to %s\n", spacer, modelParams[i].ratemultFormat);
9674 MrBayesPrint ("%s Setting rate multiplier (ratemult) format to %s for partition %d\n", spacer, modelParams[i].ratemultFormat, i+1);
9680 MrBayesPrint ("%s Invalid rate multiplier (ratemult) format \n", spacer);
9683 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9688 /* set report format of tree ***************************************************/
9689 else if (!strcmp(parmName, "Tree"))
9691 if (expecting == Expecting(EQUALSIGN))
9692 expecting = Expecting (ALPHA);
9693 else if (expecting == Expecting(ALPHA))
9695 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9697 nApplied = NumActiveParts ();
9699 for (i=0; i<numCurrentDivisions; i++)
9701 strcpy(modelParams[i].treeFormat, tempStr);
9702 if (nApplied == 0 && numCurrentDivisions == 1)
9703 MrBayesPrint ("%s Setting tree report format to %s\n", spacer, modelParams[i].treeFormat);
9705 MrBayesPrint ("%s Setting tree report format to %s for partition %d\n", spacer, modelParams[i].treeFormat, i+1);
9710 MrBayesPrint ("%s Invalid tree report format \n", spacer);
9713 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9718 /* set inferancstates ***********************************************************/
9719 else if (!strcmp(parmName, "Ancstates"))
9721 if (expecting == Expecting(EQUALSIGN))
9722 expecting = Expecting (ALPHA);
9723 else if (expecting == Expecting(ALPHA))
9725 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9727 nApplied = NumActiveParts ();
9728 for (i=0; i<numCurrentDivisions; i++)
9730 if (activeParts[i] == YES || nApplied == 0)
9732 strcpy(modelParams[i].inferAncStates,tempStr);
9733 if (!strcmp(tempStr,"Yes"))
9735 if (nApplied == 0 && numCurrentDivisions == 1)
9736 MrBayesPrint ("%s Reporting ancestral states (if applicable)\n", spacer);
9738 MrBayesPrint ("%s Reporting ancestral states for partition %d (if applicable)\n", spacer, i+1);
9742 if (nApplied == 0 && numCurrentDivisions == 1)
9743 MrBayesPrint ("%s Not reporting ancestral states\n", spacer);
9745 MrBayesPrint ("%s Not reporting ancestral states for partition %d\n", spacer, i+1);
9752 MrBayesPrint ("%s Invalid ancstates option\n", spacer);
9755 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9760 /* set inferSiteRates ***************************************************************/
9761 else if (!strcmp(parmName, "Siterates"))
9763 if (expecting == Expecting(EQUALSIGN))
9764 expecting = Expecting (ALPHA);
9765 else if (expecting == Expecting(ALPHA))
9767 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9769 nApplied = NumActiveParts ();
9770 for (i=0; i<numCurrentDivisions; i++)
9772 if (activeParts[i] == YES || nApplied == 0)
9774 strcpy (modelParams[i].inferSiteRates, tempStr);
9775 if (!strcmp(tempStr,"Yes"))
9777 if (nApplied == 0 && numCurrentDivisions == 1)
9778 MrBayesPrint ("%s Reporting site rates (if applicable)\n", spacer);
9780 MrBayesPrint ("%s Reporting site rates for partition %d (if applicable)\n", spacer, i+1);
9784 if (nApplied == 0 && numCurrentDivisions == 1)
9785 MrBayesPrint ("%s Not reporting site rates\n", spacer);
9787 MrBayesPrint ("%s Not reporting site rates for partition %d\n", spacer, i+1);
9794 MrBayesPrint ("%s Invalid siterates option\n", spacer);
9797 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9802 /* set inferpossel *************************************************************/
9803 else if (!strcmp(parmName, "Possel"))
9805 if (expecting == Expecting(EQUALSIGN))
9806 expecting = Expecting (ALPHA);
9807 else if (expecting == Expecting(ALPHA))
9809 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9811 nApplied = NumActiveParts ();
9812 for (i=0; i<numCurrentDivisions; i++)
9814 if (activeParts[i] == YES || nApplied == 0)
9816 strcpy (modelParams[i].inferPosSel, tempStr);
9817 if (!strcmp(tempStr, "Yes"))
9819 if (nApplied == 0 && numCurrentDivisions == 1)
9820 MrBayesPrint ("%s Reporting positive selection (if applicable)\n", spacer);
9822 MrBayesPrint ("%s Reporting positive selection for partition %d (if applicable)\n", spacer, i+1);
9826 if (nApplied == 0 && numCurrentDivisions == 1)
9827 MrBayesPrint ("%s Not reporting positive selection\n", spacer);
9829 MrBayesPrint ("%s Not reporting positive selection for partition %d\n", spacer, i+1);
9836 MrBayesPrint ("%s Invalid possel option\n", spacer);
9839 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9844 /* set inferSiteOmegas *************************************************************/
9845 else if (!strcmp(parmName, "Siteomega"))
9847 if (expecting == Expecting(EQUALSIGN))
9848 expecting = Expecting (ALPHA);
9849 else if (expecting == Expecting(ALPHA))
9851 if (IsArgValid(tkn, tempStr) == NO_ERROR)
9853 nApplied = NumActiveParts ();
9854 for (i=0; i<numCurrentDivisions; i++)
9856 if (activeParts[i] == YES || nApplied == 0)
9858 strcpy (modelParams[i].inferSiteOmegas, tempStr);
9859 if (!strcmp(tempStr, "Yes"))
9861 if (nApplied == 0 && numCurrentDivisions == 1)
9862 MrBayesPrint ("%s Reporting site omega values (if applicable)\n", spacer);
9864 MrBayesPrint ("%s Reporting site omega values for partition %d (if applicable)\n", spacer, i+1);
9868 if (nApplied == 0 && numCurrentDivisions == 1)
9869 MrBayesPrint ("%s Not reporting site omega values\n", spacer);
9871 MrBayesPrint ("%s Not reporting site omega values for partition %d\n", spacer, i+1);
9878 MrBayesPrint ("%s Invalid siteomega option\n", spacer);
9881 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
9896 int DoStartvals (void)
9898 MrBayesPrint ("%s Successfully set starting values\n", spacer);
9900 for (i=0; i<numParams; i++)
9901 assert (IsTreeConsistent(¶ms[i], 0, 0) == YES);
9907 int DoStartvalsParm (char *parmName, char *tkn)
9909 int i, j, k, nMatches, tempInt, treeIndex, chainId, ret;
9910 MrBFlt tempFloat, *value, *subValue;
9911 Tree *theTree, *usrTree;
9912 PolyTree *thePolyTree;
9913 MrBFlt minRate, maxRate, clockRate;
9914 static Param *param = NULL;
9915 static MrBFlt *theValue, theValueMin, theValueMax;
9916 static int useSubvalues, useStdStateFreqs, useIntValues, numExpectedValues, nValuesRead, runIndex, chainIndex, foundName, foundDash;
9917 static char *temp=NULL, *tempName=NULL;
9919 if (defMatrix == NO)
9921 MrBayesPrint ("%s A matrix must be specified before starting values can be changed\n", spacer);
9925 if (expecting == Expecting(PARAMETER))
9927 if (!strcmp(parmName, "Xxxxxxxxxx"))
9929 /* we expect a parameter name with possible run and chain specification as follows:
9930 <param_name>(<run>,<chain>)=(<number>,...) -- apply to run <run> and chain <chain>
9931 <param_name>(,<chain>)=(<number>,...) -- apply to chain <chain> for all runs
9932 <param_name>(<run>,)=(<number>,...) -- apply to run <run> for all chains
9934 topology and branch length parameters are specified like
9935 <param_name>(<run>,<chain>)=<tree_name>|<Newick_tree_spec>
9937 parameter names will often be followed by partition specifiers like:
9940 so we need to assemble the parameter name from several tokens that are parsed out separately;
9941 here we receive only the first part (before the left curly, if present)
9944 /* copy to local parameter name */
9945 SafeStrcpy (&tempName, tkn);
9947 runIndex = chainIndex = -1;
9950 useStdStateFreqs = NO;
9951 foundComma = foundEqual = foundName = foundDash = NO;
9952 expecting = Expecting(LEFTCURL) | Expecting(LEFTPAR) | Expecting(EQUALSIGN);
9957 else if (expecting == Expecting(ALPHA))
9961 /* we are still assembling the parameter name */
9962 SafeStrcat (&tempName, tkn);
9963 expecting = Expecting(RIGHTCURL) | Expecting(COMMA) | Expecting(LEFTPAR) | Expecting(EQUALSIGN);
9967 /* we have a tree name; now find the tree based on name, case insensitive */
9968 if (GetUserTreeFromName (&treeIndex, tkn) == ERROR || treeIndex == -1)
9970 MrBayesPrint ("%s Error in finding user tree\n", spacer);
9974 /* set the tree parameter */
9975 for (i=0; i<chainParams.numRuns; i++)
9977 if (runIndex != -1 && i != runIndex)
9979 for (j=0; j<chainParams.numChains; j++)
9981 if (chainIndex != -1 && j != chainIndex)
9983 chainId = i*chainParams.numChains + j;
9984 if (param->paramType != P_POPSIZE)
9986 if (param->paramType == P_TOPOLOGY || param->paramType == P_BRLENS || param->paramType == P_SPECIESTREE)
9988 /* topology or brlens or speciestree params */
9989 theTree = GetTree (param, chainId, 0);
9990 usrTree = GetTree (param, chainId, 1); /* use as scratch space */
9994 /* relaxed clock params */
9995 theTree = GetTree (modelSettings[param->relParts[0]].brlens, chainId, 0);
9996 usrTree = GetTree (modelSettings[param->relParts[0]].brlens, chainId, 1);
9998 CopyToTreeFromTree (usrTree, theTree);
9999 if (param->paramType == P_SPECIESTREE)
10000 thePolyTree = AllocatePolyTree(numSpecies);
10002 thePolyTree = AllocatePolyTree (numTaxa);
10003 CopyToPolyTreeFromPolyTree (thePolyTree, userTree[treeIndex]);
10004 if (param->paramType == P_SPECIESTREE)
10006 ResetIntNodeIndices(thePolyTree);
10010 PrunePolyTree (thePolyTree);
10011 ResetTipIndices(thePolyTree);
10013 RandResolve (NULL, thePolyTree, &globalSeed, theTree->isRooted);
10014 GetPolyDownPass(thePolyTree);
10015 ResetIntNodeIndices(thePolyTree);
10016 if (param->paramType == P_SPECIESTREE)
10018 ret=CopyToSpeciesTreeFromPolyTree (usrTree, thePolyTree);
10021 ret=CopyToTreeFromPolyTree (usrTree, thePolyTree);
10022 FreePolyTree (thePolyTree);
10028 /* param->paramType == P_POPSIZE */
10029 theTree = GetTree (modelSettings[param->relParts[0]].speciesTree, chainId, 0);
10030 usrTree = GetTree (modelSettings[param->relParts[0]].speciesTree, chainId, 1);
10031 CopyToTreeFromTree (usrTree, theTree);
10032 thePolyTree = AllocatePolyTree(numSpecies);
10033 CopyToPolyTreeFromPolyTree (thePolyTree, userTree[treeIndex]);
10034 ResetIntNodeIndices(thePolyTree);
10035 RandResolve (NULL, thePolyTree, &globalSeed, theTree->isRooted);
10036 CopyToSpeciesTreeFromPolyTree (usrTree, thePolyTree);
10037 FreePolyTree (thePolyTree);
10039 if (param->paramType == P_TOPOLOGY)
10041 if (theTree->checkConstraints == YES && CheckSetConstraints (usrTree) == ERROR)
10043 MrBayesPrint ("%s Could not set the constraints for topology parameter '%s'\n", spacer, param->name);
10046 if (ResetTopologyFromTree (theTree, usrTree) == ERROR)
10048 MrBayesPrint ("%s Could not set the topology parameter '%s'\n", spacer, param->name);
10051 if (theTree->checkConstraints == YES && CheckSetConstraints (theTree)==ERROR)
10053 MrBayesPrint ("%s Could not set the constraints for topology parameter '%s'\n", spacer, param->name);
10056 FillTopologySubParams (param, chainId, 0, &globalSeed);
10057 //MrBayesPrint ("%s Branch lengths and relaxed clock subparameters of a parameter '%s' are reset.\n", spacer, param->name);
10058 if (param->paramId == TOPOLOGY_SPECIESTREE)
10059 FillSpeciesTreeParams(&globalSeed, chainId, chainId+1);
10060 //assert (IsTreeConsistent(param, chainId, 0) == YES);
10062 else if (param->paramType == P_BRLENS)
10064 if (usrTree->allDownPass[0]->length == 0.0 && param->paramId != BRLENS_CLOCK_FOSSIL)
10066 MrBayesPrint ("%s User tree '%s' does not have branch lengths so it cannot be used in setting parameter '%s'\n", spacer, userTree[treeIndex]->name, param->name);
10069 if (AreTopologiesSame (theTree, usrTree) == NO)
10071 MrBayesPrint ("%s Topology of user tree '%s' wrong in setting parameter '%s'\n", spacer, userTree[treeIndex]->name, param->name);
10074 //assert (IsTreeConsistent(param, chainId, 0) == YES);
10075 /* reset node depths to ensure that non-dated tips have node depth 0.0 */
10076 /* if (usrTree->isClock == YES)
10077 SetNodeDepths(usrTree); */
10078 if (ResetBrlensFromTree (theTree, usrTree) == ERROR)
10080 MrBayesPrint ("%s Could not set parameter '%s' from user tree '%s'\n", spacer, param->name, userTree[treeIndex]->name);
10083 if (theTree->isClock == YES && modelParams[theTree->relParts[0]].treeAgePr.prior == fixed)
10085 if (!strcmp(modelParams[theTree->relParts[0]].clockPr,"Uniform")
10086 || !strcmp(modelParams[theTree->relParts[0]].clockPr,"Fossilization"))
10087 ResetRootHeight (theTree, modelParams[theTree->relParts[0]].treeAgePr.priorParams[0]);
10089 /* the test will find suitable clock rate and ages of nodes in theTree */
10090 if (theTree->isClock == YES && IsClockSatisfied (theTree,0.001) == NO)
10092 MrBayesPrint ("%s Non-calibrated tips are not at the same level after setting up starting tree branch lengthes(%s) from user tree '%s'.\n",
10093 spacer, param->name, userTree[treeIndex]->name);
10094 ShowNodes(theTree->root,0,YES);
10097 if (theTree->isCalibrated == YES && IsCalibratedClockSatisfied (theTree, &minRate,&maxRate, 0.001) == NO)
10099 MrBayesPrint ("%s Problem setting calibrated tree parameters\n", spacer);
10102 if (theTree->isCalibrated == YES && !strcmp(modelParams[theTree->relParts[0]].clockRatePr, "Fixed"))
10104 clockRate = modelParams[theTree->relParts[0]].clockRateFix;
10105 if ((clockRate < minRate && AreDoublesEqual (clockRate, minRate , 0.001) == NO) || (clockRate > maxRate && AreDoublesEqual (clockRate, maxRate , 0.001) == NO))
10107 MrBayesPrint("%s Fixed branch lengths do not satisfy fixed clockrate\n", spacer);
10111 theTree->fromUserTree=YES;
10113 FillBrlensSubParams (param, chainId, 0);
10114 //MrBayesPrint ("%s Rrelaxed clock subparamiters of a parameter '%s' are reset.\n", spacer, param->name);
10115 //assert (IsTreeConsistent(param, chainId, 0) == YES);
10116 if (param->paramId == BRLENS_CLOCK_SPCOAL)
10117 FillSpeciesTreeParams(&globalSeed, chainId, chainId+1);
10118 //assert (IsTreeConsistent(param, chainId, 0) == YES);
10120 else if (param->paramType == P_CPPEVENTS || param->paramType == P_TK02BRANCHRATES ||
10121 param->paramType == P_IGRBRANCHRATES || param->paramType == P_MIXEDBRCHRATES)
10123 if (theTree->isCalibrated == YES && theTree->fromUserTree == NO)
10124 { /* if theTree is not set from user tree then we can not garanty that branch lenghts will stay the same
10125 by the time we start mcmc run because of clockrate adjustment. */
10126 MrBayesPrint ("%s Set starting values for branch lengthes first before setting starting values of relaxed parameters!\n", spacer);
10129 if (theTree->isCalibrated == NO && IsClockSatisfied (usrTree, 0.001) == NO) // user tree is not calibrated so do not check it if calibration is in place
10131 MrBayesPrint ("%s Branch lengths of the user tree '%s' do not satisfy clock in setting parameter '%s'\n", spacer, userTree[treeIndex], param->name);
10132 ShowNodes(usrTree->root,0,YES);
10135 if (AreTopologiesSame (theTree, usrTree) == NO)
10137 MrBayesPrint ("%s Topology of user tree '%s' is wrong in setting parameter '%s'\n", spacer, userTree[treeIndex]->name, param->name);
10140 if (SetRelaxedClockParam (param, chainId, 0, userTree[treeIndex]) == ERROR)
10142 MrBayesPrint ("%s Could not set parameter '%s' from user tree '%s'\n", spacer, param->name, userTree[treeIndex]->name);
10145 //assert (IsTreeConsistent(param, chainId, 0) == YES);
10147 else if (param->paramType == P_POPSIZE)
10149 if (AreTopologiesSame (theTree, usrTree) == NO)
10151 MrBayesPrint ("%s Topology of user tree '%s' is wrong in setting parameter '%s'\n", spacer, userTree[treeIndex]->name, param->name);
10154 if (SetPopSizeParam (param, chainId, 0, userTree[treeIndex]) == ERROR)
10156 MrBayesPrint ("%s Could not set parameter '%s' from user tree '%s'\n", spacer, param->name, userTree[treeIndex]->name);
10160 else if (param->paramType == P_SPECIESTREE)
10162 if (IsSpeciesTreeConsistent (usrTree, chainId) == NO)
10164 MrBayesPrint ("%s User-specified species tree '%s' is inconsistent with gene trees\n", spacer, userTree[treeIndex]->name);
10167 if (CopyToTreeFromTree (theTree, usrTree) == ERROR)
10169 MrBayesPrint ("%s Could not set the species tree parameter '%s'\n", spacer, param->name);
10172 //assert (IsTreeConsistent(param, chainId, 0) == YES);
10176 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
10179 else if (expecting == Expecting(LEFTCURL))
10181 /* we are still assembling the parameter name */
10182 SafeStrcat (&tempName, tkn);
10183 expecting = Expecting(NUMBER) | Expecting(ALPHA) | Expecting(LEFTPAR) | Expecting(EQUALSIGN);
10185 else if (expecting == Expecting(RIGHTCURL))
10187 /* we are still assembling the parameter name */
10188 SafeStrcat (&tempName, tkn);
10189 foundComma = NO; /*! if there was a comma in the partition part, we should reset this variable. Otherwise we can't parse something like A{1,2}(3,4) */
10190 expecting = Expecting(LEFTPAR) | Expecting(EQUALSIGN);
10192 else if (expecting == Expecting(LEFTPAR))
10194 if (foundEqual == NO)
10196 foundName = YES; /* we found the name */
10197 /* we will be reading in run and chain indices */
10198 expecting = Expecting(NUMBER) | Expecting(COMMA);
10202 expecting = Expecting(NUMBER);
10203 expecting |= Expecting(DASH);
10206 else if (expecting == Expecting(DASH))
10209 expecting = Expecting(NUMBER);
10211 else if (expecting == Expecting(NUMBER))
10213 if (foundName == NO)
10215 /* we are still assembling the parameter name */
10216 SafeStrcat (&tempName, tkn);
10217 expecting = Expecting(COMMA) | Expecting(LEFTPAR) | Expecting(RIGHTCURL) | Expecting(EQUALSIGN);
10219 else if (foundEqual == YES)
10221 theValueMin = param->min;
10222 theValueMax = param->max;
10224 /* we are reading in a parameter value */
10225 if (param->paramType==P_OMEGA && nValuesRead==numExpectedValues && useSubvalues == NO)
10227 /* continue with subvalues */
10229 numExpectedValues = param->nSubValues/2;
10230 useSubvalues = YES;
10234 if (param->paramType==P_OMEGA && nValuesRead==numExpectedValues && useSubvalues == NO)
10236 /* continue with subvalues */
10238 numExpectedValues = param->nSubValues/2;
10239 useSubvalues = YES;
10243 if (param->nIntValues > 0 && nValuesRead==numExpectedValues && useIntValues == NO)
10245 /* continue with intValues */
10247 numExpectedValues = param->nIntValues;
10248 useIntValues = YES;
10250 if (param->paramType==P_PI && modelSettings[param->relParts[0]].dataType == STANDARD && param->paramId != SYMPI_EQUAL
10251 && nValuesRead==numExpectedValues && useStdStateFreqs == NO)
10253 /* we have read alpha_symdir, continue with multistate char state freqs */
10255 numExpectedValues = param->nStdStateFreqs;
10256 if (param->hasBinaryStd == YES)
10257 numExpectedValues -= 2 * modelSettings[param->relParts[0]].numBetaCats;
10258 useStdStateFreqs = YES;
10263 if (nValuesRead > numExpectedValues)
10265 if (param->paramType == P_OMEGA)
10266 MrBayesPrint ("%s Only %d values were expected for parameter '%s'\n", spacer, param->nValues+param->nSubValues/2, param->name);
10267 else if (param->nIntValues > 0)
10268 MrBayesPrint ("%s Only %d values were expected for parameter '%s'\n", spacer, param->nValues+param->nIntValues, param->name);
10270 MrBayesPrint ("%s Only %d values were expected for parameter '%s'\n", spacer, numExpectedValues, param->name);
10273 if (useIntValues == YES)
10274 sscanf (tkn, "%d", &tempInt);
10276 sscanf (tkn, "%lf", &tempFloat);
10277 if (foundDash == YES)
10279 if (useIntValues == NO)
10280 tempFloat = -tempFloat;
10282 tempInt = -tempInt;
10285 if (useIntValues == NO && (tempFloat < theValueMin || tempFloat > theValueMax))
10287 MrBayesPrint ("%s The value is out of range (min = %lf; max = %lf)\n", spacer, theValueMin, theValueMax);
10290 for (i=0; i<chainParams.numRuns; i++)
10292 if (runIndex != -1 && runIndex != i)
10294 for (j=0; j<chainParams.numChains; j++)
10296 if (chainIndex != -1 && chainIndex != j)
10298 if (useIntValues == YES)
10300 GetParamIntVals (param, i*chainParams.numChains+j, 0)[nValuesRead-1] = tempInt;
10304 if (useSubvalues == NO && useStdStateFreqs == NO)
10305 theValue = GetParamVals (param, i*chainParams.numChains+j, 0);
10306 else if (useSubvalues == YES)
10307 theValue = GetParamSubVals (param, i*chainParams.numChains+j, 0);
10308 else if (useStdStateFreqs == YES)
10310 theValue = GetParamStdStateFreqs (param, i*chainParams.numChains+j, 0);
10311 if (param->hasBinaryStd == YES)
10312 theValue += 2 * modelSettings[param->relParts[0]].numBetaCats;
10316 if (param->paramType == P_CLOCKRATE)
10318 if (UpdateClockRate(tempFloat, i*chainParams.numChains+j) == ERROR)
10323 theValue[nValuesRead-1] = tempFloat;
10327 expecting = Expecting (COMMA) | Expecting(RIGHTPAR);
10329 else /* if (foundEqual == NO) */
10331 sscanf (tkn, "%d", &tempInt);
10332 if (foundComma == NO)
10334 if (tempInt <= 0 || tempInt > chainParams.numRuns)
10336 MrBayesPrint ("%s Run index is out of range (min=1; max=%d)\n", spacer, chainParams.numRuns);
10339 runIndex = tempInt - 1;
10340 expecting = Expecting(COMMA);
10344 if (tempInt <= 0 || tempInt > chainParams.numChains)
10346 MrBayesPrint ("%s Chain index is out of range (min=1; max=%d)\n", spacer, chainParams.numChains);
10349 chainIndex = tempInt - 1;
10351 expecting = Expecting(RIGHTPAR);
10355 else if (expecting == Expecting(COMMA))
10357 if (foundEqual == YES)
10359 /* we expect another parameter value */
10360 expecting = Expecting(NUMBER);
10362 else /* if (foundEqual == NO) */
10364 /* we will be reading in chain index, if present */
10366 expecting = Expecting(RIGHTPAR) | Expecting(NUMBER);
10367 /* if the comma is in a list of partitions (so between { and }) we have to add the comma to the parameter name */
10368 if (param == NULL && strchr(tempName, '}')==NULL && strchr(tempName, '{')!=NULL)
10369 SafeStrcat (&tempName, ",");
10372 else if (expecting == Expecting(RIGHTPAR))
10374 if (foundEqual == NO)
10376 /* this is the end of the run and chain specification */
10377 expecting = Expecting(EQUALSIGN);
10379 else /* if (foundEqual == YES) */
10381 /* this is the end of the parameter values */
10382 if (nValuesRead != numExpectedValues)
10384 MrBayesPrint ("%s Expected %d values but only found %d values for parameter '%s'\n", spacer, numExpectedValues, nValuesRead, param->name);
10387 /* Post processing needed for some parameters */
10388 if (param->paramType == P_SHAPE || param->paramType == P_CORREL)
10390 for (i=0; i<chainParams.numRuns; i++)
10392 if (runIndex != -1 && runIndex != i)
10394 for (j=0; j<chainParams.numChains; j++)
10396 if (chainIndex != -1 && chainIndex != j)
10398 value = GetParamVals(param,i*chainParams.numChains+j,0);
10399 subValue = GetParamSubVals(param,i*chainParams.numChains+j,0);
10400 if (param->paramType == P_SHAPE && !strncmp(param->name, "Alpha", 5))
10402 if (DiscreteGamma (subValue, value[0], value[0], param->nSubValues, 0) == ERROR)
10405 else if (param->paramType == P_SHAPE && !strncmp(param->name, "Sigma", 5))
10407 if( DiscreteLogNormal(subValue, value[0], param->nSubValues, 1) == ERROR)
10410 else if (param->paramType == P_CORREL)
10412 if (AutodGamma (subValue, value[0], (int)(sqrt(param->nSubValues) + 0.5)) == ERROR)
10418 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
10421 else if (expecting == Expecting(EQUALSIGN))
10426 /* we now know that the name is complete; try to find the parameter with this name (case insensitive) */
10427 for (i=0; i<(int)strlen(tempName); i++)
10428 tempName[i] = tolower(tempName[i]);
10430 /* first check exact matches */
10432 for (i=0; i<numParams; i++)
10434 param = ¶ms[i];
10435 SafeStrcpy (&temp, param->name);
10436 for (k=0; k<(int)(strlen(temp)); k++)
10437 temp[k] = tolower(temp[k]);
10438 if (strcmp(tempName,temp) == 0)
10444 /* now check unambiguous abbreviation matches */
10448 for (i=0; i<numParams; i++)
10450 param = ¶ms[i];
10451 SafeStrcpy (&temp, param->name);
10452 for (k=0; k<(int)strlen(temp); k++)
10453 temp[k] = tolower(temp[k]);
10454 if (strncmp(tempName,temp,strlen(tempName)) == 0)
10464 extern char *tokenP;
10465 MrBayesPrint ("%s Could not find parameter '%s': ignoring values\n", spacer, tempName);
10466 while (*tokenP && *tokenP++!=')') {};
10467 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
10468 return (*tokenP ? NO_ERROR:ERROR);
10470 else if (nMatches > 1)
10472 MrBayesPrint ("%s Several parameters matched the abbreviated name '%s'\n", spacer, tempName);
10476 param = ¶ms[j];
10477 if (param->printParam == NO && !(param->paramType == P_TOPOLOGY && strcmp(modelParams[param->relParts[0]].topologyPr,"Fixed")!=0)
10478 && !(param->paramType == P_CPPEVENTS)
10479 && !(param->paramType == P_TK02BRANCHRATES)
10480 && !(param->paramType == P_IGRBRANCHRATES)
10481 && !(param->paramType == P_MIXEDBRCHRATES)
10482 && !(param->paramType == P_POPSIZE && param->nValues > 1))
10484 MrBayesPrint ("%s The parameter '%s' is fixed so the starting value cannot be set\n", spacer, param->name);
10487 if (param->paramType == P_BRLENS || param->paramType == P_TOPOLOGY || param->paramType == P_CPPEVENTS ||
10488 param->paramType == P_TK02BRANCHRATES || param->paramType == P_IGRBRANCHRATES || param->paramType == P_MIXEDBRCHRATES ||
10489 param->paramType == P_SPECIESTREE || (param->paramType == P_POPSIZE && param->nValues > 1))
10491 /* all these parameters are set from a tree */
10492 expecting = Expecting (ALPHA);
10495 /* run of the mill character */
10497 theValueMin = param->min;
10498 theValueMax = param->max;
10499 if ((param->paramType == P_PI && modelParams[param->relParts[0]].dataType != STANDARD))
10501 useSubvalues = YES;
10503 numExpectedValues = param->nSubValues;
10505 else if (param->nValues == 0 && param->nIntValues > 0)
10508 useIntValues = YES;
10509 numExpectedValues = param->nIntValues;
10511 else if (param->nValues > 0)
10515 numExpectedValues = param->nValues;
10519 MrBayesPrint ("%s Not expecting any values for parameter '%s'\n", spacer, param->name);
10523 expecting = Expecting(LEFTPAR);
10529 SafeFree ((void **)&temp);
10534 int DoUnlink (void)
10538 MrBayesPrint ("%s Unlinking\n", spacer);
10540 /* update status of linkTable */
10541 for (j=0; j<NUM_LINKED; j++)
10543 for (i=0; i<numCurrentDivisions; i++)
10545 if (tempLinkUnlink[j][i] == YES)
10547 linkTable[j][i] = ++linkNum;
10553 for (j=0; j<NUM_LINKED; j++)
10555 MrBayesPrint ("%s ", spacer);
10556 for (i=0; i<numCurrentDivisions; i++)
10557 MrBayesPrint ("%d", linkTable[j][i]);
10558 MrBayesPrint ("\n");
10562 /* reinitialize the temporary table */
10563 for (j=0; j<NUM_LINKED; j++)
10564 for (i=0; i<numCurrentDivisions; i++)
10565 tempLinkUnlink[j][i] = NO;
10567 /* set up parameters and moves */
10568 if (SetUpAnalysis (&globalSeed) == ERROR)
10575 int DoShowMcmcTrees (void)
10577 int run, chain, chainIndex, i;
10580 for (run=0; run<chainParams.numRuns; run++)
10582 for (chain=0; chain<chainParams.numChains; chain++)
10584 chainIndex = run*chainParams.numChains + chain;
10585 for (i=0; i<numTrees; i++)
10587 t = GetTreeFromIndex (i, chainIndex, 0);
10588 if (t->isRooted == YES)
10589 MrBayesPrint ("\n Tree '%s' [rooted]:\n\n", t->name);
10591 MrBayesPrint ("\n Tree '%s' [unrooted]:\n\n", t->name);
10592 if (ShowTree (t) == ERROR)
10595 MrBayesPrint ("\n");
10604 int DoShowModel (void)
10606 if (defMatrix == NO)
10608 MrBayesPrint ("%s A matrix must be specified before the model can be defined\n", spacer);
10612 if (ShowModel() == ERROR)
10619 int DoShowMoves (void)
10621 if (defMatrix == NO)
10623 MrBayesPrint ("%s A matrix must be specified before moves can be assigned\n", spacer);
10627 MrBayesPrint ("%s Moves that will be used by MCMC sampler (rel. proposal prob. > 0.0):\n\n", spacer);
10628 if (ShowMoves(YES) == ERROR)
10631 if (showmovesParams.allavailable == YES)
10633 MrBayesPrint ("%s Other available moves (rel. proposal prob. = 0.0):\n\n", spacer);
10634 if (ShowMoves(NO) == ERROR)
10638 MrBayesPrint ("%s Use 'Showmoves allavailable=yes' to see a list of all available moves\n", spacer);
10644 int DoShowmovesParm (char *parmName, char *tkn)
10648 if (expecting == Expecting(PARAMETER))
10650 expecting = Expecting(EQUALSIGN);
10654 /* set Allavailable **********************************************************/
10655 if (!strcmp(parmName, "Allavailable"))
10657 if (expecting == Expecting(EQUALSIGN))
10658 expecting = Expecting(ALPHA);
10659 else if (expecting == Expecting(ALPHA))
10661 if (IsArgValid(tkn, tempStr) == NO_ERROR)
10663 if (!strcmp(tempStr, "Yes"))
10664 showmovesParams.allavailable = YES;
10666 showmovesParams.allavailable = NO;
10670 MrBayesPrint ("%s Invalid argument for allavailable\n", spacer);
10673 expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
10687 int DoShowParams (void)
10689 if (defMatrix == NO)
10691 MrBayesPrint ("%s A matrix must be specified before model parameters can be shown\n", spacer);
10695 if (ShowParameters(YES, YES, YES) == ERROR)
10702 /*------------------------------------------------------------------------
10704 | FillNormalParams: Allocate and fill in non-tree parameters
10706 -------------------------------------------------------------------------*/
10707 int FillNormalParams (RandLong *seed, int fromChain, int toChain)
10709 int i, j, k, chn, tempInt, *intValue;
10710 MrBFlt *bs, *value, *subValue, scaler;
10716 /* fill in values for nontree params for state 0 of chains */
10717 for (chn=fromChain; chn<toChain; chn++)
10719 for (k=0; k<numParams; k++)
10722 mp = &modelParams[p->relParts[0]];
10723 m = &modelSettings[p->relParts[0]];
10725 /* find model settings and nStates, pInvar, invar cond likes */
10727 value = GetParamVals (p, chn, 0);
10728 subValue = GetParamSubVals (p, chn, 0);
10729 intValue = GetParamIntVals (p, chn, 0);
10731 if (p->paramType == P_TRATIO)
10733 /* Fill in tratios **************************************************************************************/
10734 if (p->paramId == TRATIO_DIR)
10736 else if (p->paramId == TRATIO_FIX)
10737 value[0] = mp->tRatioFix;
10739 else if (p->paramType == P_REVMAT)
10741 /* Fill in revMat ***************************************************************************************/
10742 /* rates are stored in order, AC or AR first, using the Dirichlet parameterization */
10743 if (p->paramId == REVMAT_DIR)
10745 for (j=0; j<p->nValues; j++)
10746 value[j] = 1.0 / (MrBFlt) (p->nValues);
10748 else if (p->paramId == REVMAT_FIX)
10751 if (m->dataType == PROTEIN)
10753 for (j=0; j<190; j++)
10754 scaler += (value[j] = mp->aaRevMatFix[j]);
10755 for (j=0; j<190; j++)
10756 value[j] /= scaler;
10760 for (j=0; j<6; j++)
10761 scaler += (value[j] = mp->revMatFix[j]);
10762 for (j=0; j<6; j++)
10763 value[j] /= scaler;
10766 else if (p->paramId == REVMAT_MIX)
10768 for (j=0; j<6; j++)
10770 value[j] = 1.0 / 6.0;
10775 else if (p->paramType == P_OMEGA)
10777 /* Fill in omega ****************************************************************************************/
10778 if (p->nValues == 1)
10780 if (p->paramId == OMEGA_DIR)
10782 else if (p->paramId == OMEGA_FIX)
10783 value[0] = mp->omegaFix;
10787 if (!strcmp(mp->omegaVar, "Ny98"))
10789 if (p->paramId == OMEGA_BUD || p->paramId == OMEGA_BUF || p->paramId == OMEGA_BED ||
10790 p->paramId == OMEGA_BEF || p->paramId == OMEGA_BFD || p->paramId == OMEGA_BFF)
10791 value[0] = RandomNumber(seed);
10792 else if (p->paramId == OMEGA_FUD || p->paramId == OMEGA_FUF || p->paramId == OMEGA_FED ||
10793 p->paramId == OMEGA_FEF || p->paramId == OMEGA_FFD || p->paramId == OMEGA_FFF)
10794 value[0] = mp->ny98omega1Fixed;
10796 if (p->paramId == OMEGA_BUD || p->paramId == OMEGA_BUF || p->paramId == OMEGA_FUD ||
10797 p->paramId == OMEGA_FUF)
10798 value[2] = mp->ny98omega3Uni[0] + RandomNumber(seed) * (mp->ny98omega3Uni[1] - mp->ny98omega3Uni[0]);
10799 else if (p->paramId == OMEGA_BED || p->paramId == OMEGA_BEF || p->paramId == OMEGA_FED ||
10800 p->paramId == OMEGA_FEF)
10801 value[2] = (1.0 - (1.0/mp->ny98omega3Exp) * log(RandomNumber(seed)));
10803 value[2] = mp->ny98omega3Fixed;
10804 if (p->paramId == OMEGA_BUD || p->paramId == OMEGA_BED || p->paramId == OMEGA_BFD ||
10805 p->paramId == OMEGA_FUD || p->paramId == OMEGA_FED || p->paramId == OMEGA_FFD)
10807 subValue[3] = mp->codonCatDir[0];
10808 subValue[4] = mp->codonCatDir[1];
10809 subValue[5] = mp->codonCatDir[2];
10810 DirichletRandomVariable (&subValue[3], &subValue[0], 3, seed);
10814 subValue[0] = mp->codonCatFreqFix[0];
10815 subValue[1] = mp->codonCatFreqFix[1];
10816 subValue[2] = mp->codonCatFreqFix[2];
10822 else if (!strcmp(mp->omegaVar, "M3"))
10824 if (p->paramId == OMEGA_FD || p->paramId == OMEGA_FF)
10826 value[0] = mp->m3omegaFixed[0];
10827 value[1] = mp->m3omegaFixed[1];
10828 value[2] = mp->m3omegaFixed[2];
10836 if (p->paramId == OMEGA_ED || p->paramId == OMEGA_FD)
10838 subValue[3] = mp->codonCatDir[0];
10839 subValue[4] = mp->codonCatDir[1];
10840 subValue[5] = mp->codonCatDir[2];
10841 DirichletRandomVariable (&subValue[3], &subValue[0], 3, seed);
10845 subValue[0] = mp->codonCatFreqFix[0];
10846 subValue[1] = mp->codonCatFreqFix[1];
10847 subValue[2] = mp->codonCatFreqFix[2];
10853 else if (!strcmp(mp->omegaVar, "M10"))
10855 if (p->paramId == OMEGA_10UUB || p->paramId == OMEGA_10UEB || p->paramId == OMEGA_10UFB ||
10856 p->paramId == OMEGA_10EUB || p->paramId == OMEGA_10EEB || p->paramId == OMEGA_10EFB ||
10857 p->paramId == OMEGA_10FUB || p->paramId == OMEGA_10FEB || p->paramId == OMEGA_10FFB)
10859 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 2] = mp->codonCatDir[0];
10860 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 3] = mp->codonCatDir[1];
10861 DirichletRandomVariable (&subValue[mp->numM10BetaCats + mp->numM10GammaCats + 2], &subValue[mp->numM10BetaCats + mp->numM10GammaCats + 0], 2, seed);
10865 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 0] = mp->codonCatFreqFix[0];
10866 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 1] = mp->codonCatFreqFix[1];
10867 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 2] = 0.0;
10868 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 3] = 0.0;
10871 for (i=0; i<mp->numM10BetaCats; i++)
10872 subValue[i] = subValue[mp->numM10BetaCats + mp->numM10GammaCats + 0] / mp->numM10BetaCats;
10873 for (i=mp->numM10BetaCats; i<mp->numM10BetaCats+mp->numM10GammaCats; i++)
10874 subValue[i] = subValue[mp->numM10BetaCats + mp->numM10GammaCats + 1] / mp->numM10GammaCats;
10876 if (p->paramId == OMEGA_10FUB || p->paramId == OMEGA_10FUF || p->paramId == OMEGA_10FEB ||
10877 p->paramId == OMEGA_10FEF || p->paramId == OMEGA_10FFB || p->paramId == OMEGA_10FFF)
10879 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 4] = mp->m10betaFix[0];
10880 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 5] = mp->m10betaFix[1];
10884 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 4] = 1.0;
10885 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 5] = 1.0;
10888 if (p->paramId == OMEGA_10UFB || p->paramId == OMEGA_10UFF || p->paramId == OMEGA_10EFB ||
10889 p->paramId == OMEGA_10EFF || p->paramId == OMEGA_10FFB || p->paramId == OMEGA_10FFF)
10891 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 6] = mp->m10gammaFix[0];
10892 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 7] = mp->m10gammaFix[1];
10896 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 6] = 1.0;
10897 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 7] = 1.0;
10900 BetaBreaks (subValue[mp->numM10BetaCats + mp->numM10GammaCats + 4], subValue[mp->numM10BetaCats + mp->numM10GammaCats + 5], &value[0], mp->numM10BetaCats);
10901 if (DiscreteGamma (&value[mp->numM10BetaCats], subValue[mp->numM10BetaCats + mp->numM10GammaCats + 6],
10902 subValue[mp->numM10BetaCats + mp->numM10GammaCats + 7], mp->numM10GammaCats, 0) == ERROR)
10904 for (i=0; i<mp->numM10GammaCats; i++)
10905 value[mp->numM10BetaCats + i] += 1.0;
10909 else if (p->paramType == P_PI)
10911 /* Fill in state frequencies ****************************************************************************/
10912 /* note that standard chars are mainly dealt with in ProcessStdChars in mcmc.c */
10913 if (p->paramId == SYMPI_UNI || p->paramId == SYMPI_UNI_MS)
10915 else if (p->paramId == SYMPI_EXP || p->paramId == SYMPI_EXP_MS)
10918 else if (p->paramId == SYMPI_FIX || p->paramId == SYMPI_FIX_MS)
10919 value[0] = mp->symBetaFix;
10921 else if (p->paramId == PI_DIR)
10923 if (mp->numDirParams != mp->nStates && mp->numDirParams != 0)
10925 MrBayesPrint ("%s Mismatch between number of dirichlet parameters (%d) and the number of states (%d)\n", spacer, mp->numDirParams, m->numStates);
10929 /* if user has not set dirichlet parameters, go with default */
10930 /* overall variance equals number of states */
10931 if (mp->numDirParams == 0)
10932 for (i=0; i<mp->nStates; i++)
10933 value[i] = mp->stateFreqsDir[i] = 1.0;
10935 for (i=0; i<m->numStates; i++)
10936 value[i] = mp->stateFreqsDir[i];
10938 /* now fill in subvalues */
10939 for (i=0; i<m->numStates; i++)
10940 subValue[i] = 1.0 / mp->nStates;
10943 else if (p->paramId == PI_USER)
10945 for (i=0; i<m->numStates; i++)
10946 subValue[i] = mp->stateFreqsFix[i];
10949 else if (p->paramId == PI_FIXED)
10951 if (!strcmp(mp->aaModelPr, "Fixed"))
10953 if (!strcmp(mp->aaModel, "Jones"))
10955 for (i=0; i<mp->nStates; i++)
10956 subValue[i] = jonesPi[i];
10958 else if (!strcmp(mp->aaModel, "Dayhoff"))
10960 for (i=0; i<mp->nStates; i++)
10961 subValue[i] = dayhoffPi[i];
10963 else if (!strcmp(mp->aaModel, "Mtrev"))
10965 for (i=0; i<mp->nStates; i++)
10966 subValue[i] = mtrev24Pi[i];
10968 else if (!strcmp(mp->aaModel, "Mtmam"))
10970 for (i=0; i<mp->nStates; i++)
10971 subValue[i] = mtmamPi[i];
10973 else if (!strcmp(mp->aaModel, "Wag"))
10975 for (i=0; i<mp->nStates; i++)
10976 subValue[i] = wagPi[i];
10978 else if (!strcmp(mp->aaModel, "Rtrev"))
10980 for (i=0; i<mp->nStates; i++)
10981 subValue[i] = rtrevPi[i];
10983 else if (!strcmp(mp->aaModel, "Cprev"))
10985 for (i=0; i<mp->nStates; i++)
10986 subValue[i] = cprevPi[i];
10988 else if (!strcmp(mp->aaModel, "Vt"))
10990 for (i=0; i<mp->nStates; i++)
10991 subValue[i] = vtPi[i];
10993 else if (!strcmp(mp->aaModel, "Blosum"))
10995 for (i=0; i<mp->nStates; i++)
10996 subValue[i] = blosPi[i];
10998 else if (!strcmp(mp->aaModel, "LG"))
11000 for (i=0; i<mp->nStates; i++)
11001 subValue[i] = lgPi[i];
11006 else if (p->paramId == PI_EMPIRICAL)
11008 if (GetEmpiricalFreqs (p->relParts, p->nRelParts) == ERROR)
11010 for (i=0; i<mp->nStates; i++)
11011 subValue[i] = empiricalFreqs[i];
11014 else if (p->paramId == PI_EQUAL)
11016 for (i=0; i<mp->nStates; i++)
11017 subValue[i] = 1.0 / mp->nStates;
11020 else if (p->paramType == P_SHAPE)
11022 /* Fill in shape values ********************************************************************************/
11023 /* first get hyperprior */
11024 if (p->paramId == SHAPE_UNI)
11027 if (value[0] < mp->shapeUni[0] || value[0] > mp->shapeUni[1])
11028 value[0] = mp->shapeUni[0] + (mp->shapeUni[1] - mp->shapeUni[0]) * 0.5;
11030 else if (p->paramId == SHAPE_EXP)
11031 value[0] = 1.0; // was 100.0
11032 else if (p->paramId == SHAPE_FIX)
11033 value[0] = mp->shapeFix;
11034 /* now fill in rates */
11035 if (!strcmp(mp->ratesModel, "LNorm"))
11037 if (DiscreteLogNormal (subValue, value[0], mp->numGammaCats, 1) == ERROR)
11040 else /* gamma rate */
11042 if (DiscreteGamma (subValue, value[0], value[0], mp->numGammaCats, 0) == ERROR)
11046 else if (p->paramType == P_PINVAR)
11048 /* Fill in pInvar ***************************************************************************************/
11049 if (p->paramId == PINVAR_UNI)
11052 else if (p->paramId == PINVAR_FIX)
11053 value[0] = mp->pInvarFix;
11055 else if (p->paramType == P_CORREL)
11057 /* Fill in correlation parameter of adgamma model *******************************************************/
11058 if (p->paramId == CORREL_UNI)
11061 else if (p->paramId == CORREL_FIX)
11062 value[0] = mp->corrFix;
11064 /* Fill in correlation matrices */
11065 AutodGamma (subValue, value[0], mp->numGammaCats);
11067 else if (p->paramType == P_SWITCH)
11069 /* Fill in switchRates for covarion model ***************************************************************/
11070 for (j=0; j<2; j++)
11072 if (p->paramId == SWITCH_UNI)
11073 value[j] = RandomNumber(seed) * (mp->covswitchUni[1] - mp->covswitchUni[0]) + mp->covswitchUni[0];
11075 else if (p->paramId == SWITCH_EXP)
11076 value[j] = -(1.0/mp->covswitchExp) * log(RandomNumber(seed));
11078 else if (p->paramId == SWITCH_FIX)
11079 value[j] = mp->covswitchFix[j];
11082 else if (p->paramType == P_RATEMULT)
11084 /* Fill in division rates *****************************************************************************/
11085 for (j=0; j<p->nValues; j++)
11088 /* fill in more info about the divisions if this is a true rate multiplier
11089 and not a base rate */
11090 if (p->nSubValues > 0)
11092 /* num uncompressed chars */
11093 subValue[j] = (modelSettings[p->relParts[j]].numUncompressedChars);
11094 /* Dirichlet parameters */
11095 subValue[p->nValues + j] = modelParams[p->relParts[j]].ratePrDir;
11099 else if (p->paramType == P_GENETREERATE)
11101 /* Fill in division rates *****************************************************************************/
11102 for (j=0; j<p->nValues; j++)
11105 /* Dirichlet parameters fixed to 1.0 for now; ignored if the rate is fixed */
11106 subValue[p->nValues + j] = 1.0;
11107 /* Get number of uncompressed chars from tree */
11108 tree = GetTreeFromIndex(j, 0, 0);
11110 for (i=0; i<tree->nRelParts; i++) /* num uncompressed chars */
11111 subValue[j] += modelSettings[tree->relParts[i]].numUncompressedChars;
11114 else if (p->paramType == P_SPECRATE)
11116 /* Fill in speciation rates *****************************************************************************/
11117 for (j=0; j<p->nValues; j++)
11119 if (p->paramId == SPECRATE_FIX)
11120 value[j] = mp->speciationFix;
11125 else if (p->paramType == P_EXTRATE)
11127 /* Fill in extinction rates *****************************************************************************/
11128 for (j=0; j<p->nValues; j++)
11130 if (p->paramId == EXTRATE_FIX)
11131 value[j] = mp->extinctionFix;
11136 else if (p->paramType == P_FOSLRATE)
11138 /* Fill in fossilization rates */
11139 for (j=0; j<p->nValues; j++)
11141 if (p->paramId == FOSLRATE_FIX)
11142 value[j] = mp->fossilizationFix;
11147 else if (p->paramType == P_GROWTH)
11149 /* Fill in growth rate ****************************************************************************************/
11150 if (p->paramId == GROWTH_FIX)
11151 value[0] = mp->growthFix;
11155 else if (p->paramType == P_POPSIZE)
11157 /* Fill in population size ****************************************************************************************/
11158 for (j=0; j<p->nValues; j++)
11160 if (p->paramId == POPSIZE_UNI)
11161 value[j] = RandomNumber(seed) * (mp->popSizeUni[1] - mp->popSizeUni[0]) + mp->popSizeUni[0];
11162 else if (p->paramId == POPSIZE_LOGNORMAL)
11163 value[j] = exp(mp->popSizeLognormal[0]);
11164 else if (p->paramId == POPSIZE_NORMAL)
11165 value[j] = mp->popSizeNormal[0];
11166 else if (p->paramId == POPSIZE_GAMMA)
11167 value[j] = mp->popSizeGamma[0] / mp->popSizeGamma[1];
11168 else if (p->paramId == POPSIZE_FIX)
11169 value[j] = mp->popSizeFix;
11172 else if (p->paramType == P_AAMODEL)
11174 /* Fill in theta ****************************************************************************************/
11175 if (p->paramId == AAMODEL_MIX)
11177 /* amino acid model ID's
11187 AAMODEL_BLOSUM 9 */
11189 /* set the amino acid model (the meaning of the numbers is defined) */
11190 tempInt = (int)(RandomNumber(seed) * 10);
11191 value[0] = tempInt;
11193 /* we need to make certain that the aa frequencies are filled in correctly */
11194 bs = GetParamSubVals (m->stateFreq, chn, 0);
11195 if (tempInt == AAMODEL_POISSON)
11197 for (i=0; i<mp->nStates; i++)
11198 bs[i] = (1.0 / 20.0);
11200 else if (tempInt == AAMODEL_JONES)
11202 for (i=0; i<mp->nStates; i++)
11203 bs[i] = jonesPi[i];
11205 else if (tempInt == AAMODEL_DAY)
11207 for (i=0; i<mp->nStates; i++)
11208 bs[i] = dayhoffPi[i];
11210 else if (tempInt == AAMODEL_MTREV)
11212 for (i=0; i<mp->nStates; i++)
11213 bs[i] = mtrev24Pi[i];
11215 else if (tempInt == AAMODEL_MTMAM)
11217 for (i=0; i<mp->nStates; i++)
11218 bs[i] = mtmamPi[i];
11220 else if (tempInt == AAMODEL_WAG)
11222 for (i=0; i<mp->nStates; i++)
11225 else if (tempInt == AAMODEL_RTREV)
11227 for (i=0; i<mp->nStates; i++)
11228 bs[i] = rtrevPi[i];
11230 else if (tempInt == AAMODEL_CPREV)
11232 for (i=0; i<mp->nStates; i++)
11233 bs[i] = cprevPi[i];
11235 else if (tempInt == AAMODEL_VT)
11237 for (i=0; i<mp->nStates; i++)
11240 else if (tempInt == AAMODEL_BLOSUM)
11242 for (i=0; i<mp->nStates; i++)
11246 for (i=0; i<p->nSubValues; i++)
11248 subValue[i] = mp->aaModelPrProbs[i];
11252 else if (p->paramType == P_CPPRATE)
11254 /* Fill in lambda (cpp rate) ********************************************************************************************/
11255 if (p->paramId == CPPRATE_EXP)
11256 value[0] = -(1.0/mp->cppRateExp) * log(RandomNumber(seed));
11257 else if (p->paramId == CPPRATE_FIX)
11258 value[0] = mp->cppRateFix;
11260 else if (p->paramType == P_CPPMULTDEV)
11262 /* Fill in log standard deviation (for relaxed clock rate multiplier) ***********************************************************/
11263 if (p->paramId == CPPMULTDEV_FIX)
11264 value[0] = mp->cppMultDevFix;
11266 else if (p->paramType == P_CPPEVENTS)
11268 /* We fill in these when we fill in tree params **************************************************************************/
11270 else if (p->paramType == P_TK02VAR)
11272 /* Fill in variance of relaxed clock lognormal **************************************************************************/
11273 if (p->paramId == TK02VAR_UNI)
11274 value[0] = RandomNumber(seed) * (mp->tk02varUni[1] - mp->tk02varUni[0]) + mp->tk02varUni[0];
11275 else if (p->paramId == TK02VAR_EXP)
11276 value[0] = 2.0/(mp->tk02varExp);
11277 else if (p->paramId == TK02VAR_FIX)
11278 value[0] = mp->tk02varFix;
11280 else if (p->paramType == P_TK02BRANCHRATES)
11282 /* We fill in these when we fill in tree params **************************************************************************/
11284 else if (p->paramType == P_IGRVAR)
11286 /* Fill in variance of relaxed clock lognormal **************************************************************************/
11287 if (p->paramId == IGRVAR_UNI)
11288 value[0] = RandomNumber(seed) * (mp->igrvarUni[1] - mp->igrvarUni[0]) + mp->igrvarUni[0];
11289 else if (p->paramId == IGRVAR_EXP)
11290 value[0] = 1.0/(mp->igrvarExp);
11291 else if (p->paramId == IGRVAR_FIX)
11292 value[0] = mp->igrvarFix;
11294 else if (p->paramType == P_IGRBRANCHRATES)
11296 /* We fill in these when we fill in tree params **************************************************************************/
11298 else if (p->paramType == P_MIXEDVAR)
11300 /* Fill in variance of mixed relaxed clock **************************************************************************/
11301 if (p->paramId == MIXEDVAR_UNI)
11302 value[0] = RandomNumber(seed) * (mp->mixedvarUni[1] - mp->mixedvarUni[0]) + mp->mixedvarUni[0];
11303 else if (p->paramId == MIXEDVAR_EXP)
11304 value[0] = 1.0/(mp->mixedvarExp);
11305 else if (p->paramId == MIXEDVAR_FIX)
11306 value[0] = mp->mixedvarFix;
11308 else if (p->paramType == P_MIXEDBRCHRATES)
11310 /* initialize the mixed relaxed clock model to TK02 or IGR */
11311 intValue[0] = (RandomNumber(seed) <0.5) ? RCL_TK02 : RCL_IGR;
11312 /* We fill in the rest when we fill in tree params **************************************************************************/
11314 else if (p->paramType == P_CLOCKRATE)
11316 /* Fill in base rate of molecular clock **************************************************************************/
11317 if (p->paramId == CLOCKRATE_FIX)
11318 value[0] = mp->clockRateFix;
11319 else if (p->paramId == CLOCKRATE_NORMAL)
11320 value[0] = mp->clockRateNormal[0];
11321 else if (p->paramId == CLOCKRATE_LOGNORMAL)
11322 value[0] = exp(mp->clockRateLognormal[0]);
11323 else if (p->paramId == CLOCKRATE_EXP)
11324 value[0] = 1.0/(mp->clockRateExp);
11325 else if (p->paramId == CLOCKRATE_GAMMA)
11326 value[0] = mp->clockRateGamma[0]/mp->clockRateGamma[1];
11335 int FillRelPartsString (Param *p, char **relPartString)
11337 int i, n, filledString;
11339 int tempStrSize=50;
11341 tempStr = (char *) SafeMalloc((size_t)tempStrSize * sizeof(char));
11344 MrBayesPrint ("%s Problem allocating tempString (%d)\n", spacer, tempStrSize * sizeof(char));
11348 if (numCurrentDivisions == 1)
11351 SafeStrcpy (relPartString, "");
11355 filledString = YES;
11356 if (p->nRelParts == numCurrentDivisions)
11358 SafeStrcpy (relPartString, "{all}");
11362 SafeStrcpy (relPartString, "{");
11363 for (i=n=0; i<p->nRelParts; i++)
11366 SafeSprintf (&tempStr, &tempStrSize, "%d", p->relParts[i] + 1);
11367 SafeStrcat (relPartString, tempStr);
11368 if (n < p->nRelParts)
11369 SafeStrcat (relPartString, ",");
11371 SafeStrcat (relPartString, "}");
11375 return (filledString);
11379 /*--------------------------------------------------------------
11381 | FillStdStateFreqs: fills stationary frequencies for standard data divisions of chains in range [chfrom, chto)
11383 ---------------------------------------------------------------*/
11384 void FillStdStateFreqs (int chfrom, int chto, RandLong *seed)
11386 int chn, n, i, j, k, b, c, nb, index;
11387 MrBFlt *subValue, sum, symDir[10];
11390 for (chn=chfrom; chn<chto; chn++)
11392 for (k=0; k<numParams; k++)
11395 if (p->paramType != P_PI || modelParams[p->relParts[0]].dataType != STANDARD)
11397 subValue = GetParamStdStateFreqs (p, chn, 0);
11398 if (p->paramId == SYMPI_EQUAL)
11400 for (n=index=0; n<9; n++)
11402 for (i=0; i<p->nRelParts; i++)
11403 if (modelSettings[p->relParts[i]].isTiNeeded[n] == YES)
11405 if (i < p->nRelParts)
11407 for (j=0; j<(n+2); j++)
11409 subValue[index++] = (1.0 / (n + 2));
11413 for (n=9; n<13; n++)
11415 for (i=0; i<p->nRelParts; i++)
11416 if (modelSettings[p->relParts[i]].isTiNeeded[n] == YES)
11418 if (i < p->nRelParts)
11420 for (j=0; j<(n-6); j++)
11422 subValue[index++] = (1.0 / (n - 6));
11428 /* Deal with transition asymmetry for standard characters */
11429 /* First, fill in stationary frequencies for beta categories if needed; */
11430 /* discard category frequencies (assume equal) */
11431 if (p->paramId == SYMPI_FIX || p->paramId == SYMPI_UNI || p->paramId == SYMPI_EXP ||
11432 p->paramId == SYMPI_FIX_MS || p->paramId == SYMPI_UNI_MS || p->paramId == SYMPI_EXP_MS)
11434 if (p->hasBinaryStd == YES)
11436 nb=modelParams[p->relParts[0]].numBetaCats;
11437 BetaBreaks (p->values[0], p->values[0], subValue, nb);
11439 for (i=b-2; i>0; i-=2)
11441 subValue[i] = subValue[i/2];
11443 for (i=1; i<b; i+=2)
11445 subValue[i] = (1.0 - subValue[i-1]);
11447 subValue += (2 * nb);
11450 /* Then fill in state frequencies for multistate chars, one set for each */
11451 for (i=0; i<10; i++)
11452 symDir[i] = p->values[0];
11454 for (c=0; c<p->nSympi; c++)
11456 /* now fill in subvalues */
11457 DirichletRandomVariable (symDir, subValue, p->sympinStates[c], seed);
11459 for (i=0; i<p->sympinStates[c]; i++)
11461 if (subValue[i] < 0.0001)
11462 subValue[i] = 0.0001;
11463 sum += subValue[i];
11465 for (i=0; i<modelParams[p->relParts[0]].nStates; i++)
11466 subValue[i] /= sum;
11467 subValue += p->sympinStates[c];
11470 } /* next parameter */
11475 /* FillTopologySubParams: Fill subparams (brlens) for a topology */
11476 int FillTopologySubParams (Param *param, int chn, int state, RandLong *seed)
11479 Tree *tree, *tree1;
11482 PolyTree *sourceTree;
11483 MrBFlt minRate,maxRate;
11485 tree = GetTree (param, chn, state);
11487 for (i=1; i<param->nSubParams; i++)
11489 q = param->subParams[i];
11490 tree1 = GetTree (q, chn, state);
11491 if (CopyToTreeFromTree(tree1, tree) == ERROR)
11494 for (i=0; i<param->nSubParams; i++)
11496 q = param->subParams[i];
11497 tree = GetTree (q, chn, state);
11498 if (q->paramId == BRLENS_FIXED || q->paramId == BRLENS_CLOCK_FIXED)
11500 if (param->paramId == TOPOLOGY_NCL_FIXED ||
11501 param->paramId == TOPOLOGY_NCL_FIXED_HOMO ||
11502 param->paramId == TOPOLOGY_NCL_FIXED_HETERO ||
11503 param->paramId == TOPOLOGY_CL_FIXED ||
11504 param->paramId == TOPOLOGY_RCL_FIXED ||
11505 param->paramId == TOPOLOGY_CCL_FIXED ||
11506 param->paramId == TOPOLOGY_RCCL_FIXED||
11507 param->paramId == TOPOLOGY_FIXED)
11509 sourceTree = AllocatePolyTree(numTaxa);
11510 CopyToPolyTreeFromPolyTree (sourceTree, userTree[modelParams[q->relParts[0]].brlensFix]);
11511 PrunePolyTree (sourceTree);
11512 ResetTipIndices (sourceTree);
11513 ResetIntNodeIndices (sourceTree);
11514 if (tree->isRooted != sourceTree->isRooted)
11516 MrBayesPrint("%s Cannot set fixed branch lengths because of mismatch in rootedness", spacer);
11517 FreePolyTree (sourceTree);
11520 if (CopyToTreeFromPolyTree(tree,sourceTree) == ERROR)
11522 MrBayesPrint("%s Problem setting fixed branch lengths", spacer);
11523 FreePolyTree (sourceTree);
11526 FreePolyTree (sourceTree);
11527 if (tree->isClock == YES && IsClockSatisfied(tree, 0.0001) == NO)
11529 MrBayesPrint("%s Fixed branch lengths do not satisfy clock", spacer);
11532 if (tree->isCalibrated == YES && IsCalibratedClockSatisfied(tree,&minRate,&maxRate, 0.0001) == NO)
11534 MrBayesPrint("%s Fixed branch lengths do not satisfy calibrations", spacer);
11537 if (tree->isCalibrated == YES && !strcmp(modelParams[tree->relParts[0]].clockRatePr, "Fixed"))
11539 clockRate = modelParams[tree->relParts[0]].clockRateFix;
11540 if ((clockRate < minRate && AreDoublesEqual (clockRate, minRate , 0.0001) == NO) ||
11541 (clockRate > maxRate && AreDoublesEqual (clockRate, maxRate , 0.0001) == NO))
11543 MrBayesPrint("%s Fixed branch lengths do not satisfy fixed clockrate", spacer);
11548 tree->fromUserTree=YES;
11549 returnVal = NO_ERROR;
11553 MrBayesPrint("%s Fixed branch lengths can only be used for a fixed topology\n", spacer);
11557 else if (tree->isCalibrated == YES || (tree->isClock == YES && (!strcmp(modelParams[tree->relParts[0]].clockPr,"Uniform") ||
11558 !strcmp(modelParams[tree->relParts[0]].clockPr,"Fossilization"))))
11560 assert (tree->isClock == YES);
11561 clockRate = *GetParamVals(modelSettings[tree->relParts[0]].clockRate, chn, state);
11562 returnVal = InitCalibratedBrlens (tree, clockRate, seed);
11563 if (IsClockSatisfied (tree,0.0001) == NO)
11565 MrBayesPrint ("%s Branch lengths of the tree does not satisfy clock\n", spacer);
11568 tree->fromUserTree=NO;
11570 else if (tree->isClock == YES)
11571 returnVal = InitClockBrlens (tree);
11573 returnVal = InitBrlens (tree, 0.02);
11575 if (returnVal == ERROR)
11578 if (FillBrlensSubParams (q, chn, state) == ERROR)
11586 /* FillBrlensSubParams: Fill any relaxed clock subparams of a brlens param */
11587 int FillBrlensSubParams (Param *param, int chn, int state)
11589 int i, j, *nEvents;
11590 MrBFlt *brlen, *branchRate, **position, **rateMult;
11595 tree = GetTree (param, chn, state);
11597 for (i=0; i<param->nSubParams; i++)
11599 q = param->subParams[i];
11600 if (q->paramType == P_CPPEVENTS)
11602 nEvents = q->nEvents[2*chn+state];
11603 position = q->position[2*chn+state];
11604 rateMult = q->rateMult[2*chn+state];
11605 brlen = GetParamSubVals (q, chn, state);
11606 for (j=0; j<tree->nNodes-1; j++)
11608 p = tree->allDownPass[j];
11609 if (nEvents[p->index] != 0)
11611 free (position[p->index]);
11612 position[p->index] = NULL;
11613 free (rateMult[p->index]);
11614 rateMult[p->index] = NULL;
11616 nEvents[p->index] = 0;
11617 assert (j==tree->nNodes-2 || fabs(p->length - (p->anc->nodeDepth - p->nodeDepth)) < 0.000001);
11618 brlen[p->index] = p->length;
11621 else if (q->paramType == P_TK02BRANCHRATES || q->paramType == P_IGRBRANCHRATES || q->paramType == P_MIXEDBRCHRATES)
11623 branchRate = GetParamVals (q, chn, state);
11624 brlen = GetParamSubVals (q, chn, state);
11625 for (j=0; j<tree->nNodes-1; j++)
11627 p = tree->allDownPass[j];
11628 assert (j==tree->nNodes-2 || fabs(p->length - (p->anc->nodeDepth - p->nodeDepth)) < 0.000001);
11629 branchRate[p->index] = 1.0;
11630 brlen[p->index] = p->length;
11639 /* Note: In PruneConstraintPartitions() we can not relay on specific rootnes of a tree since different partitions
11640 may theoreticly have different clock models, while constraints apply to all partitions/trees */
11641 int PruneConstraintPartitions()
11643 int i, j, constraintId, nLongsNeeded;
11645 nLongsNeeded = (numLocalTaxa - 1) / nBitsInALong + 1;
11647 for (constraintId=0; constraintId<numDefinedConstraints; constraintId++)
11649 definedConstraintPruned[constraintId] = (BitsLong *) SafeRealloc ((void *)definedConstraintPruned[constraintId], nLongsNeeded*sizeof(BitsLong));
11650 if (!definedConstraintPruned[constraintId])
11652 MrBayesPrint ("%s Problems allocating constraintPartition in PruneConstraintPartitions", spacer);
11656 /* initialize bits in partition to add; get rid of deleted taxa in the process */
11657 ClearBits(definedConstraintPruned[constraintId], nLongsNeeded);
11658 for (i=j=0; i<numTaxa; i++)
11660 if (taxaInfo[i].isDeleted == YES)
11662 if (IsBitSet(i, definedConstraint[constraintId]) == YES)
11663 SetBit(j, definedConstraintPruned[constraintId]);
11666 assert (j == numLocalTaxa);
11668 if (definedConstraintsType[constraintId] == PARTIAL)
11670 definedConstraintTwoPruned[constraintId] = (BitsLong *) SafeRealloc ((void *)definedConstraintTwoPruned[constraintId], nLongsNeeded*sizeof(BitsLong));
11671 if (!definedConstraintTwoPruned[constraintId])
11673 MrBayesPrint ("%s Problems allocating constraintPartition in PruneConstraintPartitions", spacer);
11677 /* initialize bits in partition to add; get rid of deleted taxa in the process */
11678 ClearBits(definedConstraintTwoPruned[constraintId], nLongsNeeded);
11679 for (i=j=0; i<numTaxa; i++)
11681 if (taxaInfo[i].isDeleted == YES)
11683 if (IsBitSet(i, definedConstraintTwo[constraintId]) == YES)
11684 SetBit(j, definedConstraintTwoPruned[constraintId]);
11687 assert (j == numLocalTaxa);
11689 else if (definedConstraintsType[constraintId] == NEGATIVE || (definedConstraintsType[constraintId] == HARD))
11691 /* Here we create definedConstraintTwoPruned[constraintId] which is complemente of definedConstraintPruned[constraintId] */
11692 definedConstraintTwoPruned[constraintId] = (BitsLong *) SafeRealloc ((void *)definedConstraintTwoPruned[constraintId], nLongsNeeded*sizeof(BitsLong));
11693 if (!definedConstraintTwoPruned[constraintId])
11695 MrBayesPrint ("%s Problems allocating constraintPartition in PruneConstraintPartitions", spacer);
11699 /* initialize bits in partition to add; get rid of deleted taxa in the process */
11700 ClearBits(definedConstraintTwoPruned[constraintId], nLongsNeeded);
11701 for (i=j=0; i<numTaxa; i++)
11703 if (taxaInfo[i].isDeleted == YES)
11705 if (IsBitSet(i, definedConstraint[constraintId]) == NO)
11706 SetBit(j, definedConstraintTwoPruned[constraintId]);
11709 assert (j == numLocalTaxa);
11717 int DoesTreeSatisfyConstraints(Tree *t)
11719 int i, k, numTaxa, nLongsNeeded;
11721 int CheckFirst, CheckSecond; /*Flag indicating wheather corresponding set(first/second) of partial constraint has to be checked*/
11722 # if defined (DEBUG_CONSTRAINTS)
11726 if (t->checkConstraints == NO)
11728 /* get some handy numbers */
11729 numTaxa = t->nNodes - t->nIntNodes - (t->isRooted == YES ? 1 : 0);
11730 nLongsNeeded = (numTaxa - 1) / nBitsInALong + 1;
11732 if (t->bitsets == NULL)
11734 AllocateTreePartitions(t);
11738 ResetTreePartitions(t); /*Inefficient function, rewrite faster version*/
11740 # if defined (DEBUG_CONSTRAINTS)
11741 for (i=0; i<t->nIntNodes; i++)
11743 p = t->intDownPass[i];
11744 if (p->isLocked == YES)
11746 if (IsUnionEqThird (definedConstraintPruned[p->lockID], definedConstraintPruned[p->lockID], p->partition, nLongsNeeded) == NO && IsUnionEqThird (definedConstraintTwoPruned[p->lockID], definedConstraintTwoPruned[p->lockID], p->partition, nLongsNeeded) == NO)
11748 printf ("DEBUG ERROR: Locked node does not represent right partition. \n");
11758 if (locks_count != t->nLocks)
11760 printf ("DEBUG ERROR: locks_count:%d should be locks_count:%d\n", locks_count, t->nLocks);
11765 for (k=0; k<numDefinedConstraints; k++)
11767 # if defined (DEBUG_CONSTRAINTS)
11768 if (t->constraints[k] == YES && definedConstraintsType[k] == HARD)
11770 if (t->isRooted == YES)
11777 /*exactly one of next two will be YES*/
11778 CheckFirst = IsBitSet(localOutGroup, definedConstraintPruned[k])==YES ? NO : YES;
11779 CheckSecond = IsBitSet(localOutGroup, definedConstraintTwoPruned[k])==YES ? NO : YES;
11780 assert ((CheckFirst^CheckSecond)==1);
11783 for (i=0; i<t->nIntNodes; i++)
11785 p = t->intDownPass[i];
11786 if (p->anc != NULL)
11788 if (CheckFirst==YES && IsPartNested(definedConstraintPruned[k], p->partition, nLongsNeeded) && IsPartNested(p->partition,definedConstraintPruned[k], nLongsNeeded))
11790 if (CheckSecond==YES && IsPartNested(definedConstraintTwoPruned[k], p->partition, nLongsNeeded) && IsPartNested(p->partition, definedConstraintTwoPruned[k], nLongsNeeded))
11795 if (i==t->nIntNodes)
11797 printf ("DEBUG ERROR: Hard constraint is not satisfied. \n");
11804 if (t->constraints[k] == NO || definedConstraintsType[k] == HARD)
11807 if (definedConstraintsType[k] == PARTIAL)
11810 if (t->isRooted == NO && !IsBitSet(localOutGroup, definedConstraintPruned[k]))
11812 m = FirstTaxonInPartition (constraintPartition, nLongsNeeded);
11813 for (i=0; t->nodes[i].index != m; i++)
11818 while (!IsPartNested(definedConstraintPruned[k], p->partition, nLongsNeeded))
11821 if (IsSectionEmpty(definedConstraintTwoPruned[k], p->partition, nLongsNeeded))
11825 if (t->isRooted == YES)
11828 CheckSecond = NO; /* In rooted case even if we have a node with partition fully containing second set and not containing the first set it would not satisfy the constraint */
11832 if (NumBits(definedConstraintPruned[k], nLongsNeeded) == 1 || NumBits(definedConstraintTwoPruned[k], nLongsNeeded) == 1)
11834 /*one or two of the next two statments will be YES*/
11835 CheckFirst = IsBitSet(localOutGroup, definedConstraintPruned[k])==YES ? NO : YES;
11836 CheckSecond = IsBitSet(localOutGroup, definedConstraintTwoPruned[k])==YES ? NO : YES;
11837 assert ((CheckFirst|CheckSecond)==1);
11839 for (i=0; i<t->nIntNodes; i++)
11841 p = t->intDownPass[i];
11842 if (p->anc != NULL)
11844 if (CheckFirst== YES && IsPartNested(definedConstraintPruned[k], p->partition, nLongsNeeded) && IsSectionEmpty(definedConstraintTwoPruned[k], p->partition, nLongsNeeded))
11846 if (CheckSecond==YES && IsPartNested(definedConstraintTwoPruned[k], p->partition, nLongsNeeded) && IsSectionEmpty(definedConstraintPruned[k], p->partition, nLongsNeeded))
11850 if (i==t->nIntNodes)
11855 assert (definedConstraintsType[k] == NEGATIVE);
11856 if (t->isRooted == YES)
11863 /*exactly one of next two will be YES*/
11864 CheckFirst = IsBitSet(localOutGroup, definedConstraintPruned[k])==YES ? NO : YES;
11865 CheckSecond = IsBitSet(localOutGroup, definedConstraintTwoPruned[k])==YES ? NO : YES;
11866 assert ((CheckFirst^CheckSecond)==1);
11869 for (i=0; i<t->nIntNodes; i++)
11871 p = t->intDownPass[i];
11872 if (p->anc != NULL)
11874 if (CheckFirst==YES && AreBitfieldsEqual(definedConstraintPruned[k], p->partition, nLongsNeeded))
11876 if (CheckSecond==YES && AreBitfieldsEqual(definedConstraintTwoPruned[k], p->partition, nLongsNeeded))
11880 if (i!=t->nIntNodes)
11889 /*------------------------------------------------------------------
11891 | FillTreeParams: Fill in trees and branch lengths
11893 | Note: Should be run after FillNormalParams because
11894 | clockrate needs to be set if calibrated tree needs
11897 ------------------------------------------------------------------*/
11898 int FillTreeParams (RandLong *seed, int fromChain, int toChain)
11900 int i, k, chn, nTaxa, tmp;
11903 PolyTree *constraintTree;
11904 PolyTree *constraintTreeRef;
11906 if (PruneConstraintPartitions() == ERROR)
11909 /* Build starting trees for state 0 */
11910 for (chn=fromChain; chn<toChain; chn++)
11912 for (k=0; k<numParams; k++)
11915 if (p->paramType == P_TOPOLOGY)
11917 q = p->subParams[0];
11918 tree = GetTree (q, chn, 0);
11919 if (tree->isRooted == YES)
11920 nTaxa = tree->nNodes - tree->nIntNodes - 1;
11922 nTaxa = tree->nNodes - tree->nIntNodes;
11924 /* fixed topology */
11925 if (p->paramId == TOPOLOGY_NCL_FIXED ||
11926 p->paramId == TOPOLOGY_NCL_FIXED_HOMO ||
11927 p->paramId == TOPOLOGY_NCL_FIXED_HETERO ||
11928 p->paramId == TOPOLOGY_CL_FIXED ||
11929 p->paramId == TOPOLOGY_RCL_FIXED ||
11930 p->paramId == TOPOLOGY_CCL_FIXED ||
11931 p->paramId == TOPOLOGY_RCCL_FIXED||
11932 p->paramId == TOPOLOGY_FIXED ||
11933 p->paramId == TOPOLOGY_PARSIMONY_FIXED)
11935 constraintTree = AllocatePolyTree (numTaxa);
11936 CopyToPolyTreeFromPolyTree (constraintTree, userTree[modelParams[p->relParts[0]].topologyFix]);
11937 PrunePolyTree (constraintTree);
11938 ResetTipIndices(constraintTree);
11939 ResetIntNodeIndices(constraintTree);
11940 RandResolve (NULL, constraintTree, seed, constraintTree->isRooted);
11941 if (tree->nIntNodes != constraintTree->nIntNodes)
11943 if (tree->isRooted != constraintTree->isRooted)
11945 MrBayesPrint ("%s Could not fix topology because user tree '%s' differs in rootedness with the model tree.\n", spacer,
11946 userTree[modelParams[p->relParts[0]].topologyFix]->name);
11947 MrBayesPrint ("%s The user tree %s is%srooted, while expected model tree is%srooted.\n", spacer,
11948 userTree[modelParams[p->relParts[0]].topologyFix]->name, (constraintTree->isRooted?" ":" not "), (tree->isRooted?" ":" not "));
11949 MrBayesPrint ("%s Check brlenspr is set correctly before fixing topology.\n", spacer);
11952 MrBayesPrint ("%s Could not fix topology because user tree '%s' is not fully resolved.\n",
11953 spacer, userTree[modelParams[p->relParts[0]].topologyFix]->name);
11954 FreePolyTree (constraintTree);
11957 if (CopyToTreeFromPolyTree(tree, constraintTree) == ERROR)
11959 MrBayesPrint ("%s Could not fix topology according to user tree '%s'\n", spacer, userTree[modelParams[p->relParts[0]].topologyFix]->name);
11960 FreePolyTree (constraintTree);
11963 FreePolyTree (constraintTree);
11965 /* constrained topology */
11966 else if (tree->nConstraints > 0)
11968 constraintTreeRef = AllocatePolyTree (nTaxa);
11969 if (!constraintTreeRef)
11971 if (BuildConstraintTree (tree, constraintTreeRef, localTaxonNames) == ERROR)
11973 FreePolyTree (constraintTreeRef);
11976 if (AllocatePolyTreePartitions (constraintTreeRef) == ERROR)
11979 constraintTree = AllocatePolyTree (nTaxa);
11980 if (!constraintTree)
11982 if (AllocatePolyTreePartitions (constraintTree) == ERROR)
11985 for (i=0;i<100;i++)
11987 CopyToPolyTreeFromPolyTree(constraintTree,constraintTreeRef);
11988 tmp = RandResolve (tree, constraintTree, &globalSeed, tree->isRooted);
11989 if (tmp != NO_ERROR)
11993 FreePolyTree (constraintTree);
11998 assert (tmp == ABORT);
12003 CopyToTreeFromPolyTree(tree, constraintTree);
12004 if (DoesTreeSatisfyConstraints(tree)==YES)
12007 # if defined (DEBUG_CONSTRAINTS)
12008 if (theTree->checkConstraints == YES && CheckConstraints (tree) == ERROR)
12010 printf ("Error in constraints of starting tree\n");
12014 FreePolyTree (constraintTree);
12015 FreePolyTree (constraintTreeRef);
12018 MrBayesPrint ("%s Could not build a starting tree satisfying all constraints\n", spacer);
12022 /* random topology */
12025 if (tree->isRooted == YES)
12027 if (BuildRandomRTopology (tree, &globalSeed) == ERROR)
12032 if (BuildRandomUTopology (tree, &globalSeed) == ERROR)
12034 if (MoveCalculationRoot (tree, localOutGroup) == ERROR)
12039 if (LabelTree (tree, localTaxonNames) == ERROR)
12042 continue; /* this is a parsimony tree without branch lengths */
12043 if (InitializeTreeCalibrations (tree) == ERROR)
12045 if (FillTopologySubParams(p, chn, 0, seed)== ERROR)
12051 if (numTopologies > 1 && !strcmp(modelParams[0].topologyPr,"Speciestree"))
12053 if (FillSpeciesTreeParams(seed, fromChain, toChain) == ERROR)
12061 void FreeCppEvents (Param *p)
12065 if (p->paramType != P_CPPEVENTS)
12068 if (p->nEvents != NULL)
12070 free (p->nEvents[0]);
12072 for (i=0; i<numGlobalChains; i++)
12074 for (j=0; j<2*numLocalTaxa; j++)
12076 free (p->position[2*i][j]);
12077 free (p->rateMult[2*i][j]);
12078 free (p->position[2*i+1][j]);
12079 free (p->rateMult[2*i+1][j]);
12082 free (p->position[0]);
12083 free (p->position);
12084 free (p->rateMult[0]);
12085 free (p->rateMult);
12087 p->position = NULL;
12088 p->rateMult = NULL;
12093 int FreeModel (void)
12098 if (memAllocs[ALLOC_MODEL] == YES)
12100 for (i=0; i<numCurrentDivisions; i++)
12102 free (modelParams[i].activeConstraints);
12103 if (memAllocs[ALLOC_SAMPLEFOSSILSLICE] == YES)
12105 free(modelParams[i].sampleFSProb);
12106 free(modelParams[i].sampleFSTime);
12107 memAllocs[ALLOC_SAMPLEFOSSILSLICE] = NO;
12110 free (modelParams);
12111 free (modelSettings);
12112 memAllocs[ALLOC_MODEL] = NO;
12114 if (memAllocs[ALLOC_MOVES] == YES)
12116 for (i=0; i<numApplicableMoves; i++)
12117 FreeMove (moves[i]);
12120 numApplicableMoves = 0;
12121 memAllocs[ALLOC_MOVES] = NO;
12123 if (memAllocs[ALLOC_COMPMATRIX] == YES)
12126 memAllocs[ALLOC_COMPMATRIX] = NO;
12128 if (memAllocs[ALLOC_NUMSITESOFPAT] == YES)
12130 free (numSitesOfPat);
12131 memAllocs[ALLOC_NUMSITESOFPAT] = NO;
12133 if (memAllocs[ALLOC_COMPCOLPOS] == YES)
12136 memAllocs[ALLOC_COMPCOLPOS] = NO;
12138 if (memAllocs[ALLOC_COMPCHARPOS] == YES)
12140 free (compCharPos);
12141 memAllocs[ALLOC_COMPCHARPOS] = NO;
12143 if (memAllocs[ALLOC_ORIGCHAR] == YES)
12146 memAllocs[ALLOC_ORIGCHAR] = NO;
12148 if (memAllocs[ALLOC_STDTYPE] == YES)
12151 memAllocs[ALLOC_STDTYPE] = NO;
12153 if (memAllocs[ALLOC_STDSTATEFREQS] == YES)
12155 free (stdStateFreqs);
12156 stdStateFreqs = NULL;
12157 memAllocs[ALLOC_STDSTATEFREQS] = NO;
12159 if (memAllocs[ALLOC_PARAMVALUES] == YES)
12161 for (i=0; i<numParams; i++)
12164 if (p->paramType == P_CPPEVENTS)
12167 free (paramValues);
12168 paramValues = NULL;
12171 paramValsRowSize = intValsRowSize = 0;
12172 memAllocs[ALLOC_PARAMVALUES] = NO;
12174 if (memAllocs[ALLOC_PARAMS] == YES)
12176 for (i=0; i<numParams; i++)
12178 SafeFree ((void **)¶ms[i].name);
12179 if (params[i].paramHeader)
12181 free (params[i].paramHeader);
12182 params[i].paramHeader = NULL;
12186 free (relevantParts);
12188 relevantParts = NULL;
12190 memAllocs[ALLOC_PARAMS] = NO;
12192 if (memAllocs[ALLOC_MCMCTREES] == YES)
12195 free (subParamPtrs);
12197 subParamPtrs = NULL;
12198 memAllocs[ALLOC_MCMCTREES] = NO;
12200 if (memAllocs[ALLOC_SYMPIINDEX] == YES)
12203 memAllocs[ALLOC_SYMPIINDEX] = NO;
12205 if (memAllocs[ALLOC_LOCTAXANAMES] == YES)
12207 free (localTaxonNames);
12208 memAllocs[ALLOC_LOCTAXANAMES] = NO;
12210 if (memAllocs[ALLOC_LOCALTAXONCALIBRATION] == YES)
12212 free (localTaxonCalibration);
12213 memAllocs[ALLOC_LOCALTAXONCALIBRATION] = NO;
12220 void FreeMove (MCMCMove *mv)
12222 free (mv->tuningParam[0]);
12223 free (mv->tuningParam);
12224 free (mv->relProposalProb);
12225 free (mv->nAccepted);
12231 /* Compute empirical state freq are return it in global array empiricalFreqs[] */
12232 int GetEmpiricalFreqs (int *relParts, int nRelParts)
12234 int i, j, k, m, n, thePartition, nuc[20], ns, temp, isDNA, isProtein, firstRel;
12235 MrBFlt freqN[20], sum, sumN[20]/*, rawCounts[20]*/;
12237 isDNA = isProtein = NO;
12240 for (i=0; i<nRelParts; i++)
12242 thePartition = relParts[i];
12245 if (modelParams[thePartition].dataType == DNA || modelParams[i].dataType == RNA)
12250 else if (modelParams[thePartition].dataType == PROTEIN)
12255 else if (modelParams[thePartition].dataType == RESTRICTION)
12261 MrBayesPrint ("%s Cannot get empirical state frequencies for this datatype (%d)\n", spacer, modelSettings[i].dataType);
12264 firstRel = thePartition;
12268 if (modelParams[thePartition].dataType == DNA || modelParams[i].dataType == RNA)
12270 else if (modelParams[thePartition].dataType == PROTEIN)
12272 else if (modelParams[thePartition].dataType == RESTRICTION)
12276 MrBayesPrint ("%s Unknown data type in GetEmpiricalFreqs\n", spacer);
12281 MrBayesPrint ("%s Averaging state frequencies over partitions with different data types\n", spacer);
12288 MrBayesPrint ("%s Could not find a relevant partition\n", spacer);
12292 for (i=0; i<200; i++)
12293 empiricalFreqs[i] = 0.0;
12295 for (m=0; m<ns; m++)
12296 freqN[m] = 1.0 / ns;
12298 /* for (m=0; m<ns; m++)
12299 rawCounts[m] = 0.0; NEVER USED */
12301 for (m=0; m<ns; m++)
12303 for (k=0; k<nRelParts; k++)
12305 thePartition = relParts[k];
12306 for (i=0; i<numTaxa; i++)
12308 if (taxaInfo[i].isDeleted == NO)
12310 for (j=0; j<numChar; j++)
12312 if (charInfo[j].isExcluded == NO && partitionId[j][partitionNum] - 1 == thePartition)
12315 GetPossibleNucs (matrix[pos(i,j,numChar)], nuc);
12316 else if (isProtein == YES)
12317 GetPossibleAAs (matrix[pos(i,j,numChar)], nuc);
12319 GetPossibleRestrictionSites (matrix[pos(i,j,numChar)], nuc);
12321 for (m=0; m<ns; m++)
12322 sum += freqN[m] * nuc[m];
12323 for (m=0; m<ns; m++)
12324 sumN[m] += freqN[m] * nuc[m] / sum;
12331 for (m=0; m<ns; m++)
12333 for (m=0; m<ns; m++)
12334 freqN[m] = sumN[m] / sum;
12336 if (modelParams[firstRel].dataType == DNA || modelParams[firstRel].dataType == RNA)
12338 if (!strcmp(modelParams[firstRel].nucModel, "4by4"))
12340 for (m=0; m<ns; m++)
12341 empiricalFreqs[m] = freqN[m];
12343 else if (!strcmp(modelParams[firstRel].nucModel, "Doublet"))
12346 for (m=0; m<ns; m++)
12347 for (n=0; n<ns; n++)
12348 empiricalFreqs[i++] = freqN[m] * freqN[n];
12352 if (!strcmp(modelParams[firstRel].geneticCode, "Universal"))
12354 for (i=0; i<61; i++)
12355 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12357 else if (!strcmp(modelParams[firstRel].geneticCode, "Vertmt"))
12359 for (i=0; i<60; i++)
12360 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12362 else if (!strcmp(modelParams[firstRel].geneticCode, "Invermt"))
12364 for (i=0; i<62; i++)
12365 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12367 else if (!strcmp(modelParams[firstRel].geneticCode, "Mycoplasma"))
12369 for (i=0; i<62; i++)
12370 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12372 else if (!strcmp(modelParams[firstRel].geneticCode, "Yeast"))
12374 for (i=0; i<62; i++)
12375 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12377 else if (!strcmp(modelParams[firstRel].geneticCode, "Ciliate"))
12379 for (i=0; i<63; i++)
12380 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12382 else if (!strcmp(modelParams[firstRel].geneticCode, "Echinoderm"))
12384 for (i=0; i<62; i++)
12385 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12387 else if (!strcmp(modelParams[firstRel].geneticCode, "Euplotid"))
12389 for (i=0; i<62; i++)
12390 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12392 else if (!strcmp(modelParams[firstRel].geneticCode, "Metmt"))
12394 for (i=0; i<62; i++)
12395 empiricalFreqs[i] = freqN[modelParams[firstRel].codonNucs[i][0]] * freqN[modelParams[firstRel].codonNucs[i][1]] * freqN[modelParams[firstRel].codonNucs[i][2]];
12398 for (i=0; i<64; i++)
12399 sum += empiricalFreqs[i];
12400 for (i=0; i<64; i++)
12401 empiricalFreqs[i] /= sum;
12407 for (m=0; m<ns; m++)
12408 empiricalFreqs[m] = freqN[m];
12415 int GetNumDivisionChars (void)
12420 /* count number of characters in each division */
12421 for (d=0; d<numCurrentDivisions; d++)
12423 m = &modelSettings[d];
12426 for (c=0; c<numChar; c++)
12428 if (charInfo[c].isExcluded == NO && partitionId[c][partitionNum] == d+1)
12431 if (m->dataType == DNA || m->dataType == RNA)
12433 if (m->nucModelId == NUCMODEL_DOUBLET)
12435 else if (m->nucModelId == NUCMODEL_CODON)
12439 m->numUncompressedChars = n;
12446 int *GetParamIntVals (Param *parm, int chain, int state)
12448 return parm->intValues + (2 * chain + state) * intValsRowSize;
12452 MrBFlt *GetParamStdStateFreqs (Param *parm, int chain, int state)
12454 return parm->stdStateFreqs + (2 * chain + state) * stdStateFreqsRowSize;
12458 MrBFlt *GetParamSubVals (Param *parm, int chain, int state)
12460 return parm->subValues + (2 * chain + state) * paramValsRowSize;
12464 MrBFlt *GetParamVals (Param *parm, int chain, int state)
12466 return parm->values + (2 * chain + state) * paramValsRowSize;
12470 void GetPossibleAAs (int aaCode, int aa[])
12474 for (m=0; m<20; m++)
12477 if (aaCode > 0 && aaCode <= 20)
12481 for (m=0; m<20; m++)
12486 printf ("%2d -- ", aaCode);
12487 for (m=0; m<20; m++)
12488 printf ("%d", aa[m]);
12494 void GetPossibleNucs (int nucCode, int nuc[])
12503 else if (nucCode == 2)
12510 else if (nucCode == 3)
12517 else if (nucCode == 4)
12524 else if (nucCode == 5)
12531 else if (nucCode == 6)
12538 else if (nucCode == 7)
12545 else if (nucCode == 8)
12552 else if (nucCode == 9)
12559 else if (nucCode == 10)
12566 else if (nucCode == 11)
12573 else if (nucCode == 12)
12580 else if (nucCode == 13)
12587 else if (nucCode == 14)
12604 void GetPossibleRestrictionSites (int resSiteCode, int *sites)
12608 for (m=0; m<2; m++)
12611 if (resSiteCode == 1)
12613 else if (resSiteCode == 2)
12616 sites[0] = sites[1] = 1;
12619 printf ("%2d -- ", aaCode);
12620 for (m=0; m<20; m++)
12621 printf ("%d", aa[m]);
12627 Tree *GetTree (Param *parm, int chain, int state)
12629 return mcmcTree[parm->treeIndex + ((2 * chain + state) * numTrees)];
12633 Tree *GetTreeFromIndex (int index, int chain, int state)
12635 return mcmcTree[index + ((2 * chain + state) * numTrees)];
12639 /*-----------------------------------------------------------
12641 | GetUserTreeFromName: Do case-insensitive search for user
12642 | tree, return index if match, -1 and ERROR if error
12644 ------------------------------------------------------------*/
12645 int GetUserTreeFromName (int *index, char *treeName)
12647 int i, j, k, nMatches;
12648 char localName[100], temp[100];
12650 (*index) = -1; /* appropriate return if no match */
12652 if ((int)strlen(treeName) > 99)
12654 MrBayesPrint ("%s Too many characters in tree name\n", spacer);
12658 strcpy (localName, treeName);
12659 for (i=0; i<(int)strlen(localName); i++)
12660 localName[i] = tolower(localName[i]);
12663 for (i=0; i<numUserTrees; i++)
12665 strcpy (temp, userTree[i]->name);
12666 for (k=0; k<(int)strlen(temp); k++)
12667 temp[k] = tolower(temp[k]);
12668 if (strcmp(localName,temp) == 0)
12676 for (i=0; i<numUserTrees; i++)
12678 strcpy (temp, userTree[i]->name);
12679 for (k=0; k<(int)strlen(temp); k++)
12680 temp[k] = tolower(temp[k]);
12681 if (strncmp(localName,temp,strlen(localName)) == 0)
12690 MrBayesPrint ("%s Could not find tree '%s'\n", spacer, localName);
12693 else if (nMatches > 1)
12695 MrBayesPrint ("%s Several trees matched the abbreviated name '%s'\n", spacer, localName);
12706 /*----------------------------------------------------------------------
12708 | InitializeChainTrees: 'Constructor' for chain trees
12710 -----------------------------------------------------------------------*/
12711 int InitializeChainTrees (Param *p, int from, int to, int isRooted)
12713 int i, st, isCalibrated, isClock, nTaxa, numActiveHardConstraints=0;
12714 Tree *tree, **treeHandle;
12717 mp = &modelParams[p->relParts[0]];
12719 if (p->paramType == P_SPECIESTREE)
12720 nTaxa = numSpecies;
12722 nTaxa = numLocalTaxa;
12724 /* figure out whether the trees are clock */
12725 if (!strcmp(mp->brlensPr,"Clock"))
12730 /* figure out whether the trees are calibrated */
12731 if (!strcmp(mp->brlensPr,"Clock") && (strcmp(mp->nodeAgePr,"Calibrated") == 0 || strcmp(mp->clockRatePr,"Fixed") != 0 ||
12732 (strcmp(mp->clockRatePr, "Fixed") == 0 && AreDoublesEqual(mp->clockRateFix, 1.0, 1E-6) == NO)))
12733 isCalibrated = YES;
12737 if (p->checkConstraints == YES)
12739 for (i=0; i<numDefinedConstraints; i++)
12741 if (mp->activeConstraints[i] == YES && definedConstraintsType[i] == HARD)
12742 numActiveHardConstraints++;
12746 /* allocate space for and construct the trees */
12747 /* NOTE: The memory allocation scheme used here must match GetTree and GetTreeFromIndex */
12748 for (i=from; i<to; i++)
12750 treeHandle = mcmcTree + p->treeIndex + 2*i*numTrees;
12753 if ((*treeHandle = AllocateTree (nTaxa)) == NULL)
12755 MrBayesPrint ("%s Problem allocating mcmc trees\n", spacer);
12758 treeHandle = mcmcTree + p->treeIndex + (2*i + 1)*numTrees;
12761 if ((*treeHandle = AllocateTree (nTaxa)) == NULL)
12763 MrBayesPrint ("%s Problem allocating mcmc trees\n", spacer);
12768 /* initialize the trees */
12769 for (i=from; i<to; i++)
12771 for (st=0; st<2; st++)
12773 tree = GetTree (p, i, st);
12775 sprintf (tree->name, "mcmc.tree%d_%d", p->treeIndex+1, i+1);
12776 else /* if (numTrees == 1) */
12777 sprintf (tree->name, "mcmc.tree_%d", i+1);
12778 tree->nRelParts = p->nRelParts;
12779 tree->relParts = p->relParts;
12780 tree->isRooted = isRooted;
12781 tree->isClock = isClock;
12782 tree->isCalibrated = isCalibrated;
12783 if (p->paramType == P_SPECIESTREE)
12785 tree->nNodes = 2*numSpecies;
12786 tree->nIntNodes = numSpecies - 1;
12788 else if (tree->isRooted == YES)
12790 tree->nNodes = 2*numLocalTaxa;
12791 tree->nIntNodes = numLocalTaxa - 1;
12793 else /* if (tree->isRooted == NO) */
12795 tree->nNodes = 2*numLocalTaxa - 2;
12796 tree->nIntNodes = numLocalTaxa - 2;
12798 if (p->checkConstraints == YES)
12800 tree->checkConstraints = YES;
12801 tree->nLocks = NumInformativeHardConstraints(mp);
12802 tree->nConstraints = mp->numActiveConstraints; /* nConstraints is number of constraints to check */
12803 tree->constraints = mp->activeConstraints;
12807 tree->checkConstraints = NO;
12808 tree->nConstraints = tree->nLocks = 0;
12809 tree->constraints = NULL;
12818 int InitializeLinks (void)
12823 for (i=0; i<NUM_LINKED; i++)
12825 for (j=0; j<numCurrentDivisions; j++)
12826 linkTable[i][j] = linkNum;
12833 /* InitializeTreeCalibrations: Set calibrations for tree nodes */
12834 int InitializeTreeCalibrations (Tree *t)
12839 if (t->isCalibrated == NO)
12842 /* Set tip calibrations */
12843 for (i=0; i<t->nNodes; i++)
12845 p = t->allDownPass[i];
12846 if (p->left == NULL && p->right == NULL && localTaxonCalibration[p->index]->prior != unconstrained)
12849 p->calibration = localTaxonCalibration[p->index];
12850 p->age = p->calibration->min;
12852 else if (p->left == NULL && p->right == NULL)
12855 p->calibration = NULL;
12860 /* Initialize interior calibrations */
12861 if (CheckSetConstraints(t) == ERROR)
12868 int IsApplicable (Param *param)
12877 int IsApplicable_ThreeTaxaOrMore (Param *param)
12879 if (LargestMovableSubtree (param) >= 3)
12886 int IsApplicable_FourTaxaOrMore (Param *param)
12888 if (LargestMovableSubtree (param) >= 4)
12895 int IsApplicable_FiveTaxaOrMore (Param *param)
12897 if (LargestMovableSubtree (param) >= 5)
12904 int IsApplicable_TreeAgeMove (Param *param)
12912 if (param->paramType != P_BRLENS)
12915 t = GetTree (param, 0, 0);
12918 if (p->isDated == NO)
12920 if (p->calibration->prior == fixed)
12927 int IsApplicable_AncestralFossil (Param *param)
12929 ModelParams *mp = &modelParams[param->relParts[0]];
12931 if (!strcmp(mp->sampleStrat, "FossilTip"))
12933 else if (mp->fossilizationFix == 0.0)
12935 else /* fossils may be ancestors of other fossils or extant species */
12940 int IsModelSame (int whichParam, int part1, int part2, int *isApplic1, int *isApplic2)
12942 int i, isSame, isFirstNucleotide, isSecondNucleotide, isFirstProtein, isSecondProtein, nDiff, temp1, temp2;
12948 /* We cannot rely on SetModelInfo being called first so we need to be smart in figuring out model data type by looking at several model params */
12949 isFirstNucleotide = isSecondNucleotide = NO;
12950 if ((modelParams[part1].dataType == DNA || modelParams[part1].dataType == RNA) && strcmp(modelParams[part1].nucModel,"Protein") != 0)
12951 isFirstNucleotide = YES;
12952 if ((modelParams[part2].dataType == DNA || modelParams[part2].dataType == RNA) && strcmp(modelParams[part2].nucModel,"Protein") != 0)
12953 isSecondNucleotide = YES;
12954 isFirstProtein = isSecondProtein = NO;
12955 if (modelParams[part1].dataType == PROTEIN || ((modelParams[part1].dataType == DNA || modelParams[part1].dataType == RNA) && !strcmp(modelParams[part1].nucModel,"Protein")))
12956 isFirstProtein = YES;
12957 if (modelParams[part2].dataType == PROTEIN || ((modelParams[part2].dataType == DNA || modelParams[part2].dataType == RNA) && !strcmp(modelParams[part2].nucModel,"Protein")))
12958 isSecondProtein = YES;
12960 if (whichParam == P_TRATIO)
12962 /* Check the ti/tv rate ratio for partitions 1 and 2. */
12964 /* Check if the model is parsimony for either partition */
12965 if (!strcmp(modelParams[part1].parsModel, "Yes"))
12966 *isApplic1 = NO; /* part1 has a parsimony model and tratio does not apply */
12967 if (!strcmp(modelParams[part2].parsModel, "Yes"))
12968 *isApplic2 = NO; /* part2 has a parsimony model and tratio does not apply */
12970 /* Check that the data are nucleotide for both partitions 1 and 2 */
12971 if (isFirstNucleotide == NO)
12972 *isApplic1 = NO; /* part1 is not nucleotide data so tratio does not apply */
12973 if (isSecondNucleotide == NO)
12974 *isApplic2 = NO; /* part2 is not nucleotide data so tratio does not apply */
12976 /* check that nst=2 for both partitions */
12977 if (strcmp(modelParams[part1].nst, "2"))
12978 *isApplic1 = NO; /* part1 does not have nst=2 and tratio does not apply */
12979 if (strcmp(modelParams[part2].nst, "2"))
12980 *isApplic2 = NO; /* part2 does not have nst=2 and tratio does not apply */
12982 /* Check if part1 & part2 are restriction */
12983 if (modelParams[part1].dataType == RESTRICTION)
12985 if (modelParams[part2].dataType == RESTRICTION)
12988 /* If Nst = 2 for both part1 and part2, we now need to check if the prior is the same for both. */
12989 if (!strcmp(modelParams[part1].tRatioPr,"Beta") && !strcmp(modelParams[part2].tRatioPr,"Beta"))
12991 if (AreDoublesEqual (modelParams[part1].tRatioDir[0], modelParams[part2].tRatioDir[0], (MrBFlt) 0.00001) == NO)
12993 if (AreDoublesEqual (modelParams[part1].tRatioDir[1], modelParams[part2].tRatioDir[1], (MrBFlt) 0.00001) == NO)
12996 else if (!strcmp(modelParams[part1].tRatioPr,"Fixed") && !strcmp(modelParams[part2].tRatioPr,"Fixed"))
12998 if (AreDoublesEqual (modelParams[part1].tRatioFix, modelParams[part2].tRatioFix, (MrBFlt) 0.00001) == NO)
13002 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13004 /* Check to see if tratio is inapplicable for either partition. */
13005 if ((*isApplic1) == NO || (*isApplic2) == NO)
13006 isSame = NO; /* if tratio is inapplicable for either partition, then the parameter cannot be the same */
13008 else if (whichParam == P_REVMAT)
13010 /* Check the GTR rates for partitions 1 and 2. */
13012 /* Check if the model is parsimony for either partition */
13013 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13014 *isApplic1 = NO; /* part1 has a parsimony model and GTR rates do not apply */
13015 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13016 *isApplic2 = NO; /* part2 has a parsimony model and GTR rates do not apply */
13018 /* Check that the data are nucleotide or protein for both partitions 1 and 2 */
13019 if (isFirstNucleotide == NO && isFirstProtein == NO)
13020 *isApplic1 = NO; /* part1 is not nucleotide or protein data so GTR rates do not apply */
13021 if (isSecondNucleotide == NO && isSecondProtein == NO)
13022 *isApplic2 = NO; /* part2 is not nucleotide or protein data so GTR rates do not apply */
13024 /* check that nst=6 or mixed for both partitions if nucleotide */
13025 if (isFirstNucleotide == YES && strcmp(modelParams[part1].nst, "6") && strcmp(modelParams[part1].nst, "Mixed"))
13026 *isApplic1 = NO; /* part1 does not have nst=6/Mixed and GTR rates do not apply */
13027 if (isSecondNucleotide == YES && strcmp(modelParams[part2].nst, "6") && strcmp(modelParams[part2].nst, "Mixed"))
13028 *isApplic2 = NO; /* part2 does not have nst=6/Mixed and GTR rates do not apply */
13030 /* check that model is GTR for both partitions if protein */
13031 if (isFirstProtein == YES && (strcmp(modelParams[part1].aaModel,"Gtr")!=0 || strcmp(modelParams[part1].aaModelPr,"Fixed")!=0))
13033 if (isSecondProtein == YES && (strcmp(modelParams[part2].aaModel,"Gtr")!=0 || strcmp(modelParams[part2].aaModelPr,"Fixed")!=0))
13036 /* check that data type is the same for both partitions */
13037 if (isFirstNucleotide == YES && isSecondNucleotide == NO)
13039 if (isFirstProtein == YES && isSecondProtein == NO)
13042 /* GTR applies to both part1 and part2. We now need to check if the prior is the same for both. */
13043 if (isFirstNucleotide == YES)
13045 if (strcmp(modelParams[part1].nst, modelParams[part2].nst) != 0)
13047 if (!strcmp(modelParams[part1].nst,"Mixed"))
13049 if (AreDoublesEqual (modelParams[part1].revMatSymDir, modelParams[part2].revMatSymDir, (MrBFlt) 0.00001) == NO)
13052 else if (!strcmp(modelParams[part1].nst,"6") && !strcmp(modelParams[part1].revMatPr,"Dirichlet") && !strcmp(modelParams[part2].revMatPr,"Dirichlet"))
13054 for (i=0; i<6; i++)
13056 if (AreDoublesEqual (modelParams[part1].revMatDir[i], modelParams[part2].revMatDir[i], (MrBFlt) 0.00001) == NO)
13060 else if (!strcmp(modelParams[part1].nst,"6") && !strcmp(modelParams[part1].revMatPr,"Fixed") && !strcmp(modelParams[part2].revMatPr,"Fixed"))
13062 for (i=0; i<6; i++)
13064 if (AreDoublesEqual (modelParams[part1].revMatFix[i], modelParams[part2].revMatFix[i], (MrBFlt) 0.00001) == NO)
13069 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13071 else /* if (isFirstProtein == YES) */
13073 if (!strcmp(modelParams[part1].aaRevMatPr,"Dirichlet") && !strcmp(modelParams[part2].aaRevMatPr,"Dirichlet"))
13075 for (i=0; i<190; i++)
13077 if (AreDoublesEqual (modelParams[part1].aaRevMatDir[i], modelParams[part2].aaRevMatDir[i], (MrBFlt) 0.00001) == NO)
13081 else if (!strcmp(modelParams[part1].aaRevMatPr,"Fixed") && !strcmp(modelParams[part2].aaRevMatPr,"Fixed"))
13083 for (i=0; i<190; i++)
13085 if (AreDoublesEqual (modelParams[part1].aaRevMatFix[i], modelParams[part2].aaRevMatFix[i], (MrBFlt) 0.00001) == NO)
13090 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13093 /* Check to see if the GTR rates are inapplicable for either partition. */
13094 if ((*isApplic1) == NO || (*isApplic2) == NO)
13095 isSame = NO; /* if GTR rates are inapplicable for either partition, then the parameter cannot be the same */
13097 else if (whichParam == P_OMEGA)
13099 /* Check the nonsynonymous/synonymous rate ratio for partitions 1 and 2. */
13101 /* Check if the model is parsimony for either partition */
13102 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13103 *isApplic1 = NO; /* part1 has a parsimony model and nonsynonymous/synonymous rate ratio does not apply */
13104 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13105 *isApplic2 = NO; /* part2 has a parsimony model and nonsynonymous/synonymous rate ratio does not apply */
13107 /* Check that the data are nucleotide for both partitions 1 and 2 */
13108 if (isFirstNucleotide == NO)
13109 *isApplic1 = NO; /* part1 is not nucleotide data so a nonsynonymous/synonymous rate ratio does not apply */
13110 if (isSecondNucleotide == NO)
13111 *isApplic2 = NO; /* part2 is not nucleotide data so a nonsynonymous/synonymous rate ratio does not apply */
13113 /* Check that the model structure is the same for both. The nucmodel should be "codon". */
13114 if (strcmp(modelParams[part1].nucModel, "Codon"))
13115 *isApplic1 = NO; /* part1 does not have Nucmodel = Codon and nonsynonymous/synonymous rate ratio does not apply */
13116 if (strcmp(modelParams[part2].nucModel, "Codon"))
13117 *isApplic2 = NO; /* part2 does not have Nucmodel = Codon and nonsynonymous/synonymous rate ratio does not apply */
13119 /* Assuming that Nucmodel = Codon for both part1 and part2, we now need to check if the prior is the
13121 if (!strcmp(modelParams[part1].omegaVar, "M3") && !strcmp(modelParams[part2].omegaVar, "M3"))
13123 if (!strcmp(modelParams[part1].m3omegapr, "Exponential") && !strcmp(modelParams[part2].m3omegapr, "Exponential"))
13126 else if (!strcmp(modelParams[part1].m3omegapr, "Fixed") && !strcmp(modelParams[part1].m3omegapr, "Fixed"))
13128 if (AreDoublesEqual (modelParams[part1].m3omegaFixed[0], modelParams[part2].m3omegaFixed[0], (MrBFlt) 0.00001) == NO)
13130 if (AreDoublesEqual (modelParams[part1].m3omegaFixed[1], modelParams[part2].m3omegaFixed[1], (MrBFlt) 0.00001) == NO)
13134 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13136 if (!strcmp(modelParams[part1].codonCatFreqPr, "Dirichlet") && !strcmp(modelParams[part2].codonCatFreqPr, "Dirichlet"))
13138 if (AreDoublesEqual (modelParams[part1].codonCatDir[0], modelParams[part2].codonCatDir[0], (MrBFlt) 0.00001) == NO)
13140 if (AreDoublesEqual (modelParams[part1].codonCatDir[1], modelParams[part2].codonCatDir[1], (MrBFlt) 0.00001) == NO)
13142 if (AreDoublesEqual (modelParams[part1].codonCatDir[2], modelParams[part2].codonCatDir[2], (MrBFlt) 0.00001) == NO)
13145 else if (!strcmp(modelParams[part1].codonCatFreqPr, "Fixed") && !strcmp(modelParams[part1].codonCatFreqPr, "Fixed"))
13147 if (AreDoublesEqual (modelParams[part1].codonCatFreqFix[0], modelParams[part2].codonCatFreqFix[0], (MrBFlt) 0.00001) == NO)
13149 if (AreDoublesEqual (modelParams[part1].codonCatFreqFix[1], modelParams[part2].codonCatFreqFix[1], (MrBFlt) 0.00001) == NO)
13151 if (AreDoublesEqual (modelParams[part1].codonCatFreqFix[2], modelParams[part2].codonCatFreqFix[2], (MrBFlt) 0.00001) == NO)
13155 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13157 else if (!strcmp(modelParams[part1].omegaVar, "M10") && !strcmp(modelParams[part2].omegaVar, "M10"))
13159 if (!strcmp(modelParams[part1].codonCatFreqPr, "Dirichlet") && !strcmp(modelParams[part2].codonCatFreqPr, "Dirichlet"))
13161 if (AreDoublesEqual (modelParams[part1].codonCatDir[0], modelParams[part2].codonCatDir[0], (MrBFlt) 0.00001) == NO)
13163 if (AreDoublesEqual (modelParams[part1].codonCatDir[1], modelParams[part2].codonCatDir[1], (MrBFlt) 0.00001) == NO)
13166 else if (!strcmp(modelParams[part1].codonCatFreqPr, "Fixed") && !strcmp(modelParams[part1].codonCatFreqPr, "Fixed"))
13168 if (AreDoublesEqual (modelParams[part1].codonCatFreqFix[0], modelParams[part2].codonCatFreqFix[0], (MrBFlt) 0.00001) == NO)
13170 if (AreDoublesEqual (modelParams[part1].codonCatFreqFix[1], modelParams[part2].codonCatFreqFix[1], (MrBFlt) 0.00001) == NO)
13174 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13176 else if (!strcmp(modelParams[part1].omegaVar, "Ny98") && !strcmp(modelParams[part2].omegaVar, "Ny98"))
13178 if (!strcmp(modelParams[part1].ny98omega1pr, "Beta") && !strcmp(modelParams[part2].ny98omega1pr, "Beta"))
13180 if (AreDoublesEqual (modelParams[part1].ny98omega1Beta[0], modelParams[part2].ny98omega1Beta[0], (MrBFlt) 0.00001) == NO)
13182 if (AreDoublesEqual (modelParams[part1].ny98omega1Beta[1], modelParams[part2].ny98omega1Beta[1], (MrBFlt) 0.00001) == NO)
13185 else if (!strcmp(modelParams[part1].ny98omega1pr, "Fixed") && !strcmp(modelParams[part1].ny98omega1pr, "Fixed"))
13187 if (AreDoublesEqual (modelParams[part1].ny98omega1Fixed, modelParams[part2].ny98omega1Fixed, (MrBFlt) 0.00001) == NO)
13191 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13192 if (!strcmp(modelParams[part1].ny98omega3pr, "Uniform") && !strcmp(modelParams[part2].ny98omega3pr, "Uniform"))
13194 if (AreDoublesEqual (modelParams[part1].ny98omega3Uni[0], modelParams[part2].ny98omega3Uni[0], (MrBFlt) 0.00001) == NO)
13196 if (AreDoublesEqual (modelParams[part1].ny98omega3Uni[1], modelParams[part2].ny98omega3Uni[1], (MrBFlt) 0.00001) == NO)
13199 else if (!strcmp(modelParams[part1].ny98omega3pr, "Exponential") && !strcmp(modelParams[part1].ny98omega3pr, "Exponential"))
13201 if (AreDoublesEqual (modelParams[part1].ny98omega3Exp, modelParams[part2].ny98omega3Exp, (MrBFlt) 0.00001) == NO)
13204 else if (!strcmp(modelParams[part1].ny98omega3pr, "Fixed") && !strcmp(modelParams[part1].ny98omega3pr, "Fixed"))
13206 if (AreDoublesEqual (modelParams[part1].ny98omega3Fixed, modelParams[part2].ny98omega3Fixed, (MrBFlt) 0.00001) == NO)
13210 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13211 if (!strcmp(modelParams[part1].codonCatFreqPr, "Dirichlet") && !strcmp(modelParams[part2].codonCatFreqPr, "Dirichlet"))
13213 if (AreDoublesEqual (modelParams[part1].codonCatDir[0], modelParams[part2].codonCatDir[0], (MrBFlt) 0.00001) == NO)
13215 if (AreDoublesEqual (modelParams[part1].codonCatDir[1], modelParams[part2].codonCatDir[1], (MrBFlt) 0.00001) == NO)
13217 if (AreDoublesEqual (modelParams[part1].codonCatDir[2], modelParams[part2].codonCatDir[2], (MrBFlt) 0.00001) == NO)
13220 else if (!strcmp(modelParams[part1].codonCatFreqPr, "Fixed") && !strcmp(modelParams[part1].codonCatFreqPr, "Fixed"))
13222 if (AreDoublesEqual (modelParams[part1].codonCatFreqFix[0], modelParams[part2].codonCatFreqFix[0], (MrBFlt) 0.00001) == NO)
13224 if (AreDoublesEqual (modelParams[part1].codonCatFreqFix[1], modelParams[part2].codonCatFreqFix[1], (MrBFlt) 0.00001) == NO)
13226 if (AreDoublesEqual (modelParams[part1].codonCatFreqFix[2], modelParams[part2].codonCatFreqFix[2], (MrBFlt) 0.00001) == NO)
13230 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13232 else if (!strcmp(modelParams[part1].omegaVar, "Equal") && !strcmp(modelParams[part2].omegaVar, "Equal"))
13234 if (!strcmp(modelParams[part1].omegaPr,"Dirichlet") && !strcmp(modelParams[part2].omegaPr,"Dirichlet"))
13236 if (AreDoublesEqual (modelParams[part1].omegaDir[0], modelParams[part2].omegaDir[0], (MrBFlt) 0.00001) == NO)
13238 if (AreDoublesEqual (modelParams[part1].omegaDir[1], modelParams[part2].omegaDir[1], (MrBFlt) 0.00001) == NO)
13241 else if (!strcmp(modelParams[part1].omegaPr,"Fixed") && !strcmp(modelParams[part2].omegaPr,"Fixed"))
13243 if (AreDoublesEqual (modelParams[part1].omegaFix, modelParams[part2].omegaFix, (MrBFlt) 0.00001) == NO)
13247 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13250 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13252 /* Check to see if omega is inapplicable for either partition. */
13253 if ((*isApplic1) == NO || (*isApplic2) == NO)
13254 isSame = NO; /* if omega is inapplicable for either partition, then the parameter cannot be the same */
13256 else if (whichParam == P_PI)
13258 /* Check the state frequencies for partitions 1 and 2. */
13260 /* Check if the model is parsimony for either partition */
13261 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13262 *isApplic1 = NO; /* part1 has a parsimony model and state frequencies do not apply */
13263 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13264 *isApplic2 = NO; /* part2 has a parsimony model and state frequencies do not apply */
13266 /* Check that the data are not CONTINUOUS for partitions 1 and 2 */
13267 if (modelParams[part1].dataType == CONTINUOUS)
13268 *isApplic1 = NO; /* state frequencies do not make sense for part1 */
13269 if (modelParams[part2].dataType == CONTINUOUS)
13270 *isApplic2 = NO; /* state frequencies do not make sense for part2 */
13272 /* Now, check that the data are the same (i.e., both nucleotide or both amino acid, or whatever). */
13273 if (isFirstNucleotide != isSecondNucleotide)
13274 isSame = NO; /* data are not both nucleotide or both note nucleotide */
13275 else if (modelParams[part1].dataType != modelParams[part2].dataType && isFirstNucleotide == NO)
13276 isSame = NO; /* data are not the same */
13278 /* Check that the model structure is the same for both partitions */
13279 if (strcmp(modelParams[part1].nucModel, modelParams[part2].nucModel))
13280 isSame = NO; /* the nucleotide models are different */
13281 if (strcmp(modelParams[part1].covarionModel, modelParams[part2].covarionModel) && !(!strcmp(modelParams[part1].nucModel, "Codon") && !strcmp(modelParams[part2].nucModel, "Codon")))
13282 isSame = NO; /* the models have different covarion struture */
13284 /* If both partitions have nucmodel=codon, then we also have to make certain that the same genetic code is used. */
13285 if (!strcmp(modelParams[part1].nucModel, "Codon") && !strcmp(modelParams[part2].nucModel, "Codon"))
13287 if (strcmp(modelParams[part1].geneticCode, modelParams[part2].geneticCode))
13288 isSame = NO; /* the models have different genetic codes */
13291 /* Let's see if the prior is the same. */
13292 if (modelParams[part1].dataType == STANDARD && modelParams[part2].dataType == STANDARD)
13294 /* The data are morphological (STANDARD). The state frequencies are specified by a
13295 symmetric beta distribution, the parameter of which needs to be the same to apply to both
13296 partitions. Note that symPiPr = -1 is equivalent to setting the variance to 0.0. */
13297 if (!strcmp(modelParams[part1].symPiPr,"Uniform") && !strcmp(modelParams[part2].symPiPr,"Uniform"))
13299 if (AreDoublesEqual (modelParams[part1].symBetaUni[0], modelParams[part2].symBetaUni[0], (MrBFlt) 0.00001) == NO)
13301 if (AreDoublesEqual (modelParams[part1].symBetaUni[1], modelParams[part2].symBetaUni[1], (MrBFlt) 0.00001) == NO)
13303 if (modelParams[part1].numBetaCats != modelParams[part2].numBetaCats)
13304 isSame = NO; /* can't link because the discrete beta approximation is different */
13306 else if (!strcmp(modelParams[part1].symPiPr,"Exponential") && !strcmp(modelParams[part2].symPiPr,"Exponential"))
13308 if (AreDoublesEqual (modelParams[part1].symBetaExp, modelParams[part2].symBetaExp, (MrBFlt) 0.00001) == NO)
13310 if (modelParams[part1].numBetaCats != modelParams[part2].numBetaCats)
13311 isSame = NO; /* can't link because the discrete beta approximation is different */
13313 else if (!strcmp(modelParams[part1].symPiPr,"Fixed") && !strcmp(modelParams[part2].symPiPr,"Fixed"))
13315 if (AreDoublesEqual (modelParams[part1].symBetaFix, modelParams[part2].symBetaFix, (MrBFlt) 0.00001) == NO)
13317 if (AreDoublesEqual (modelParams[part1].symBetaFix, (MrBFlt) -1.0, (MrBFlt) 0.00001) == NO && modelParams[part1].numBetaCats != modelParams[part2].numBetaCats)
13318 isSame = NO; /* can't link because the discrete beta approximation is different */
13321 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13323 if (modelSettings[part1].dataType == PROTEIN && modelSettings[part2].dataType == PROTEIN)
13325 /* We are dealing with protein data. */
13326 if (!strcmp(modelParams[part1].aaModelPr, modelParams[part2].aaModelPr))
13328 if (!strcmp(modelParams[part1].aaModelPr, "Fixed"))
13330 /* only have a single, fixed, amino acid rate matrix */
13331 if (!strcmp(modelParams[part1].aaModel, modelParams[part2].aaModel))
13334 isSame = NO; /* we have different amino acid models, and the state frequencies must be different */
13335 /* if we have an equalin model or Gtr model, then we need to check the prior on the state frequencies */
13336 if (!strcmp(modelParams[part1].aaModel, "Equalin") || !strcmp(modelParams[part1].aaModel, "Gtr"))
13338 if (!strcmp(modelParams[part1].stateFreqPr, modelParams[part2].stateFreqPr))
13340 /* the prior form is the same */
13341 if (!strcmp(modelParams[part1].stateFreqPr, "Dirichlet")) /* both prior models must be dirichlet */
13343 for (i=0; i<modelParams[part1].nStates; i++)
13344 if (AreDoublesEqual (modelParams[part1].stateFreqsDir[i], modelParams[part2].stateFreqsDir[i], (MrBFlt) 0.00001) == NO)
13345 isSame = NO; /* the dirichlet parameters are different */
13347 else /* both prior models must be fixed */
13349 if (!strcmp(modelParams[part1].stateFreqsFixType, modelParams[part2].stateFreqsFixType))
13351 /* if (!strcmp(modelParams[part1].stateFreqsFixType, "Empirical"))
13352 isSame = NO; Even though it is unlikely that the empirical values for both partitions are exactly the same, we will
13353 allow isSame to equal YES. This means pooled base frequencies are used to determine the empirical
13354 base frequencies. The user can still unlink this parameter. */
13355 if (!strcmp(modelParams[part1].stateFreqsFixType, "User"))
13357 for (i=0; i<modelParams[part1].nStates; i++)
13358 if (AreDoublesEqual (modelParams[part1].stateFreqsDir[i], modelParams[part2].stateFreqsDir[i], (MrBFlt) 0.00001) == NO)
13359 isSame = NO; /* the user-specified base frequencies are different */
13361 /* if the frequencies were both fixed to "equal", we are golden, and they are the same */
13364 isSame = NO; /* the fixed parameters must be the same. The only other possibility is that the
13365 user specified equal or empirical for one partition and then specified specific
13366 numbers (user) for the other _and_ happened to set the user values to the equal
13367 or empirical values. We ignore this possibility. */
13374 /* averaging over models */
13375 if (linkTable[P_AAMODEL][part1] != linkTable[P_AAMODEL][part2])
13376 isSame = NO; /* the amino acid model is mixed, but independently estimated */
13382 /* Otherwise, we are dealing with RESTRICTION or NUCLEOTIDE data. The dirichlet should be the same
13383 for both partitions. */
13384 if (!strcmp(modelParams[part1].stateFreqPr, modelParams[part2].stateFreqPr))
13386 /* the prior form is the same */
13387 if (!strcmp(modelParams[part1].stateFreqPr, "Dirichlet")) /* both prior models must be dirichlet */
13389 for (i=0; i<modelParams[part1].nStates; i++)
13390 if (AreDoublesEqual (modelParams[part1].stateFreqsDir[i], modelParams[part2].stateFreqsDir[i], (MrBFlt) 0.00001) == NO)
13391 isSame = NO; /* the dirichlet parameters are different */
13393 else /* both prior models must be fixed */
13395 if (!strcmp(modelParams[part1].stateFreqsFixType, modelParams[part2].stateFreqsFixType))
13397 /* if (!strcmp(modelParams[part1].stateFreqsFixType, "Empirical"))
13398 isSame = NO; Even though it is unlikely that the empirical values for both partitions are exactly the same, we will
13399 allow isSame to equal YES. This means pooled base frequencies are used to determine the empirical
13400 base frequencies. The user can still unlink this parameter. */
13401 if (!strcmp(modelParams[part1].stateFreqsFixType, "User"))
13403 for (i=0; i<modelParams[part1].nStates; i++)
13404 if (AreDoublesEqual (modelParams[part1].stateFreqsDir[i], modelParams[part2].stateFreqsDir[i], (MrBFlt) 0.00001) == NO)
13405 isSame = NO; /* the user-specified base frequencies are different */
13407 /* if the frequencies were both fixed to "equal", we are golden, and they are the same */
13410 isSame = NO; /* the fixed parameters must be the same. The only other possibility is that the
13411 user specified equal or empirical for one partition and then specified specific
13412 numbers (user) for the other _and_ happened to set the user values to the equal
13413 or empirical values. We ignore this possibility. */
13418 /* Check to see if the state frequencies are inapplicable for either partition. */
13419 if ((*isApplic1) == NO || (*isApplic2) == NO)
13420 isSame = NO; /* if the state frequencies are inapplicable for either partition, then the parameter cannot be the same */
13422 else if (whichParam == P_SHAPE)
13424 /* Check the shape parameter for partitions 1 and 2. */
13426 /* Check if the model is parsimony for either partition */
13427 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13428 *isApplic1 = NO; /* part1 has a parsimony model and shape parameter does not apply */
13429 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13430 *isApplic2 = NO; /* part2 has a parsimony model and shape parameter does not apply */
13432 /* Check that the data are not CONTINUOUS for partitions 1 and 2 */
13433 if (modelParams[part1].dataType == CONTINUOUS)
13434 *isApplic1 = NO; /* the shape parameter does not make sense for part1 */
13435 if (modelParams[part2].dataType == CONTINUOUS)
13436 *isApplic2 = NO; /* the shape parameter does not make sense for part2 */
13438 /* Now, check that the data are the same (i.e., both nucleotide or both amino acid, or whatever). */
13439 if (isFirstNucleotide != isSecondNucleotide)
13440 isSame = NO; /* data are not both nucleotide */
13441 else if (modelParams[part1].dataType != modelParams[part2].dataType && isFirstNucleotide == NO)
13442 isSame = NO; /* data are not the same */
13444 /* Let's check that the shape parameter is even relevant for the two partitions */
13445 if (!strcmp(modelParams[part1].ratesModel, "Equal") || !strcmp(modelParams[part1].ratesModel, "Propinv"))
13446 *isApplic1 = NO; /* the shape parameter does not make sense for part1 */
13447 if (!strcmp(modelParams[part2].ratesModel, "Equal") || !strcmp(modelParams[part2].ratesModel, "Propinv"))
13448 *isApplic2 = NO; /* the shape parameter does not make sense for part2 */
13450 /* We may have a nucleotide model. Make certain the models are not of type codon. */
13451 if (!strcmp(modelParams[part1].nucModel, "Codon"))
13452 *isApplic1 = NO; /* we have a codon model for part1, and a shape parameter does not apply */
13453 if (!strcmp(modelParams[part2].nucModel, "Codon"))
13454 *isApplic2 = NO;/* we have a codon model for part2, and a shape parameter does not apply */
13456 /* Check that the model structure is the same for both partitions */
13457 if ((!strcmp(modelParams[part1].nucModel, "4by4") || !strcmp(modelParams[part1].nucModel, "Doublet")) && !strcmp(modelParams[part2].nucModel, "Codon"))
13458 isSame = NO; /* the nucleotide models are incompatible with the same shape parameter */
13459 if ((!strcmp(modelParams[part2].nucModel, "4by4") || !strcmp(modelParams[part2].nucModel, "Doublet")) && !strcmp(modelParams[part1].nucModel, "Codon"))
13460 isSame = NO; /* the nucleotide models are incompatible with the same shape parameter */
13461 /* if (strcmp(modelParams[part1].covarionModel, modelParams[part2].covarionModel))
13462 isSame = NO; */ /* the models have different covarion struture */
13463 /* NOTE: Perhaps we should allow the possiblity that the shape parameter is the same for the case
13464 where one partition has a covarion model but the other does not and both datatypes are the same. */
13466 /* Check that the number of rate categories is the same */
13467 if (modelParams[part1].numGammaCats != modelParams[part2].numGammaCats)
13468 isSame = NO; /* the number of rate categories is not the same, so we cannot set the parameter to be equal for both partitions */
13470 /* Check that the priors are the same. */
13471 if (!strcmp(modelParams[part1].shapePr,"Uniform") && !strcmp(modelParams[part2].shapePr,"Uniform"))
13473 if (AreDoublesEqual (modelParams[part1].shapeUni[0], modelParams[part2].shapeUni[0], (MrBFlt) 0.00001) == NO)
13475 if (AreDoublesEqual (modelParams[part1].shapeUni[1], modelParams[part2].shapeUni[1], (MrBFlt) 0.00001) == NO)
13478 else if (!strcmp(modelParams[part1].shapePr,"Exponential") && !strcmp(modelParams[part2].shapePr,"Exponential"))
13480 if (AreDoublesEqual (modelParams[part1].shapeExp, modelParams[part2].shapeExp, (MrBFlt) 0.00001) == NO)
13483 else if (!strcmp(modelParams[part1].shapePr,"Fixed") && !strcmp(modelParams[part2].shapePr,"Fixed"))
13485 if (AreDoublesEqual (modelParams[part1].shapeFix, modelParams[part2].shapeFix, (MrBFlt) 0.00001) == NO)
13489 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13491 /* Check to see if the shape parameter is inapplicable for either partition. */
13492 if ((*isApplic1) == NO || (*isApplic2) == NO)
13493 isSame = NO; /* if the shape parameter is inapplicable for either partition, then the parameter cannot be the same */
13495 else if (whichParam == P_PINVAR)
13497 /* Check the proportion of invariable sites parameter for partitions 1 and 2. */
13499 /* Check if the model is parsimony for either partition */
13500 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13501 *isApplic1 = NO; /* part1 has a parsimony model and proportion of invariable sites parameter does not apply */
13502 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13503 *isApplic2 = NO; /* part2 has a parsimony model and proportion of invariable sites parameter does not apply */
13505 /* Check that the data are not CONTINUOUS for partitions 1 and 2 */
13506 if (modelParams[part1].dataType == CONTINUOUS)
13507 *isApplic1 = NO; /* the proportion of invariable sites parameter does not make sense for part1 */
13508 if (modelParams[part2].dataType == CONTINUOUS)
13509 *isApplic2 = NO; /* the proportion of invariable sites parameter does not make sense for part2 */
13511 /* Now, check that the data are the same (i.e., both nucleotide or both amino acid, or whatever). */
13512 if (isFirstNucleotide != isSecondNucleotide)
13513 isSame = NO; /* data are not both nucleotide */
13514 else if (modelParams[part1].dataType != modelParams[part2].dataType && isFirstNucleotide == NO)
13515 isSame = NO; /* data are not the same */
13517 /* Let's check that proportion of invariable sites parameter is even relevant for the two partitions */
13518 if (!strcmp(modelParams[part1].ratesModel, "Equal") || !strcmp(modelParams[part1].ratesModel, "Gamma") ||
13519 !strcmp(modelParams[part1].ratesModel, "LNorm") || !strcmp(modelParams[part1].ratesModel, "Adgamma"))
13520 *isApplic1 = NO; /* the proportion of invariable sites parameter does not make sense for part1 */
13521 if (!strcmp(modelParams[part2].ratesModel, "Equal") || !strcmp(modelParams[part2].ratesModel, "Gamma") ||
13522 !strcmp(modelParams[part2].ratesModel, "LNorm") || !strcmp(modelParams[part2].ratesModel, "Adgamma"))
13523 *isApplic2 = NO; /* the proportion of invariable sites parameter does not make sense for part2 */
13525 /* It is not sensible to have a covarion model and a proportion of invariable sites */
13526 if (!strcmp(modelParams[part1].covarionModel, "Yes"))
13528 if (!strcmp(modelParams[part2].covarionModel, "Yes"))
13531 /* We have a nucleotide model. Make certain the models are not of type codon. */
13532 if (!strcmp(modelParams[part1].nucModel, "Codon"))
13533 *isApplic1 = NO; /* we have a codon model for part1, and a proportion of invariable sites parameter does not apply */
13534 if (!strcmp(modelParams[part2].nucModel, "Codon"))
13535 *isApplic2 = NO;/* we have a codon model for part2, and a proportion of invariable sites parameter does not apply */
13537 /* Check that the model structure is the same for both partitions */
13538 if (strcmp(modelParams[part1].nucModel, modelParams[part2].nucModel))
13539 isSame = NO; /* the nucleotide models are different */
13540 if (strcmp(modelParams[part1].covarionModel, modelParams[part2].covarionModel))
13541 isSame = NO; /* the models have different covarion struture */
13543 /* check the priors */
13544 if (!strcmp(modelParams[part1].pInvarPr,"Uniform") && !strcmp(modelParams[part2].pInvarPr,"Uniform"))
13546 if (AreDoublesEqual (modelParams[part1].pInvarUni[0], modelParams[part2].pInvarUni[0], (MrBFlt) 0.00001) == NO)
13548 if (AreDoublesEqual (modelParams[part1].pInvarUni[1], modelParams[part2].pInvarUni[1], (MrBFlt) 0.00001) == NO)
13551 else if (!strcmp(modelParams[part1].pInvarPr,"Fixed") && !strcmp(modelParams[part2].pInvarPr,"Fixed"))
13553 if (AreDoublesEqual (modelParams[part1].pInvarFix, modelParams[part2].pInvarFix, (MrBFlt) 0.00001) == NO)
13557 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13559 /* Check to see if the switching rates are inapplicable for either partition. */
13560 if ((*isApplic1) == NO || (*isApplic2) == NO)
13561 isSame = NO; /* if the switching rates are inapplicable for either partition, then the parameter cannot be the same */
13563 else if (whichParam == P_CORREL)
13565 /* Check the autocorrelation parameter for gamma rates on partitions 1 and 2. */
13567 /* Check if the model is parsimony for either partition */
13568 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13569 *isApplic1 = NO; /* part1 has a parsimony model and autocorrelation parameter does not apply */
13570 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13571 *isApplic2 = NO; /* part2 has a parsimony model and autocorrelation parameter does not apply */
13573 /* Check that the data are either DNA, RNA, or PROTEIN for partitions 1 and 2 */
13574 if (modelSettings[part1].dataType != DNA && modelSettings[part1].dataType != RNA && modelSettings[part1].dataType != PROTEIN)
13575 *isApplic1 = NO; /* the switching rates do not make sense for part1 */
13576 if (modelSettings[part2].dataType != DNA && modelSettings[part2].dataType != RNA && modelSettings[part2].dataType != PROTEIN)
13577 *isApplic2 = NO; /* the switching rates do not make sense for part2 */
13579 /* Now, check that the data are the same (i.e., both nucleotide or both amino acid). */
13580 if (isFirstNucleotide != isSecondNucleotide)
13581 isSame = NO; /* one or the other is nucleotide, so they cannot be the same */
13582 else if (modelSettings[part1].dataType != modelSettings[part2].dataType && isFirstNucleotide == NO)
13583 isSame = NO; /* data are not both nucleotide or both amino acid */
13585 /* Let's check that autocorrelation parameter is even relevant for the two partitions */
13586 if (strcmp(modelParams[part1].ratesModel, "Adgamma"))
13587 *isApplic1 = NO; /* the autocorrelation parameter does not make sense for part1 */
13588 if (strcmp(modelParams[part2].ratesModel, "Adgamma"))
13589 *isApplic2 = NO; /* the autocorrelation parameter does not make sense for part2 */
13591 /* Assuming that we have a nucleotide model, make certain the models are not of type codon. */
13592 if (!strcmp(modelParams[part1].nucModel, "Codon"))
13593 *isApplic1 = NO; /* we have a codon model for part1, and a autocorrelation parameter does not apply */
13594 if (!strcmp(modelParams[part2].nucModel, "Codon"))
13595 *isApplic2 = NO; /* we have a codon model for part2, and a autocorrelation parameter does not apply */
13597 /* Check that the model structure is the same for both partitions */
13598 if (strcmp(modelParams[part1].nucModel, modelParams[part2].nucModel))
13599 isSame = NO; /* the nucleotide models are different */
13600 if (strcmp(modelParams[part1].covarionModel, modelParams[part2].covarionModel))
13601 isSame = NO; /* the models have different covarion struture */
13603 /* Check the priors for both partitions. */
13604 if (!strcmp(modelParams[part1].adGammaCorPr,"Uniform") && !strcmp(modelParams[part2].adGammaCorPr,"Uniform"))
13606 if (AreDoublesEqual (modelParams[part1].corrUni[0], modelParams[part2].corrUni[0], (MrBFlt) 0.00001) == NO)
13608 if (AreDoublesEqual (modelParams[part1].corrUni[1], modelParams[part2].corrUni[1], (MrBFlt) 0.00001) == NO)
13611 else if (!strcmp(modelParams[part1].adGammaCorPr,"Fixed") && !strcmp(modelParams[part2].adGammaCorPr,"Fixed"))
13613 if (AreDoublesEqual (modelParams[part1].corrFix, modelParams[part2].corrFix, (MrBFlt) 0.00001) == NO)
13617 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13619 /* Check to see if the switching rates are inapplicable for either partition. */
13620 if ((*isApplic1) == NO || (*isApplic2) == NO)
13621 isSame = NO; /* if the switching rates are inapplicable for either partition, then the parameter cannot be the same */
13623 else if (whichParam == P_SWITCH)
13625 /* Check the covarion switching rates on partitions 1 and 2. */
13627 /* Check if the model is parsimony for either partition */
13628 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13629 *isApplic1 = NO; /* part1 has a parsimony model and switching rates do not apply */
13630 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13631 *isApplic2 = NO; /* part2 has a parsimony model and switching rates do not apply */
13633 /* Check that the data are either DNA, RNA, or PROTEIN for partitions 1 and 2 */
13634 if (modelSettings[part1].dataType != DNA && modelSettings[part1].dataType != RNA && modelSettings[part1].dataType != PROTEIN)
13635 *isApplic1 = NO; /* the switching rates do not make sense for part1 */
13636 if (modelSettings[part2].dataType != DNA && modelSettings[part2].dataType != RNA && modelSettings[part2].dataType != PROTEIN)
13637 *isApplic2 = NO; /* the switching rates do not make sense for part2 */
13639 /* Now, check that the data are the same (i.e., both nucleotide or both amino acid). */
13640 if (isFirstNucleotide != isSecondNucleotide)
13641 isSame = NO; /* one or the other is nucleotide, so they cannot be the same */
13642 else if (modelSettings[part1].dataType != modelSettings[part2].dataType && isFirstNucleotide == NO)
13643 isSame = NO; /* data are not both nucleotide or both amino acid */
13645 /* Lets check that covarion model has been selected for partitions 1 and 2 */
13646 if (!strcmp(modelParams[part1].covarionModel, "No"))
13647 *isApplic1 = NO; /* the switching rates do not make sense for part1 */
13648 if (!strcmp(modelParams[part2].covarionModel, "No"))
13649 *isApplic2 = NO; /* the switching rates do not make sense for part2 */
13651 /* If we have a nucleotide model make certain the models are not of type codon or doublet. */
13652 if (!strcmp(modelParams[part1].nucModel, "Codon") || !strcmp(modelParams[part1].nucModel, "Doublet"))
13653 *isApplic1 = NO; /* we have a codon model for part1, and a covarion switch parameter does not apply */
13654 if (!strcmp(modelParams[part2].nucModel, "Codon") || !strcmp(modelParams[part2].nucModel, "Doublet"))
13655 *isApplic2 = NO; /* we have a codon model for part2, and a covarion switch parameter does not apply */
13657 /* Check that the priors are the same. */
13658 if (!strcmp(modelParams[part1].covSwitchPr,"Uniform") && !strcmp(modelParams[part2].covSwitchPr,"Uniform"))
13660 if (AreDoublesEqual (modelParams[part1].covswitchUni[0], modelParams[part2].covswitchUni[0], (MrBFlt) 0.00001) == NO)
13662 if (AreDoublesEqual (modelParams[part1].covswitchUni[1], modelParams[part2].covswitchUni[1], (MrBFlt) 0.00001) == NO)
13665 else if (!strcmp(modelParams[part1].covSwitchPr,"Exponential") && !strcmp(modelParams[part2].covSwitchPr,"Exponential"))
13667 if (AreDoublesEqual (modelParams[part1].covswitchExp, modelParams[part2].covswitchExp, (MrBFlt) 0.00001) == NO)
13670 else if (!strcmp(modelParams[part1].covSwitchPr,"Fixed") && !strcmp(modelParams[part2].covSwitchPr,"Fixed"))
13672 if (AreDoublesEqual (modelParams[part1].covswitchFix[0], modelParams[part2].covswitchFix[0], (MrBFlt) 0.00001) == NO)
13674 if (AreDoublesEqual (modelParams[part1].covswitchFix[1], modelParams[part2].covswitchFix[1], (MrBFlt) 0.00001) == NO)
13678 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
13680 /* Check to see if the switching rates are inapplicable for either partition. */
13681 if ((*isApplic1) == NO || (*isApplic2) == NO)
13682 isSame = NO; /* if the switching rates are inapplicable for either partition, then the parameter cannot be the same */
13684 else if (whichParam == P_RATEMULT)
13686 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
13687 silly and doesn't take this information into account) and a rate multiplier is nonsensical. */
13688 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13690 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13693 /* Check that the branch lengths are at least proportional. */
13694 if (IsModelSame (P_BRLENS, part1, part2, &temp1, &temp2) == NO)
13696 if (linkTable[P_BRLENS][part1] != linkTable[P_BRLENS][part2])
13699 /* See if the rate prior is the same for the partitions */
13700 if (strcmp(modelParams[part1].ratePr, modelParams[part2].ratePr) != 0)
13703 /* Check to see if rate multipliers are inapplicable for either partition. */
13704 if ((*isApplic1) == NO || (*isApplic2) == NO)
13708 else if (whichParam == P_TOPOLOGY)
13710 /* Check the topology for partitions 1 and 2. */
13712 /* If the prior is different, then the topologies cannot be the same. */
13713 if (strcmp(modelParams[part1].topologyPr, modelParams[part2].topologyPr))
13716 /* If both partitions have topologies constrained, then we need to make certain that the constraints are the same. */
13717 /* This also guarantees that any calibrations will be the same. */
13718 if (!strcmp(modelParams[part1].topologyPr, "Constraints") && !strcmp(modelParams[part2].topologyPr, "Constraints"))
13720 if (modelParams[part1].numActiveConstraints != modelParams[part2].numActiveConstraints)
13725 for (i=0; i<numDefinedConstraints; i++)
13726 if (modelParams[part1].activeConstraints[i] != modelParams[part2].activeConstraints[i])
13733 else if (whichParam == P_BRLENS)
13735 /* Check the branch lengths for partitions 1 and 2. */
13737 /* First, if the topologies are different, the same branch lengths cannot apply. */
13738 if (IsModelSame (P_TOPOLOGY, part1, part2, &temp1, &temp2) == NO)
13740 if (linkTable[P_TOPOLOGY][part1] != linkTable[P_TOPOLOGY][part2])
13743 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
13744 silly and doesn't take this information into account). */
13745 if (!strcmp(modelParams[part1].parsModel, "Yes"))
13747 if (!strcmp(modelParams[part2].parsModel, "Yes"))
13750 /* Check to see if the branch lengths are inapplicable for either partition. */
13751 if ((*isApplic1) == NO || (*isApplic2) == NO)
13754 /* Make sure the branch lengths have the same priors and are not unlinked */
13755 if (*isApplic1 == YES && *isApplic2 == YES)
13757 /* We are dealing with real branch lengths (not parsimony) for both partitions */
13759 /* The branch length prior should be the same */
13760 if (strcmp(modelParams[part1].brlensPr, modelParams[part2].brlensPr))
13763 /* if both partitions have unconstrained brlens, then we need to check that the priors on the branch lengths are the same */
13764 if (!strcmp(modelParams[part1].brlensPr, "Unconstrained") && !strcmp(modelParams[part2].brlensPr, "Unconstrained"))
13766 if (strcmp(modelParams[part1].unconstrainedPr, modelParams[part2].unconstrainedPr))
13770 if (!strcmp(modelParams[part1].unconstrainedPr, "Uniform"))
13772 if (AreDoublesEqual (modelParams[part1].brlensUni[0], modelParams[part2].brlensUni[0], (MrBFlt) 0.00001) == NO)
13774 if (AreDoublesEqual (modelParams[part1].brlensUni[1], modelParams[part2].brlensUni[1], (MrBFlt) 0.00001) == NO)
13777 else if (!strcmp(modelParams[part1].unconstrainedPr, "Exponential"))
13779 if (AreDoublesEqual (modelParams[part1].brlensExp, modelParams[part2].brlensExp, (MrBFlt) 0.00001) == NO)
13782 else if (!strcmp(modelParams[part1].unconstrainedPr, "twoExp"))
13784 if (AreDoublesEqual (modelParams[part1].brlens2Exp[0], modelParams[part2].brlens2Exp[0], (MrBFlt) 0.00001) == NO)
13786 if (AreDoublesEqual (modelParams[part1].brlens2Exp[1], modelParams[part2].brlens2Exp[1], (MrBFlt) 0.00001) == NO)
13791 if (AreDoublesEqual (modelParams[part1].brlensDir[0], modelParams[part2].brlensDir[0], (MrBFlt) 0.00001) == NO)
13793 if (AreDoublesEqual (modelParams[part1].brlensDir[1], modelParams[part2].brlensDir[1], (MrBFlt) 0.00001) == NO)
13795 if (AreDoublesEqual (modelParams[part1].brlensDir[2], modelParams[part2].brlensDir[2], (MrBFlt) 0.00001) == NO)
13797 if (AreDoublesEqual (modelParams[part1].brlensDir[3], modelParams[part2].brlensDir[3], (MrBFlt) 0.00001) == NO)
13803 /* if both partitions have clock brlens, then we need to check that the priors on the clock are the same */
13804 if (!strcmp(modelParams[part1].brlensPr, "Clock") && !strcmp(modelParams[part2].brlensPr, "Clock"))
13806 if (strcmp(modelParams[part1].clockPr, modelParams[part2].clockPr))
13810 if (!strcmp(modelParams[part1].clockPr, "Birthdeath"))
13812 if (!strcmp(modelParams[part1].speciationPr,"Uniform") && !strcmp(modelParams[part2].speciationPr,"Uniform"))
13814 if (AreDoublesEqual (modelParams[part1].speciationUni[0], modelParams[part2].speciationUni[0], (MrBFlt) 0.00001) == NO)
13816 if (AreDoublesEqual (modelParams[part1].speciationUni[1], modelParams[part2].speciationUni[1], (MrBFlt) 0.00001) == NO)
13819 else if (!strcmp(modelParams[part1].speciationPr,"Exponential") && !strcmp(modelParams[part2].speciationPr,"Exponential"))
13821 if (AreDoublesEqual (modelParams[part1].speciationExp, modelParams[part2].speciationExp, (MrBFlt) 0.00001) == NO)
13824 else if (!strcmp(modelParams[part1].speciationPr,"Fixed") && !strcmp(modelParams[part2].speciationPr,"Fixed"))
13826 if (AreDoublesEqual (modelParams[part1].speciationFix, modelParams[part2].speciationFix, (MrBFlt) 0.00001) == NO)
13832 if (!strcmp(modelParams[part1].extinctionPr,"Beta") && !strcmp(modelParams[part2].extinctionPr,"Beta"))
13834 if (AreDoublesEqual (modelParams[part1].extinctionBeta[0], modelParams[part2].extinctionBeta[0], (MrBFlt) 0.00001) == NO)
13836 if (AreDoublesEqual (modelParams[part1].extinctionBeta[1], modelParams[part2].extinctionBeta[1], (MrBFlt) 0.00001) == NO)
13839 else if (!strcmp(modelParams[part1].extinctionPr,"Fixed") && !strcmp(modelParams[part2].extinctionPr,"Fixed"))
13841 if (AreDoublesEqual (modelParams[part1].extinctionFix, modelParams[part2].extinctionFix, (MrBFlt) 0.00001) == NO)
13847 if (AreDoublesEqual (modelParams[part1].sampleProb, modelParams[part2].sampleProb, 0.00001) == NO)
13849 if (strcmp(modelParams[part1].sampleStrat,modelParams[part2].sampleStrat))
13852 else if (!strcmp(modelParams[part1].clockPr, "Coalescence") || !strcmp(modelParams[part1].clockPr, "Speciestreecoalescence"))
13854 if (!strcmp(modelParams[part1].popSizePr,"Uniform") && !strcmp(modelParams[part2].popSizePr,"Uniform"))
13856 if (AreDoublesEqual (modelParams[part1].popSizeUni[0], modelParams[part2].popSizeUni[0], (MrBFlt) 0.00001) == NO)
13858 if (AreDoublesEqual (modelParams[part1].popSizeUni[1], modelParams[part2].popSizeUni[1], (MrBFlt) 0.00001) == NO)
13861 else if (!strcmp(modelParams[part1].popSizePr,"Lognormal") && !strcmp(modelParams[part2].popSizePr,"Lognormal"))
13863 if (AreDoublesEqual (modelParams[part1].popSizeLognormal[0], modelParams[part2].popSizeLognormal[0], (MrBFlt) 0.00001) == NO)
13865 if (AreDoublesEqual (modelParams[part1].popSizeLognormal[1], modelParams[part2].popSizeLognormal[1], (MrBFlt) 0.00001) == NO)
13868 else if (!strcmp(modelParams[part1].popSizePr,"Normal") && !strcmp(modelParams[part2].popSizePr,"Normal"))
13870 if (AreDoublesEqual (modelParams[part1].popSizeNormal[0], modelParams[part2].popSizeNormal[0], (MrBFlt) 0.00001) == NO)
13872 if (AreDoublesEqual (modelParams[part1].popSizeNormal[1], modelParams[part2].popSizeNormal[1], (MrBFlt) 0.00001) == NO)
13875 else if (!strcmp(modelParams[part1].popSizePr,"Gamma") && !strcmp(modelParams[part2].popSizePr,"Gamma"))
13877 if (AreDoublesEqual (modelParams[part1].popSizeGamma[0], modelParams[part2].popSizeGamma[0], (MrBFlt) 0.00001) == NO)
13879 if (AreDoublesEqual (modelParams[part1].popSizeGamma[1], modelParams[part2].popSizeGamma[1], (MrBFlt) 0.00001) == NO)
13882 else if (!strcmp(modelParams[part1].popSizePr,"Fixed") && !strcmp(modelParams[part2].popSizePr,"Fixed"))
13884 if (AreDoublesEqual (modelParams[part1].popSizeFix, modelParams[part2].popSizeFix, (MrBFlt) 0.00001) == NO)
13890 if (strcmp(modelParams[part1].ploidy, modelParams[part2].ploidy) != 0)
13893 if (strcmp(modelParams[part1].clockPr, "Uniform") == 0 && strcmp(modelParams[part1].nodeAgePr, "Calibrated") != 0)
13895 if (modelParams[part1].treeAgePr.prior != modelParams[part2].treeAgePr.prior)
13897 if (modelParams[part1].treeAgePr.prior == fixed)
13899 if (AreDoublesEqual (modelParams[part1].treeAgePr.priorParams[0], modelParams[part2].treeAgePr.priorParams[0], (MrBFlt) 0.00001) == NO)
13902 else if (modelParams[part1].treeAgePr.prior == offsetLogNormal ||
13903 modelParams[part1].treeAgePr.prior == truncatedNormal ||
13904 modelParams[part1].treeAgePr.prior == offsetGamma)
13906 for (i=0; i<3; i++)
13908 if (AreDoublesEqual (modelParams[part1].treeAgePr.priorParams[i], modelParams[part2].treeAgePr.priorParams[i], (MrBFlt) 0.00001) == NO)
13914 for (i=0; i<2; i++)
13916 if (AreDoublesEqual (modelParams[part1].treeAgePr.priorParams[i], modelParams[part2].treeAgePr.priorParams[i], (MrBFlt) 0.00001) == NO)
13921 else if (strcmp(modelParams[part1].clockPr, "Fossilization") == 0)
13923 if (modelParams[part1].treeAgePr.prior != modelParams[part2].treeAgePr.prior)
13925 if (modelParams[part1].treeAgePr.prior == fixed)
13927 if (AreDoublesEqual (modelParams[part1].treeAgePr.priorParams[0], modelParams[part2].treeAgePr.priorParams[0], (MrBFlt) 0.00001) == NO)
13930 else if (modelParams[part1].treeAgePr.prior == offsetLogNormal ||
13931 modelParams[part1].treeAgePr.prior == truncatedNormal ||
13932 modelParams[part1].treeAgePr.prior == offsetGamma)
13934 for (i=0; i<3; i++)
13936 if (AreDoublesEqual (modelParams[part1].treeAgePr.priorParams[i], modelParams[part2].treeAgePr.priorParams[i], (MrBFlt) 0.00001) == NO)
13942 for (i=0; i<2; i++)
13944 if (AreDoublesEqual (modelParams[part1].treeAgePr.priorParams[i], modelParams[part2].treeAgePr.priorParams[i], (MrBFlt) 0.00001) == NO)
13949 if (!strcmp(modelParams[part1].speciationPr,"Uniform") && !strcmp(modelParams[part2].speciationPr,"Uniform"))
13951 if (AreDoublesEqual (modelParams[part1].speciationUni[0], modelParams[part2].speciationUni[0], (MrBFlt) 0.00001) == NO)
13953 if (AreDoublesEqual (modelParams[part1].speciationUni[1], modelParams[part2].speciationUni[1], (MrBFlt) 0.00001) == NO)
13956 else if (!strcmp(modelParams[part1].speciationPr,"Exponential") && !strcmp(modelParams[part2].speciationPr,"Exponential"))
13958 if (AreDoublesEqual (modelParams[part1].speciationExp, modelParams[part2].speciationExp, (MrBFlt) 0.00001) == NO)
13961 else if (!strcmp(modelParams[part1].speciationPr,"Fixed") && !strcmp(modelParams[part2].speciationPr,"Fixed"))
13963 if (AreDoublesEqual (modelParams[part1].speciationFix, modelParams[part2].speciationFix, (MrBFlt) 0.00001) == NO)
13969 if (!strcmp(modelParams[part1].extinctionPr,"Beta") && !strcmp(modelParams[part2].extinctionPr,"Beta"))
13971 if (AreDoublesEqual (modelParams[part1].extinctionBeta[0], modelParams[part2].extinctionBeta[0], (MrBFlt) 0.00001) == NO)
13973 if (AreDoublesEqual (modelParams[part1].extinctionBeta[1], modelParams[part2].extinctionBeta[1], (MrBFlt) 0.00001) == NO)
13976 else if (!strcmp(modelParams[part1].extinctionPr,"Fixed") && !strcmp(modelParams[part2].extinctionPr,"Fixed"))
13978 if (AreDoublesEqual (modelParams[part1].extinctionFix, modelParams[part2].extinctionFix, (MrBFlt) 0.00001) == NO)
13984 if (!strcmp(modelParams[part1].fossilizationPr,"Beta") && !strcmp(modelParams[part2].fossilizationPr,"Beta"))
13986 if (AreDoublesEqual (modelParams[part1].fossilizationBeta[0], modelParams[part2].fossilizationBeta[0], (MrBFlt) 0.00001) == NO)
13988 if (AreDoublesEqual (modelParams[part1].fossilizationBeta[1], modelParams[part2].fossilizationBeta[1], (MrBFlt) 0.00001) == NO)
13991 else if (!strcmp(modelParams[part1].fossilizationPr,"Fixed") && !strcmp(modelParams[part2].fossilizationPr,"Fixed"))
13993 if (AreDoublesEqual (modelParams[part1].fossilizationFix, modelParams[part2].fossilizationFix, (MrBFlt) 0.00001) == NO)
13999 if (AreDoublesEqual (modelParams[part1].sampleProb, modelParams[part2].sampleProb, 0.00001) == NO)
14001 if (strcmp(modelParams[part1].sampleStrat,modelParams[part2].sampleStrat))
14006 /* if the same clock prior, we need to check calibrations */
14007 if (strcmp(modelParams[part1].nodeAgePr,modelParams[part2].nodeAgePr) != 0)
14010 /* If fixed clock brlens, check if the brlens come from the same tree */
14011 if (!strcmp(modelParams[part1].clockPr, "Fixed") && !strcmp(modelParams[part2].clockPr, "Fixed"))
14013 if (modelParams[part1].brlensFix != modelParams[part2].brlensFix)
14017 /* If fixed brlens, check if the brlens come from the same tree */
14018 if (!strcmp(modelParams[part1].brlensPr, "Fixed") && !strcmp(modelParams[part2].brlensPr, "Fixed"))
14020 if (modelParams[part1].brlensFix != modelParams[part2].brlensFix)
14025 else if (whichParam == P_SPECRATE)
14027 /* Check the speciation rates for partitions 1 and 2. */
14029 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14030 silly and doesn't take this information into account) and a speciation rate cannot be estimated. */
14031 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14033 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14036 /* Check that the branch length prior is a clock:birthdeath or clock:fossilization for both partitions. */
14037 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14039 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14041 if (strcmp(modelParams[part1].clockPr, "Birthdeath") != 0 && strcmp(modelParams[part1].clockPr, "Fossilization") != 0)
14043 if (strcmp(modelParams[part2].clockPr, "Birthdeath") != 0 && strcmp(modelParams[part2].clockPr, "Fossilization") != 0)
14046 /* Now, check that the prior on the speciation rates are the same. */
14047 if (!strcmp(modelParams[part1].speciationPr,"Uniform") && !strcmp(modelParams[part2].speciationPr,"Uniform"))
14049 if (AreDoublesEqual (modelParams[part1].speciationUni[0], modelParams[part2].speciationUni[0], (MrBFlt) 0.00001) == NO)
14051 if (AreDoublesEqual (modelParams[part1].speciationUni[1], modelParams[part2].speciationUni[1], (MrBFlt) 0.00001) == NO)
14054 else if (!strcmp(modelParams[part1].speciationPr,"Exponential") && !strcmp(modelParams[part2].speciationPr,"Exponential"))
14056 if (AreDoublesEqual (modelParams[part1].speciationExp, modelParams[part2].speciationExp, (MrBFlt) 0.00001) == NO)
14059 else if (!strcmp(modelParams[part1].speciationPr,"Fixed") && !strcmp(modelParams[part2].speciationPr,"Fixed"))
14061 if (AreDoublesEqual (modelParams[part1].speciationFix, modelParams[part2].speciationFix, (MrBFlt) 0.00001) == NO)
14067 /* Check to see if the speciation rates are inapplicable for either partition. */
14068 if ((*isApplic1) == NO || (*isApplic2) == NO)
14071 else if (whichParam == P_EXTRATE)
14073 /* Check the extinction rates for partitions 1 and 2. */
14075 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14076 silly and doesn't take this information into account) and a extinction rate cannot be estimated. */
14077 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14079 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14082 /* Check that the branch length prior is a clock:birthdeath or clock:fossilization for both partitions. */
14083 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14085 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14087 if (strcmp(modelParams[part1].clockPr, "Birthdeath")!= 0 && strcmp(modelParams[part1].clockPr, "Fossilization") != 0)
14089 if (strcmp(modelParams[part2].clockPr, "Birthdeath")!= 0 && strcmp(modelParams[part2].clockPr, "Fossilization") != 0)
14092 /* Now, check that the prior on the extinction rates are the same. */
14093 if (!strcmp(modelParams[part1].extinctionPr,"Beta") && !strcmp(modelParams[part2].extinctionPr,"Beta"))
14095 if (AreDoublesEqual (modelParams[part1].extinctionBeta[0], modelParams[part2].extinctionBeta[0], (MrBFlt) 0.00001) == NO)
14097 if (AreDoublesEqual (modelParams[part1].extinctionBeta[1], modelParams[part2].extinctionBeta[1], (MrBFlt) 0.00001) == NO)
14100 else if (!strcmp(modelParams[part1].extinctionPr,"Fixed") && !strcmp(modelParams[part2].extinctionPr,"Fixed"))
14102 if (AreDoublesEqual (modelParams[part1].extinctionFix, modelParams[part2].extinctionFix, (MrBFlt) 0.00001) == NO)
14108 /* Check to see if the extinction rates are inapplicable for either partition. */
14109 if ((*isApplic1) == NO || (*isApplic2) == NO)
14112 else if (whichParam == P_FOSLRATE)
14114 /* Check the fossilization rates for partitions 1 and 2. */
14116 /* Check if the model is parsimony for either partition. */
14117 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14119 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14122 /* Check that the branch length prior is a clock:birthdeath or clock:fossilization for both partitions. */
14123 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14125 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14127 if (strcmp(modelParams[part1].clockPr, "Fossilization") != 0)
14129 if (strcmp(modelParams[part2].clockPr, "Fossilization") != 0)
14132 /* Now, check that the prior on the fossilization rates are the same. */
14133 if (!strcmp(modelParams[part1].fossilizationPr,"Beta") && !strcmp(modelParams[part2].fossilizationPr,"Beta"))
14135 if (AreDoublesEqual (modelParams[part1].fossilizationBeta[0], modelParams[part2].fossilizationBeta[0], (MrBFlt) 0.00001) == NO)
14137 if (AreDoublesEqual (modelParams[part1].fossilizationBeta[1], modelParams[part2].fossilizationBeta[1], (MrBFlt) 0.00001) == NO)
14140 else if (!strcmp(modelParams[part1].fossilizationPr,"Fixed") && !strcmp(modelParams[part2].fossilizationPr,"Fixed"))
14142 if (AreDoublesEqual (modelParams[part1].fossilizationFix, modelParams[part2].fossilizationFix, (MrBFlt) 0.00001) == NO)
14148 /* Check to see if the fossilization rates are inapplicable for either partition. */
14149 if ((*isApplic1) == NO || (*isApplic2) == NO)
14152 else if (whichParam == P_POPSIZE)
14154 /* Check population size for partitions 1 and 2. */
14156 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14157 silly and doesn't take this information into account) and population size cannot be estimated. */
14158 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14160 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14163 /* Check that the branch length prior is a clock:coalescence or clock:speciestreecoalescence for both partitions. */
14164 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14166 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14168 if (strcmp(modelParams[part1].clockPr, "Coalescence") != 0 && strcmp(modelParams[part1].clockPr, "Speciestreecoalescence") != 0)
14170 if (strcmp(modelParams[part2].clockPr, "Coalescence") != 0 && strcmp(modelParams[part2].clockPr, "Speciestreecoalescence") != 0)
14173 /* Now, check that the prior on population size is the same. */
14174 if (!strcmp(modelParams[part1].popSizePr,"Uniform") && !strcmp(modelParams[part2].popSizePr,"Uniform"))
14176 if (AreDoublesEqual (modelParams[part1].popSizeUni[0], modelParams[part2].popSizeUni[0], (MrBFlt) 0.00001) == NO)
14178 if (AreDoublesEqual (modelParams[part1].popSizeUni[1], modelParams[part2].popSizeUni[1], (MrBFlt) 0.00001) == NO)
14181 else if (!strcmp(modelParams[part1].popSizePr,"Lognormal") && !strcmp(modelParams[part2].popSizePr,"Lognormal"))
14183 if (AreDoublesEqual (modelParams[part1].popSizeLognormal[0], modelParams[part2].popSizeLognormal[0], (MrBFlt) 0.00001) == NO)
14185 if (AreDoublesEqual (modelParams[part1].popSizeLognormal[1], modelParams[part2].popSizeLognormal[1], (MrBFlt) 0.00001) == NO)
14188 else if (!strcmp(modelParams[part1].popSizePr,"Normal") && !strcmp(modelParams[part2].popSizePr,"Normal"))
14190 if (AreDoublesEqual (modelParams[part1].popSizeNormal[0], modelParams[part2].popSizeNormal[0], (MrBFlt) 0.00001) == NO)
14192 if (AreDoublesEqual (modelParams[part1].popSizeNormal[1], modelParams[part2].popSizeNormal[1], (MrBFlt) 0.00001) == NO)
14195 else if (!strcmp(modelParams[part1].popSizePr,"Gamma") && !strcmp(modelParams[part2].popSizePr,"Gamma"))
14197 if (AreDoublesEqual (modelParams[part1].popSizeGamma[0], modelParams[part2].popSizeGamma[0], (MrBFlt) 0.00001) == NO)
14199 if (AreDoublesEqual (modelParams[part1].popSizeGamma[1], modelParams[part2].popSizeGamma[1], (MrBFlt) 0.00001) == NO)
14202 else if (!strcmp(modelParams[part1].popSizePr,"Fixed") && !strcmp(modelParams[part2].popSizePr,"Fixed"))
14204 if (AreDoublesEqual (modelParams[part1].popSizeFix, modelParams[part2].popSizeFix, (MrBFlt) 0.00001) == NO)
14210 /* Check to see if population size is inapplicable for either partition. */
14211 if ((*isApplic1) == NO || (*isApplic2) == NO)
14214 else if (whichParam == P_GROWTH)
14216 /* Check growth rate for partitions 1 and 2. */
14218 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14219 silly and doesn't take this information into account) and growth rate cannot be estimated. */
14220 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14222 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14225 /* Check that the branch length prior is a clock:coalescence for both partitions. */
14226 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14228 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14230 if (strcmp(modelParams[part1].clockPr, "Coalescence"))
14232 if (strcmp(modelParams[part2].clockPr, "Coalescence"))
14235 /* Now, check that the prior on growth rate is the same. */
14236 if (!strcmp(modelParams[part1].growthPr,"Uniform") && !strcmp(modelParams[part2].growthPr,"Uniform"))
14238 if (AreDoublesEqual (modelParams[part1].growthUni[0], modelParams[part2].growthUni[0], (MrBFlt) 0.00001) == NO)
14240 if (AreDoublesEqual (modelParams[part1].growthUni[1], modelParams[part2].growthUni[1], (MrBFlt) 0.00001) == NO)
14243 else if (!strcmp(modelParams[part1].growthPr,"Exponential") && !strcmp(modelParams[part2].growthPr,"Exponential"))
14245 if (AreDoublesEqual (modelParams[part1].growthExp, modelParams[part2].growthExp, (MrBFlt) 0.00001) == NO)
14248 else if (!strcmp(modelParams[part1].growthPr,"Fixed") && !strcmp(modelParams[part2].growthPr,"Fixed"))
14250 if (AreDoublesEqual (modelParams[part1].growthFix, modelParams[part2].growthFix, (MrBFlt) 0.00001) == NO)
14256 /* Check to see if growth rate is inapplicable for either partition. */
14257 if ((*isApplic1) == NO || (*isApplic2) == NO)
14260 else if (whichParam == P_AAMODEL)
14262 /* Check the amino acid model settings for partitions 1 and 2. */
14264 /* Check if the model is parsimony for either partition */
14265 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14266 *isApplic1 = NO; /* part1 has a parsimony model and aamodel does not apply */
14267 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14268 *isApplic2 = NO; /* part2 has a parsimony model and aamodel does not apply */
14270 /* Check that the data are protein for both partitions 1 and 2 */
14271 if (isFirstProtein == NO)
14272 *isApplic1 = NO; /* part1 is not amino acid data so tratio does not apply */
14273 if (isSecondProtein == NO)
14274 *isApplic2 = NO; /* part2 is not amino acid data so tratio does not apply */
14276 /* If the model is fixed for a partition, then it is not a free parameter and
14277 we set it to isApplic = NO */
14278 if (!strcmp(modelParams[part1].aaModelPr,"Fixed"))
14280 if (!strcmp(modelParams[part2].aaModelPr,"Fixed"))
14283 /* We now need to check if the prior is the same for both. */
14284 if (!strcmp(modelParams[part1].aaModelPr,"Mixed") && !strcmp(modelParams[part2].aaModelPr,"Mixed"))
14287 else if (!strcmp(modelParams[part1].aaModelPr,"Fixed") && !strcmp(modelParams[part2].aaModelPr,"Fixed"))
14289 if (strcmp(modelParams[part1].aaModel,modelParams[part2].aaModel))
14293 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
14295 /* Check to see if amino acid model is inapplicable for either partition. */
14296 if ((*isApplic1) == NO || (*isApplic2) == NO)
14297 isSame = NO; /* if tratio is inapplicable for either partition, then the parameter cannot be the same */
14299 else if (whichParam == P_BRCORR)
14301 /* Check the correlation parameter for brownian motion 1 and 2. */
14303 /* Check that the data are either CONTINUOUS for partitions 1 and 2 */
14304 if (modelParams[part1].dataType != CONTINUOUS)
14305 *isApplic1 = NO; /* the correlation parameter does not make sense for part1 */
14306 if (modelParams[part2].dataType != CONTINUOUS)
14307 *isApplic2 = NO; /* the correlation parameter does not make sense for part2 */
14309 /* Now, check that the data are the same. */
14310 if (modelParams[part1].dataType != modelParams[part2].dataType)
14311 isSame = NO; /* data are not both continuous */
14313 /* Check the priors for both partitions. */
14314 if (!strcmp(modelParams[part1].brownCorPr,"Uniform") && !strcmp(modelParams[part2].brownCorPr,"Uniform"))
14316 if (AreDoublesEqual (modelParams[part1].brownCorrUni[0], modelParams[part2].brownCorrUni[0], (MrBFlt) 0.00001) == NO)
14318 if (AreDoublesEqual (modelParams[part1].brownCorrUni[1], modelParams[part2].brownCorrUni[1], (MrBFlt) 0.00001) == NO)
14321 else if (!strcmp(modelParams[part1].brownCorPr,"Fixed") && !strcmp(modelParams[part2].brownCorPr,"Fixed"))
14323 if (AreDoublesEqual (modelParams[part1].brownCorrFix, modelParams[part2].brownCorrFix, (MrBFlt) 0.00001) == NO)
14327 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
14329 /* Check to see if the correlation parameters are inapplicable for either partition. */
14330 if ((*isApplic1) == NO || (*isApplic2) == NO)
14331 isSame = NO; /* if the correlation parameters are inapplicable for either partition, then the parameter cannot be the same */
14333 else if (whichParam == P_BRSIGMA)
14335 /* Check the sigma parameter for brownian motion 1 and 2. */
14337 /* Check that the data are either CONTINUOUS for partitions 1 and 2 */
14338 if (modelParams[part1].dataType != CONTINUOUS)
14339 *isApplic1 = NO; /* the sigma parameter does not make sense for part1 */
14340 if (modelParams[part2].dataType != CONTINUOUS)
14341 *isApplic2 = NO; /* the sigma parameter does not make sense for part2 */
14343 /* Now, check that the data are the same. */
14344 if (modelParams[part1].dataType != modelParams[part2].dataType)
14345 isSame = NO; /* data are not both continuous */
14347 /* Check the priors for both partitions. */
14348 if (!strcmp(modelParams[part1].brownScalesPr,"Uniform") && !strcmp(modelParams[part2].brownScalesPr,"Uniform"))
14350 if (AreDoublesEqual (modelParams[part1].brownScalesUni[0], modelParams[part2].brownScalesUni[0], (MrBFlt) 0.00001) == NO)
14352 if (AreDoublesEqual (modelParams[part1].brownScalesUni[1], modelParams[part2].brownScalesUni[1], (MrBFlt) 0.00001) == NO)
14355 else if (!strcmp(modelParams[part1].brownScalesPr,"Fixed") && !strcmp(modelParams[part2].brownScalesPr,"Fixed"))
14357 if (AreDoublesEqual (modelParams[part1].brownScalesFix, modelParams[part2].brownScalesFix, (MrBFlt) 0.00001) == NO)
14360 else if (!strcmp(modelParams[part1].brownScalesPr,"Gamma") && !strcmp(modelParams[part2].brownScalesPr,"Gamma"))
14362 if (AreDoublesEqual (modelParams[part1].brownScalesGamma[0], modelParams[part2].brownScalesGamma[0], (MrBFlt) 0.00001) == NO)
14364 if (AreDoublesEqual (modelParams[part1].brownScalesGamma[1], modelParams[part2].brownScalesGamma[1], (MrBFlt) 0.00001) == NO)
14367 else if (!strcmp(modelParams[part1].brownScalesPr,"Gammamean") && !strcmp(modelParams[part2].brownScalesPr,"Gammamean"))
14369 if (AreDoublesEqual (modelParams[part1].brownScalesGammaMean, modelParams[part2].brownScalesGammaMean, (MrBFlt) 0.00001) == NO)
14373 isSame = NO; /* the priors are not the same, so we cannot set the parameter to be equal for both partitions */
14375 /* Check to see if the sigma parameters are inapplicable for either partition. */
14376 if ((*isApplic1) == NO || (*isApplic2) == NO)
14377 isSame = NO; /* if the sigma parameters are inapplicable for either partition, then the parameter cannot be the same */
14379 else if (whichParam == P_CPPRATE)
14381 /* Check cpp rate for partitions 1 and 2. */
14383 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14384 silly and doesn't take this information into account) and cpp rate cannot be estimated. */
14385 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14387 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14390 /* Check that the branch length prior is clock for both partitions. */
14391 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14393 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14396 /* Check that the clock rate prior is cpp for both partitions */
14397 if (strcmp(modelParams[part1].clockVarPr, "Cpp"))
14399 if (strcmp(modelParams[part2].clockVarPr, "Cpp"))
14402 /* Now, check that the prior on cpp rate is the same. */
14403 if (!strcmp(modelParams[part1].cppRatePr,"Exponential") && !strcmp(modelParams[part2].cppRatePr,"Exponential"))
14405 if (AreDoublesEqual (modelParams[part1].cppRateExp, modelParams[part2].cppRateExp, (MrBFlt) 0.00001) == NO)
14408 else if (!strcmp(modelParams[part1].cppRatePr,"Fixed") && !strcmp(modelParams[part2].cppRatePr,"Fixed"))
14410 if (AreDoublesEqual (modelParams[part1].cppRateFix, modelParams[part2].cppRateFix, (MrBFlt) 0.00001) == NO)
14416 /* Check to see if cpp rate is inapplicable for either partition. */
14417 if ((*isApplic1) == NO || (*isApplic2) == NO)
14420 else if (whichParam == P_CPPMULTDEV)
14422 /* Check cpp multiplier deviation prior for partitions 1 and 2. */
14424 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14425 silly and doesn't take this information into account) and this parameter is inapplicable. */
14426 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14428 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14431 /* Check that the branch length prior is clock for both partitions. */
14432 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14434 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14437 /* Check that the clock rate prior is cpp for both partitions */
14438 if (strcmp(modelParams[part1].clockVarPr, "Cpp"))
14440 if (strcmp(modelParams[part2].clockVarPr, "Cpp"))
14443 /* Now, check that the prior on sigma is the same. */
14444 if (!strcmp(modelParams[part1].cppMultDevPr,"Fixed") && !strcmp(modelParams[part2].cppMultDevPr,"Fixed"))
14446 if (AreDoublesEqual (modelParams[part1].cppMultDevFix, modelParams[part2].cppMultDevFix, (MrBFlt) 0.00001) == NO)
14452 /* Check to see if cpp multiplier sigma is inapplicable for either partition. */
14453 if ((*isApplic1) == NO || (*isApplic2) == NO)
14456 else if (whichParam == P_CPPEVENTS)
14458 /* Check cpp events for partitions 1 and 2. */
14460 /* Check if the model is parsimony for either partition. If so, then branch lengths do not apply (as parsimony is very
14461 silly and doesn't take this information into account) and cpp events are inapplicable. */
14462 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14464 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14467 /* Check that the branch length prior is clock for both partitions. */
14468 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14470 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14473 /* Check that the clock rate prior is cpp for both partitions */
14474 if (strcmp(modelParams[part1].clockVarPr, "Cpp"))
14476 if (strcmp(modelParams[part2].clockVarPr, "Cpp"))
14479 /* Now, check that the cpp parameter is the same */
14480 if (IsModelSame (P_CPPRATE, part1, part2, &temp1, &temp2) == NO)
14482 if (linkTable[P_CPPRATE][part1] != linkTable[P_CPPRATE][part2])
14485 /* ... and that the psigamma parameter is the same */
14486 if (IsModelSame (P_CPPMULTDEV, part1, part2, &temp1, &temp2) == NO)
14488 if (linkTable[P_CPPMULTDEV][part1] != linkTable[P_CPPRATE][part2])
14491 /* Not same if branch lengths are not the same */
14492 if (IsModelSame(P_BRLENS, part1, part2, &temp1, &temp2) == NO)
14494 if (linkTable[P_BRLENS][part1] != linkTable[P_BRLENS][part2])
14497 /* Set isSame to NO if cpp events are inapplicable for either partition. */
14498 if ((*isApplic1) == NO || (*isApplic2) == NO)
14501 else if (whichParam == P_TK02VAR)
14503 /* Check prior for variance of rate autocorrelation for partitions 1 and 2. */
14505 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14506 silly and doesn't take this information into account) and ratevar is inapplicable. */
14507 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14509 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14512 /* Check that the branch length prior is clock for both partitions. */
14513 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14515 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14518 /* Check that the clock rate prior is tk02 for both partitions */
14519 if (strcmp(modelParams[part1].clockVarPr, "TK02"))
14521 if (strcmp(modelParams[part2].clockVarPr, "TK02"))
14524 /* Now, check that the prior on tk02 variance is the same. */
14525 if (!strcmp(modelParams[part1].tk02varPr,"Uniform") && !strcmp(modelParams[part2].tk02varPr,"Uniform"))
14527 if (AreDoublesEqual (modelParams[part1].tk02varUni[0], modelParams[part2].tk02varUni[0], (MrBFlt) 0.00001) == NO)
14529 if (AreDoublesEqual (modelParams[part1].tk02varUni[1], modelParams[part2].tk02varUni[1], (MrBFlt) 0.00001) == NO)
14532 else if (!strcmp(modelParams[part1].tk02varPr,"Exponential") && !strcmp(modelParams[part2].tk02varPr,"Exponential"))
14534 if (AreDoublesEqual (modelParams[part1].tk02varExp, modelParams[part2].tk02varExp, (MrBFlt) 0.00001) == NO)
14537 else if (!strcmp(modelParams[part1].tk02varPr,"Fixed") && !strcmp(modelParams[part2].tk02varPr,"Fixed"))
14539 if (AreDoublesEqual (modelParams[part1].tk02varFix, modelParams[part2].tk02varFix, (MrBFlt) 0.00001) == NO)
14545 /* Check to see if tk02 variance is inapplicable for either partition. */
14546 if ((*isApplic1) == NO || (*isApplic2) == NO)
14549 else if (whichParam == P_TK02BRANCHRATES)
14551 /* Check TK02 relaxed clock branch rates for partitions 1 and 2. */
14553 /* Check if the model is parsimony for either partition. If so, then branch lengths do not apply (as parsimony is very
14554 silly and doesn't take this information into account) and tk02 relaxed clock branch rates are inapplicable. */
14555 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14557 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14560 /* Check that the branch length prior is clock for both partitions. */
14561 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14563 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14566 /* Check that the clock rate prior is tk02 for both partitions */
14567 if (strcmp(modelParams[part1].clockVarPr, "TK02"))
14569 if (strcmp(modelParams[part2].clockVarPr, "TK02"))
14572 /* Now, check that the tk02 variance parameter is the same */
14573 if (IsModelSame (P_TK02VAR, part1, part2, &temp1, &temp2) == NO)
14575 if (linkTable[P_TK02VAR][part1] != linkTable[P_TK02VAR][part2])
14578 /* Not same if branch lengths are not the same */
14579 if (IsModelSame(P_BRLENS, part1, part2, &temp1, &temp2) == NO)
14581 if (linkTable[P_BRLENS][part1] != linkTable[P_BRLENS][part2])
14584 /* Set isSame to NO if tk02 branch rates are inapplicable for either partition. */
14585 if ((*isApplic1) == NO || (*isApplic2) == NO)
14588 else if (whichParam == P_IGRVAR)
14590 /* Check prior for igr shape for partitions 1 and 2. */
14592 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14593 silly and doesn't take this information into account) and igr shape is inapplicable. */
14594 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14596 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14599 /* Check that the branch length prior is clock for both partitions. */
14600 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14602 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14605 /* Check that the clock rate prior is igr for both partitions */
14606 if (strcmp(modelParams[part1].clockVarPr, "Igr"))
14608 if (strcmp(modelParams[part2].clockVarPr, "Igr"))
14611 /* Now, check that the prior on igr shape is the same. */
14612 if (!strcmp(modelParams[part1].igrvarPr,"Uniform") && !strcmp(modelParams[part2].igrvarPr,"Uniform"))
14614 if (AreDoublesEqual (modelParams[part1].igrvarUni[0], modelParams[part2].igrvarUni[0], (MrBFlt) 0.00001) == NO)
14616 if (AreDoublesEqual (modelParams[part1].igrvarUni[1], modelParams[part2].igrvarUni[1], (MrBFlt) 0.00001) == NO)
14619 else if (!strcmp(modelParams[part1].igrvarPr,"Exponential") && !strcmp(modelParams[part2].igrvarPr,"Exponential"))
14621 if (AreDoublesEqual (modelParams[part1].igrvarExp, modelParams[part2].igrvarExp, (MrBFlt) 0.00001) == NO)
14624 else if (!strcmp(modelParams[part1].igrvarPr,"Fixed") && !strcmp(modelParams[part2].igrvarPr,"Fixed"))
14626 if (AreDoublesEqual (modelParams[part1].igrvarFix, modelParams[part2].igrvarFix, (MrBFlt) 0.00001) == NO)
14632 /* Check to see if igr variance is inapplicable for either partition. */
14633 if ((*isApplic1) == NO || (*isApplic2) == NO)
14636 else if (whichParam == P_IGRBRANCHRATES)
14638 /* Check IGR relaxed clock branch rates for partitions 1 and 2. */
14640 /* Check if the model is parsimony for either partition. If so, then branch lengths do not apply (as parsimony is very
14641 silly and doesn't take this information into account) and igr relaxed clock branch rates are inapplicable. */
14642 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14644 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14647 /* Check that the branch length prior is clock for both partitions. */
14648 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14650 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14653 /* Check that the clock rate prior is igr for both partitions */
14654 if (strcmp(modelParams[part1].clockVarPr, "Igr"))
14656 if (strcmp(modelParams[part2].clockVarPr, "Igr"))
14659 /* Now, check that the igr shape parameter is the same */
14660 if (IsModelSame (P_IGRVAR, part1, part2, &temp1, &temp2) == NO)
14662 if (linkTable[P_IGRVAR][part1] != linkTable[P_IGRVAR][part2])
14665 /* Not same if branch lengths are not the same */
14666 if (IsModelSame(P_BRLENS, part1, part2, &temp1, &temp2) == NO)
14668 if (linkTable[P_BRLENS][part1] != linkTable[P_BRLENS][part2])
14671 /* Set isSame to NO if igr branch rates are inapplicable for either partition. */
14672 if ((*isApplic1) == NO || (*isApplic2) == NO)
14675 else if (whichParam == P_MIXEDVAR)
14677 /* Check prior for mixed var for partitions 1 and 2. */
14679 /* Check if the model is parsimony for either partition. If so, then the branch lengths cannot apply (as parsimony is very
14680 silly and doesn't take this information into account) and variance is inapplicable. */
14681 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14683 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14686 /* Check that the branch length prior is clock for both partitions. */
14687 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14689 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14692 /* Check that the clock rate prior is mixed for both partitions */
14693 if (strcmp(modelParams[part1].clockVarPr, "Mixed"))
14695 if (strcmp(modelParams[part2].clockVarPr, "Mixed"))
14698 /* Now, check that the prior on var mixed is the same. */
14699 if (!strcmp(modelParams[part1].mixedvarPr,"Uniform") && !strcmp(modelParams[part2].mixedvarPr,"Uniform"))
14701 if (AreDoublesEqual (modelParams[part1].mixedvarUni[0], modelParams[part2].mixedvarUni[0], (MrBFlt) 0.00001) == NO)
14703 if (AreDoublesEqual (modelParams[part1].mixedvarUni[1], modelParams[part2].mixedvarUni[1], (MrBFlt) 0.00001) == NO)
14706 else if (!strcmp(modelParams[part1].mixedvarPr,"Exponential") && !strcmp(modelParams[part2].mixedvarPr,"Exponential"))
14708 if (AreDoublesEqual (modelParams[part1].mixedvarExp, modelParams[part2].mixedvarExp, (MrBFlt) 0.00001) == NO)
14711 else if (!strcmp(modelParams[part1].mixedvarPr,"Fixed") && !strcmp(modelParams[part2].mixedvarPr,"Fixed"))
14713 if (AreDoublesEqual (modelParams[part1].mixedvarFix, modelParams[part2].mixedvarFix, (MrBFlt) 0.00001) == NO)
14719 /* Check to see if variance is inapplicable for either partition. */
14720 if ((*isApplic1) == NO || (*isApplic2) == NO)
14723 else if (whichParam == P_MIXEDBRCHRATES)
14725 /* Check mixed relaxed clock branch rates for partitions 1 and 2. */
14727 /* Check if the model is parsimony for either partition. If so, then branch lengths do not apply (as parsimony is very
14728 silly and doesn't take this information into account) and relaxed clock branch rates are inapplicable. */
14729 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14731 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14734 /* Check that the branch length prior is clock for both partitions. */
14735 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14737 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14740 /* Check that the clock rate prior is mixed for both partitions */
14741 if (strcmp(modelParams[part1].clockVarPr, "Mixed"))
14743 if (strcmp(modelParams[part2].clockVarPr, "Mixed"))
14746 /* Now, check that the var parameter is the same */
14747 if (IsModelSame (P_MIXEDVAR, part1, part2, &temp1, &temp2) == NO)
14749 if (linkTable[P_MIXEDVAR][part1] != linkTable[P_MIXEDVAR][part2])
14752 /* Not same if branch lengths are not the same */
14753 if (IsModelSame(P_BRLENS, part1, part2, &temp1, &temp2) == NO)
14755 if (linkTable[P_BRLENS][part1] != linkTable[P_BRLENS][part2])
14758 /* Set isSame to NO if mixed branch rates are inapplicable for either partition. */
14759 if ((*isApplic1) == NO || (*isApplic2) == NO)
14762 else if (whichParam == P_CLOCKRATE)
14764 /* Check base substitution rates of clock tree for partitions 1 and 2. */
14766 /* Check if the model is parsimony for either partition. If so, then branch lengths do not apply (as parsimony is very
14767 silly and doesn't take this information into account) and clock branch rates are inapplicable. */
14768 if (!strcmp(modelParams[part1].parsModel, "Yes"))
14770 if (!strcmp(modelParams[part2].parsModel, "Yes"))
14773 /* Check that the branch length prior is clock for both partitions. */
14774 if (strcmp(modelParams[part1].brlensPr, "Clock"))
14776 if (strcmp(modelParams[part2].brlensPr, "Clock"))
14779 /* Set isSame to NO if base substitution rate parameter is inapplicable for either partition. */
14780 if ((*isApplic1) == NO || (*isApplic2) == NO)
14783 else if (whichParam == P_SPECIESTREE)
14785 /* Species tree; check that it is used in both partitions */
14786 if (strcmp(modelParams[part1].topologyPr, "Speciestree") != 0)
14788 if (strcmp(modelParams[part2].topologyPr, "Speciestree") != 0)
14791 /* Not same if inapplicable to either partition */
14792 if ((*isApplic1) == NO || (*isApplic2) == NO)
14795 else if (whichParam == P_GENETREERATE)
14797 /* Gene tree rate; check that it is used in both partitions */
14798 if (strcmp(modelParams[part1].topologyPr, "Speciestree") != 0)
14800 if (strcmp(modelParams[part2].topologyPr, "Speciestree") != 0)
14803 /* Not same if inapplicable to either partition */
14804 if ((*isApplic1) == NO || (*isApplic2) == NO)
14809 MrBayesPrint ("%s Could not find parameter in IsModelSame\n", spacer);
14817 int LargestMovableSubtree(Param *treeParam)
14819 int i, j, k, a, nLongsNeeded, numPartitions, largestSubtree;
14820 BitsLong **constraintPartition, *subtreePartition, *testPartition, *mask;
14823 mp = &modelParams[treeParam->relParts[0]];
14825 if (treeParam->paramType == P_SPECIESTREE)
14826 return numLocalTaxa; /* no constraints allowed in species tree; set constraints in gene trees instead */
14828 /* This is difficult because we cannot rely on the tree being initialized.
14829 We need to retrieve the bitfields ourselves and figure out what they mean. */
14830 nLongsNeeded = ((numLocalTaxa - 1) / nBitsInALong) + 1;
14831 subtreePartition = (BitsLong *) SafeCalloc(3*nLongsNeeded, sizeof(BitsLong));
14832 constraintPartition = (BitsLong **) SafeCalloc (numDefinedConstraints+1, sizeof(BitsLong *));
14833 constraintPartition[0] = (BitsLong *) SafeCalloc ((numDefinedConstraints+1)*nLongsNeeded, sizeof(BitsLong));
14834 for (i=1; i<numDefinedConstraints+1; i++)
14835 constraintPartition[i] = constraintPartition[i-1] + nLongsNeeded;
14836 testPartition = subtreePartition + nLongsNeeded;
14837 mask = testPartition + nLongsNeeded;
14839 /* set mask (needed to take care of unused bits when flipping partitions) */
14840 for (i=0; i<numLocalTaxa; i++)
14843 /* retrieve partitions */
14845 for (a=0; a<numDefinedConstraints; a++)
14847 if (mp->activeConstraints[a] == NO || definedConstraintsType[a] != HARD)
14850 /* set bits in partition under consideration */
14851 ClearBits(constraintPartition[numPartitions], nLongsNeeded);
14852 for (i=j=0; i<numTaxa; i++)
14854 if (taxaInfo[i].isDeleted == YES)
14856 if (IsBitSet(i, definedConstraint[a]) == YES)
14857 SetBit(j, constraintPartition[numPartitions]);
14861 /* make sure outgroup is outside constrained partition (marked 0) */
14862 if (strcmp(mp->brlensPr,"Clock") != 0 && IsBitSet(localOutGroup, constraintPartition[numPartitions]) == YES)
14863 FlipBits(constraintPartition[numPartitions], nLongsNeeded, mask);
14865 /* skip partition if uninformative */
14866 k = NumBits(constraintPartition[numPartitions], nLongsNeeded);
14867 if (k == 0 || k == 1)
14873 /* Add all-species partition */
14874 CopyBits(constraintPartition[numPartitions], mask, nLongsNeeded);
14877 /* Now we have all constraints. Calculate the movable subtree for each */
14878 largestSubtree = 0;
14879 for (i=0; i<numPartitions; i++)
14881 CopyBits (subtreePartition, constraintPartition[i], nLongsNeeded);
14883 for (j=0; j<numPartitions; j++)
14887 if (IsPartNested(constraintPartition[j], constraintPartition[i], nLongsNeeded))
14889 k++; /* add one for clade we are removing from subtreePartition */
14890 CopyBits (testPartition, constraintPartition[j], nLongsNeeded);
14891 FlipBits (testPartition, nLongsNeeded, mask);
14892 for (k=0; k<nLongsNeeded; k++)
14893 subtreePartition[k] = subtreePartition[k] & testPartition[k];
14896 k += NumBits (subtreePartition, nLongsNeeded); /* add remaming free tips in subtreePartition */
14897 /* add calculation root if an unrooted tree and we are dealing with the root partition */
14898 if (strcmp(mp->brlensPr,"Clock") != 0 && NumBits (constraintPartition[i], nLongsNeeded) == numLocalTaxa - 1)
14900 if (k > largestSubtree)
14901 largestSubtree = k;
14904 free(subtreePartition);
14905 free(constraintPartition[0]);
14906 free(constraintPartition);
14908 return largestSubtree;
14916 for (j=0; j<NUM_LINKED; j++)
14918 MrBayesPrint ("%4d -- ", j+1);
14919 for (i=0; i<numCurrentDivisions; i++)
14920 MrBayesPrint (" %2d", tempLinkUnlink[j][i]);
14921 MrBayesPrint ("\n");
14928 int NumActiveParts (void)
14933 for (i=0; i<numCurrentDivisions; i++)
14934 if (activeParts[i] == YES)
14941 int NumInformativeHardConstraints (ModelParams *mp)
14943 int i, j, k, a, numInformativeHardConstraints, nLongsNeeded;
14944 BitsLong *constraintPartition, *mask;
14946 numInformativeHardConstraints = 0;
14948 nLongsNeeded = ((numLocalTaxa - 1) / nBitsInALong) + 1;
14949 constraintPartition = (BitsLong *) SafeCalloc (2*nLongsNeeded, sizeof(BitsLong));
14950 if (!constraintPartition)
14952 MrBayesPrint ("%s Problems allocating constraintPartition", spacer);
14955 mask = constraintPartition + nLongsNeeded;
14957 /* set mask (needed to take care of unused bits when flipping partitions) */
14958 for (i=0; i<numLocalTaxa; i++)
14961 for (a=0; a<numDefinedConstraints; a++)
14963 if (mp->activeConstraints[a] == NO || definedConstraintsType[a] != HARD)
14966 /* set bits in partition to add */
14967 ClearBits(constraintPartition, nLongsNeeded);
14968 for (i=j=0; i<numTaxa; i++)
14970 if (taxaInfo[i].isDeleted == YES)
14972 if (IsBitSet(i, definedConstraint[a]) == YES)
14973 SetBit(j, constraintPartition);
14977 /* make sure outgroup is outside constrained partition (marked 0) */
14978 if (strcmp(mp->brlensPr,"Clock") != 0 && IsBitSet(localOutGroup, constraintPartition) == YES)
14979 FlipBits(constraintPartition, nLongsNeeded, mask);
14981 /* skip partition if uninformative */
14982 k = NumBits(constraintPartition, nLongsNeeded);
14983 if (k == 0 || k == 1)
14986 numInformativeHardConstraints++;
14989 return numInformativeHardConstraints;
14993 int NumNonExcludedChar (void)
14997 /* count number of non-excluded characters */
14999 for (i=0; i<numChar; i++)
15001 if (charInfo[i].isExcluded == NO)
15011 int NumStates (int part)
15013 if (modelParams[part].dataType == DNA || modelParams[part].dataType == RNA)
15015 if (!strcmp(modelParams[part].nucModel, "4by4"))
15017 else if (!strcmp(modelParams[part].nucModel, "Doublet"))
15019 else if (!strcmp(modelParams[part].nucModel, "Protein"))
15023 if (!strcmp(modelParams[part].geneticCode, "Universal"))
15025 else if (!strcmp(modelParams[part].geneticCode, "Vertmt"))
15027 else if (!strcmp(modelParams[part].geneticCode, "Invermt"))
15029 else if (!strcmp(modelParams[part].geneticCode, "Mycoplasma"))
15031 else if (!strcmp(modelParams[part].geneticCode, "Yeast"))
15033 else if (!strcmp(modelParams[part].geneticCode, "Ciliate"))
15035 else if (!strcmp(modelParams[part].geneticCode, "Echinoderm"))
15037 else if (!strcmp(modelParams[part].geneticCode, "Euplotid"))
15039 else if (!strcmp(modelParams[part].geneticCode, "Metmt"))
15043 else if (modelParams[part].dataType == PROTEIN)
15047 else if (modelParams[part].dataType == RESTRICTION)
15051 else if (modelParams[part].dataType == STANDARD)
15060 /*-----------------------------------------------------------------------
15062 | PrintCompMatrix: Print compressed matrix
15064 ------------------------------------------------------------------------*/
15065 int PrintCompMatrix (void)
15070 char tempName[100];
15071 char (*whichChar)(int);
15076 whichChar = &WhichNuc;
15078 for (d=0; d<numCurrentDivisions; d++)
15080 m = &modelSettings[d];
15081 mp = &modelParams[d];
15083 if (mp->dataType == DNA || mp->dataType == RNA)
15084 whichChar = &WhichNuc;
15085 if (mp->dataType == PROTEIN)
15086 whichChar = &WhichAA;
15087 if (mp->dataType == RESTRICTION)
15088 whichChar = &WhichRes;
15089 if (mp->dataType == STANDARD)
15090 whichChar = &WhichStand;
15092 MrBayesPrint ("\nCompressed matrix for division %d\n\n", d+1);
15095 if (mp->dataType == CONTINUOUS)
15098 for (c=m->compMatrixStart; c<m->compMatrixStop; c+=k)
15100 for (i=0; i<numLocalTaxa; i++)
15102 strcpy (tempName, localTaxonNames[i]);
15103 MrBayesPrint ("%-10.10s ", tempName);
15104 for (j=c; j<c+k; j++)
15106 if (j >= m->compMatrixStop)
15108 if (mp->dataType == CONTINUOUS)
15109 MrBayesPrint ("%3d ", compMatrix[pos(i,j,compMatrixRowSize)]);
15111 MrBayesPrint ("%c", whichChar((int)compMatrix[pos(i,j,compMatrixRowSize)]));
15113 MrBayesPrint("\n");
15115 MrBayesPrint("\nNo. sites ");
15116 for (j=c; j<c+k; j++)
15118 if (j >= m->compMatrixStop)
15120 i = (int) numSitesOfPat[m->compCharStart + (0*numCompressedChars) + (j - m->compMatrixStart)/m->nCharsPerSite]; /* NOTE: We are printing the unadulterated site pat nums */
15125 if (mp->dataType == CONTINUOUS)
15126 MrBayesPrint(" %c ", i);
15129 if ((j-m->compMatrixStart) % m->nCharsPerSite == 0)
15130 MrBayesPrint ("%c", i);
15135 MrBayesPrint ("\nOrig. char ");
15136 for (j=c; j<c+k; j++)
15138 if (j >= m->compMatrixStop)
15142 i = '0' + (i % 10);
15145 if (mp->dataType == CONTINUOUS)
15146 MrBayesPrint(" %c ", i);
15148 MrBayesPrint ("%c", i);
15151 if (mp->dataType == STANDARD && m->nStates != NULL)
15153 MrBayesPrint ("\nNo. states ");
15154 for (j=c; j<c+k; j++)
15156 if (j >= m->compMatrixStop)
15158 i = m->nStates[j-m->compCharStart];
15159 MrBayesPrint ("%d", i);
15161 MrBayesPrint ("\nCharType ");
15162 for (j=c; j<c+k; j++)
15164 if (j >= m->compMatrixStop)
15166 i = m->cType[j-m->compMatrixStart];
15168 MrBayesPrint ("%c", 'O');
15169 else if (i == UNORD)
15170 MrBayesPrint ("%c", 'U');
15172 MrBayesPrint ("%c", 'I');
15174 MrBayesPrint ("\ntiIndex ");
15175 for (j=c; j<c+k; j++)
15177 if (j >= m->compMatrixStop)
15179 i = m->tiIndex[j-m->compCharStart];
15180 MrBayesPrint ("%d", i % 10);
15182 MrBayesPrint ("\nbsIndex ");
15183 for (j=c; j<c+k; j++)
15185 if (j >= m->compMatrixStop)
15187 i = m->bsIndex[j-m->compCharStart];
15188 MrBayesPrint ("%d", i % 10);
15191 MrBayesPrint ("\n\n");
15193 MrBayesPrint ("Press return to continue\n");
15195 } /* next division */
15201 /*----------------------------------------------------------------------
15203 | PrintMatrix: Print data matrix
15206 ------------------------------------------------------------------------*/
15207 int PrintMatrix (void)
15209 int i, j=0, c, printWidth, nextColumn;
15214 MrBayesPrint ("\nData matrix\n\n");
15218 for (c=0; c<numChar; c=j)
15220 for (i=0; i<numTaxa; i++)
15222 MrBayesPrint ("%-10.10s ", taxaNames[i]);
15224 for (nextColumn=13; nextColumn < printWidth; nextColumn++)
15228 if (charInfo[j].charType == CONTINUOUS && nextColumn < printWidth - 3)
15230 if (charInfo[j].charType == CONTINUOUS)
15232 MrBayesPrint ("%3d ", matrix[pos(i,j,numChar)]);
15235 else if (charInfo[j].charType == DNA || charInfo[j].charType == RNA)
15236 MrBayesPrint ("%c", WhichNuc(matrix[pos(i,j,numChar)]));
15237 else if (charInfo[j].charType == PROTEIN)
15238 MrBayesPrint ("%c", WhichAA(matrix[pos(i,j,numChar)]));
15239 else if (charInfo[j].charType == RESTRICTION)
15240 MrBayesPrint ("%c", WhichRes(matrix[pos(i,j,numChar)]));
15241 else if (charInfo[j].charType == STANDARD)
15242 MrBayesPrint ("%c", WhichStand(matrix[pos(i,j,numChar)]));
15245 MrBayesPrint("\n");
15247 MrBayesPrint ("\n");
15254 /*--------------------------------------------------------------
15256 | ProcessStdChars: process standard characters
15258 ---------------------------------------------------------------*/
15259 int ProcessStdChars (RandLong *seed)
15261 int c, d, i, j, k, n, ts, index, numStandardChars, origCharPos, *bsIndex;
15264 ModelParams *mp=NULL;
15267 /* set character type, no. states, ti index and bs index for standard characters */
15268 /* first calculate how many standard characters we have */
15269 numStandardChars = 0;
15270 for (d=0; d<numCurrentDivisions; d++)
15272 mp = &modelParams[d];
15273 m = &modelSettings[d];
15275 if (mp->dataType != STANDARD)
15278 numStandardChars += m->numChars;
15281 /* return if there are no standard characters */
15282 if (numStandardChars == 0)
15285 /* we are still here so we have standard characters and need to deal with them */
15287 /* first allocate space for stdType, stateSize, tiIndex, bsIndex */
15288 if (memAllocs[ALLOC_STDTYPE] == YES)
15292 memAllocs[ALLOC_STDTYPE] = NO;
15294 stdType = (int *)SafeCalloc(4 * (size_t)numStandardChars, sizeof(int));
15297 MrBayesPrint ("%s Problem allocating stdType (%d ints)\n", 4 * numStandardChars);
15300 memAllocs[ALLOC_STDTYPE] = YES;
15301 stateSize = stdType + numStandardChars;
15302 tiIndex = stateSize + numStandardChars;
15303 bsIndex = tiIndex + numStandardChars;
15305 /* then fill in stdType and stateSize, set pointers */
15306 /* also fill in isTiNeeded for each division and tiIndex for each character */
15307 for (d=j=0; d<numCurrentDivisions; d++)
15309 mp = &modelParams[d];
15310 m = &modelSettings[d];
15312 if (mp->dataType != STANDARD)
15315 m->cType = stdType + j;
15316 m->nStates = stateSize + j;
15317 m->tiIndex = tiIndex + j;
15318 m->bsIndex = bsIndex + j;
15322 for (c=0; c<m->numChars; c++)
15324 if (origChar[c+m->compMatrixStart] < 0)
15326 /* this is a dummy character */
15327 m->cType[c] = UNORD;
15332 /* this is an ordinary character */
15333 m->cType[c] = charInfo[origChar[c + m->compMatrixStart]].ctype;
15334 m->nStates[c] = charInfo[origChar[c + m->compMatrixStart]].numStates;
15337 /* check ctype settings */
15338 if (m->nStates[c] < 2)
15340 MrBayesPrint ("%s WARNING: Compressed character %d (original character %d) of division %d has less \n", spacer, c+m->compCharStart,origChar[c+m->compCharStart]+1, d+1);
15341 MrBayesPrint ("%s than two observed states; it will be assumed to have two states.\n", spacer);
15344 if (m->nStates[c] > 6 && m->cType[c] != UNORD)
15346 MrBayesPrint ("%s Only unordered model supported for characters with more than 6 states\n", spacer);
15349 if (m->nStates[c] == 2 && m->cType[c] == ORD)
15350 m->cType[c] = UNORD;
15351 if (m->cType[c] == IRREV)
15353 MrBayesPrint ("%s Irreversible model not yet supported\n", spacer);
15357 /* find max number of states */
15358 if (m->nStates[c] > m->numModelStates)
15359 m->numModelStates = m->nStates[c];
15361 /* update Cijk info */
15362 if (strcmp(mp->symPiPr,"Fixed") != 0 || AreDoublesEqual(mp->symBetaFix, -1.0, 0.00001) == NO)
15364 /* Asymmetry between stationary state frequencies -- we need one cijk and eigenvalue
15365 set for each multistate character */
15366 if (m->nStates[c] > 2 && (m->cType[c] == UNORD || m->cType[c] == ORD))
15368 ts = m->nStates[c];
15369 m->cijkLength += (ts * ts * ts) + (2 * ts);
15374 /* set the ti probs needed */
15375 if (m->stateFreq->nValues == 0 || m->nStates[c] == 2)
15377 if (m->cType[c] == UNORD)
15378 m->isTiNeeded[m->nStates[c]-2] = YES;
15379 if (m->cType[c] == ORD)
15380 m->isTiNeeded[m->nStates[c]+6] = YES;
15381 if (m->cType[c] == IRREV)
15382 m->isTiNeeded[m->nStates[c]+11] = YES;
15386 /* set ti index for each compressed character first */
15387 /* set bs index later (below) */
15389 /* set base index, valid for binary chars */
15392 /* first adjust for unordered characters */
15393 for (k=0; k<9; k++)
15395 if (m->isTiNeeded [k] == NO)
15398 for (c=0; c<m->numChars; c++)
15400 if (m->cType[c] != UNORD || m->nStates[c] > k + 2)
15402 m->tiIndex[c] += (k + 2) * (k + 2) * m->numGammaCats;
15407 /* second for ordered characters */
15408 for (k=9; k<13; k++)
15410 if (m->isTiNeeded [k] == NO)
15413 for (c=0; c<m->numChars; c++)
15415 if (m->cType[c] == IRREV || (m->cType[c] == ORD && m->nStates[c] > k - 6))
15417 m->tiIndex[c] += (k - 6) * (k - 6) * m->numGammaCats;
15422 /* third for irrev characters */
15423 for (k=13; k<18; k++)
15425 if (m->isTiNeeded [k] == NO)
15428 for (c=0; c<m->numChars; c++)
15430 if (m->cType[c] == IRREV && m->nStates[c] > k - 11)
15432 m->tiIndex[c] += (k - 11) * (k - 11) * m->numGammaCats;
15437 /* finally take beta cats into account in tiIndex */
15438 /* the beta cats will only be used for binary characters */
15439 /* multistate characters get their ti indices reset here */
15440 if (m->numBetaCats > 1 && m->isTiNeeded[0] == YES)
15442 k = 4 * m->numBetaCats * m->numGammaCats; /* offset for binary character ti probs */
15443 for (c=0; c<m->numChars; c++)
15445 if (m->nStates[c] > 2)
15448 k += m->nStates[c] * m->nStates[c] * m->numGammaCats;
15455 /* deal with bsIndex */
15456 for (k=0; k<numParams; k++)
15459 if (p->paramType != P_PI || modelParams[p->relParts[0]].dataType != STANDARD)
15462 p->hasBinaryStd = NO;
15463 for (i=0; i<p->nRelParts; i++)
15464 if (modelSettings[p->relParts[i]].isTiNeeded[0] == YES)
15466 if (i < p->nRelParts)
15467 p->hasBinaryStd = YES;
15468 if (p->paramId == SYMPI_EQUAL)
15470 /* calculate the number of state frequencies needed */
15471 /* also set bsIndex appropriately */
15472 for (n=index=0; n<9; n++)
15474 for (i=0; i<p->nRelParts; i++)
15475 if (modelSettings[p->relParts[i]].isTiNeeded[n] == YES)
15477 if (i < p->nRelParts)
15479 for (i=0; i<p->nRelParts; i++)
15481 m = &modelSettings[p->relParts[i]];
15482 for (c=0; c<m->numChars; c++)
15484 if (m->cType[c] != UNORD || m->nStates[c] > n + 2)
15486 m->bsIndex[c] += (n + 2);
15493 for (n=9; n<13; n++)
15495 for (i=0; i<p->nRelParts; i++)
15496 if (modelSettings[p->relParts[i]].isTiNeeded[n] == YES)
15498 if (i < p->nRelParts)
15500 for (i=0; i<p->nRelParts; i++)
15502 m = &modelSettings[p->relParts[i]];
15503 for (c=0; c<m->numChars; c++)
15505 if (m->cType[c] == ORD && m->nStates[c] > n - 6)
15507 m->bsIndex[c] += (n - 6);
15514 p->nStdStateFreqs = index;
15518 /* if not equal we need space for beta category frequencies */
15520 if (p->hasBinaryStd == YES)
15521 index += (2 * modelSettings[p->relParts[0]].numBetaCats);
15522 /* as well as one set of frequencies for each multistate character */
15523 for (i=0; i<p->nRelParts; i++)
15525 m = &modelSettings[p->relParts[i]];
15526 for (c=0; c<m->numChars; c++)
15528 if (m->nStates[c] > 2 && (m->cType[c] == UNORD || m->cType[c] == ORD))
15530 m->bsIndex[c] = index;
15531 index += m->nStates[c];
15537 p->nStdStateFreqs = index;
15540 /* allocate space for bsIndex, sympiIndex, stdStateFreqs; then fill */
15542 /* first count number of sympis needed */
15543 for (k=n=i=0; k<numParams; k++)
15546 n += p->nSympi; /* nsympi calculated above */
15549 /* then allocate and fill in */
15552 if (memAllocs[ALLOC_SYMPIINDEX] == YES)
15554 sympiIndex = (int *) SafeRealloc ((void *) sympiIndex, 3*n * sizeof (int));
15555 for (i=0; i<3*n; i++)
15559 sympiIndex = (int *) SafeCalloc (3*n, sizeof (int));
15562 MrBayesPrint ("%s Problem allocating sympiIndex\n", spacer);
15566 memAllocs[ALLOC_SYMPIINDEX] = YES;
15568 /* set up sympi pointers and fill sympiIndex */
15569 for (k=i=0; k<numParams; k++)
15574 p->printParam = YES; /* print even if fixed alpha_symdir */
15576 p->sympiBsIndex = sympiIndex + i;
15577 p->sympinStates = sympiIndex + i + n;
15578 p->sympiCType = sympiIndex + i + (2 * n);
15579 for (j=0; j<p->nRelParts; j++)
15581 m = &modelSettings[p->relParts[j]];
15582 for (c=0; c<m->numChars; c++)
15584 if (m->nStates[c] > 2 && (m->cType[c] == UNORD || m->cType[c] == ORD))
15586 p->sympinStates[index] = m->nStates[c];
15587 p->sympiBsIndex[index] = m->bsIndex[c];
15588 p->sympiCType[index] = m->cType[c];
15589 origCharPos = origChar[m->compCharStart + c];
15590 for (ts=0; ts<m->nStates[c]; ts++)
15592 sprintf (piHeader, "\tpi_%d(%d)", origCharPos+1, ts);
15593 SafeStrcat(&p->paramHeader, piHeader);
15599 assert (index == p->nSympi);
15606 /* count space needed for state frequencies */
15607 for (k=n=0; k<numParams; k++)
15610 if (p->paramType != P_PI || modelParams[p->relParts[0]].dataType != STANDARD)
15612 n += p->nStdStateFreqs;
15615 stdStateFreqsRowSize = n;
15617 /* allocate space */
15618 if (memAllocs[ALLOC_STDSTATEFREQS] == YES)
15620 free (stdStateFreqs);
15621 stdStateFreqs = NULL;
15622 memAllocs[ALLOC_STDSTATEFREQS] = NO;
15624 stdStateFreqs = (MrBFlt *) SafeCalloc (n * 2 * numGlobalChains, sizeof (MrBFlt));
15625 if (!stdStateFreqs)
15627 MrBayesPrint ("%s Problem allocating stdStateFreqs in ProcessStdChars\n", spacer);
15631 memAllocs[ALLOC_STDSTATEFREQS] = YES;
15634 for (k=n=0; k<numParams; k++)
15637 if (p->paramType != P_PI || modelParams[p->relParts[0]].dataType != STANDARD)
15639 p->stdStateFreqs = stdStateFreqs + n;
15640 n += p->nStdStateFreqs;
15643 FillStdStateFreqs (0 , numGlobalChains, seed);
15649 int SetAARates (void)
15652 MrBFlt diff, sum, scaler;
15654 /* A R N D C Q E G H I L K M F P S T W Y V */
15657 aaJones[ 0][ 0] = 0; aaJones[ 0][ 1] = 58; aaJones[ 0][ 2] = 54; aaJones[ 0][ 3] = 81; aaJones[ 0][ 4] = 56;
15658 aaJones[ 0][ 5] = 57; aaJones[ 0][ 6] = 105; aaJones[ 0][ 7] = 179; aaJones[ 0][ 8] = 27; aaJones[ 0][ 9] = 36;
15659 aaJones[ 0][10] = 30; aaJones[ 0][11] = 35; aaJones[ 0][12] = 54; aaJones[ 0][13] = 15; aaJones[ 0][14] = 194;
15660 aaJones[ 0][15] = 378; aaJones[ 0][16] = 475; aaJones[ 0][17] = 9; aaJones[ 0][18] = 11; aaJones[ 0][19] = 298;
15661 aaJones[ 1][ 0] = 58; aaJones[ 1][ 1] = 0; aaJones[ 1][ 2] = 45; aaJones[ 1][ 3] = 16; aaJones[ 1][ 4] = 113;
15662 aaJones[ 1][ 5] = 310; aaJones[ 1][ 6] = 29; aaJones[ 1][ 7] = 137; aaJones[ 1][ 8] = 328; aaJones[ 1][ 9] = 22;
15663 aaJones[ 1][10] = 38; aaJones[ 1][11] = 646; aaJones[ 1][12] = 44; aaJones[ 1][13] = 5; aaJones[ 1][14] = 74;
15664 aaJones[ 1][15] = 101; aaJones[ 1][16] = 64; aaJones[ 1][17] = 126; aaJones[ 1][18] = 20; aaJones[ 1][19] = 17;
15665 aaJones[ 2][ 0] = 54; aaJones[ 2][ 1] = 45; aaJones[ 2][ 2] = 0; aaJones[ 2][ 3] = 528; aaJones[ 2][ 4] = 34;
15666 aaJones[ 2][ 5] = 86; aaJones[ 2][ 6] = 58; aaJones[ 2][ 7] = 81; aaJones[ 2][ 8] = 391; aaJones[ 2][ 9] = 47;
15667 aaJones[ 2][10] = 12; aaJones[ 2][11] = 263; aaJones[ 2][12] = 30; aaJones[ 2][13] = 10; aaJones[ 2][14] = 15;
15668 aaJones[ 2][15] = 503; aaJones[ 2][16] = 232; aaJones[ 2][17] = 8; aaJones[ 2][18] = 70; aaJones[ 2][19] = 16;
15669 aaJones[ 3][ 0] = 81; aaJones[ 3][ 1] = 16; aaJones[ 3][ 2] = 528; aaJones[ 3][ 3] = 0; aaJones[ 3][ 4] = 10;
15670 aaJones[ 3][ 5] = 49; aaJones[ 3][ 6] = 767; aaJones[ 3][ 7] = 130; aaJones[ 3][ 8] = 112; aaJones[ 3][ 9] = 11;
15671 aaJones[ 3][10] = 7; aaJones[ 3][11] = 26; aaJones[ 3][12] = 15; aaJones[ 3][13] = 4; aaJones[ 3][14] = 15;
15672 aaJones[ 3][15] = 59; aaJones[ 3][16] = 38; aaJones[ 3][17] = 4; aaJones[ 3][18] = 46; aaJones[ 3][19] = 31;
15673 aaJones[ 4][ 0] = 56; aaJones[ 4][ 1] = 113; aaJones[ 4][ 2] = 34; aaJones[ 4][ 3] = 10; aaJones[ 4][ 4] = 0;
15674 aaJones[ 4][ 5] = 9; aaJones[ 4][ 6] = 5; aaJones[ 4][ 7] = 59; aaJones[ 4][ 8] = 69; aaJones[ 4][ 9] = 17;
15675 aaJones[ 4][10] = 23; aaJones[ 4][11] = 7; aaJones[ 4][12] = 31; aaJones[ 4][13] = 78; aaJones[ 4][14] = 14;
15676 aaJones[ 4][15] = 223; aaJones[ 4][16] = 42; aaJones[ 4][17] = 115; aaJones[ 4][18] = 209; aaJones[ 4][19] = 62;
15677 aaJones[ 5][ 0] = 57; aaJones[ 5][ 1] = 310; aaJones[ 5][ 2] = 86; aaJones[ 5][ 3] = 49; aaJones[ 5][ 4] = 9;
15678 aaJones[ 5][ 5] = 0; aaJones[ 5][ 6] = 323; aaJones[ 5][ 7] = 26; aaJones[ 5][ 8] = 597; aaJones[ 5][ 9] = 9;
15679 aaJones[ 5][10] = 72; aaJones[ 5][11] = 292; aaJones[ 5][12] = 43; aaJones[ 5][13] = 4; aaJones[ 5][14] = 164;
15680 aaJones[ 5][15] = 53; aaJones[ 5][16] = 51; aaJones[ 5][17] = 18; aaJones[ 5][18] = 24; aaJones[ 5][19] = 20;
15681 aaJones[ 6][ 0] = 105; aaJones[ 6][ 1] = 29; aaJones[ 6][ 2] = 58; aaJones[ 6][ 3] = 767; aaJones[ 6][ 4] = 5;
15682 aaJones[ 6][ 5] = 323; aaJones[ 6][ 6] = 0; aaJones[ 6][ 7] = 119; aaJones[ 6][ 8] = 26; aaJones[ 6][ 9] = 12;
15683 aaJones[ 6][10] = 9; aaJones[ 6][11] = 181; aaJones[ 6][12] = 18; aaJones[ 6][13] = 5; aaJones[ 6][14] = 18;
15684 aaJones[ 6][15] = 30; aaJones[ 6][16] = 32; aaJones[ 6][17] = 10; aaJones[ 6][18] = 7; aaJones[ 6][19] = 45;
15685 aaJones[ 7][ 0] = 179; aaJones[ 7][ 1] = 137; aaJones[ 7][ 2] = 81; aaJones[ 7][ 3] = 130; aaJones[ 7][ 4] = 59;
15686 aaJones[ 7][ 5] = 26; aaJones[ 7][ 6] = 119; aaJones[ 7][ 7] = 0; aaJones[ 7][ 8] = 23; aaJones[ 7][ 9] = 6;
15687 aaJones[ 7][10] = 6; aaJones[ 7][11] = 27; aaJones[ 7][12] = 14; aaJones[ 7][13] = 5; aaJones[ 7][14] = 24;
15688 aaJones[ 7][15] = 201; aaJones[ 7][16] = 33; aaJones[ 7][17] = 55; aaJones[ 7][18] = 8; aaJones[ 7][19] = 47;
15689 aaJones[ 8][ 0] = 27; aaJones[ 8][ 1] = 328; aaJones[ 8][ 2] = 391; aaJones[ 8][ 3] = 112; aaJones[ 8][ 4] = 69;
15690 aaJones[ 8][ 5] = 597; aaJones[ 8][ 6] = 26; aaJones[ 8][ 7] = 23; aaJones[ 8][ 8] = 0; aaJones[ 8][ 9] = 16;
15691 aaJones[ 8][10] = 56; aaJones[ 8][11] = 45; aaJones[ 8][12] = 33; aaJones[ 8][13] = 40; aaJones[ 8][14] = 115;
15692 aaJones[ 8][15] = 73; aaJones[ 8][16] = 46; aaJones[ 8][17] = 8; aaJones[ 8][18] = 573; aaJones[ 8][19] = 11;
15693 aaJones[ 9][ 0] = 36; aaJones[ 9][ 1] = 22; aaJones[ 9][ 2] = 47; aaJones[ 9][ 3] = 11; aaJones[ 9][ 4] = 17;
15694 aaJones[ 9][ 5] = 9; aaJones[ 9][ 6] = 12; aaJones[ 9][ 7] = 6; aaJones[ 9][ 8] = 16; aaJones[ 9][ 9] = 0;
15695 aaJones[ 9][10] = 229; aaJones[ 9][11] = 21; aaJones[ 9][12] = 479; aaJones[ 9][13] = 89; aaJones[ 9][14] = 10;
15696 aaJones[ 9][15] = 40; aaJones[ 9][16] = 245; aaJones[ 9][17] = 9; aaJones[ 9][18] = 32; aaJones[ 9][19] = 961;
15697 aaJones[10][ 0] = 30; aaJones[10][ 1] = 38; aaJones[10][ 2] = 12; aaJones[10][ 3] = 7; aaJones[10][ 4] = 23;
15698 aaJones[10][ 5] = 72; aaJones[10][ 6] = 9; aaJones[10][ 7] = 6; aaJones[10][ 8] = 56; aaJones[10][ 9] = 229;
15699 aaJones[10][10] = 0; aaJones[10][11] = 14; aaJones[10][12] = 388; aaJones[10][13] = 248; aaJones[10][14] = 102;
15700 aaJones[10][15] = 59; aaJones[10][16] = 25; aaJones[10][17] = 52; aaJones[10][18] = 24; aaJones[10][19] = 180;
15701 aaJones[11][ 0] = 35; aaJones[11][ 1] = 646; aaJones[11][ 2] = 263; aaJones[11][ 3] = 26; aaJones[11][ 4] = 7;
15702 aaJones[11][ 5] = 292; aaJones[11][ 6] = 181; aaJones[11][ 7] = 27; aaJones[11][ 8] = 45; aaJones[11][ 9] = 21;
15703 aaJones[11][10] = 14; aaJones[11][11] = 0; aaJones[11][12] = 65; aaJones[11][13] = 4; aaJones[11][14] = 21;
15704 aaJones[11][15] = 47; aaJones[11][16] = 103; aaJones[11][17] = 10; aaJones[11][18] = 8; aaJones[11][19] = 14;
15705 aaJones[12][ 0] = 54; aaJones[12][ 1] = 44; aaJones[12][ 2] = 30; aaJones[12][ 3] = 15; aaJones[12][ 4] = 31;
15706 aaJones[12][ 5] = 43; aaJones[12][ 6] = 18; aaJones[12][ 7] = 14; aaJones[12][ 8] = 33; aaJones[12][ 9] = 479;
15707 aaJones[12][10] = 388; aaJones[12][11] = 65; aaJones[12][12] = 0; aaJones[12][13] = 43; aaJones[12][14] = 16;
15708 aaJones[12][15] = 29; aaJones[12][16] = 226; aaJones[12][17] = 24; aaJones[12][18] = 18; aaJones[12][19] = 323;
15709 aaJones[13][ 0] = 15; aaJones[13][ 1] = 5; aaJones[13][ 2] = 10; aaJones[13][ 3] = 4; aaJones[13][ 4] = 78;
15710 aaJones[13][ 5] = 4; aaJones[13][ 6] = 5; aaJones[13][ 7] = 5; aaJones[13][ 8] = 40; aaJones[13][ 9] = 89;
15711 aaJones[13][10] = 248; aaJones[13][11] = 4; aaJones[13][12] = 43; aaJones[13][13] = 0; aaJones[13][14] = 17;
15712 aaJones[13][15] = 92; aaJones[13][16] = 12; aaJones[13][17] = 53; aaJones[13][18] = 536; aaJones[13][19] = 62;
15713 aaJones[14][ 0] = 194; aaJones[14][ 1] = 74; aaJones[14][ 2] = 15; aaJones[14][ 3] = 15; aaJones[14][ 4] = 14;
15714 aaJones[14][ 5] = 164; aaJones[14][ 6] = 18; aaJones[14][ 7] = 24; aaJones[14][ 8] = 115; aaJones[14][ 9] = 10;
15715 aaJones[14][10] = 102; aaJones[14][11] = 21; aaJones[14][12] = 16; aaJones[14][13] = 17; aaJones[14][14] = 0;
15716 aaJones[14][15] = 285; aaJones[14][16] = 118; aaJones[14][17] = 6; aaJones[14][18] = 10; aaJones[14][19] = 23;
15717 aaJones[15][ 0] = 378; aaJones[15][ 1] = 101; aaJones[15][ 2] = 503; aaJones[15][ 3] = 59; aaJones[15][ 4] = 223;
15718 aaJones[15][ 5] = 53; aaJones[15][ 6] = 30; aaJones[15][ 7] = 201; aaJones[15][ 8] = 73; aaJones[15][ 9] = 40;
15719 aaJones[15][10] = 59; aaJones[15][11] = 47; aaJones[15][12] = 29; aaJones[15][13] = 92; aaJones[15][14] = 285;
15720 aaJones[15][15] = 0; aaJones[15][16] = 477; aaJones[15][17] = 35; aaJones[15][18] = 63; aaJones[15][19] = 38;
15721 aaJones[16][ 0] = 475; aaJones[16][ 1] = 64; aaJones[16][ 2] = 232; aaJones[16][ 3] = 38; aaJones[16][ 4] = 42;
15722 aaJones[16][ 5] = 51; aaJones[16][ 6] = 32; aaJones[16][ 7] = 33; aaJones[16][ 8] = 46; aaJones[16][ 9] = 245;
15723 aaJones[16][10] = 25; aaJones[16][11] = 103; aaJones[16][12] = 226; aaJones[16][13] = 12; aaJones[16][14] = 118;
15724 aaJones[16][15] = 477; aaJones[16][16] = 0; aaJones[16][17] = 12; aaJones[16][18] = 21; aaJones[16][19] = 112;
15725 aaJones[17][ 0] = 9; aaJones[17][ 1] = 126; aaJones[17][ 2] = 8; aaJones[17][ 3] = 4; aaJones[17][ 4] = 115;
15726 aaJones[17][ 5] = 18; aaJones[17][ 6] = 10; aaJones[17][ 7] = 55; aaJones[17][ 8] = 8; aaJones[17][ 9] = 9;
15727 aaJones[17][10] = 52; aaJones[17][11] = 10; aaJones[17][12] = 24; aaJones[17][13] = 53; aaJones[17][14] = 6;
15728 aaJones[17][15] = 35; aaJones[17][16] = 12; aaJones[17][17] = 0; aaJones[17][18] = 71; aaJones[17][19] = 25;
15729 aaJones[18][ 0] = 11; aaJones[18][ 1] = 20; aaJones[18][ 2] = 70; aaJones[18][ 3] = 46; aaJones[18][ 4] = 209;
15730 aaJones[18][ 5] = 24; aaJones[18][ 6] = 7; aaJones[18][ 7] = 8; aaJones[18][ 8] = 573; aaJones[18][ 9] = 32;
15731 aaJones[18][10] = 24; aaJones[18][11] = 8; aaJones[18][12] = 18; aaJones[18][13] = 536; aaJones[18][14] = 10;
15732 aaJones[18][15] = 63; aaJones[18][16] = 21; aaJones[18][17] = 71; aaJones[18][18] = 0; aaJones[18][19] = 16;
15733 aaJones[19][ 0] = 298; aaJones[19][ 1] = 17; aaJones[19][ 2] = 16; aaJones[19][ 3] = 31; aaJones[19][ 4] = 62;
15734 aaJones[19][ 5] = 20; aaJones[19][ 6] = 45; aaJones[19][ 7] = 47; aaJones[19][ 8] = 11; aaJones[19][ 9] = 961;
15735 aaJones[19][10] = 180; aaJones[19][11] = 14; aaJones[19][12] = 323; aaJones[19][13] = 62; aaJones[19][14] = 23;
15736 aaJones[19][15] = 38; aaJones[19][16] = 112; aaJones[19][17] = 25; aaJones[19][18] = 16; aaJones[19][19] = 0;
15738 jonesPi[ 0] = 0.076748;
15739 jonesPi[ 1] = 0.051691;
15740 jonesPi[ 2] = 0.042645;
15741 jonesPi[ 3] = 0.051544;
15742 jonesPi[ 4] = 0.019803;
15743 jonesPi[ 5] = 0.040752;
15744 jonesPi[ 6] = 0.061830;
15745 jonesPi[ 7] = 0.073152;
15746 jonesPi[ 8] = 0.022944;
15747 jonesPi[ 9] = 0.053761;
15748 jonesPi[10] = 0.091904;
15749 jonesPi[11] = 0.058676;
15750 jonesPi[12] = 0.023826;
15751 jonesPi[13] = 0.040126;
15752 jonesPi[14] = 0.050901;
15753 jonesPi[15] = 0.068765;
15754 jonesPi[16] = 0.058565;
15755 jonesPi[17] = 0.014261;
15756 jonesPi[18] = 0.032102;
15757 jonesPi[19] = 0.066005;
15760 aaDayhoff[ 0][ 0] = 0; aaDayhoff[ 0][ 1] = 27; aaDayhoff[ 0][ 2] = 98; aaDayhoff[ 0][ 3] = 120; aaDayhoff[ 0][ 4] = 36;
15761 aaDayhoff[ 0][ 5] = 89; aaDayhoff[ 0][ 6] = 198; aaDayhoff[ 0][ 7] = 240; aaDayhoff[ 0][ 8] = 23; aaDayhoff[ 0][ 9] = 65;
15762 aaDayhoff[ 0][10] = 41; aaDayhoff[ 0][11] = 26; aaDayhoff[ 0][12] = 72; aaDayhoff[ 0][13] = 18; aaDayhoff[ 0][14] = 250;
15763 aaDayhoff[ 0][15] = 409; aaDayhoff[ 0][16] = 371; aaDayhoff[ 0][17] = 0; aaDayhoff[ 0][18] = 24; aaDayhoff[ 0][19] = 208;
15764 aaDayhoff[ 1][ 0] = 27; aaDayhoff[ 1][ 1] = 0; aaDayhoff[ 1][ 2] = 32; aaDayhoff[ 1][ 3] = 0; aaDayhoff[ 1][ 4] = 23;
15765 aaDayhoff[ 1][ 5] = 246; aaDayhoff[ 1][ 6] = 1; aaDayhoff[ 1][ 7] = 9; aaDayhoff[ 1][ 8] = 240; aaDayhoff[ 1][ 9] = 64;
15766 aaDayhoff[ 1][10] = 15; aaDayhoff[ 1][11] = 464; aaDayhoff[ 1][12] = 90; aaDayhoff[ 1][13] = 14; aaDayhoff[ 1][14] = 103;
15767 aaDayhoff[ 1][15] = 154; aaDayhoff[ 1][16] = 26; aaDayhoff[ 1][17] = 201; aaDayhoff[ 1][18] = 8; aaDayhoff[ 1][19] = 24;
15768 aaDayhoff[ 2][ 0] = 98; aaDayhoff[ 2][ 1] = 32; aaDayhoff[ 2][ 2] = 0; aaDayhoff[ 2][ 3] = 905; aaDayhoff[ 2][ 4] = 0;
15769 aaDayhoff[ 2][ 5] = 103; aaDayhoff[ 2][ 6] = 148; aaDayhoff[ 2][ 7] = 139; aaDayhoff[ 2][ 8] = 535; aaDayhoff[ 2][ 9] = 77;
15770 aaDayhoff[ 2][10] = 34; aaDayhoff[ 2][11] = 318; aaDayhoff[ 2][12] = 1; aaDayhoff[ 2][13] = 14; aaDayhoff[ 2][14] = 42;
15771 aaDayhoff[ 2][15] = 495; aaDayhoff[ 2][16] = 229; aaDayhoff[ 2][17] = 23; aaDayhoff[ 2][18] = 95; aaDayhoff[ 2][19] = 15;
15772 aaDayhoff[ 3][ 0] = 120; aaDayhoff[ 3][ 1] = 0; aaDayhoff[ 3][ 2] = 905; aaDayhoff[ 3][ 3] = 0; aaDayhoff[ 3][ 4] = 0;
15773 aaDayhoff[ 3][ 5] = 134; aaDayhoff[ 3][ 6] = 1153; aaDayhoff[ 3][ 7] = 125; aaDayhoff[ 3][ 8] = 86; aaDayhoff[ 3][ 9] = 24;
15774 aaDayhoff[ 3][10] = 0; aaDayhoff[ 3][11] = 71; aaDayhoff[ 3][12] = 0; aaDayhoff[ 3][13] = 0; aaDayhoff[ 3][14] = 13;
15775 aaDayhoff[ 3][15] = 95; aaDayhoff[ 3][16] = 66; aaDayhoff[ 3][17] = 0; aaDayhoff[ 3][18] = 0; aaDayhoff[ 3][19] = 18;
15776 aaDayhoff[ 4][ 0] = 36; aaDayhoff[ 4][ 1] = 23; aaDayhoff[ 4][ 2] = 0; aaDayhoff[ 4][ 3] = 0; aaDayhoff[ 4][ 4] = 0;
15777 aaDayhoff[ 4][ 5] = 0; aaDayhoff[ 4][ 6] = 0; aaDayhoff[ 4][ 7] = 11; aaDayhoff[ 4][ 8] = 28; aaDayhoff[ 4][ 9] = 44;
15778 aaDayhoff[ 4][10] = 0; aaDayhoff[ 4][11] = 0; aaDayhoff[ 4][12] = 0; aaDayhoff[ 4][13] = 0; aaDayhoff[ 4][14] = 19;
15779 aaDayhoff[ 4][15] = 161; aaDayhoff[ 4][16] = 16; aaDayhoff[ 4][17] = 0; aaDayhoff[ 4][18] = 96; aaDayhoff[ 4][19] = 49;
15780 aaDayhoff[ 5][ 0] = 89; aaDayhoff[ 5][ 1] = 246; aaDayhoff[ 5][ 2] = 103; aaDayhoff[ 5][ 3] = 134; aaDayhoff[ 5][ 4] = 0;
15781 aaDayhoff[ 5][ 5] = 0; aaDayhoff[ 5][ 6] = 716; aaDayhoff[ 5][ 7] = 28; aaDayhoff[ 5][ 8] = 606; aaDayhoff[ 5][ 9] = 18;
15782 aaDayhoff[ 5][10] = 73; aaDayhoff[ 5][11] = 153; aaDayhoff[ 5][12] = 114; aaDayhoff[ 5][13] = 0; aaDayhoff[ 5][14] = 153;
15783 aaDayhoff[ 5][15] = 56; aaDayhoff[ 5][16] = 53; aaDayhoff[ 5][17] = 0; aaDayhoff[ 5][18] = 0; aaDayhoff[ 5][19] = 35;
15784 aaDayhoff[ 6][ 0] = 198; aaDayhoff[ 6][ 1] = 1; aaDayhoff[ 6][ 2] = 148; aaDayhoff[ 6][ 3] = 1153; aaDayhoff[ 6][ 4] = 0;
15785 aaDayhoff[ 6][ 5] = 716; aaDayhoff[ 6][ 6] = 0; aaDayhoff[ 6][ 7] = 81; aaDayhoff[ 6][ 8] = 43; aaDayhoff[ 6][ 9] = 61;
15786 aaDayhoff[ 6][10] = 11; aaDayhoff[ 6][11] = 83; aaDayhoff[ 6][12] = 30; aaDayhoff[ 6][13] = 0; aaDayhoff[ 6][14] = 51;
15787 aaDayhoff[ 6][15] = 79; aaDayhoff[ 6][16] = 34; aaDayhoff[ 6][17] = 0; aaDayhoff[ 6][18] = 22; aaDayhoff[ 6][19] = 37;
15788 aaDayhoff[ 7][ 0] = 240; aaDayhoff[ 7][ 1] = 9; aaDayhoff[ 7][ 2] = 139; aaDayhoff[ 7][ 3] = 125; aaDayhoff[ 7][ 4] = 11;
15789 aaDayhoff[ 7][ 5] = 28; aaDayhoff[ 7][ 6] = 81; aaDayhoff[ 7][ 7] = 0; aaDayhoff[ 7][ 8] = 10; aaDayhoff[ 7][ 9] = 0;
15790 aaDayhoff[ 7][10] = 7; aaDayhoff[ 7][11] = 27; aaDayhoff[ 7][12] = 17; aaDayhoff[ 7][13] = 15; aaDayhoff[ 7][14] = 34;
15791 aaDayhoff[ 7][15] = 234; aaDayhoff[ 7][16] = 30; aaDayhoff[ 7][17] = 0; aaDayhoff[ 7][18] = 0; aaDayhoff[ 7][19] = 54;
15792 aaDayhoff[ 8][ 0] = 23; aaDayhoff[ 8][ 1] = 240; aaDayhoff[ 8][ 2] = 535; aaDayhoff[ 8][ 3] = 86; aaDayhoff[ 8][ 4] = 28;
15793 aaDayhoff[ 8][ 5] = 606; aaDayhoff[ 8][ 6] = 43; aaDayhoff[ 8][ 7] = 10; aaDayhoff[ 8][ 8] = 0; aaDayhoff[ 8][ 9] = 7;
15794 aaDayhoff[ 8][10] = 44; aaDayhoff[ 8][11] = 26; aaDayhoff[ 8][12] = 0; aaDayhoff[ 8][13] = 48; aaDayhoff[ 8][14] = 94;
15795 aaDayhoff[ 8][15] = 35; aaDayhoff[ 8][16] = 22; aaDayhoff[ 8][17] = 27; aaDayhoff[ 8][18] = 127; aaDayhoff[ 8][19] = 44;
15796 aaDayhoff[ 9][ 0] = 65; aaDayhoff[ 9][ 1] = 64; aaDayhoff[ 9][ 2] = 77; aaDayhoff[ 9][ 3] = 24; aaDayhoff[ 9][ 4] = 44;
15797 aaDayhoff[ 9][ 5] = 18; aaDayhoff[ 9][ 6] = 61; aaDayhoff[ 9][ 7] = 0; aaDayhoff[ 9][ 8] = 7; aaDayhoff[ 9][ 9] = 0;
15798 aaDayhoff[ 9][10] = 257; aaDayhoff[ 9][11] = 46; aaDayhoff[ 9][12] = 336; aaDayhoff[ 9][13] = 196; aaDayhoff[ 9][14] = 12;
15799 aaDayhoff[ 9][15] = 24; aaDayhoff[ 9][16] = 192; aaDayhoff[ 9][17] = 0; aaDayhoff[ 9][18] = 37; aaDayhoff[ 9][19] = 889;
15800 aaDayhoff[10][ 0] = 41; aaDayhoff[10][ 1] = 15; aaDayhoff[10][ 2] = 34; aaDayhoff[10][ 3] = 0; aaDayhoff[10][ 4] = 0;
15801 aaDayhoff[10][ 5] = 73; aaDayhoff[10][ 6] = 11; aaDayhoff[10][ 7] = 7; aaDayhoff[10][ 8] = 44; aaDayhoff[10][ 9] = 257;
15802 aaDayhoff[10][10] = 0; aaDayhoff[10][11] = 18; aaDayhoff[10][12] = 527; aaDayhoff[10][13] = 157; aaDayhoff[10][14] = 32;
15803 aaDayhoff[10][15] = 17; aaDayhoff[10][16] = 33; aaDayhoff[10][17] = 46; aaDayhoff[10][18] = 28; aaDayhoff[10][19] = 175;
15804 aaDayhoff[11][ 0] = 26; aaDayhoff[11][ 1] = 464; aaDayhoff[11][ 2] = 318; aaDayhoff[11][ 3] = 71; aaDayhoff[11][ 4] = 0;
15805 aaDayhoff[11][ 5] = 153; aaDayhoff[11][ 6] = 83; aaDayhoff[11][ 7] = 27; aaDayhoff[11][ 8] = 26; aaDayhoff[11][ 9] = 46;
15806 aaDayhoff[11][10] = 18; aaDayhoff[11][11] = 0; aaDayhoff[11][12] = 243; aaDayhoff[11][13] = 0; aaDayhoff[11][14] = 33;
15807 aaDayhoff[11][15] = 96; aaDayhoff[11][16] = 136; aaDayhoff[11][17] = 0; aaDayhoff[11][18] = 13; aaDayhoff[11][19] = 10;
15808 aaDayhoff[12][ 0] = 72; aaDayhoff[12][ 1] = 90; aaDayhoff[12][ 2] = 1; aaDayhoff[12][ 3] = 0; aaDayhoff[12][ 4] = 0;
15809 aaDayhoff[12][ 5] = 114; aaDayhoff[12][ 6] = 30; aaDayhoff[12][ 7] = 17; aaDayhoff[12][ 8] = 0; aaDayhoff[12][ 9] = 336;
15810 aaDayhoff[12][10] = 527; aaDayhoff[12][11] = 243; aaDayhoff[12][12] = 0; aaDayhoff[12][13] = 92; aaDayhoff[12][14] = 17;
15811 aaDayhoff[12][15] = 62; aaDayhoff[12][16] = 104; aaDayhoff[12][17] = 0; aaDayhoff[12][18] = 0; aaDayhoff[12][19] = 258;
15812 aaDayhoff[13][ 0] = 18; aaDayhoff[13][ 1] = 14; aaDayhoff[13][ 2] = 14; aaDayhoff[13][ 3] = 0; aaDayhoff[13][ 4] = 0;
15813 aaDayhoff[13][ 5] = 0; aaDayhoff[13][ 6] = 0; aaDayhoff[13][ 7] = 15; aaDayhoff[13][ 8] = 48; aaDayhoff[13][ 9] = 196;
15814 aaDayhoff[13][10] = 157; aaDayhoff[13][11] = 0; aaDayhoff[13][12] = 92; aaDayhoff[13][13] = 0; aaDayhoff[13][14] = 11;
15815 aaDayhoff[13][15] = 46; aaDayhoff[13][16] = 13; aaDayhoff[13][17] = 76; aaDayhoff[13][18] = 698; aaDayhoff[13][19] = 12;
15816 aaDayhoff[14][ 0] = 250; aaDayhoff[14][ 1] = 103; aaDayhoff[14][ 2] = 42; aaDayhoff[14][ 3] = 13; aaDayhoff[14][ 4] = 19;
15817 aaDayhoff[14][ 5] = 153; aaDayhoff[14][ 6] = 51; aaDayhoff[14][ 7] = 34; aaDayhoff[14][ 8] = 94; aaDayhoff[14][ 9] = 12;
15818 aaDayhoff[14][10] = 32; aaDayhoff[14][11] = 33; aaDayhoff[14][12] = 17; aaDayhoff[14][13] = 11; aaDayhoff[14][14] = 0;
15819 aaDayhoff[14][15] = 245; aaDayhoff[14][16] = 78; aaDayhoff[14][17] = 0; aaDayhoff[14][18] = 0; aaDayhoff[14][19] = 48;
15820 aaDayhoff[15][ 0] = 409; aaDayhoff[15][ 1] = 154; aaDayhoff[15][ 2] = 495; aaDayhoff[15][ 3] = 95; aaDayhoff[15][ 4] = 161;
15821 aaDayhoff[15][ 5] = 56; aaDayhoff[15][ 6] = 79; aaDayhoff[15][ 7] = 234; aaDayhoff[15][ 8] = 35; aaDayhoff[15][ 9] = 24;
15822 aaDayhoff[15][10] = 17; aaDayhoff[15][11] = 96; aaDayhoff[15][12] = 62; aaDayhoff[15][13] = 46; aaDayhoff[15][14] = 245;
15823 aaDayhoff[15][15] = 0; aaDayhoff[15][16] = 550; aaDayhoff[15][17] = 75; aaDayhoff[15][18] = 34; aaDayhoff[15][19] = 30;
15824 aaDayhoff[16][ 0] = 371; aaDayhoff[16][ 1] = 26; aaDayhoff[16][ 2] = 229; aaDayhoff[16][ 3] = 66; aaDayhoff[16][ 4] = 16;
15825 aaDayhoff[16][ 5] = 53; aaDayhoff[16][ 6] = 34; aaDayhoff[16][ 7] = 30; aaDayhoff[16][ 8] = 22; aaDayhoff[16][ 9] = 192;
15826 aaDayhoff[16][10] = 33; aaDayhoff[16][11] = 136; aaDayhoff[16][12] = 104; aaDayhoff[16][13] = 13; aaDayhoff[16][14] = 78;
15827 aaDayhoff[16][15] = 550; aaDayhoff[16][16] = 0; aaDayhoff[16][17] = 0; aaDayhoff[16][18] = 42; aaDayhoff[16][19] = 157;
15828 aaDayhoff[17][ 0] = 0; aaDayhoff[17][ 1] = 201; aaDayhoff[17][ 2] = 23; aaDayhoff[17][ 3] = 0; aaDayhoff[17][ 4] = 0;
15829 aaDayhoff[17][ 5] = 0; aaDayhoff[17][ 6] = 0; aaDayhoff[17][ 7] = 0; aaDayhoff[17][ 8] = 27; aaDayhoff[17][ 9] = 0;
15830 aaDayhoff[17][10] = 46; aaDayhoff[17][11] = 0; aaDayhoff[17][12] = 0; aaDayhoff[17][13] = 76; aaDayhoff[17][14] = 0;
15831 aaDayhoff[17][15] = 75; aaDayhoff[17][16] = 0; aaDayhoff[17][17] = 0; aaDayhoff[17][18] = 61; aaDayhoff[17][19] = 0;
15832 aaDayhoff[18][ 0] = 24; aaDayhoff[18][ 1] = 8; aaDayhoff[18][ 2] = 95; aaDayhoff[18][ 3] = 0; aaDayhoff[18][ 4] = 96;
15833 aaDayhoff[18][ 5] = 0; aaDayhoff[18][ 6] = 22; aaDayhoff[18][ 7] = 0; aaDayhoff[18][ 8] = 127; aaDayhoff[18][ 9] = 37;
15834 aaDayhoff[18][10] = 28; aaDayhoff[18][11] = 13; aaDayhoff[18][12] = 0; aaDayhoff[18][13] = 698; aaDayhoff[18][14] = 0;
15835 aaDayhoff[18][15] = 34; aaDayhoff[18][16] = 42; aaDayhoff[18][17] = 61; aaDayhoff[18][18] = 0; aaDayhoff[18][19] = 28;
15836 aaDayhoff[19][ 0] = 208; aaDayhoff[19][ 1] = 24; aaDayhoff[19][ 2] = 15; aaDayhoff[19][ 3] = 18; aaDayhoff[19][ 4] = 49;
15837 aaDayhoff[19][ 5] = 35; aaDayhoff[19][ 6] = 37; aaDayhoff[19][ 7] = 54; aaDayhoff[19][ 8] = 44; aaDayhoff[19][ 9] = 889;
15838 aaDayhoff[19][10] = 175; aaDayhoff[19][11] = 10; aaDayhoff[19][12] = 258; aaDayhoff[19][13] = 12; aaDayhoff[19][14] = 48;
15839 aaDayhoff[19][15] = 30; aaDayhoff[19][16] = 157; aaDayhoff[19][17] = 0; aaDayhoff[19][18] = 28; aaDayhoff[19][19] = 0;
15841 dayhoffPi[ 0] = 0.087127;
15842 dayhoffPi[ 1] = 0.040904;
15843 dayhoffPi[ 2] = 0.040432;
15844 dayhoffPi[ 3] = 0.046872;
15845 dayhoffPi[ 4] = 0.033474;
15846 dayhoffPi[ 5] = 0.038255;
15847 dayhoffPi[ 6] = 0.049530;
15848 dayhoffPi[ 7] = 0.088612;
15849 dayhoffPi[ 8] = 0.033618;
15850 dayhoffPi[ 9] = 0.036886;
15851 dayhoffPi[10] = 0.085357;
15852 dayhoffPi[11] = 0.080482;
15853 dayhoffPi[12] = 0.014753;
15854 dayhoffPi[13] = 0.039772;
15855 dayhoffPi[14] = 0.050680;
15856 dayhoffPi[15] = 0.069577;
15857 dayhoffPi[16] = 0.058542;
15858 dayhoffPi[17] = 0.010494;
15859 dayhoffPi[18] = 0.029916;
15860 dayhoffPi[19] = 0.064718;
15863 aaMtrev24[ 0][ 0] = 0.00; aaMtrev24[ 0][ 1] = 23.18; aaMtrev24[ 0][ 2] = 26.95; aaMtrev24[ 0][ 3] = 17.67; aaMtrev24[ 0][ 4] = 59.93;
15864 aaMtrev24[ 0][ 5] = 1.90; aaMtrev24[ 0][ 6] = 9.77; aaMtrev24[ 0][ 7] = 120.71; aaMtrev24[ 0][ 8] = 13.90; aaMtrev24[ 0][ 9] = 96.49;
15865 aaMtrev24[ 0][10] = 25.46; aaMtrev24[ 0][11] = 8.36; aaMtrev24[ 0][12] = 141.88; aaMtrev24[ 0][13] = 6.37; aaMtrev24[ 0][14] = 54.31;
15866 aaMtrev24[ 0][15] = 387.86; aaMtrev24[ 0][16] = 480.72; aaMtrev24[ 0][17] = 1.90; aaMtrev24[ 0][18] = 6.48; aaMtrev24[ 0][19] = 195.06;
15867 aaMtrev24[ 1][ 0] = 23.18; aaMtrev24[ 1][ 1] = 0.00; aaMtrev24[ 1][ 2] = 13.24; aaMtrev24[ 1][ 3] = 1.90; aaMtrev24[ 1][ 4] = 103.33;
15868 aaMtrev24[ 1][ 5] = 220.99; aaMtrev24[ 1][ 6] = 1.90; aaMtrev24[ 1][ 7] = 23.03; aaMtrev24[ 1][ 8] = 165.23; aaMtrev24[ 1][ 9] = 1.90;
15869 aaMtrev24[ 1][10] = 15.58; aaMtrev24[ 1][11] = 141.40; aaMtrev24[ 1][12] = 1.90; aaMtrev24[ 1][13] = 4.69; aaMtrev24[ 1][14] = 23.64;
15870 aaMtrev24[ 1][15] = 6.04; aaMtrev24[ 1][16] = 2.08; aaMtrev24[ 1][17] = 21.95; aaMtrev24[ 1][18] = 1.90; aaMtrev24[ 1][19] = 7.64;
15871 aaMtrev24[ 2][ 0] = 26.95; aaMtrev24[ 2][ 1] = 13.24; aaMtrev24[ 2][ 2] = 0.00; aaMtrev24[ 2][ 3] = 794.38; aaMtrev24[ 2][ 4] = 58.94;
15872 aaMtrev24[ 2][ 5] = 173.56; aaMtrev24[ 2][ 6] = 63.05; aaMtrev24[ 2][ 7] = 53.30; aaMtrev24[ 2][ 8] = 496.13; aaMtrev24[ 2][ 9] = 27.10;
15873 aaMtrev24[ 2][10] = 15.16; aaMtrev24[ 2][11] = 608.70; aaMtrev24[ 2][12] = 65.41; aaMtrev24[ 2][13] = 15.20; aaMtrev24[ 2][14] = 73.31;
15874 aaMtrev24[ 2][15] = 494.39; aaMtrev24[ 2][16] = 238.46; aaMtrev24[ 2][17] = 10.68; aaMtrev24[ 2][18] = 191.36; aaMtrev24[ 2][19] = 1.90;
15875 aaMtrev24[ 3][ 0] = 17.67; aaMtrev24[ 3][ 1] = 1.90; aaMtrev24[ 3][ 2] = 794.38; aaMtrev24[ 3][ 3] = 0.00; aaMtrev24[ 3][ 4] = 1.90;
15876 aaMtrev24[ 3][ 5] = 55.28; aaMtrev24[ 3][ 6] = 583.55; aaMtrev24[ 3][ 7] = 56.77; aaMtrev24[ 3][ 8] = 113.99; aaMtrev24[ 3][ 9] = 4.34;
15877 aaMtrev24[ 3][10] = 1.90; aaMtrev24[ 3][11] = 2.31; aaMtrev24[ 3][12] = 1.90; aaMtrev24[ 3][13] = 4.98; aaMtrev24[ 3][14] = 13.43;
15878 aaMtrev24[ 3][15] = 69.02; aaMtrev24[ 3][16] = 28.01; aaMtrev24[ 3][17] = 19.86; aaMtrev24[ 3][18] = 21.21; aaMtrev24[ 3][19] = 1.90;
15879 aaMtrev24[ 4][ 0] = 59.93; aaMtrev24[ 4][ 1] = 103.33; aaMtrev24[ 4][ 2] = 58.94; aaMtrev24[ 4][ 3] = 1.90; aaMtrev24[ 4][ 4] = 0.00;
15880 aaMtrev24[ 4][ 5] = 75.24; aaMtrev24[ 4][ 6] = 1.90; aaMtrev24[ 4][ 7] = 30.71; aaMtrev24[ 4][ 8] = 141.49; aaMtrev24[ 4][ 9] = 62.73;
15881 aaMtrev24[ 4][10] = 25.65; aaMtrev24[ 4][11] = 1.90; aaMtrev24[ 4][12] = 6.18; aaMtrev24[ 4][13] = 70.80; aaMtrev24[ 4][14] = 31.26;
15882 aaMtrev24[ 4][15] = 277.05; aaMtrev24[ 4][16] = 179.97; aaMtrev24[ 4][17] = 33.60; aaMtrev24[ 4][18] = 254.77; aaMtrev24[ 4][19] = 1.90;
15883 aaMtrev24[ 5][ 0] = 1.90; aaMtrev24[ 5][ 1] = 220.99; aaMtrev24[ 5][ 2] = 173.56; aaMtrev24[ 5][ 3] = 55.28; aaMtrev24[ 5][ 4] = 75.24;
15884 aaMtrev24[ 5][ 5] = 0.00; aaMtrev24[ 5][ 6] = 313.56; aaMtrev24[ 5][ 7] = 6.75; aaMtrev24[ 5][ 8] = 582.40; aaMtrev24[ 5][ 9] = 8.34;
15885 aaMtrev24[ 5][10] = 39.70; aaMtrev24[ 5][11] = 465.58; aaMtrev24[ 5][12] = 47.37; aaMtrev24[ 5][13] = 19.11; aaMtrev24[ 5][14] = 137.29;
15886 aaMtrev24[ 5][15] = 54.11; aaMtrev24[ 5][16] = 94.93; aaMtrev24[ 5][17] = 1.90; aaMtrev24[ 5][18] = 38.82; aaMtrev24[ 5][19] = 19.00;
15887 aaMtrev24[ 6][ 0] = 9.77; aaMtrev24[ 6][ 1] = 1.90; aaMtrev24[ 6][ 2] = 63.05; aaMtrev24[ 6][ 3] = 583.55; aaMtrev24[ 6][ 4] = 1.90;
15888 aaMtrev24[ 6][ 5] = 313.56; aaMtrev24[ 6][ 6] = 0.00; aaMtrev24[ 6][ 7] = 28.28; aaMtrev24[ 6][ 8] = 49.12; aaMtrev24[ 6][ 9] = 3.31;
15889 aaMtrev24[ 6][10] = 1.90; aaMtrev24[ 6][11] = 313.86; aaMtrev24[ 6][12] = 1.90; aaMtrev24[ 6][13] = 2.67; aaMtrev24[ 6][14] = 12.83;
15890 aaMtrev24[ 6][15] = 54.71; aaMtrev24[ 6][16] = 14.82; aaMtrev24[ 6][17] = 1.90; aaMtrev24[ 6][18] = 13.12; aaMtrev24[ 6][19] = 21.14;
15891 aaMtrev24[ 7][ 0] = 120.71; aaMtrev24[ 7][ 1] = 23.03; aaMtrev24[ 7][ 2] = 53.30; aaMtrev24[ 7][ 3] = 56.77; aaMtrev24[ 7][ 4] = 30.71;
15892 aaMtrev24[ 7][ 5] = 6.75; aaMtrev24[ 7][ 6] = 28.28; aaMtrev24[ 7][ 7] = 0.00; aaMtrev24[ 7][ 8] = 1.90; aaMtrev24[ 7][ 9] = 5.98;
15893 aaMtrev24[ 7][10] = 2.41; aaMtrev24[ 7][11] = 22.73; aaMtrev24[ 7][12] = 1.90; aaMtrev24[ 7][13] = 1.90; aaMtrev24[ 7][14] = 1.90;
15894 aaMtrev24[ 7][15] = 125.93; aaMtrev24[ 7][16] = 11.17; aaMtrev24[ 7][17] = 10.92; aaMtrev24[ 7][18] = 3.21; aaMtrev24[ 7][19] = 2.53;
15895 aaMtrev24[ 8][ 0] = 13.90; aaMtrev24[ 8][ 1] = 165.23; aaMtrev24[ 8][ 2] = 496.13; aaMtrev24[ 8][ 3] = 113.99; aaMtrev24[ 8][ 4] = 141.49;
15896 aaMtrev24[ 8][ 5] = 582.40; aaMtrev24[ 8][ 6] = 49.12; aaMtrev24[ 8][ 7] = 1.90; aaMtrev24[ 8][ 8] = 0.00; aaMtrev24[ 8][ 9] = 12.26;
15897 aaMtrev24[ 8][10] = 11.49; aaMtrev24[ 8][11] = 127.67; aaMtrev24[ 8][12] = 11.97; aaMtrev24[ 8][13] = 48.16; aaMtrev24[ 8][14] = 60.97;
15898 aaMtrev24[ 8][15] = 77.46; aaMtrev24[ 8][16] = 44.78; aaMtrev24[ 8][17] = 7.08; aaMtrev24[ 8][18] = 670.14; aaMtrev24[ 8][19] = 1.90;
15899 aaMtrev24[ 9][ 0] = 96.49; aaMtrev24[ 9][ 1] = 1.90; aaMtrev24[ 9][ 2] = 27.10; aaMtrev24[ 9][ 3] = 4.34; aaMtrev24[ 9][ 4] = 62.73;
15900 aaMtrev24[ 9][ 5] = 8.34; aaMtrev24[ 9][ 6] = 3.31; aaMtrev24[ 9][ 7] = 5.98; aaMtrev24[ 9][ 8] = 12.26; aaMtrev24[ 9][ 9] = 0.00;
15901 aaMtrev24[ 9][10] = 329.09; aaMtrev24[ 9][11] = 19.57; aaMtrev24[ 9][12] = 517.98; aaMtrev24[ 9][13] = 84.67; aaMtrev24[ 9][14] = 20.63;
15902 aaMtrev24[ 9][15] = 47.70; aaMtrev24[ 9][16] = 368.43; aaMtrev24[ 9][17] = 1.90; aaMtrev24[ 9][18] = 25.01; aaMtrev24[ 9][19] =1222.94;
15903 aaMtrev24[10][ 0] = 25.46; aaMtrev24[10][ 1] = 15.58; aaMtrev24[10][ 2] = 15.16; aaMtrev24[10][ 3] = 1.90; aaMtrev24[10][ 4] = 25.65;
15904 aaMtrev24[10][ 5] = 39.70; aaMtrev24[10][ 6] = 1.90; aaMtrev24[10][ 7] = 2.41; aaMtrev24[10][ 8] = 11.49; aaMtrev24[10][ 9] = 329.09;
15905 aaMtrev24[10][10] = 0.00; aaMtrev24[10][11] = 14.88; aaMtrev24[10][12] = 537.53; aaMtrev24[10][13] = 216.06; aaMtrev24[10][14] = 40.10;
15906 aaMtrev24[10][15] = 73.61; aaMtrev24[10][16] = 126.40; aaMtrev24[10][17] = 32.44; aaMtrev24[10][18] = 44.15; aaMtrev24[10][19] = 91.67;
15907 aaMtrev24[11][ 0] = 8.36; aaMtrev24[11][ 1] = 141.40; aaMtrev24[11][ 2] = 608.70; aaMtrev24[11][ 3] = 2.31; aaMtrev24[11][ 4] = 1.90;
15908 aaMtrev24[11][ 5] = 465.58; aaMtrev24[11][ 6] = 313.86; aaMtrev24[11][ 7] = 22.73; aaMtrev24[11][ 8] = 127.67; aaMtrev24[11][ 9] = 19.57;
15909 aaMtrev24[11][10] = 14.88; aaMtrev24[11][11] = 0.00; aaMtrev24[11][12] = 91.37; aaMtrev24[11][13] = 6.44; aaMtrev24[11][14] = 50.10;
15910 aaMtrev24[11][15] = 105.79; aaMtrev24[11][16] = 136.33; aaMtrev24[11][17] = 24.00; aaMtrev24[11][18] = 51.17; aaMtrev24[11][19] = 1.90;
15911 aaMtrev24[12][ 0] = 141.88; aaMtrev24[12][ 1] = 1.90; aaMtrev24[12][ 2] = 65.41; aaMtrev24[12][ 3] = 1.90; aaMtrev24[12][ 4] = 6.18;
15912 aaMtrev24[12][ 5] = 47.37; aaMtrev24[12][ 6] = 1.90; aaMtrev24[12][ 7] = 1.90; aaMtrev24[12][ 8] = 11.97; aaMtrev24[12][ 9] = 517.98;
15913 aaMtrev24[12][10] = 537.53; aaMtrev24[12][11] = 91.37; aaMtrev24[12][12] = 0.00; aaMtrev24[12][13] = 90.82; aaMtrev24[12][14] = 18.84;
15914 aaMtrev24[12][15] = 111.16; aaMtrev24[12][16] = 528.17; aaMtrev24[12][17] = 21.71; aaMtrev24[12][18] = 39.96; aaMtrev24[12][19] = 387.54;
15915 aaMtrev24[13][ 0] = 6.37; aaMtrev24[13][ 1] = 4.69; aaMtrev24[13][ 2] = 15.20; aaMtrev24[13][ 3] = 4.98; aaMtrev24[13][ 4] = 70.80;
15916 aaMtrev24[13][ 5] = 19.11; aaMtrev24[13][ 6] = 2.67; aaMtrev24[13][ 7] = 1.90; aaMtrev24[13][ 8] = 48.16; aaMtrev24[13][ 9] = 84.67;
15917 aaMtrev24[13][10] = 216.06; aaMtrev24[13][11] = 6.44; aaMtrev24[13][12] = 90.82; aaMtrev24[13][13] = 0.00; aaMtrev24[13][14] = 17.31;
15918 aaMtrev24[13][15] = 64.29; aaMtrev24[13][16] = 33.85; aaMtrev24[13][17] = 7.84; aaMtrev24[13][18] = 465.58; aaMtrev24[13][19] = 6.35;
15919 aaMtrev24[14][ 0] = 54.31; aaMtrev24[14][ 1] = 23.64; aaMtrev24[14][ 2] = 73.31; aaMtrev24[14][ 3] = 13.43; aaMtrev24[14][ 4] = 31.26;
15920 aaMtrev24[14][ 5] = 137.29; aaMtrev24[14][ 6] = 12.83; aaMtrev24[14][ 7] = 1.90; aaMtrev24[14][ 8] = 60.97; aaMtrev24[14][ 9] = 20.63;
15921 aaMtrev24[14][10] = 40.10; aaMtrev24[14][11] = 50.10; aaMtrev24[14][12] = 18.84; aaMtrev24[14][13] = 17.31; aaMtrev24[14][14] = 0.00;
15922 aaMtrev24[14][15] = 169.90; aaMtrev24[14][16] = 128.22; aaMtrev24[14][17] = 4.21; aaMtrev24[14][18] = 16.21; aaMtrev24[14][19] = 8.23;
15923 aaMtrev24[15][ 0] = 387.86; aaMtrev24[15][ 1] = 6.04; aaMtrev24[15][ 2] = 494.39; aaMtrev24[15][ 3] = 69.02; aaMtrev24[15][ 4] = 277.05;
15924 aaMtrev24[15][ 5] = 54.11; aaMtrev24[15][ 6] = 54.71; aaMtrev24[15][ 7] = 125.93; aaMtrev24[15][ 8] = 77.46; aaMtrev24[15][ 9] = 47.70;
15925 aaMtrev24[15][10] = 73.61; aaMtrev24[15][11] = 105.79; aaMtrev24[15][12] = 111.16; aaMtrev24[15][13] = 64.29; aaMtrev24[15][14] = 169.90;
15926 aaMtrev24[15][15] = 0.00; aaMtrev24[15][16] = 597.21; aaMtrev24[15][17] = 38.58; aaMtrev24[15][18] = 64.92; aaMtrev24[15][19] = 1.90;
15927 aaMtrev24[16][ 0] = 480.72; aaMtrev24[16][ 1] = 2.08; aaMtrev24[16][ 2] = 238.46; aaMtrev24[16][ 3] = 28.01; aaMtrev24[16][ 4] = 179.97;
15928 aaMtrev24[16][ 5] = 94.93; aaMtrev24[16][ 6] = 14.82; aaMtrev24[16][ 7] = 11.17; aaMtrev24[16][ 8] = 44.78; aaMtrev24[16][ 9] = 368.43;
15929 aaMtrev24[16][10] = 126.40; aaMtrev24[16][11] = 136.33; aaMtrev24[16][12] = 528.17; aaMtrev24[16][13] = 33.85; aaMtrev24[16][14] = 128.22;
15930 aaMtrev24[16][15] = 597.21; aaMtrev24[16][16] = 0.00; aaMtrev24[16][17] = 9.99; aaMtrev24[16][18] = 38.73; aaMtrev24[16][19] = 204.54;
15931 aaMtrev24[17][ 0] = 1.90; aaMtrev24[17][ 1] = 21.95; aaMtrev24[17][ 2] = 10.68; aaMtrev24[17][ 3] = 19.86; aaMtrev24[17][ 4] = 33.60;
15932 aaMtrev24[17][ 5] = 1.90; aaMtrev24[17][ 6] = 1.90; aaMtrev24[17][ 7] = 10.92; aaMtrev24[17][ 8] = 7.08; aaMtrev24[17][ 9] = 1.90;
15933 aaMtrev24[17][10] = 32.44; aaMtrev24[17][11] = 24.00; aaMtrev24[17][12] = 21.71; aaMtrev24[17][13] = 7.84; aaMtrev24[17][14] = 4.21;
15934 aaMtrev24[17][15] = 38.58; aaMtrev24[17][16] = 9.99; aaMtrev24[17][17] = 0.00; aaMtrev24[17][18] = 26.25; aaMtrev24[17][19] = 5.37;
15935 aaMtrev24[18][ 0] = 6.48; aaMtrev24[18][ 1] = 1.90; aaMtrev24[18][ 2] = 191.36; aaMtrev24[18][ 3] = 21.21; aaMtrev24[18][ 4] = 254.77;
15936 aaMtrev24[18][ 5] = 38.82; aaMtrev24[18][ 6] = 13.12; aaMtrev24[18][ 7] = 3.21; aaMtrev24[18][ 8] = 670.14; aaMtrev24[18][ 9] = 25.01;
15937 aaMtrev24[18][10] = 44.15; aaMtrev24[18][11] = 51.17; aaMtrev24[18][12] = 39.96; aaMtrev24[18][13] = 465.58; aaMtrev24[18][14] = 16.21;
15938 aaMtrev24[18][15] = 64.92; aaMtrev24[18][16] = 38.73; aaMtrev24[18][17] = 26.25; aaMtrev24[18][18] = 0.00; aaMtrev24[18][19] = 1.90;
15939 aaMtrev24[19][ 0] = 195.06; aaMtrev24[19][ 1] = 7.64; aaMtrev24[19][ 2] = 1.90; aaMtrev24[19][ 3] = 1.90; aaMtrev24[19][ 4] = 1.90;
15940 aaMtrev24[19][ 5] = 19.00; aaMtrev24[19][ 6] = 21.14; aaMtrev24[19][ 7] = 2.53; aaMtrev24[19][ 8] = 1.90; aaMtrev24[19][ 9] =1222.94;
15941 aaMtrev24[19][10] = 91.67; aaMtrev24[19][11] = 1.90; aaMtrev24[19][12] = 387.54; aaMtrev24[19][13] = 6.35; aaMtrev24[19][14] = 8.23;
15942 aaMtrev24[19][15] = 1.90; aaMtrev24[19][16] = 204.54; aaMtrev24[19][17] = 5.37; aaMtrev24[19][18] = 1.90; aaMtrev24[19][19] = 0.00;
15944 mtrev24Pi[ 0] = 0.072;
15945 mtrev24Pi[ 1] = 0.019;
15946 mtrev24Pi[ 2] = 0.039;
15947 mtrev24Pi[ 3] = 0.019;
15948 mtrev24Pi[ 4] = 0.006;
15949 mtrev24Pi[ 5] = 0.025;
15950 mtrev24Pi[ 6] = 0.024;
15951 mtrev24Pi[ 7] = 0.056;
15952 mtrev24Pi[ 8] = 0.028;
15953 mtrev24Pi[ 9] = 0.088;
15954 mtrev24Pi[10] = 0.168;
15955 mtrev24Pi[11] = 0.023;
15956 mtrev24Pi[12] = 0.054;
15957 mtrev24Pi[13] = 0.061;
15958 mtrev24Pi[14] = 0.054;
15959 mtrev24Pi[15] = 0.072;
15960 mtrev24Pi[16] = 0.086;
15961 mtrev24Pi[17] = 0.029;
15962 mtrev24Pi[18] = 0.033;
15963 mtrev24Pi[19] = 0.043;
15966 aaMtmam[ 0][ 0] = 0; aaMtmam[ 0][ 1] = 32; aaMtmam[ 0][ 2] = 2; aaMtmam[ 0][ 3] = 11; aaMtmam[ 0][ 4] = 0;
15967 aaMtmam[ 0][ 5] = 0; aaMtmam[ 0][ 6] = 0; aaMtmam[ 0][ 7] = 78; aaMtmam[ 0][ 8] = 8; aaMtmam[ 0][ 9] = 75;
15968 aaMtmam[ 0][10] = 21; aaMtmam[ 0][11] = 0; aaMtmam[ 0][12] = 76; aaMtmam[ 0][13] = 0; aaMtmam[ 0][14] = 53;
15969 aaMtmam[ 0][15] = 342; aaMtmam[ 0][16] = 681; aaMtmam[ 0][17] = 5; aaMtmam[ 0][18] = 0; aaMtmam[ 0][19] = 398;
15970 aaMtmam[ 1][ 0] = 32; aaMtmam[ 1][ 1] = 0; aaMtmam[ 1][ 2] = 4; aaMtmam[ 1][ 3] = 0; aaMtmam[ 1][ 4] = 186;
15971 aaMtmam[ 1][ 5] = 246; aaMtmam[ 1][ 6] = 0; aaMtmam[ 1][ 7] = 18; aaMtmam[ 1][ 8] = 232; aaMtmam[ 1][ 9] = 0;
15972 aaMtmam[ 1][10] = 6; aaMtmam[ 1][11] = 50; aaMtmam[ 1][12] = 0; aaMtmam[ 1][13] = 0; aaMtmam[ 1][14] = 9;
15973 aaMtmam[ 1][15] = 3; aaMtmam[ 1][16] = 0; aaMtmam[ 1][17] = 16; aaMtmam[ 1][18] = 0; aaMtmam[ 1][19] = 0;
15974 aaMtmam[ 2][ 0] = 2; aaMtmam[ 2][ 1] = 4; aaMtmam[ 2][ 2] = 0; aaMtmam[ 2][ 3] = 864; aaMtmam[ 2][ 4] = 0;
15975 aaMtmam[ 2][ 5] = 8; aaMtmam[ 2][ 6] = 0; aaMtmam[ 2][ 7] = 47; aaMtmam[ 2][ 8] = 458; aaMtmam[ 2][ 9] = 19;
15976 aaMtmam[ 2][10] = 0; aaMtmam[ 2][11] = 408; aaMtmam[ 2][12] = 21; aaMtmam[ 2][13] = 6; aaMtmam[ 2][14] = 33;
15977 aaMtmam[ 2][15] = 446; aaMtmam[ 2][16] = 110; aaMtmam[ 2][17] = 6; aaMtmam[ 2][18] = 156; aaMtmam[ 2][19] = 0;
15978 aaMtmam[ 3][ 0] = 11; aaMtmam[ 3][ 1] = 0; aaMtmam[ 3][ 2] = 864; aaMtmam[ 3][ 3] = 0; aaMtmam[ 3][ 4] = 0;
15979 aaMtmam[ 3][ 5] = 49; aaMtmam[ 3][ 6] = 569; aaMtmam[ 3][ 7] = 79; aaMtmam[ 3][ 8] = 11; aaMtmam[ 3][ 9] = 0;
15980 aaMtmam[ 3][10] = 0; aaMtmam[ 3][11] = 0; aaMtmam[ 3][12] = 0; aaMtmam[ 3][13] = 5; aaMtmam[ 3][14] = 2;
15981 aaMtmam[ 3][15] = 16; aaMtmam[ 3][16] = 0; aaMtmam[ 3][17] = 0; aaMtmam[ 3][18] = 0; aaMtmam[ 3][19] = 10;
15982 aaMtmam[ 4][ 0] = 0; aaMtmam[ 4][ 1] = 186; aaMtmam[ 4][ 2] = 0; aaMtmam[ 4][ 3] = 0; aaMtmam[ 4][ 4] = 0;
15983 aaMtmam[ 4][ 5] = 0; aaMtmam[ 4][ 6] = 0; aaMtmam[ 4][ 7] = 0; aaMtmam[ 4][ 8] = 305; aaMtmam[ 4][ 9] = 41;
15984 aaMtmam[ 4][10] = 27; aaMtmam[ 4][11] = 0; aaMtmam[ 4][12] = 0; aaMtmam[ 4][13] = 7; aaMtmam[ 4][14] = 0;
15985 aaMtmam[ 4][15] = 347; aaMtmam[ 4][16] = 114; aaMtmam[ 4][17] = 65; aaMtmam[ 4][18] = 530; aaMtmam[ 4][19] = 0;
15986 aaMtmam[ 5][ 0] = 0; aaMtmam[ 5][ 1] = 246; aaMtmam[ 5][ 2] = 8; aaMtmam[ 5][ 3] = 49; aaMtmam[ 5][ 4] = 0;
15987 aaMtmam[ 5][ 5] = 0; aaMtmam[ 5][ 6] = 274; aaMtmam[ 5][ 7] = 0; aaMtmam[ 5][ 8] = 550; aaMtmam[ 5][ 9] = 0;
15988 aaMtmam[ 5][10] = 20; aaMtmam[ 5][11] = 242; aaMtmam[ 5][12] = 22; aaMtmam[ 5][13] = 0; aaMtmam[ 5][14] = 51;
15989 aaMtmam[ 5][15] = 30; aaMtmam[ 5][16] = 0; aaMtmam[ 5][17] = 0; aaMtmam[ 5][18] = 54; aaMtmam[ 5][19] = 33;
15990 aaMtmam[ 6][ 0] = 0; aaMtmam[ 6][ 1] = 0; aaMtmam[ 6][ 2] = 0; aaMtmam[ 6][ 3] = 569; aaMtmam[ 6][ 4] = 0;
15991 aaMtmam[ 6][ 5] = 274; aaMtmam[ 6][ 6] = 0; aaMtmam[ 6][ 7] = 22; aaMtmam[ 6][ 8] = 22; aaMtmam[ 6][ 9] = 0;
15992 aaMtmam[ 6][10] = 0; aaMtmam[ 6][11] = 215; aaMtmam[ 6][12] = 0; aaMtmam[ 6][13] = 0; aaMtmam[ 6][14] = 0;
15993 aaMtmam[ 6][15] = 21; aaMtmam[ 6][16] = 4; aaMtmam[ 6][17] = 0; aaMtmam[ 6][18] = 0; aaMtmam[ 6][19] = 20;
15994 aaMtmam[ 7][ 0] = 78; aaMtmam[ 7][ 1] = 18; aaMtmam[ 7][ 2] = 47; aaMtmam[ 7][ 3] = 79; aaMtmam[ 7][ 4] = 0;
15995 aaMtmam[ 7][ 5] = 0; aaMtmam[ 7][ 6] = 22; aaMtmam[ 7][ 7] = 0; aaMtmam[ 7][ 8] = 0; aaMtmam[ 7][ 9] = 0;
15996 aaMtmam[ 7][10] = 0; aaMtmam[ 7][11] = 0; aaMtmam[ 7][12] = 0; aaMtmam[ 7][13] = 0; aaMtmam[ 7][14] = 0;
15997 aaMtmam[ 7][15] = 112; aaMtmam[ 7][16] = 0; aaMtmam[ 7][17] = 0; aaMtmam[ 7][18] = 1; aaMtmam[ 7][19] = 5;
15998 aaMtmam[ 8][ 0] = 8; aaMtmam[ 8][ 1] = 232; aaMtmam[ 8][ 2] = 458; aaMtmam[ 8][ 3] = 11; aaMtmam[ 8][ 4] = 305;
15999 aaMtmam[ 8][ 5] = 550; aaMtmam[ 8][ 6] = 22; aaMtmam[ 8][ 7] = 0; aaMtmam[ 8][ 8] = 0; aaMtmam[ 8][ 9] = 0;
16000 aaMtmam[ 8][10] = 26; aaMtmam[ 8][11] = 0; aaMtmam[ 8][12] = 0; aaMtmam[ 8][13] = 0; aaMtmam[ 8][14] = 53;
16001 aaMtmam[ 8][15] = 20; aaMtmam[ 8][16] = 1; aaMtmam[ 8][17] = 0; aaMtmam[ 8][18] =1525; aaMtmam[ 8][19] = 0;
16002 aaMtmam[ 9][ 0] = 75; aaMtmam[ 9][ 1] = 0; aaMtmam[ 9][ 2] = 19; aaMtmam[ 9][ 3] = 0; aaMtmam[ 9][ 4] = 41;
16003 aaMtmam[ 9][ 5] = 0; aaMtmam[ 9][ 6] = 0; aaMtmam[ 9][ 7] = 0; aaMtmam[ 9][ 8] = 0; aaMtmam[ 9][ 9] = 0;
16004 aaMtmam[ 9][10] = 232; aaMtmam[ 9][11] = 6; aaMtmam[ 9][12] = 378; aaMtmam[ 9][13] = 57; aaMtmam[ 9][14] = 5;
16005 aaMtmam[ 9][15] = 0; aaMtmam[ 9][16] = 360; aaMtmam[ 9][17] = 0; aaMtmam[ 9][18] = 16; aaMtmam[ 9][19] =2220;
16006 aaMtmam[10][ 0] = 21; aaMtmam[10][ 1] = 6; aaMtmam[10][ 2] = 0; aaMtmam[10][ 3] = 0; aaMtmam[10][ 4] = 27;
16007 aaMtmam[10][ 5] = 20; aaMtmam[10][ 6] = 0; aaMtmam[10][ 7] = 0; aaMtmam[10][ 8] = 26; aaMtmam[10][ 9] = 232;
16008 aaMtmam[10][10] = 0; aaMtmam[10][11] = 4; aaMtmam[10][12] = 609; aaMtmam[10][13] = 246; aaMtmam[10][14] = 43;
16009 aaMtmam[10][15] = 74; aaMtmam[10][16] = 34; aaMtmam[10][17] = 12; aaMtmam[10][18] = 25; aaMtmam[10][19] = 100;
16010 aaMtmam[11][ 0] = 0; aaMtmam[11][ 1] = 50; aaMtmam[11][ 2] = 408; aaMtmam[11][ 3] = 0; aaMtmam[11][ 4] = 0;
16011 aaMtmam[11][ 5] = 242; aaMtmam[11][ 6] = 215; aaMtmam[11][ 7] = 0; aaMtmam[11][ 8] = 0; aaMtmam[11][ 9] = 6;
16012 aaMtmam[11][10] = 4; aaMtmam[11][11] = 0; aaMtmam[11][12] = 59; aaMtmam[11][13] = 0; aaMtmam[11][14] = 18;
16013 aaMtmam[11][15] = 65; aaMtmam[11][16] = 50; aaMtmam[11][17] = 0; aaMtmam[11][18] = 67; aaMtmam[11][19] = 0;
16014 aaMtmam[12][ 0] = 76; aaMtmam[12][ 1] = 0; aaMtmam[12][ 2] = 21; aaMtmam[12][ 3] = 0; aaMtmam[12][ 4] = 0;
16015 aaMtmam[12][ 5] = 22; aaMtmam[12][ 6] = 0; aaMtmam[12][ 7] = 0; aaMtmam[12][ 8] = 0; aaMtmam[12][ 9] = 378;
16016 aaMtmam[12][10] = 609; aaMtmam[12][11] = 59; aaMtmam[12][12] = 0; aaMtmam[12][13] = 11; aaMtmam[12][14] = 0;
16017 aaMtmam[12][15] = 47; aaMtmam[12][16] = 691; aaMtmam[12][17] = 13; aaMtmam[12][18] = 0; aaMtmam[12][19] = 832;
16018 aaMtmam[13][ 0] = 0; aaMtmam[13][ 1] = 0; aaMtmam[13][ 2] = 6; aaMtmam[13][ 3] = 5; aaMtmam[13][ 4] = 7;
16019 aaMtmam[13][ 5] = 0; aaMtmam[13][ 6] = 0; aaMtmam[13][ 7] = 0; aaMtmam[13][ 8] = 0; aaMtmam[13][ 9] = 57;
16020 aaMtmam[13][10] = 246; aaMtmam[13][11] = 0; aaMtmam[13][12] = 11; aaMtmam[13][13] = 0; aaMtmam[13][14] = 17;
16021 aaMtmam[13][15] = 90; aaMtmam[13][16] = 8; aaMtmam[13][17] = 0; aaMtmam[13][18] = 682; aaMtmam[13][19] = 6;
16022 aaMtmam[14][ 0] = 53; aaMtmam[14][ 1] = 9; aaMtmam[14][ 2] = 33; aaMtmam[14][ 3] = 2; aaMtmam[14][ 4] = 0;
16023 aaMtmam[14][ 5] = 51; aaMtmam[14][ 6] = 0; aaMtmam[14][ 7] = 0; aaMtmam[14][ 8] = 53; aaMtmam[14][ 9] = 5;
16024 aaMtmam[14][10] = 43; aaMtmam[14][11] = 18; aaMtmam[14][12] = 0; aaMtmam[14][13] = 17; aaMtmam[14][14] = 0;
16025 aaMtmam[14][15] = 202; aaMtmam[14][16] = 78; aaMtmam[14][17] = 7; aaMtmam[14][18] = 8; aaMtmam[14][19] = 0;
16026 aaMtmam[15][ 0] = 342; aaMtmam[15][ 1] = 3; aaMtmam[15][ 2] = 446; aaMtmam[15][ 3] = 16; aaMtmam[15][ 4] = 347;
16027 aaMtmam[15][ 5] = 30; aaMtmam[15][ 6] = 21; aaMtmam[15][ 7] = 112; aaMtmam[15][ 8] = 20; aaMtmam[15][ 9] = 0;
16028 aaMtmam[15][10] = 74; aaMtmam[15][11] = 65; aaMtmam[15][12] = 47; aaMtmam[15][13] = 90; aaMtmam[15][14] = 202;
16029 aaMtmam[15][15] = 0; aaMtmam[15][16] = 614; aaMtmam[15][17] = 17; aaMtmam[15][18] = 107; aaMtmam[15][19] = 0;
16030 aaMtmam[16][ 0] = 681; aaMtmam[16][ 1] = 0; aaMtmam[16][ 2] = 110; aaMtmam[16][ 3] = 0; aaMtmam[16][ 4] = 114;
16031 aaMtmam[16][ 5] = 0; aaMtmam[16][ 6] = 4; aaMtmam[16][ 7] = 0; aaMtmam[16][ 8] = 1; aaMtmam[16][ 9] = 360;
16032 aaMtmam[16][10] = 34; aaMtmam[16][11] = 50; aaMtmam[16][12] = 691; aaMtmam[16][13] = 8; aaMtmam[16][14] = 78;
16033 aaMtmam[16][15] = 614; aaMtmam[16][16] = 0; aaMtmam[16][17] = 0; aaMtmam[16][18] = 0; aaMtmam[16][19] = 237;
16034 aaMtmam[17][ 0] = 5; aaMtmam[17][ 1] = 16; aaMtmam[17][ 2] = 6; aaMtmam[17][ 3] = 0; aaMtmam[17][ 4] = 65;
16035 aaMtmam[17][ 5] = 0; aaMtmam[17][ 6] = 0; aaMtmam[17][ 7] = 0; aaMtmam[17][ 8] = 0; aaMtmam[17][ 9] = 0;
16036 aaMtmam[17][10] = 12; aaMtmam[17][11] = 0; aaMtmam[17][12] = 13; aaMtmam[17][13] = 0; aaMtmam[17][14] = 7;
16037 aaMtmam[17][15] = 17; aaMtmam[17][16] = 0; aaMtmam[17][17] = 0; aaMtmam[17][18] = 14; aaMtmam[17][19] = 0;
16038 aaMtmam[18][ 0] = 0; aaMtmam[18][ 1] = 0; aaMtmam[18][ 2] = 156; aaMtmam[18][ 3] = 0; aaMtmam[18][ 4] = 530;
16039 aaMtmam[18][ 5] = 54; aaMtmam[18][ 6] = 0; aaMtmam[18][ 7] = 1; aaMtmam[18][ 8] =1525; aaMtmam[18][ 9] = 16;
16040 aaMtmam[18][10] = 25; aaMtmam[18][11] = 67; aaMtmam[18][12] = 0; aaMtmam[18][13] = 682; aaMtmam[18][14] = 8;
16041 aaMtmam[18][15] = 107; aaMtmam[18][16] = 0; aaMtmam[18][17] = 14; aaMtmam[18][18] = 0; aaMtmam[18][19] = 0;
16042 aaMtmam[19][ 0] = 398; aaMtmam[19][ 1] = 0; aaMtmam[19][ 2] = 0; aaMtmam[19][ 3] = 10; aaMtmam[19][ 4] = 0;
16043 aaMtmam[19][ 5] = 33; aaMtmam[19][ 6] = 20; aaMtmam[19][ 7] = 5; aaMtmam[19][ 8] = 0; aaMtmam[19][ 9] =2220;
16044 aaMtmam[19][10] = 100; aaMtmam[19][11] = 0; aaMtmam[19][12] = 832; aaMtmam[19][13] = 6; aaMtmam[19][14] = 0;
16045 aaMtmam[19][15] = 0; aaMtmam[19][16] = 237; aaMtmam[19][17] = 0; aaMtmam[19][18] = 0; aaMtmam[19][19] = 0;
16047 mtmamPi[ 0] = 0.0692;
16048 mtmamPi[ 1] = 0.0184;
16049 mtmamPi[ 2] = 0.0400;
16050 mtmamPi[ 3] = 0.0186;
16051 mtmamPi[ 4] = 0.0065;
16052 mtmamPi[ 5] = 0.0238;
16053 mtmamPi[ 6] = 0.0236;
16054 mtmamPi[ 7] = 0.0557;
16055 mtmamPi[ 8] = 0.0277;
16056 mtmamPi[ 9] = 0.0905;
16057 mtmamPi[10] = 0.1675;
16058 mtmamPi[11] = 0.0221;
16059 mtmamPi[12] = 0.0561;
16060 mtmamPi[13] = 0.0611;
16061 mtmamPi[14] = 0.0536;
16062 mtmamPi[15] = 0.0725;
16063 mtmamPi[16] = 0.0870;
16064 mtmamPi[17] = 0.0293;
16065 mtmamPi[18] = 0.0340;
16066 mtmamPi[19] = 0.0428;
16069 aartREV[ 0][ 0] = 0; aartREV[ 1][ 0] = 34; aartREV[ 2][ 0] = 51; aartREV[ 3][ 0] = 10; aartREV[ 4][ 0] = 439;
16070 aartREV[ 5][ 0] = 32; aartREV[ 6][ 0] = 81; aartREV[ 7][ 0] = 135; aartREV[ 8][ 0] = 30; aartREV[ 9][ 0] = 1;
16071 aartREV[10][ 0] = 45; aartREV[11][ 0] = 38; aartREV[12][ 0] = 235; aartREV[13][ 0] = 1; aartREV[14][ 0] = 97;
16072 aartREV[15][ 0] = 460; aartREV[16][ 0] = 258; aartREV[17][ 0] = 5; aartREV[18][ 0] = 55; aartREV[19][ 0] = 197;
16073 aartREV[ 0][ 1] = 34; aartREV[ 1][ 1] = 0; aartREV[ 2][ 1] = 35; aartREV[ 3][ 1] = 30; aartREV[ 4][ 1] = 92;
16074 aartREV[ 5][ 1] = 221; aartREV[ 6][ 1] = 10; aartREV[ 7][ 1] = 41; aartREV[ 8][ 1] = 90; aartREV[ 9][ 1] = 24;
16075 aartREV[10][ 1] = 18; aartREV[11][ 1] = 593; aartREV[12][ 1] = 57; aartREV[13][ 1] = 7; aartREV[14][ 1] = 24;
16076 aartREV[15][ 1] = 102; aartREV[16][ 1] = 64; aartREV[17][ 1] = 13; aartREV[18][ 1] = 47; aartREV[19][ 1] = 29;
16077 aartREV[ 0][ 2] = 51; aartREV[ 1][ 2] = 35; aartREV[ 2][ 2] = 0; aartREV[ 3][ 2] = 384; aartREV[ 4][ 2] = 128;
16078 aartREV[ 5][ 2] = 236; aartREV[ 6][ 2] = 79; aartREV[ 7][ 2] = 94; aartREV[ 8][ 2] = 320; aartREV[ 9][ 2] = 35;
16079 aartREV[10][ 2] = 15; aartREV[11][ 2] = 123; aartREV[12][ 2] = 1; aartREV[13][ 2] = 49; aartREV[14][ 2] = 33;
16080 aartREV[15][ 2] = 294; aartREV[16][ 2] = 148; aartREV[17][ 2] = 16; aartREV[18][ 2] = 28; aartREV[19][ 2] = 21;
16081 aartREV[ 0][ 3] = 10; aartREV[ 1][ 3] = 30; aartREV[ 2][ 3] = 384; aartREV[ 3][ 3] = 0; aartREV[ 4][ 3] = 1;
16082 aartREV[ 5][ 3] = 78; aartREV[ 6][ 3] = 542; aartREV[ 7][ 3] = 61; aartREV[ 8][ 3] = 91; aartREV[ 9][ 3] = 1;
16083 aartREV[10][ 3] = 5; aartREV[11][ 3] = 20; aartREV[12][ 3] = 1; aartREV[13][ 3] = 1; aartREV[14][ 3] = 55;
16084 aartREV[15][ 3] = 136; aartREV[16][ 3] = 55; aartREV[17][ 3] = 1; aartREV[18][ 3] = 1; aartREV[19][ 3] = 6;
16085 aartREV[ 0][ 4] = 439; aartREV[ 1][ 4] = 92; aartREV[ 2][ 4] = 128; aartREV[ 3][ 4] = 1; aartREV[ 4][ 4] = 0;
16086 aartREV[ 5][ 4] = 70; aartREV[ 6][ 4] = 1; aartREV[ 7][ 4] = 48; aartREV[ 8][ 4] = 124; aartREV[ 9][ 4] = 104;
16087 aartREV[10][ 4] = 110; aartREV[11][ 4] = 16; aartREV[12][ 4] = 156; aartREV[13][ 4] = 70; aartREV[14][ 4] = 1;
16088 aartREV[15][ 4] = 75; aartREV[16][ 4] = 117; aartREV[17][ 4] = 55; aartREV[18][ 4] = 131; aartREV[19][ 4] = 295;
16089 aartREV[ 0][ 5] = 32; aartREV[ 1][ 5] = 221; aartREV[ 2][ 5] = 236; aartREV[ 3][ 5] = 78; aartREV[ 4][ 5] = 70;
16090 aartREV[ 5][ 5] = 0; aartREV[ 6][ 5] = 372; aartREV[ 7][ 5] = 18; aartREV[ 8][ 5] = 387; aartREV[ 9][ 5] = 33;
16091 aartREV[10][ 5] = 54; aartREV[11][ 5] = 309; aartREV[12][ 5] = 158; aartREV[13][ 5] = 1; aartREV[14][ 5] = 68;
16092 aartREV[15][ 5] = 225; aartREV[16][ 5] = 146; aartREV[17][ 5] = 10; aartREV[18][ 5] = 45; aartREV[19][ 5] = 36;
16093 aartREV[ 0][ 6] = 81; aartREV[ 1][ 6] = 10; aartREV[ 2][ 6] = 79; aartREV[ 3][ 6] = 542; aartREV[ 4][ 6] = 1;
16094 aartREV[ 5][ 6] = 372; aartREV[ 6][ 6] = 0; aartREV[ 7][ 6] = 70; aartREV[ 8][ 6] = 34; aartREV[ 9][ 6] = 1;
16095 aartREV[10][ 6] = 21; aartREV[11][ 6] = 141; aartREV[12][ 6] = 1; aartREV[13][ 6] = 1; aartREV[14][ 6] = 52;
16096 aartREV[15][ 6] = 95; aartREV[16][ 6] = 82; aartREV[17][ 6] = 17; aartREV[18][ 6] = 1; aartREV[19][ 6] = 35;
16097 aartREV[ 0][ 7] = 135; aartREV[ 1][ 7] = 41; aartREV[ 2][ 7] = 94; aartREV[ 3][ 7] = 61; aartREV[ 4][ 7] = 48;
16098 aartREV[ 5][ 7] = 18; aartREV[ 6][ 7] = 70; aartREV[ 7][ 7] = 0; aartREV[ 8][ 7] = 68; aartREV[ 9][ 7] = 1;
16099 aartREV[10][ 7] = 3; aartREV[11][ 7] = 30; aartREV[12][ 7] = 37; aartREV[13][ 7] = 7; aartREV[14][ 7] = 17;
16100 aartREV[15][ 7] = 152; aartREV[16][ 7] = 7; aartREV[17][ 7] = 23; aartREV[18][ 7] = 21; aartREV[19][ 7] = 3;
16101 aartREV[ 0][ 8] = 30; aartREV[ 1][ 8] = 90; aartREV[ 2][ 8] = 320; aartREV[ 3][ 8] = 91; aartREV[ 4][ 8] = 124;
16102 aartREV[ 5][ 8] = 387; aartREV[ 6][ 8] = 34; aartREV[ 7][ 8] = 68; aartREV[ 8][ 8] = 0; aartREV[ 9][ 8] = 34;
16103 aartREV[10][ 8] = 51; aartREV[11][ 8] = 76; aartREV[12][ 8] = 116; aartREV[13][ 8] = 141; aartREV[14][ 8] = 44;
16104 aartREV[15][ 8] = 183; aartREV[16][ 8] = 49; aartREV[17][ 8] = 48; aartREV[18][ 8] = 307; aartREV[19][ 8] = 1;
16105 aartREV[ 0][ 9] = 1; aartREV[ 1][ 9] = 24; aartREV[ 2][ 9] = 35; aartREV[ 3][ 9] = 1; aartREV[ 4][ 9] = 104;
16106 aartREV[ 5][ 9] = 33; aartREV[ 6][ 9] = 1; aartREV[ 7][ 9] = 1; aartREV[ 8][ 9] = 34; aartREV[ 9][ 9] = 0;
16107 aartREV[10][ 9] = 385; aartREV[11][ 9] = 34; aartREV[12][ 9] = 375; aartREV[13][ 9] = 64; aartREV[14][ 9] = 10;
16108 aartREV[15][ 9] = 4; aartREV[16][ 9] = 72; aartREV[17][ 9] = 39; aartREV[18][ 9] = 26; aartREV[19][ 9] =1048;
16109 aartREV[ 0][10] = 45; aartREV[ 1][10] = 18; aartREV[ 2][10] = 15; aartREV[ 3][10] = 5; aartREV[ 4][10] = 110;
16110 aartREV[ 5][10] = 54; aartREV[ 6][10] = 21; aartREV[ 7][10] = 3; aartREV[ 8][10] = 51; aartREV[ 9][10] = 385;
16111 aartREV[10][10] = 0; aartREV[11][10] = 23; aartREV[12][10] = 581; aartREV[13][10] = 179; aartREV[14][10] = 22;
16112 aartREV[15][10] = 24; aartREV[16][10] = 25; aartREV[17][10] = 47; aartREV[18][10] = 64; aartREV[19][10] = 112;
16113 aartREV[ 0][11] = 38; aartREV[ 1][11] = 593; aartREV[ 2][11] = 123; aartREV[ 3][11] = 20; aartREV[ 4][11] = 16;
16114 aartREV[ 5][11] = 309; aartREV[ 6][11] = 141; aartREV[ 7][11] = 30; aartREV[ 8][11] = 76; aartREV[ 9][11] = 34;
16115 aartREV[10][11] = 23; aartREV[11][11] = 0; aartREV[12][11] = 134; aartREV[13][11] = 14; aartREV[14][11] = 43;
16116 aartREV[15][11] = 77; aartREV[16][11] = 110; aartREV[17][11] = 6; aartREV[18][11] = 1; aartREV[19][11] = 19;
16117 aartREV[ 0][12] = 235; aartREV[ 1][12] = 57; aartREV[ 2][12] = 1; aartREV[ 3][12] = 1; aartREV[ 4][12] = 156;
16118 aartREV[ 5][12] = 158; aartREV[ 6][12] = 1; aartREV[ 7][12] = 37; aartREV[ 8][12] = 116; aartREV[ 9][12] = 375;
16119 aartREV[10][12] = 581; aartREV[11][12] = 134; aartREV[12][12] = 0; aartREV[13][12] = 247; aartREV[14][12] = 1;
16120 aartREV[15][12] = 1; aartREV[16][12] = 131; aartREV[17][12] = 111; aartREV[18][12] = 74; aartREV[19][12] = 236;
16121 aartREV[ 0][13] = 1; aartREV[ 1][13] = 7; aartREV[ 2][13] = 49; aartREV[ 3][13] = 1; aartREV[ 4][13] = 70;
16122 aartREV[ 5][13] = 1; aartREV[ 6][13] = 1; aartREV[ 7][13] = 7; aartREV[ 8][13] = 141; aartREV[ 9][13] = 64;
16123 aartREV[10][13] = 179; aartREV[11][13] = 14; aartREV[12][13] = 247; aartREV[13][13] = 0; aartREV[14][13] = 11;
16124 aartREV[15][13] = 20; aartREV[16][13] = 69; aartREV[17][13] = 182; aartREV[18][13] =1017; aartREV[19][13] = 92;
16125 aartREV[ 0][14] = 97; aartREV[ 1][14] = 24; aartREV[ 2][14] = 33; aartREV[ 3][14] = 55; aartREV[ 4][14] = 1;
16126 aartREV[ 5][14] = 68; aartREV[ 6][14] = 52; aartREV[ 7][14] = 17; aartREV[ 8][14] = 44; aartREV[ 9][14] = 10;
16127 aartREV[10][14] = 22; aartREV[11][14] = 43; aartREV[12][14] = 1; aartREV[13][14] = 11; aartREV[14][14] = 0;
16128 aartREV[15][14] = 134; aartREV[16][14] = 62; aartREV[17][14] = 9; aartREV[18][14] = 14; aartREV[19][14] = 25;
16129 aartREV[ 0][15] = 460; aartREV[ 1][15] = 102; aartREV[ 2][15] = 294; aartREV[ 3][15] = 136; aartREV[ 4][15] = 75;
16130 aartREV[ 5][15] = 225; aartREV[ 6][15] = 95; aartREV[ 7][15] = 152; aartREV[ 8][15] = 183; aartREV[ 9][15] = 4;
16131 aartREV[10][15] = 24; aartREV[11][15] = 77; aartREV[12][15] = 1; aartREV[13][15] = 20; aartREV[14][15] = 134;
16132 aartREV[15][15] = 0; aartREV[16][15] = 671; aartREV[17][15] = 14; aartREV[18][15] = 31; aartREV[19][15] = 39;
16133 aartREV[ 0][16] = 258; aartREV[ 1][16] = 64; aartREV[ 2][16] = 148; aartREV[ 3][16] = 55; aartREV[ 4][16] = 117;
16134 aartREV[ 5][16] = 146; aartREV[ 6][16] = 82; aartREV[ 7][16] = 7; aartREV[ 8][16] = 49; aartREV[ 9][16] = 72;
16135 aartREV[10][16] = 25; aartREV[11][16] = 110; aartREV[12][16] = 131; aartREV[13][16] = 69; aartREV[14][16] = 62;
16136 aartREV[15][16] = 671; aartREV[16][16] = 0; aartREV[17][16] = 1; aartREV[18][16] = 34; aartREV[19][16] = 196;
16137 aartREV[ 0][17] = 5; aartREV[ 1][17] = 13; aartREV[ 2][17] = 16; aartREV[ 3][17] = 1; aartREV[ 4][17] = 55;
16138 aartREV[ 5][17] = 10; aartREV[ 6][17] = 17; aartREV[ 7][17] = 23; aartREV[ 8][17] = 48; aartREV[ 9][17] = 39;
16139 aartREV[10][17] = 47; aartREV[11][17] = 6; aartREV[12][17] = 111; aartREV[13][17] = 182; aartREV[14][17] = 9;
16140 aartREV[15][17] = 14; aartREV[16][17] = 1; aartREV[17][17] = 0; aartREV[18][17] = 176; aartREV[19][17] = 26;
16141 aartREV[ 0][18] = 55; aartREV[ 1][18] = 47; aartREV[ 2][18] = 28; aartREV[ 3][18] = 1; aartREV[ 4][18] = 131;
16142 aartREV[ 5][18] = 45; aartREV[ 6][18] = 1; aartREV[ 7][18] = 21; aartREV[ 8][18] = 307; aartREV[ 9][18] = 26;
16143 aartREV[10][18] = 64; aartREV[11][18] = 1; aartREV[12][18] = 74; aartREV[13][18] =1017; aartREV[14][18] = 14;
16144 aartREV[15][18] = 31; aartREV[16][18] = 34; aartREV[17][18] = 176; aartREV[18][18] = 0; aartREV[19][18] = 59;
16145 aartREV[ 0][19] = 197; aartREV[ 1][19] = 29; aartREV[ 2][19] = 21; aartREV[ 3][19] = 6; aartREV[ 4][19] = 295;
16146 aartREV[ 5][19] = 36; aartREV[ 6][19] = 35; aartREV[ 7][19] = 3; aartREV[ 8][19] = 1; aartREV[ 9][19] =1048;
16147 aartREV[10][19] = 112; aartREV[11][19] = 19; aartREV[12][19] = 236; aartREV[13][19] = 92; aartREV[14][19] = 25;
16148 aartREV[15][19] = 39; aartREV[16][19] = 196; aartREV[17][19] = 26; aartREV[18][19] = 59; aartREV[19][19] = 0;
16149 rtrevPi[ 0] = 0.0646;
16150 rtrevPi[ 1] = 0.0453;
16151 rtrevPi[ 2] = 0.0376;
16152 rtrevPi[ 3] = 0.0422;
16153 rtrevPi[ 4] = 0.0114;
16154 rtrevPi[ 5] = 0.0606;
16155 rtrevPi[ 6] = 0.0607;
16156 rtrevPi[ 7] = 0.0639;
16157 rtrevPi[ 8] = 0.0273;
16158 rtrevPi[ 9] = 0.0679;
16159 rtrevPi[10] = 0.1018;
16160 rtrevPi[11] = 0.0751;
16161 rtrevPi[12] = 0.0150;
16162 rtrevPi[13] = 0.0287;
16163 rtrevPi[14] = 0.0681;
16164 rtrevPi[15] = 0.0488;
16165 rtrevPi[16] = 0.0622;
16166 rtrevPi[17] = 0.0251;
16167 rtrevPi[18] = 0.0318;
16168 rtrevPi[19] = 0.0619;
16171 aaWAG[ 0][ 0] = 0.0000000; aaWAG[ 1][ 0] = 0.5515710; aaWAG[ 2][ 0] = 0.5098480; aaWAG[ 3][ 0] = 0.7389980; aaWAG[ 4][ 0] = 1.0270400;
16172 aaWAG[ 5][ 0] = 0.9085980; aaWAG[ 6][ 0] = 1.5828500; aaWAG[ 7][ 0] = 1.4167200; aaWAG[ 8][ 0] = 0.3169540; aaWAG[ 9][ 0] = 0.1933350;
16173 aaWAG[10][ 0] = 0.3979150; aaWAG[11][ 0] = 0.9062650; aaWAG[12][ 0] = 0.8934960; aaWAG[13][ 0] = 0.2104940; aaWAG[14][ 0] = 1.4385500;
16174 aaWAG[15][ 0] = 3.3707900; aaWAG[16][ 0] = 2.1211100; aaWAG[17][ 0] = 0.1131330; aaWAG[18][ 0] = 0.2407350; aaWAG[19][ 0] = 2.0060100;
16175 aaWAG[ 0][ 1] = 0.5515710; aaWAG[ 1][ 1] = 0.0000000; aaWAG[ 2][ 1] = 0.6353460; aaWAG[ 3][ 1] = 0.1473040; aaWAG[ 4][ 1] = 0.5281910;
16176 aaWAG[ 5][ 1] = 3.0355000; aaWAG[ 6][ 1] = 0.4391570; aaWAG[ 7][ 1] = 0.5846650; aaWAG[ 8][ 1] = 2.1371500; aaWAG[ 9][ 1] = 0.1869790;
16177 aaWAG[10][ 1] = 0.4976710; aaWAG[11][ 1] = 5.3514200; aaWAG[12][ 1] = 0.6831620; aaWAG[13][ 1] = 0.1027110; aaWAG[14][ 1] = 0.6794890;
16178 aaWAG[15][ 1] = 1.2241900; aaWAG[16][ 1] = 0.5544130; aaWAG[17][ 1] = 1.1639200; aaWAG[18][ 1] = 0.3815330; aaWAG[19][ 1] = 0.2518490;
16179 aaWAG[ 0][ 2] = 0.5098480; aaWAG[ 1][ 2] = 0.6353460; aaWAG[ 2][ 2] = 0.0000000; aaWAG[ 3][ 2] = 5.4294200; aaWAG[ 4][ 2] = 0.2652560;
16180 aaWAG[ 5][ 2] = 1.5436400; aaWAG[ 6][ 2] = 0.9471980; aaWAG[ 7][ 2] = 1.1255600; aaWAG[ 8][ 2] = 3.9562900; aaWAG[ 9][ 2] = 0.5542360;
16181 aaWAG[10][ 2] = 0.1315280; aaWAG[11][ 2] = 3.0120100; aaWAG[12][ 2] = 0.1982210; aaWAG[13][ 2] = 0.0961621; aaWAG[14][ 2] = 0.1950810;
16182 aaWAG[15][ 2] = 3.9742300; aaWAG[16][ 2] = 2.0300600; aaWAG[17][ 2] = 0.0719167; aaWAG[18][ 2] = 1.0860000; aaWAG[19][ 2] = 0.1962460;
16183 aaWAG[ 0][ 3] = 0.7389980; aaWAG[ 1][ 3] = 0.1473040; aaWAG[ 2][ 3] = 5.4294200; aaWAG[ 3][ 3] = 0.0000000; aaWAG[ 4][ 3] = 0.0302949;
16184 aaWAG[ 5][ 3] = 0.6167830; aaWAG[ 6][ 3] = 6.1741600; aaWAG[ 7][ 3] = 0.8655840; aaWAG[ 8][ 3] = 0.9306760; aaWAG[ 9][ 3] = 0.0394370;
16185 aaWAG[10][ 3] = 0.0848047; aaWAG[11][ 3] = 0.4798550; aaWAG[12][ 3] = 0.1037540; aaWAG[13][ 3] = 0.0467304; aaWAG[14][ 3] = 0.4239840;
16186 aaWAG[15][ 3] = 1.0717600; aaWAG[16][ 3] = 0.3748660; aaWAG[17][ 3] = 0.1297670; aaWAG[18][ 3] = 0.3257110; aaWAG[19][ 3] = 0.1523350;
16187 aaWAG[ 0][ 4] = 1.0270400; aaWAG[ 1][ 4] = 0.5281910; aaWAG[ 2][ 4] = 0.2652560; aaWAG[ 3][ 4] = 0.0302949; aaWAG[ 4][ 4] = 0.0000000;
16188 aaWAG[ 5][ 4] = 0.0988179; aaWAG[ 6][ 4] = 0.0213520; aaWAG[ 7][ 4] = 0.3066740; aaWAG[ 8][ 4] = 0.2489720; aaWAG[ 9][ 4] = 0.1701350;
16189 aaWAG[10][ 4] = 0.3842870; aaWAG[11][ 4] = 0.0740339; aaWAG[12][ 4] = 0.3904820; aaWAG[13][ 4] = 0.3980200; aaWAG[14][ 4] = 0.1094040;
16190 aaWAG[15][ 4] = 1.4076600; aaWAG[16][ 4] = 0.5129840; aaWAG[17][ 4] = 0.7170700; aaWAG[18][ 4] = 0.5438330; aaWAG[19][ 4] = 1.0021400;
16191 aaWAG[ 0][ 5] = 0.9085980; aaWAG[ 1][ 5] = 3.0355000; aaWAG[ 2][ 5] = 1.5436400; aaWAG[ 3][ 5] = 0.6167830; aaWAG[ 4][ 5] = 0.0988179;
16192 aaWAG[ 5][ 5] = 0.0000000; aaWAG[ 6][ 5] = 5.4694700; aaWAG[ 7][ 5] = 0.3300520; aaWAG[ 8][ 5] = 4.2941100; aaWAG[ 9][ 5] = 0.1139170;
16193 aaWAG[10][ 5] = 0.8694890; aaWAG[11][ 5] = 3.8949000; aaWAG[12][ 5] = 1.5452600; aaWAG[13][ 5] = 0.0999208; aaWAG[14][ 5] = 0.9333720;
16194 aaWAG[15][ 5] = 1.0288700; aaWAG[16][ 5] = 0.8579280; aaWAG[17][ 5] = 0.2157370; aaWAG[18][ 5] = 0.2277100; aaWAG[19][ 5] = 0.3012810;
16195 aaWAG[ 0][ 6] = 1.5828500; aaWAG[ 1][ 6] = 0.4391570; aaWAG[ 2][ 6] = 0.9471980; aaWAG[ 3][ 6] = 6.1741600; aaWAG[ 4][ 6] = 0.0213520;
16196 aaWAG[ 5][ 6] = 5.4694700; aaWAG[ 6][ 6] = 0.0000000; aaWAG[ 7][ 6] = 0.5677170; aaWAG[ 8][ 6] = 0.5700250; aaWAG[ 9][ 6] = 0.1273950;
16197 aaWAG[10][ 6] = 0.1542630; aaWAG[11][ 6] = 2.5844300; aaWAG[12][ 6] = 0.3151240; aaWAG[13][ 6] = 0.0811339; aaWAG[14][ 6] = 0.6823550;
16198 aaWAG[15][ 6] = 0.7049390; aaWAG[16][ 6] = 0.8227650; aaWAG[17][ 6] = 0.1565570; aaWAG[18][ 6] = 0.1963030; aaWAG[19][ 6] = 0.5887310;
16199 aaWAG[ 0][ 7] = 1.4167200; aaWAG[ 1][ 7] = 0.5846650; aaWAG[ 2][ 7] = 1.1255600; aaWAG[ 3][ 7] = 0.8655840; aaWAG[ 4][ 7] = 0.3066740;
16200 aaWAG[ 5][ 7] = 0.3300520; aaWAG[ 6][ 7] = 0.5677170; aaWAG[ 7][ 7] = 0.0000000; aaWAG[ 8][ 7] = 0.2494100; aaWAG[ 9][ 7] = 0.0304501;
16201 aaWAG[10][ 7] = 0.0613037; aaWAG[11][ 7] = 0.3735580; aaWAG[12][ 7] = 0.1741000; aaWAG[13][ 7] = 0.0499310; aaWAG[14][ 7] = 0.2435700;
16202 aaWAG[15][ 7] = 1.3418200; aaWAG[16][ 7] = 0.2258330; aaWAG[17][ 7] = 0.3369830; aaWAG[18][ 7] = 0.1036040; aaWAG[19][ 7] = 0.1872470;
16203 aaWAG[ 0][ 8] = 0.3169540; aaWAG[ 1][ 8] = 2.1371500; aaWAG[ 2][ 8] = 3.9562900; aaWAG[ 3][ 8] = 0.9306760; aaWAG[ 4][ 8] = 0.2489720;
16204 aaWAG[ 5][ 8] = 4.2941100; aaWAG[ 6][ 8] = 0.5700250; aaWAG[ 7][ 8] = 0.2494100; aaWAG[ 8][ 8] = 0.0000000; aaWAG[ 9][ 8] = 0.1381900;
16205 aaWAG[10][ 8] = 0.4994620; aaWAG[11][ 8] = 0.8904320; aaWAG[12][ 8] = 0.4041410; aaWAG[13][ 8] = 0.6793710; aaWAG[14][ 8] = 0.6961980;
16206 aaWAG[15][ 8] = 0.7401690; aaWAG[16][ 8] = 0.4733070; aaWAG[17][ 8] = 0.2625690; aaWAG[18][ 8] = 3.8734400; aaWAG[19][ 8] = 0.1183580;
16207 aaWAG[ 0][ 9] = 0.1933350; aaWAG[ 1][ 9] = 0.1869790; aaWAG[ 2][ 9] = 0.5542360; aaWAG[ 3][ 9] = 0.0394370; aaWAG[ 4][ 9] = 0.1701350;
16208 aaWAG[ 5][ 9] = 0.1139170; aaWAG[ 6][ 9] = 0.1273950; aaWAG[ 7][ 9] = 0.0304501; aaWAG[ 8][ 9] = 0.1381900; aaWAG[ 9][ 9] = 0.0000000;
16209 aaWAG[10][ 9] = 3.1709700; aaWAG[11][ 9] = 0.3238320; aaWAG[12][ 9] = 4.2574600; aaWAG[13][ 9] = 1.0594700; aaWAG[14][ 9] = 0.0999288;
16210 aaWAG[15][ 9] = 0.3194400; aaWAG[16][ 9] = 1.4581600; aaWAG[17][ 9] = 0.2124830; aaWAG[18][ 9] = 0.4201700; aaWAG[19][ 9] = 7.8213000;
16211 aaWAG[ 0][10] = 0.3979150; aaWAG[ 1][10] = 0.4976710; aaWAG[ 2][10] = 0.1315280; aaWAG[ 3][10] = 0.0848047; aaWAG[ 4][10] = 0.3842870;
16212 aaWAG[ 5][10] = 0.8694890; aaWAG[ 6][10] = 0.1542630; aaWAG[ 7][10] = 0.0613037; aaWAG[ 8][10] = 0.4994620; aaWAG[ 9][10] = 3.1709700;
16213 aaWAG[10][10] = 0.0000000; aaWAG[11][10] = 0.2575550; aaWAG[12][10] = 4.8540200; aaWAG[13][10] = 2.1151700; aaWAG[14][10] = 0.4158440;
16214 aaWAG[15][10] = 0.3447390; aaWAG[16][10] = 0.3266220; aaWAG[17][10] = 0.6653090; aaWAG[18][10] = 0.3986180; aaWAG[19][10] = 1.8003400;
16215 aaWAG[ 0][11] = 0.9062650; aaWAG[ 1][11] = 5.3514200; aaWAG[ 2][11] = 3.0120100; aaWAG[ 3][11] = 0.4798550; aaWAG[ 4][11] = 0.0740339;
16216 aaWAG[ 5][11] = 3.8949000; aaWAG[ 6][11] = 2.5844300; aaWAG[ 7][11] = 0.3735580; aaWAG[ 8][11] = 0.8904320; aaWAG[ 9][11] = 0.3238320;
16217 aaWAG[10][11] = 0.2575550; aaWAG[11][11] = 0.0000000; aaWAG[12][11] = 0.9342760; aaWAG[13][11] = 0.0888360; aaWAG[14][11] = 0.5568960;
16218 aaWAG[15][11] = 0.9671300; aaWAG[16][11] = 1.3869800; aaWAG[17][11] = 0.1375050; aaWAG[18][11] = 0.1332640; aaWAG[19][11] = 0.3054340;
16219 aaWAG[ 0][12] = 0.8934960; aaWAG[ 1][12] = 0.6831620; aaWAG[ 2][12] = 0.1982210; aaWAG[ 3][12] = 0.1037540; aaWAG[ 4][12] = 0.3904820;
16220 aaWAG[ 5][12] = 1.5452600; aaWAG[ 6][12] = 0.3151240; aaWAG[ 7][12] = 0.1741000; aaWAG[ 8][12] = 0.4041410; aaWAG[ 9][12] = 4.2574600;
16221 aaWAG[10][12] = 4.8540200; aaWAG[11][12] = 0.9342760; aaWAG[12][12] = 0.0000000; aaWAG[13][12] = 1.1906300; aaWAG[14][12] = 0.1713290;
16222 aaWAG[15][12] = 0.4939050; aaWAG[16][12] = 1.5161200; aaWAG[17][12] = 0.5157060; aaWAG[18][12] = 0.4284370; aaWAG[19][12] = 2.0584500;
16223 aaWAG[ 0][13] = 0.2104940; aaWAG[ 1][13] = 0.1027110; aaWAG[ 2][13] = 0.0961621; aaWAG[ 3][13] = 0.0467304; aaWAG[ 4][13] = 0.3980200;
16224 aaWAG[ 5][13] = 0.0999208; aaWAG[ 6][13] = 0.0811339; aaWAG[ 7][13] = 0.0499310; aaWAG[ 8][13] = 0.6793710; aaWAG[ 9][13] = 1.0594700;
16225 aaWAG[10][13] = 2.1151700; aaWAG[11][13] = 0.0888360; aaWAG[12][13] = 1.1906300; aaWAG[13][13] = 0.0000000; aaWAG[14][13] = 0.1614440;
16226 aaWAG[15][13] = 0.5459310; aaWAG[16][13] = 0.1719030; aaWAG[17][13] = 1.5296400; aaWAG[18][13] = 6.4542800; aaWAG[19][13] = 0.6498920;
16227 aaWAG[ 0][14] = 1.4385500; aaWAG[ 1][14] = 0.6794890; aaWAG[ 2][14] = 0.1950810; aaWAG[ 3][14] = 0.4239840; aaWAG[ 4][14] = 0.1094040;
16228 aaWAG[ 5][14] = 0.9333720; aaWAG[ 6][14] = 0.6823550; aaWAG[ 7][14] = 0.2435700; aaWAG[ 8][14] = 0.6961980; aaWAG[ 9][14] = 0.0999288;
16229 aaWAG[10][14] = 0.4158440; aaWAG[11][14] = 0.5568960; aaWAG[12][14] = 0.1713290; aaWAG[13][14] = 0.1614440; aaWAG[14][14] = 0.0000000;
16230 aaWAG[15][14] = 1.6132800; aaWAG[16][14] = 0.7953840; aaWAG[17][14] = 0.1394050; aaWAG[18][14] = 0.2160460; aaWAG[19][14] = 0.3148870;
16231 aaWAG[ 0][15] = 3.3707900; aaWAG[ 1][15] = 1.2241900; aaWAG[ 2][15] = 3.9742300; aaWAG[ 3][15] = 1.0717600; aaWAG[ 4][15] = 1.4076600;
16232 aaWAG[ 5][15] = 1.0288700; aaWAG[ 6][15] = 0.7049390; aaWAG[ 7][15] = 1.3418200; aaWAG[ 8][15] = 0.7401690; aaWAG[ 9][15] = 0.3194400;
16233 aaWAG[10][15] = 0.3447390; aaWAG[11][15] = 0.9671300; aaWAG[12][15] = 0.4939050; aaWAG[13][15] = 0.5459310; aaWAG[14][15] = 1.6132800;
16234 aaWAG[15][15] = 0.0000000; aaWAG[16][15] = 4.3780200; aaWAG[17][15] = 0.5237420; aaWAG[18][15] = 0.7869930; aaWAG[19][15] = 0.2327390;
16235 aaWAG[ 0][16] = 2.1211100; aaWAG[ 1][16] = 0.5544130; aaWAG[ 2][16] = 2.0300600; aaWAG[ 3][16] = 0.3748660; aaWAG[ 4][16] = 0.5129840;
16236 aaWAG[ 5][16] = 0.8579280; aaWAG[ 6][16] = 0.8227650; aaWAG[ 7][16] = 0.2258330; aaWAG[ 8][16] = 0.4733070; aaWAG[ 9][16] = 1.4581600;
16237 aaWAG[10][16] = 0.3266220; aaWAG[11][16] = 1.3869800; aaWAG[12][16] = 1.5161200; aaWAG[13][16] = 0.1719030; aaWAG[14][16] = 0.7953840;
16238 aaWAG[15][16] = 4.3780200; aaWAG[16][16] = 0.0000000; aaWAG[17][16] = 0.1108640; aaWAG[18][16] = 0.2911480; aaWAG[19][16] = 1.3882300;
16239 aaWAG[ 0][17] = 0.1131330; aaWAG[ 1][17] = 1.1639200; aaWAG[ 2][17] = 0.0719167; aaWAG[ 3][17] = 0.1297670; aaWAG[ 4][17] = 0.7170700;
16240 aaWAG[ 5][17] = 0.2157370; aaWAG[ 6][17] = 0.1565570; aaWAG[ 7][17] = 0.3369830; aaWAG[ 8][17] = 0.2625690; aaWAG[ 9][17] = 0.2124830;
16241 aaWAG[10][17] = 0.6653090; aaWAG[11][17] = 0.1375050; aaWAG[12][17] = 0.5157060; aaWAG[13][17] = 1.5296400; aaWAG[14][17] = 0.1394050;
16242 aaWAG[15][17] = 0.5237420; aaWAG[16][17] = 0.1108640; aaWAG[17][17] = 0.0000000; aaWAG[18][17] = 2.4853900; aaWAG[19][17] = 0.3653690;
16243 aaWAG[ 0][18] = 0.2407350; aaWAG[ 1][18] = 0.3815330; aaWAG[ 2][18] = 1.0860000; aaWAG[ 3][18] = 0.3257110; aaWAG[ 4][18] = 0.5438330;
16244 aaWAG[ 5][18] = 0.2277100; aaWAG[ 6][18] = 0.1963030; aaWAG[ 7][18] = 0.1036040; aaWAG[ 8][18] = 3.8734400; aaWAG[ 9][18] = 0.4201700;
16245 aaWAG[10][18] = 0.3986180; aaWAG[11][18] = 0.1332640; aaWAG[12][18] = 0.4284370; aaWAG[13][18] = 6.4542800; aaWAG[14][18] = 0.2160460;
16246 aaWAG[15][18] = 0.7869930; aaWAG[16][18] = 0.2911480; aaWAG[17][18] = 2.4853900; aaWAG[18][18] = 0.0000000; aaWAG[19][18] = 0.3147300;
16247 aaWAG[ 0][19] = 2.0060100; aaWAG[ 1][19] = 0.2518490; aaWAG[ 2][19] = 0.1962460; aaWAG[ 3][19] = 0.1523350; aaWAG[ 4][19] = 1.0021400;
16248 aaWAG[ 5][19] = 0.3012810; aaWAG[ 6][19] = 0.5887310; aaWAG[ 7][19] = 0.1872470; aaWAG[ 8][19] = 0.1183580; aaWAG[ 9][19] = 7.8213000;
16249 aaWAG[10][19] = 1.8003400; aaWAG[11][19] = 0.3054340; aaWAG[12][19] = 2.0584500; aaWAG[13][19] = 0.6498920; aaWAG[14][19] = 0.3148870;
16250 aaWAG[15][19] = 0.2327390; aaWAG[16][19] = 1.3882300; aaWAG[17][19] = 0.3653690; aaWAG[18][19] = 0.3147300; aaWAG[19][19] = 0.0000000;
16251 wagPi[ 0] = 0.08662790;
16252 wagPi[ 1] = 0.04397200;
16253 wagPi[ 2] = 0.03908940;
16254 wagPi[ 3] = 0.05704510;
16255 wagPi[ 4] = 0.01930780;
16256 wagPi[ 5] = 0.03672810;
16257 wagPi[ 6] = 0.05805890;
16258 wagPi[ 7] = 0.08325180;
16259 wagPi[ 8] = 0.02443130;
16260 wagPi[ 9] = 0.04846600;
16261 wagPi[10] = 0.08620970;
16262 wagPi[11] = 0.06202860;
16263 wagPi[12] = 0.01950273;
16264 wagPi[13] = 0.03843190;
16265 wagPi[14] = 0.04576310;
16266 wagPi[15] = 0.06951790;
16267 wagPi[16] = 0.06101270;
16268 wagPi[17] = 0.01438590;
16269 wagPi[18] = 0.03527420;
16270 wagPi[19] = 0.07089560;
16273 aacpREV[ 0][ 0] = 0; aacpREV[ 0][ 1] = 105; aacpREV[ 0][ 2] = 227; aacpREV[ 0][ 3] = 175; aacpREV[ 0][ 4] = 669;
16274 aacpREV[ 0][ 5] = 157; aacpREV[ 0][ 6] = 499; aacpREV[ 0][ 7] = 665; aacpREV[ 0][ 8] = 66; aacpREV[ 0][ 9] = 145;
16275 aacpREV[ 0][10] = 197; aacpREV[ 0][11] = 236; aacpREV[ 0][12] = 185; aacpREV[ 0][13] = 68; aacpREV[ 0][14] = 490;
16276 aacpREV[ 0][15] = 2440; aacpREV[ 0][16] = 1340; aacpREV[ 0][17] = 14; aacpREV[ 0][18] = 56; aacpREV[ 0][19] = 968;
16277 aacpREV[ 1][ 0] = 105; aacpREV[ 1][ 1] = 0; aacpREV[ 1][ 2] = 357; aacpREV[ 1][ 3] = 43; aacpREV[ 1][ 4] = 823;
16278 aacpREV[ 1][ 5] = 1745; aacpREV[ 1][ 6] = 152; aacpREV[ 1][ 7] = 243; aacpREV[ 1][ 8] = 715; aacpREV[ 1][ 9] = 136;
16279 aacpREV[ 1][10] = 203; aacpREV[ 1][11] = 4482; aacpREV[ 1][12] = 125; aacpREV[ 1][13] = 53; aacpREV[ 1][14] = 87;
16280 aacpREV[ 1][15] = 385; aacpREV[ 1][16] = 314; aacpREV[ 1][17] = 230; aacpREV[ 1][18] = 323; aacpREV[ 1][19] = 92;
16281 aacpREV[ 2][ 0] = 227; aacpREV[ 2][ 1] = 357; aacpREV[ 2][ 2] = 0; aacpREV[ 2][ 3] = 4435; aacpREV[ 2][ 4] = 538;
16282 aacpREV[ 2][ 5] = 768; aacpREV[ 2][ 6] = 1055; aacpREV[ 2][ 7] = 653; aacpREV[ 2][ 8] = 1405; aacpREV[ 2][ 9] = 168;
16283 aacpREV[ 2][10] = 113; aacpREV[ 2][11] = 2430; aacpREV[ 2][12] = 61; aacpREV[ 2][13] = 97; aacpREV[ 2][14] = 173;
16284 aacpREV[ 2][15] = 2085; aacpREV[ 2][16] = 1393; aacpREV[ 2][17] = 40; aacpREV[ 2][18] = 754; aacpREV[ 2][19] = 83;
16285 aacpREV[ 3][ 0] = 175; aacpREV[ 3][ 1] = 43; aacpREV[ 3][ 2] = 4435; aacpREV[ 3][ 3] = 0; aacpREV[ 3][ 4] = 10;
16286 aacpREV[ 3][ 5] = 400; aacpREV[ 3][ 6] = 3691; aacpREV[ 3][ 7] = 431; aacpREV[ 3][ 8] = 331; aacpREV[ 3][ 9] = 10;
16287 aacpREV[ 3][10] = 10; aacpREV[ 3][11] = 412; aacpREV[ 3][12] = 47; aacpREV[ 3][13] = 22; aacpREV[ 3][14] = 170;
16288 aacpREV[ 3][15] = 590; aacpREV[ 3][16] = 266; aacpREV[ 3][17] = 18; aacpREV[ 3][18] = 281; aacpREV[ 3][19] = 75;
16289 aacpREV[ 4][ 0] = 669; aacpREV[ 4][ 1] = 823; aacpREV[ 4][ 2] = 538; aacpREV[ 4][ 3] = 10; aacpREV[ 4][ 4] = 0;
16290 aacpREV[ 4][ 5] = 10; aacpREV[ 4][ 6] = 10; aacpREV[ 4][ 7] = 303; aacpREV[ 4][ 8] = 441; aacpREV[ 4][ 9] = 280;
16291 aacpREV[ 4][10] = 396; aacpREV[ 4][11] = 48; aacpREV[ 4][12] = 159; aacpREV[ 4][13] = 726; aacpREV[ 4][14] = 285;
16292 aacpREV[ 4][15] = 2331; aacpREV[ 4][16] = 576; aacpREV[ 4][17] = 435; aacpREV[ 4][18] = 1466; aacpREV[ 4][19] = 592;
16293 aacpREV[ 5][ 0] = 157; aacpREV[ 5][ 1] = 1745; aacpREV[ 5][ 2] = 768; aacpREV[ 5][ 3] = 400; aacpREV[ 5][ 4] = 10;
16294 aacpREV[ 5][ 5] = 0; aacpREV[ 5][ 6] = 3122; aacpREV[ 5][ 7] = 133; aacpREV[ 5][ 8] = 1269; aacpREV[ 5][ 9] = 92;
16295 aacpREV[ 5][10] = 286; aacpREV[ 5][11] = 3313; aacpREV[ 5][12] = 202; aacpREV[ 5][13] = 10; aacpREV[ 5][14] = 323;
16296 aacpREV[ 5][15] = 396; aacpREV[ 5][16] = 241; aacpREV[ 5][17] = 53; aacpREV[ 5][18] = 391; aacpREV[ 5][19] = 54;
16297 aacpREV[ 6][ 0] = 499; aacpREV[ 6][ 1] = 152; aacpREV[ 6][ 2] = 1055; aacpREV[ 6][ 3] = 3691; aacpREV[ 6][ 4] = 10;
16298 aacpREV[ 6][ 5] = 3122; aacpREV[ 6][ 6] = 0; aacpREV[ 6][ 7] = 379; aacpREV[ 6][ 8] = 162; aacpREV[ 6][ 9] = 148;
16299 aacpREV[ 6][10] = 82; aacpREV[ 6][11] = 2629; aacpREV[ 6][12] = 113; aacpREV[ 6][13] = 145; aacpREV[ 6][14] = 185;
16300 aacpREV[ 6][15] = 568; aacpREV[ 6][16] = 369; aacpREV[ 6][17] = 63; aacpREV[ 6][18] = 142; aacpREV[ 6][19] = 200;
16301 aacpREV[ 7][ 0] = 665; aacpREV[ 7][ 1] = 243; aacpREV[ 7][ 2] = 653; aacpREV[ 7][ 3] = 431; aacpREV[ 7][ 4] = 303;
16302 aacpREV[ 7][ 5] = 133; aacpREV[ 7][ 6] = 379; aacpREV[ 7][ 7] = 0; aacpREV[ 7][ 8] = 19; aacpREV[ 7][ 9] = 40;
16303 aacpREV[ 7][10] = 20; aacpREV[ 7][11] = 263; aacpREV[ 7][12] = 21; aacpREV[ 7][13] = 25; aacpREV[ 7][14] = 28;
16304 aacpREV[ 7][15] = 691; aacpREV[ 7][16] = 92; aacpREV[ 7][17] = 82; aacpREV[ 7][18] = 10; aacpREV[ 7][19] = 91;
16305 aacpREV[ 8][ 0] = 66; aacpREV[ 8][ 1] = 715; aacpREV[ 8][ 2] = 1405; aacpREV[ 8][ 3] = 331; aacpREV[ 8][ 4] = 441;
16306 aacpREV[ 8][ 5] = 1269; aacpREV[ 8][ 6] = 162; aacpREV[ 8][ 7] = 19; aacpREV[ 8][ 8] = 0; aacpREV[ 8][ 9] = 29;
16307 aacpREV[ 8][10] = 66; aacpREV[ 8][11] = 305; aacpREV[ 8][12] = 10; aacpREV[ 8][13] = 127; aacpREV[ 8][14] = 152;
16308 aacpREV[ 8][15] = 303; aacpREV[ 8][16] = 32; aacpREV[ 8][17] = 69; aacpREV[ 8][18] = 1971; aacpREV[ 8][19] = 25;
16309 aacpREV[ 9][ 0] = 145; aacpREV[ 9][ 1] = 136; aacpREV[ 9][ 2] = 168; aacpREV[ 9][ 3] = 10; aacpREV[ 9][ 4] = 280;
16310 aacpREV[ 9][ 5] = 92; aacpREV[ 9][ 6] = 148; aacpREV[ 9][ 7] = 40; aacpREV[ 9][ 8] = 29; aacpREV[ 9][ 9] = 0;
16311 aacpREV[ 9][10] = 1745; aacpREV[ 9][11] = 345; aacpREV[ 9][12] = 1772; aacpREV[ 9][13] = 454; aacpREV[ 9][14] = 117;
16312 aacpREV[ 9][15] = 216; aacpREV[ 9][16] = 1040; aacpREV[ 9][17] = 42; aacpREV[ 9][18] = 89; aacpREV[ 9][19] = 4797;
16313 aacpREV[10][ 0] = 197; aacpREV[10][ 1] = 203; aacpREV[10][ 2] = 113; aacpREV[10][ 3] = 10; aacpREV[10][ 4] = 396;
16314 aacpREV[10][ 5] = 286; aacpREV[10][ 6] = 82; aacpREV[10][ 7] = 20; aacpREV[10][ 8] = 66; aacpREV[10][ 9] = 1745;
16315 aacpREV[10][10] = 0; aacpREV[10][11] = 218; aacpREV[10][12] = 1351; aacpREV[10][13] = 1268; aacpREV[10][14] = 219;
16316 aacpREV[10][15] = 516; aacpREV[10][16] = 156; aacpREV[10][17] = 159; aacpREV[10][18] = 189; aacpREV[10][19] = 865;
16317 aacpREV[11][ 0] = 236; aacpREV[11][ 1] = 4482; aacpREV[11][ 2] = 2430; aacpREV[11][ 3] = 412; aacpREV[11][ 4] = 48;
16318 aacpREV[11][ 5] = 3313; aacpREV[11][ 6] = 2629; aacpREV[11][ 7] = 263; aacpREV[11][ 8] = 305; aacpREV[11][ 9] = 345;
16319 aacpREV[11][10] = 218; aacpREV[11][11] = 0; aacpREV[11][12] = 193; aacpREV[11][13] = 72; aacpREV[11][14] = 302;
16320 aacpREV[11][15] = 868; aacpREV[11][16] = 918; aacpREV[11][17] = 10; aacpREV[11][18] = 247; aacpREV[11][19] = 249;
16321 aacpREV[12][ 0] = 185; aacpREV[12][ 1] = 125; aacpREV[12][ 2] = 61; aacpREV[12][ 3] = 47; aacpREV[12][ 4] = 159;
16322 aacpREV[12][ 5] = 202; aacpREV[12][ 6] = 113; aacpREV[12][ 7] = 21; aacpREV[12][ 8] = 10; aacpREV[12][ 9] = 1772;
16323 aacpREV[12][10] = 1351; aacpREV[12][11] = 193; aacpREV[12][12] = 0; aacpREV[12][13] = 327; aacpREV[12][14] = 100;
16324 aacpREV[12][15] = 93; aacpREV[12][16] = 645; aacpREV[12][17] = 86; aacpREV[12][18] = 215; aacpREV[12][19] = 475;
16325 aacpREV[13][ 0] = 68; aacpREV[13][ 1] = 53; aacpREV[13][ 2] = 97; aacpREV[13][ 3] = 22; aacpREV[13][ 4] = 726;
16326 aacpREV[13][ 5] = 10; aacpREV[13][ 6] = 145; aacpREV[13][ 7] = 25; aacpREV[13][ 8] = 127; aacpREV[13][ 9] = 454;
16327 aacpREV[13][10] = 1268; aacpREV[13][11] = 72; aacpREV[13][12] = 327; aacpREV[13][13] = 0; aacpREV[13][14] = 43;
16328 aacpREV[13][15] = 487; aacpREV[13][16] = 148; aacpREV[13][17] = 468; aacpREV[13][18] = 2370; aacpREV[13][19] = 317;
16329 aacpREV[14][ 0] = 490; aacpREV[14][ 1] = 87; aacpREV[14][ 2] = 173; aacpREV[14][ 3] = 170; aacpREV[14][ 4] = 285;
16330 aacpREV[14][ 5] = 323; aacpREV[14][ 6] = 185; aacpREV[14][ 7] = 28; aacpREV[14][ 8] = 152; aacpREV[14][ 9] = 117;
16331 aacpREV[14][10] = 219; aacpREV[14][11] = 302; aacpREV[14][12] = 100; aacpREV[14][13] = 43; aacpREV[14][14] = 0;
16332 aacpREV[14][15] = 1202; aacpREV[14][16] = 260; aacpREV[14][17] = 49; aacpREV[14][18] = 97; aacpREV[14][19] = 122;
16333 aacpREV[15][ 0] = 2440; aacpREV[15][ 1] = 385; aacpREV[15][ 2] = 2085; aacpREV[15][ 3] = 590; aacpREV[15][ 4] = 2331;
16334 aacpREV[15][ 5] = 396; aacpREV[15][ 6] = 568; aacpREV[15][ 7] = 691; aacpREV[15][ 8] = 303; aacpREV[15][ 9] = 216;
16335 aacpREV[15][10] = 516; aacpREV[15][11] = 868; aacpREV[15][12] = 93; aacpREV[15][13] = 487; aacpREV[15][14] = 1202;
16336 aacpREV[15][15] = 0; aacpREV[15][16] = 2151; aacpREV[15][17] = 73; aacpREV[15][18] = 522; aacpREV[15][19] = 167;
16337 aacpREV[16][ 0] = 1340; aacpREV[16][ 1] = 314; aacpREV[16][ 2] = 1393; aacpREV[16][ 3] = 266; aacpREV[16][ 4] = 576;
16338 aacpREV[16][ 5] = 241; aacpREV[16][ 6] = 369; aacpREV[16][ 7] = 92; aacpREV[16][ 8] = 32; aacpREV[16][ 9] = 1040;
16339 aacpREV[16][10] = 156; aacpREV[16][11] = 918; aacpREV[16][12] = 645; aacpREV[16][13] = 148; aacpREV[16][14] = 260;
16340 aacpREV[16][15] = 2151; aacpREV[16][16] = 0; aacpREV[16][17] = 29; aacpREV[16][18] = 71; aacpREV[16][19] = 760;
16341 aacpREV[17][ 0] = 14; aacpREV[17][ 1] = 230; aacpREV[17][ 2] = 40; aacpREV[17][ 3] = 18; aacpREV[17][ 4] = 435;
16342 aacpREV[17][ 5] = 53; aacpREV[17][ 6] = 63; aacpREV[17][ 7] = 82; aacpREV[17][ 8] = 69; aacpREV[17][ 9] = 42;
16343 aacpREV[17][10] = 159; aacpREV[17][11] = 10; aacpREV[17][12] = 86; aacpREV[17][13] = 468; aacpREV[17][14] = 49;
16344 aacpREV[17][15] = 73; aacpREV[17][16] = 29; aacpREV[17][17] = 0; aacpREV[17][18] = 346; aacpREV[17][19] = 10;
16345 aacpREV[18][ 0] = 56; aacpREV[18][ 1] = 323; aacpREV[18][ 2] = 754; aacpREV[18][ 3] = 281; aacpREV[18][ 4] = 1466;
16346 aacpREV[18][ 5] = 391; aacpREV[18][ 6] = 142; aacpREV[18][ 7] = 10; aacpREV[18][ 8] = 1971; aacpREV[18][ 9] = 89;
16347 aacpREV[18][10] = 189; aacpREV[18][11] = 247; aacpREV[18][12] = 215; aacpREV[18][13] = 2370; aacpREV[18][14] = 97;
16348 aacpREV[18][15] = 522; aacpREV[18][16] = 71; aacpREV[18][17] = 346; aacpREV[18][18] = 0; aacpREV[18][19] = 119;
16349 aacpREV[19][ 0] = 968; aacpREV[19][ 1] = 92; aacpREV[19][ 2] = 83; aacpREV[19][ 3] = 75; aacpREV[19][ 4] = 592;
16350 aacpREV[19][ 5] = 54; aacpREV[19][ 6] = 200; aacpREV[19][ 7] = 91; aacpREV[19][ 8] = 25; aacpREV[19][ 9] = 4797;
16351 aacpREV[19][10] = 865; aacpREV[19][11] = 249; aacpREV[19][12] = 475; aacpREV[19][13] = 317; aacpREV[19][14] = 122;
16352 aacpREV[19][15] = 167; aacpREV[19][16] = 760; aacpREV[19][17] = 10; aacpREV[19][18] = 119; aacpREV[19][19] = 0;
16354 cprevPi[0] = 0.076;
16355 cprevPi[1] = 0.062;
16356 cprevPi[2] = 0.041;
16357 cprevPi[3] = 0.037;
16358 cprevPi[4] = 0.009;
16359 cprevPi[5] = 0.038;
16360 cprevPi[6] = 0.049;
16361 cprevPi[7] = 0.084;
16362 cprevPi[8] = 0.025;
16363 cprevPi[9] = 0.081;
16364 cprevPi[10] = 0.101;
16365 cprevPi[11] = 0.050;
16366 cprevPi[12] = 0.022;
16367 cprevPi[13] = 0.051;
16368 cprevPi[14] = 0.043;
16369 cprevPi[15] = 0.062;
16370 cprevPi[16] = 0.054;
16371 cprevPi[17] = 0.018;
16372 cprevPi[18] = 0.031;
16373 cprevPi[19] = 0.066;
16376 aaVt[ 0][ 0] = 0.000000; aaVt[ 0][ 1] = 0.233108; aaVt[ 0][ 2] = 0.199097; aaVt[ 0][ 3] = 0.265145; aaVt[ 0][ 4] = 0.227333;
16377 aaVt[ 0][ 5] = 0.310084; aaVt[ 0][ 6] = 0.567957; aaVt[ 0][ 7] = 0.876213; aaVt[ 0][ 8] = 0.078692; aaVt[ 0][ 9] = 0.222972;
16378 aaVt[ 0][10] = 0.424630; aaVt[ 0][11] = 0.393245; aaVt[ 0][12] = 0.211550; aaVt[ 0][13] = 0.116646; aaVt[ 0][14] = 0.399143;
16379 aaVt[ 0][15] = 1.817198; aaVt[ 0][16] = 0.877877; aaVt[ 0][17] = 0.030309; aaVt[ 0][18] = 0.087061; aaVt[ 0][19] = 1.230985;
16380 aaVt[ 1][ 0] = 0.233108; aaVt[ 1][ 1] = 0.000000; aaVt[ 1][ 2] = 0.210797; aaVt[ 1][ 3] = 0.105191; aaVt[ 1][ 4] = 0.031726;
16381 aaVt[ 1][ 5] = 0.493763; aaVt[ 1][ 6] = 0.255240; aaVt[ 1][ 7] = 0.156945; aaVt[ 1][ 8] = 0.213164; aaVt[ 1][ 9] = 0.081510;
16382 aaVt[ 1][10] = 0.192364; aaVt[ 1][11] = 1.755838; aaVt[ 1][12] = 0.087930; aaVt[ 1][13] = 0.042569; aaVt[ 1][14] = 0.128480;
16383 aaVt[ 1][15] = 0.292327; aaVt[ 1][16] = 0.204109; aaVt[ 1][17] = 0.046417; aaVt[ 1][18] = 0.097010; aaVt[ 1][19] = 0.113146;
16384 aaVt[ 2][ 0] = 0.199097; aaVt[ 2][ 1] = 0.210797; aaVt[ 2][ 2] = 0.000000; aaVt[ 2][ 3] = 0.883422; aaVt[ 2][ 4] = 0.027495;
16385 aaVt[ 2][ 5] = 0.275700; aaVt[ 2][ 6] = 0.270417; aaVt[ 2][ 7] = 0.362028; aaVt[ 2][ 8] = 0.290006; aaVt[ 2][ 9] = 0.087225;
16386 aaVt[ 2][10] = 0.069245; aaVt[ 2][11] = 0.503060; aaVt[ 2][12] = 0.057420; aaVt[ 2][13] = 0.039769; aaVt[ 2][14] = 0.083956;
16387 aaVt[ 2][15] = 0.847049; aaVt[ 2][16] = 0.471268; aaVt[ 2][17] = 0.010459; aaVt[ 2][18] = 0.093268; aaVt[ 2][19] = 0.049824;
16388 aaVt[ 3][ 0] = 0.265145; aaVt[ 3][ 1] = 0.105191; aaVt[ 3][ 2] = 0.883422; aaVt[ 3][ 3] = 0.000000; aaVt[ 3][ 4] = 0.010313;
16389 aaVt[ 3][ 5] = 0.205842; aaVt[ 3][ 6] = 1.599461; aaVt[ 3][ 7] = 0.311718; aaVt[ 3][ 8] = 0.134252; aaVt[ 3][ 9] = 0.011720;
16390 aaVt[ 3][10] = 0.060863; aaVt[ 3][11] = 0.261101; aaVt[ 3][12] = 0.012182; aaVt[ 3][13] = 0.016577; aaVt[ 3][14] = 0.160063;
16391 aaVt[ 3][15] = 0.461519; aaVt[ 3][16] = 0.178197; aaVt[ 3][17] = 0.011393; aaVt[ 3][18] = 0.051664; aaVt[ 3][19] = 0.048769;
16392 aaVt[ 4][ 0] = 0.227333; aaVt[ 4][ 1] = 0.031726; aaVt[ 4][ 2] = 0.027495; aaVt[ 4][ 3] = 0.010313; aaVt[ 4][ 4] = 0.000000;
16393 aaVt[ 4][ 5] = 0.004315; aaVt[ 4][ 6] = 0.005321; aaVt[ 4][ 7] = 0.050876; aaVt[ 4][ 8] = 0.016695; aaVt[ 4][ 9] = 0.046398;
16394 aaVt[ 4][10] = 0.091709; aaVt[ 4][11] = 0.004067; aaVt[ 4][12] = 0.023690; aaVt[ 4][13] = 0.051127; aaVt[ 4][14] = 0.011137;
16395 aaVt[ 4][15] = 0.175270; aaVt[ 4][16] = 0.079511; aaVt[ 4][17] = 0.007732; aaVt[ 4][18] = 0.042823; aaVt[ 4][19] = 0.163831;
16396 aaVt[ 5][ 0] = 0.310084; aaVt[ 5][ 1] = 0.493763; aaVt[ 5][ 2] = 0.275700; aaVt[ 5][ 3] = 0.205842; aaVt[ 5][ 4] = 0.004315;
16397 aaVt[ 5][ 5] = 0.000000; aaVt[ 5][ 6] = 0.960976; aaVt[ 5][ 7] = 0.128660; aaVt[ 5][ 8] = 0.315521; aaVt[ 5][ 9] = 0.054602;
16398 aaVt[ 5][10] = 0.243530; aaVt[ 5][11] = 0.738208; aaVt[ 5][12] = 0.120801; aaVt[ 5][13] = 0.026235; aaVt[ 5][14] = 0.156570;
16399 aaVt[ 5][15] = 0.358017; aaVt[ 5][16] = 0.248992; aaVt[ 5][17] = 0.021248; aaVt[ 5][18] = 0.062544; aaVt[ 5][19] = 0.112027;
16400 aaVt[ 6][ 0] = 0.567957; aaVt[ 6][ 1] = 0.255240; aaVt[ 6][ 2] = 0.270417; aaVt[ 6][ 3] = 1.599461; aaVt[ 6][ 4] = 0.005321;
16401 aaVt[ 6][ 5] = 0.960976; aaVt[ 6][ 6] = 0.000000; aaVt[ 6][ 7] = 0.250447; aaVt[ 6][ 8] = 0.104458; aaVt[ 6][ 9] = 0.046589;
16402 aaVt[ 6][10] = 0.151924; aaVt[ 6][11] = 0.888630; aaVt[ 6][12] = 0.058643; aaVt[ 6][13] = 0.028168; aaVt[ 6][14] = 0.205134;
16403 aaVt[ 6][15] = 0.406035; aaVt[ 6][16] = 0.321028; aaVt[ 6][17] = 0.018844; aaVt[ 6][18] = 0.055200; aaVt[ 6][19] = 0.205868;
16404 aaVt[ 7][ 0] = 0.876213; aaVt[ 7][ 1] = 0.156945; aaVt[ 7][ 2] = 0.362028; aaVt[ 7][ 3] = 0.311718; aaVt[ 7][ 4] = 0.050876;
16405 aaVt[ 7][ 5] = 0.128660; aaVt[ 7][ 6] = 0.250447; aaVt[ 7][ 7] = 0.000000; aaVt[ 7][ 8] = 0.058131; aaVt[ 7][ 9] = 0.051089;
16406 aaVt[ 7][10] = 0.087056; aaVt[ 7][11] = 0.193243; aaVt[ 7][12] = 0.046560; aaVt[ 7][13] = 0.050143; aaVt[ 7][14] = 0.124492;
16407 aaVt[ 7][15] = 0.612843; aaVt[ 7][16] = 0.136266; aaVt[ 7][17] = 0.023990; aaVt[ 7][18] = 0.037568; aaVt[ 7][19] = 0.082579;
16408 aaVt[ 8][ 0] = 0.078692; aaVt[ 8][ 1] = 0.213164; aaVt[ 8][ 2] = 0.290006; aaVt[ 8][ 3] = 0.134252; aaVt[ 8][ 4] = 0.016695;
16409 aaVt[ 8][ 5] = 0.315521; aaVt[ 8][ 6] = 0.104458; aaVt[ 8][ 7] = 0.058131; aaVt[ 8][ 8] = 0.000000; aaVt[ 8][ 9] = 0.020039;
16410 aaVt[ 8][10] = 0.103552; aaVt[ 8][11] = 0.153323; aaVt[ 8][12] = 0.021157; aaVt[ 8][13] = 0.079807; aaVt[ 8][14] = 0.078892;
16411 aaVt[ 8][15] = 0.167406; aaVt[ 8][16] = 0.101117; aaVt[ 8][17] = 0.020009; aaVt[ 8][18] = 0.286027; aaVt[ 8][19] = 0.068575;
16412 aaVt[ 9][ 0] = 0.222972; aaVt[ 9][ 1] = 0.081510; aaVt[ 9][ 2] = 0.087225; aaVt[ 9][ 3] = 0.011720; aaVt[ 9][ 4] = 0.046398;
16413 aaVt[ 9][ 5] = 0.054602; aaVt[ 9][ 6] = 0.046589; aaVt[ 9][ 7] = 0.051089; aaVt[ 9][ 8] = 0.020039; aaVt[ 9][ 9] = 0.000000;
16414 aaVt[ 9][10] = 2.089890; aaVt[ 9][11] = 0.093181; aaVt[ 9][12] = 0.493845; aaVt[ 9][13] = 0.321020; aaVt[ 9][14] = 0.054797;
16415 aaVt[ 9][15] = 0.081567; aaVt[ 9][16] = 0.376588; aaVt[ 9][17] = 0.034954; aaVt[ 9][18] = 0.086237; aaVt[ 9][19] = 3.654430;
16416 aaVt[10][ 0] = 0.424630; aaVt[10][ 1] = 0.192364; aaVt[10][ 2] = 0.069245; aaVt[10][ 3] = 0.060863; aaVt[10][ 4] = 0.091709;
16417 aaVt[10][ 5] = 0.243530; aaVt[10][ 6] = 0.151924; aaVt[10][ 7] = 0.087056; aaVt[10][ 8] = 0.103552; aaVt[10][ 9] = 2.089890;
16418 aaVt[10][10] = 0.000000; aaVt[10][11] = 0.201204; aaVt[10][12] = 1.105667; aaVt[10][13] = 0.946499; aaVt[10][14] = 0.169784;
16419 aaVt[10][15] = 0.214977; aaVt[10][16] = 0.243227; aaVt[10][17] = 0.083439; aaVt[10][18] = 0.189842; aaVt[10][19] = 1.337571;
16420 aaVt[11][ 0] = 0.393245; aaVt[11][ 1] = 1.755838; aaVt[11][ 2] = 0.503060; aaVt[11][ 3] = 0.261101; aaVt[11][ 4] = 0.004067;
16421 aaVt[11][ 5] = 0.738208; aaVt[11][ 6] = 0.888630; aaVt[11][ 7] = 0.193243; aaVt[11][ 8] = 0.153323; aaVt[11][ 9] = 0.093181;
16422 aaVt[11][10] = 0.201204; aaVt[11][11] = 0.000000; aaVt[11][12] = 0.096474; aaVt[11][13] = 0.038261; aaVt[11][14] = 0.212302;
16423 aaVt[11][15] = 0.400072; aaVt[11][16] = 0.446646; aaVt[11][17] = 0.023321; aaVt[11][18] = 0.068689; aaVt[11][19] = 0.144587;
16424 aaVt[12][ 0] = 0.211550; aaVt[12][ 1] = 0.087930; aaVt[12][ 2] = 0.057420; aaVt[12][ 3] = 0.012182; aaVt[12][ 4] = 0.023690;
16425 aaVt[12][ 5] = 0.120801; aaVt[12][ 6] = 0.058643; aaVt[12][ 7] = 0.046560; aaVt[12][ 8] = 0.021157; aaVt[12][ 9] = 0.493845;
16426 aaVt[12][10] = 1.105667; aaVt[12][11] = 0.096474; aaVt[12][12] = 0.000000; aaVt[12][13] = 0.173052; aaVt[12][14] = 0.010363;
16427 aaVt[12][15] = 0.090515; aaVt[12][16] = 0.184609; aaVt[12][17] = 0.022019; aaVt[12][18] = 0.073223; aaVt[12][19] = 0.307309;
16428 aaVt[13][ 0] = 0.116646; aaVt[13][ 1] = 0.042569; aaVt[13][ 2] = 0.039769; aaVt[13][ 3] = 0.016577; aaVt[13][ 4] = 0.051127;
16429 aaVt[13][ 5] = 0.026235; aaVt[13][ 6] = 0.028168; aaVt[13][ 7] = 0.050143; aaVt[13][ 8] = 0.079807; aaVt[13][ 9] = 0.321020;
16430 aaVt[13][10] = 0.946499; aaVt[13][11] = 0.038261; aaVt[13][12] = 0.173052; aaVt[13][13] = 0.000000; aaVt[13][14] = 0.042564;
16431 aaVt[13][15] = 0.138119; aaVt[13][16] = 0.085870; aaVt[13][17] = 0.128050; aaVt[13][18] = 0.898663; aaVt[13][19] = 0.247329;
16432 aaVt[14][ 0] = 0.399143; aaVt[14][ 1] = 0.128480; aaVt[14][ 2] = 0.083956; aaVt[14][ 3] = 0.160063; aaVt[14][ 4] = 0.011137;
16433 aaVt[14][ 5] = 0.156570; aaVt[14][ 6] = 0.205134; aaVt[14][ 7] = 0.124492; aaVt[14][ 8] = 0.078892; aaVt[14][ 9] = 0.054797;
16434 aaVt[14][10] = 0.169784; aaVt[14][11] = 0.212302; aaVt[14][12] = 0.010363; aaVt[14][13] = 0.042564; aaVt[14][14] = 0.000000;
16435 aaVt[14][15] = 0.430431; aaVt[14][16] = 0.207143; aaVt[14][17] = 0.014584; aaVt[14][18] = 0.032043; aaVt[14][19] = 0.129315;
16436 aaVt[15][ 0] = 1.817198; aaVt[15][ 1] = 0.292327; aaVt[15][ 2] = 0.847049; aaVt[15][ 3] = 0.461519; aaVt[15][ 4] = 0.175270;
16437 aaVt[15][ 5] = 0.358017; aaVt[15][ 6] = 0.406035; aaVt[15][ 7] = 0.612843; aaVt[15][ 8] = 0.167406; aaVt[15][ 9] = 0.081567;
16438 aaVt[15][10] = 0.214977; aaVt[15][11] = 0.400072; aaVt[15][12] = 0.090515; aaVt[15][13] = 0.138119; aaVt[15][14] = 0.430431;
16439 aaVt[15][15] = 0.000000; aaVt[15][16] = 1.767766; aaVt[15][17] = 0.035933; aaVt[15][18] = 0.121979; aaVt[15][19] = 0.127700;
16440 aaVt[16][ 0] = 0.877877; aaVt[16][ 1] = 0.204109; aaVt[16][ 2] = 0.471268; aaVt[16][ 3] = 0.178197; aaVt[16][ 4] = 0.079511;
16441 aaVt[16][ 5] = 0.248992; aaVt[16][ 6] = 0.321028; aaVt[16][ 7] = 0.136266; aaVt[16][ 8] = 0.101117; aaVt[16][ 9] = 0.376588;
16442 aaVt[16][10] = 0.243227; aaVt[16][11] = 0.446646; aaVt[16][12] = 0.184609; aaVt[16][13] = 0.085870; aaVt[16][14] = 0.207143;
16443 aaVt[16][15] = 1.767766; aaVt[16][16] = 0.000000; aaVt[16][17] = 0.020437; aaVt[16][18] = 0.094617; aaVt[16][19] = 0.740372;
16444 aaVt[17][ 0] = 0.030309; aaVt[17][ 1] = 0.046417; aaVt[17][ 2] = 0.010459; aaVt[17][ 3] = 0.011393; aaVt[17][ 4] = 0.007732;
16445 aaVt[17][ 5] = 0.021248; aaVt[17][ 6] = 0.018844; aaVt[17][ 7] = 0.023990; aaVt[17][ 8] = 0.020009; aaVt[17][ 9] = 0.034954;
16446 aaVt[17][10] = 0.083439; aaVt[17][11] = 0.023321; aaVt[17][12] = 0.022019; aaVt[17][13] = 0.128050; aaVt[17][14] = 0.014584;
16447 aaVt[17][15] = 0.035933; aaVt[17][16] = 0.020437; aaVt[17][17] = 0.000000; aaVt[17][18] = 0.124746; aaVt[17][19] = 0.022134;
16448 aaVt[18][ 0] = 0.087061; aaVt[18][ 1] = 0.097010; aaVt[18][ 2] = 0.093268; aaVt[18][ 3] = 0.051664; aaVt[18][ 4] = 0.042823;
16449 aaVt[18][ 5] = 0.062544; aaVt[18][ 6] = 0.055200; aaVt[18][ 7] = 0.037568; aaVt[18][ 8] = 0.286027; aaVt[18][ 9] = 0.086237;
16450 aaVt[18][10] = 0.189842; aaVt[18][11] = 0.068689; aaVt[18][12] = 0.073223; aaVt[18][13] = 0.898663; aaVt[18][14] = 0.032043;
16451 aaVt[18][15] = 0.121979; aaVt[18][16] = 0.094617; aaVt[18][17] = 0.124746; aaVt[18][18] = 0.000000; aaVt[18][19] = 0.125733;
16452 aaVt[19][ 0] = 1.230985; aaVt[19][ 1] = 0.113146; aaVt[19][ 2] = 0.049824; aaVt[19][ 3] = 0.048769; aaVt[19][ 4] = 0.163831;
16453 aaVt[19][ 5] = 0.112027; aaVt[19][ 6] = 0.205868; aaVt[19][ 7] = 0.082579; aaVt[19][ 8] = 0.068575; aaVt[19][ 9] = 3.654430;
16454 aaVt[19][10] = 1.337571; aaVt[19][11] = 0.144587; aaVt[19][12] = 0.307309; aaVt[19][13] = 0.247329; aaVt[19][14] = 0.129315;
16455 aaVt[19][15] = 0.127700; aaVt[19][16] = 0.740372; aaVt[19][17] = 0.022134; aaVt[19][18] = 0.125733; aaVt[19][19] = 0.000000;
16457 vtPi[ 0] = 0.078837;
16458 vtPi[ 1] = 0.051238;
16459 vtPi[ 2] = 0.042313;
16460 vtPi[ 3] = 0.053066;
16461 vtPi[ 4] = 0.015175;
16462 vtPi[ 5] = 0.036713;
16463 vtPi[ 6] = 0.061924;
16464 vtPi[ 7] = 0.070852;
16465 vtPi[ 8] = 0.023082;
16466 vtPi[ 9] = 0.062056;
16467 vtPi[10] = 0.096371;
16468 vtPi[11] = 0.057324;
16469 vtPi[12] = 0.023771;
16470 vtPi[13] = 0.043296;
16471 vtPi[14] = 0.043911;
16472 vtPi[15] = 0.063403;
16473 vtPi[16] = 0.055897;
16474 vtPi[17] = 0.013272;
16475 vtPi[18] = 0.034399;
16476 vtPi[19] = 0.073101;
16479 aaBlosum[ 0][ 0] = 0.000000000000; aaBlosum[ 0][ 1] = 0.735790389698; aaBlosum[ 0][ 2] = 0.485391055466; aaBlosum[ 0][ 3] = 0.543161820899; aaBlosum[ 0][ 4] = 1.459995310470;
16480 aaBlosum[ 0][ 5] = 1.199705704602; aaBlosum[ 0][ 6] = 1.170949042800; aaBlosum[ 0][ 7] = 1.955883574960; aaBlosum[ 0][ 8] = 0.716241444998; aaBlosum[ 0][ 9] = 0.605899003687;
16481 aaBlosum[ 0][10] = 0.800016530518; aaBlosum[ 0][11] = 1.295201266783; aaBlosum[ 0][12] = 1.253758266664; aaBlosum[ 0][13] = 0.492964679748; aaBlosum[ 0][14] = 1.173275900924;
16482 aaBlosum[ 0][15] = 4.325092687057; aaBlosum[ 0][16] = 1.729178019485; aaBlosum[ 0][17] = 0.465839367725; aaBlosum[ 0][18] = 0.718206697586; aaBlosum[ 0][19] = 2.187774522005;
16483 aaBlosum[ 1][ 0] = 0.735790389698; aaBlosum[ 1][ 1] = 0.000000000000; aaBlosum[ 1][ 2] = 1.297446705134; aaBlosum[ 1][ 3] = 0.500964408555; aaBlosum[ 1][ 4] = 0.227826574209;
16484 aaBlosum[ 1][ 5] = 3.020833610064; aaBlosum[ 1][ 6] = 1.360574190420; aaBlosum[ 1][ 7] = 0.418763308518; aaBlosum[ 1][ 8] = 1.456141166336; aaBlosum[ 1][ 9] = 0.232036445142;
16485 aaBlosum[ 1][10] = 0.622711669692; aaBlosum[ 1][11] = 5.411115141489; aaBlosum[ 1][12] = 0.983692987457; aaBlosum[ 1][13] = 0.371644693209; aaBlosum[ 1][14] = 0.448133661718;
16486 aaBlosum[ 1][15] = 1.122783104210; aaBlosum[ 1][16] = 0.914665954563; aaBlosum[ 1][17] = 0.426382310122; aaBlosum[ 1][18] = 0.720517441216; aaBlosum[ 1][19] = 0.438388343772;
16487 aaBlosum[ 2][ 0] = 0.485391055466; aaBlosum[ 2][ 1] = 1.297446705134; aaBlosum[ 2][ 2] = 0.000000000000; aaBlosum[ 2][ 3] = 3.180100048216; aaBlosum[ 2][ 4] = 0.397358949897;
16488 aaBlosum[ 2][ 5] = 1.839216146992; aaBlosum[ 2][ 6] = 1.240488508640; aaBlosum[ 2][ 7] = 1.355872344485; aaBlosum[ 2][ 8] = 2.414501434208; aaBlosum[ 2][ 9] = 0.283017326278;
16489 aaBlosum[ 2][10] = 0.211888159615; aaBlosum[ 2][11] = 1.593137043457; aaBlosum[ 2][12] = 0.648441278787; aaBlosum[ 2][13] = 0.354861249223; aaBlosum[ 2][14] = 0.494887043702;
16490 aaBlosum[ 2][15] = 2.904101656456; aaBlosum[ 2][16] = 1.898173634533; aaBlosum[ 2][17] = 0.191482046247; aaBlosum[ 2][18] = 0.538222519037; aaBlosum[ 2][19] = 0.312858797993;
16491 aaBlosum[ 3][ 0] = 0.543161820899; aaBlosum[ 3][ 1] = 0.500964408555; aaBlosum[ 3][ 2] = 3.180100048216; aaBlosum[ 3][ 3] = 0.000000000000; aaBlosum[ 3][ 4] = 0.240836614802;
16492 aaBlosum[ 3][ 5] = 1.190945703396; aaBlosum[ 3][ 6] = 3.761625208368; aaBlosum[ 3][ 7] = 0.798473248968; aaBlosum[ 3][ 8] = 0.778142664022; aaBlosum[ 3][ 9] = 0.418555732462;
16493 aaBlosum[ 3][10] = 0.218131577594; aaBlosum[ 3][11] = 1.032447924952; aaBlosum[ 3][12] = 0.222621897958; aaBlosum[ 3][13] = 0.281730694207; aaBlosum[ 3][14] = 0.730628272998;
16494 aaBlosum[ 3][15] = 1.582754142065; aaBlosum[ 3][16] = 0.934187509431; aaBlosum[ 3][17] = 0.145345046279; aaBlosum[ 3][18] = 0.261422208965; aaBlosum[ 3][19] = 0.258129289418;
16495 aaBlosum[ 4][ 0] = 1.459995310470; aaBlosum[ 4][ 1] = 0.227826574209; aaBlosum[ 4][ 2] = 0.397358949897; aaBlosum[ 4][ 3] = 0.240836614802; aaBlosum[ 4][ 4] = 0.000000000000;
16496 aaBlosum[ 4][ 5] = 0.329801504630; aaBlosum[ 4][ 6] = 0.140748891814; aaBlosum[ 4][ 7] = 0.418203192284; aaBlosum[ 4][ 8] = 0.354058109831; aaBlosum[ 4][ 9] = 0.774894022794;
16497 aaBlosum[ 4][10] = 0.831842640142; aaBlosum[ 4][11] = 0.285078800906; aaBlosum[ 4][12] = 0.767688823480; aaBlosum[ 4][13] = 0.441337471187; aaBlosum[ 4][14] = 0.356008498769;
16498 aaBlosum[ 4][15] = 1.197188415094; aaBlosum[ 4][16] = 1.119831358516; aaBlosum[ 4][17] = 0.527664418872; aaBlosum[ 4][18] = 0.470237733696; aaBlosum[ 4][19] = 1.116352478606;
16499 aaBlosum[ 5][ 0] = 1.199705704602; aaBlosum[ 5][ 1] = 3.020833610064; aaBlosum[ 5][ 2] = 1.839216146992; aaBlosum[ 5][ 3] = 1.190945703396; aaBlosum[ 5][ 4] = 0.329801504630;
16500 aaBlosum[ 5][ 5] = 0.000000000000; aaBlosum[ 5][ 6] = 5.528919177928; aaBlosum[ 5][ 7] = 0.609846305383; aaBlosum[ 5][ 8] = 2.435341131140; aaBlosum[ 5][ 9] = 0.236202451204;
16501 aaBlosum[ 5][10] = 0.580737093181; aaBlosum[ 5][11] = 3.945277674515; aaBlosum[ 5][12] = 2.494896077113; aaBlosum[ 5][13] = 0.144356959750; aaBlosum[ 5][14] = 0.858570575674;
16502 aaBlosum[ 5][15] = 1.934870924596; aaBlosum[ 5][16] = 1.277480294596; aaBlosum[ 5][17] = 0.758653808642; aaBlosum[ 5][18] = 0.958989742850; aaBlosum[ 5][19] = 0.530785790125;
16503 aaBlosum[ 6][ 0] = 1.170949042800; aaBlosum[ 6][ 1] = 1.360574190420; aaBlosum[ 6][ 2] = 1.240488508640; aaBlosum[ 6][ 3] = 3.761625208368; aaBlosum[ 6][ 4] = 0.140748891814;
16504 aaBlosum[ 6][ 5] = 5.528919177928; aaBlosum[ 6][ 6] = 0.000000000000; aaBlosum[ 6][ 7] = 0.423579992176; aaBlosum[ 6][ 8] = 1.626891056982; aaBlosum[ 6][ 9] = 0.186848046932;
16505 aaBlosum[ 6][10] = 0.372625175087; aaBlosum[ 6][11] = 2.802427151679; aaBlosum[ 6][12] = 0.555415397470; aaBlosum[ 6][13] = 0.291409084165; aaBlosum[ 6][14] = 0.926563934846;
16506 aaBlosum[ 6][15] = 1.769893238937; aaBlosum[ 6][16] = 1.071097236007; aaBlosum[ 6][17] = 0.407635648938; aaBlosum[ 6][18] = 0.596719300346; aaBlosum[ 6][19] = 0.524253846338;
16507 aaBlosum[ 7][ 0] = 1.955883574960; aaBlosum[ 7][ 1] = 0.418763308518; aaBlosum[ 7][ 2] = 1.355872344485; aaBlosum[ 7][ 3] = 0.798473248968; aaBlosum[ 7][ 4] = 0.418203192284;
16508 aaBlosum[ 7][ 5] = 0.609846305383; aaBlosum[ 7][ 6] = 0.423579992176; aaBlosum[ 7][ 7] = 0.000000000000; aaBlosum[ 7][ 8] = 0.539859124954; aaBlosum[ 7][ 9] = 0.189296292376;
16509 aaBlosum[ 7][10] = 0.217721159236; aaBlosum[ 7][11] = 0.752042440303; aaBlosum[ 7][12] = 0.459436173579; aaBlosum[ 7][13] = 0.368166464453; aaBlosum[ 7][14] = 0.504086599527;
16510 aaBlosum[ 7][15] = 1.509326253224; aaBlosum[ 7][16] = 0.641436011405; aaBlosum[ 7][17] = 0.508358924638; aaBlosum[ 7][18] = 0.308055737035; aaBlosum[ 7][19] = 0.253340790190;
16511 aaBlosum[ 8][ 0] = 0.716241444998; aaBlosum[ 8][ 1] = 1.456141166336; aaBlosum[ 8][ 2] = 2.414501434208; aaBlosum[ 8][ 3] = 0.778142664022; aaBlosum[ 8][ 4] = 0.354058109831;
16512 aaBlosum[ 8][ 5] = 2.435341131140; aaBlosum[ 8][ 6] = 1.626891056982; aaBlosum[ 8][ 7] = 0.539859124954; aaBlosum[ 8][ 8] = 0.000000000000; aaBlosum[ 8][ 9] = 0.252718447885;
16513 aaBlosum[ 8][10] = 0.348072209797; aaBlosum[ 8][11] = 1.022507035889; aaBlosum[ 8][12] = 0.984311525359; aaBlosum[ 8][13] = 0.714533703928; aaBlosum[ 8][14] = 0.527007339151;
16514 aaBlosum[ 8][15] = 1.117029762910; aaBlosum[ 8][16] = 0.585407090225; aaBlosum[ 8][17] = 0.301248600780; aaBlosum[ 8][18] = 4.218953969389; aaBlosum[ 8][19] = 0.201555971750;
16515 aaBlosum[ 9][ 0] = 0.605899003687; aaBlosum[ 9][ 1] = 0.232036445142; aaBlosum[ 9][ 2] = 0.283017326278; aaBlosum[ 9][ 3] = 0.418555732462; aaBlosum[ 9][ 4] = 0.774894022794;
16516 aaBlosum[ 9][ 5] = 0.236202451204; aaBlosum[ 9][ 6] = 0.186848046932; aaBlosum[ 9][ 7] = 0.189296292376; aaBlosum[ 9][ 8] = 0.252718447885; aaBlosum[ 9][ 9] = 0.000000000000;
16517 aaBlosum[ 9][10] = 3.890963773304; aaBlosum[ 9][11] = 0.406193586642; aaBlosum[ 9][12] = 3.364797763104; aaBlosum[ 9][13] = 1.517359325954; aaBlosum[ 9][14] = 0.388355409206;
16518 aaBlosum[ 9][15] = 0.357544412460; aaBlosum[ 9][16] = 1.179091197260; aaBlosum[ 9][17] = 0.341985787540; aaBlosum[ 9][18] = 0.674617093228; aaBlosum[ 9][19] = 8.311839405458;
16519 aaBlosum[10][ 0] = 0.800016530518; aaBlosum[10][ 1] = 0.622711669692; aaBlosum[10][ 2] = 0.211888159615; aaBlosum[10][ 3] = 0.218131577594; aaBlosum[10][ 4] = 0.831842640142;
16520 aaBlosum[10][ 5] = 0.580737093181; aaBlosum[10][ 6] = 0.372625175087; aaBlosum[10][ 7] = 0.217721159236; aaBlosum[10][ 8] = 0.348072209797; aaBlosum[10][ 9] = 3.890963773304;
16521 aaBlosum[10][10] = 0.000000000000; aaBlosum[10][11] = 0.445570274261; aaBlosum[10][12] = 6.030559379572; aaBlosum[10][13] = 2.064839703237; aaBlosum[10][14] = 0.374555687471;
16522 aaBlosum[10][15] = 0.352969184527; aaBlosum[10][16] = 0.915259857694; aaBlosum[10][17] = 0.691474634600; aaBlosum[10][18] = 0.811245856323; aaBlosum[10][19] = 2.231405688913;
16523 aaBlosum[11][ 0] = 1.295201266783; aaBlosum[11][ 1] = 5.411115141489; aaBlosum[11][ 2] = 1.593137043457; aaBlosum[11][ 3] = 1.032447924952; aaBlosum[11][ 4] = 0.285078800906;
16524 aaBlosum[11][ 5] = 3.945277674515; aaBlosum[11][ 6] = 2.802427151679; aaBlosum[11][ 7] = 0.752042440303; aaBlosum[11][ 8] = 1.022507035889; aaBlosum[11][ 9] = 0.406193586642;
16525 aaBlosum[11][10] = 0.445570274261; aaBlosum[11][11] = 0.000000000000; aaBlosum[11][12] = 1.073061184332; aaBlosum[11][13] = 0.266924750511; aaBlosum[11][14] = 1.047383450722;
16526 aaBlosum[11][15] = 1.752165917819; aaBlosum[11][16] = 1.303875200799; aaBlosum[11][17] = 0.332243040634; aaBlosum[11][18] = 0.717993486900; aaBlosum[11][19] = 0.498138475304;
16527 aaBlosum[12][ 0] = 1.253758266664; aaBlosum[12][ 1] = 0.983692987457; aaBlosum[12][ 2] = 0.648441278787; aaBlosum[12][ 3] = 0.222621897958; aaBlosum[12][ 4] = 0.767688823480;
16528 aaBlosum[12][ 5] = 2.494896077113; aaBlosum[12][ 6] = 0.555415397470; aaBlosum[12][ 7] = 0.459436173579; aaBlosum[12][ 8] = 0.984311525359; aaBlosum[12][ 9] = 3.364797763104;
16529 aaBlosum[12][10] = 6.030559379572; aaBlosum[12][11] = 1.073061184332; aaBlosum[12][12] = 0.000000000000; aaBlosum[12][13] = 1.773855168830; aaBlosum[12][14] = 0.454123625103;
16530 aaBlosum[12][15] = 0.918723415746; aaBlosum[12][16] = 1.488548053722; aaBlosum[12][17] = 0.888101098152; aaBlosum[12][18] = 0.951682162246; aaBlosum[12][19] = 2.575850755315;
16531 aaBlosum[13][ 0] = 0.492964679748; aaBlosum[13][ 1] = 0.371644693209; aaBlosum[13][ 2] = 0.354861249223; aaBlosum[13][ 3] = 0.281730694207; aaBlosum[13][ 4] = 0.441337471187;
16532 aaBlosum[13][ 5] = 0.144356959750; aaBlosum[13][ 6] = 0.291409084165; aaBlosum[13][ 7] = 0.368166464453; aaBlosum[13][ 8] = 0.714533703928; aaBlosum[13][ 9] = 1.517359325954;
16533 aaBlosum[13][10] = 2.064839703237; aaBlosum[13][11] = 0.266924750511; aaBlosum[13][12] = 1.773855168830; aaBlosum[13][13] = 0.000000000000; aaBlosum[13][14] = 0.233597909629;
16534 aaBlosum[13][15] = 0.540027644824; aaBlosum[13][16] = 0.488206118793; aaBlosum[13][17] = 2.074324893497; aaBlosum[13][18] = 6.747260430801; aaBlosum[13][19] = 0.838119610178;
16535 aaBlosum[14][ 0] = 1.173275900924; aaBlosum[14][ 1] = 0.448133661718; aaBlosum[14][ 2] = 0.494887043702; aaBlosum[14][ 3] = 0.730628272998; aaBlosum[14][ 4] = 0.356008498769;
16536 aaBlosum[14][ 5] = 0.858570575674; aaBlosum[14][ 6] = 0.926563934846; aaBlosum[14][ 7] = 0.504086599527; aaBlosum[14][ 8] = 0.527007339151; aaBlosum[14][ 9] = 0.388355409206;
16537 aaBlosum[14][10] = 0.374555687471; aaBlosum[14][11] = 1.047383450722; aaBlosum[14][12] = 0.454123625103; aaBlosum[14][13] = 0.233597909629; aaBlosum[14][14] = 0.000000000000;
16538 aaBlosum[14][15] = 1.169129577716; aaBlosum[14][16] = 1.005451683149; aaBlosum[14][17] = 0.252214830027; aaBlosum[14][18] = 0.369405319355; aaBlosum[14][19] = 0.496908410676;
16539 aaBlosum[15][ 0] = 4.325092687057; aaBlosum[15][ 1] = 1.122783104210; aaBlosum[15][ 2] = 2.904101656456; aaBlosum[15][ 3] = 1.582754142065; aaBlosum[15][ 4] = 1.197188415094;
16540 aaBlosum[15][ 5] = 1.934870924596; aaBlosum[15][ 6] = 1.769893238937; aaBlosum[15][ 7] = 1.509326253224; aaBlosum[15][ 8] = 1.117029762910; aaBlosum[15][ 9] = 0.357544412460;
16541 aaBlosum[15][10] = 0.352969184527; aaBlosum[15][11] = 1.752165917819; aaBlosum[15][12] = 0.918723415746; aaBlosum[15][13] = 0.540027644824; aaBlosum[15][14] = 1.169129577716;
16542 aaBlosum[15][15] = 0.000000000000; aaBlosum[15][16] = 5.151556292270; aaBlosum[15][17] = 0.387925622098; aaBlosum[15][18] = 0.796751520761; aaBlosum[15][19] = 0.561925457442;
16543 aaBlosum[16][ 0] = 1.729178019485; aaBlosum[16][ 1] = 0.914665954563; aaBlosum[16][ 2] = 1.898173634533; aaBlosum[16][ 3] = 0.934187509431; aaBlosum[16][ 4] = 1.119831358516;
16544 aaBlosum[16][ 5] = 1.277480294596; aaBlosum[16][ 6] = 1.071097236007; aaBlosum[16][ 7] = 0.641436011405; aaBlosum[16][ 8] = 0.585407090225; aaBlosum[16][ 9] = 1.179091197260;
16545 aaBlosum[16][10] = 0.915259857694; aaBlosum[16][11] = 1.303875200799; aaBlosum[16][12] = 1.488548053722; aaBlosum[16][13] = 0.488206118793; aaBlosum[16][14] = 1.005451683149;
16546 aaBlosum[16][15] = 5.151556292270; aaBlosum[16][16] = 0.000000000000; aaBlosum[16][17] = 0.513128126891; aaBlosum[16][18] = 0.801010243199; aaBlosum[16][19] = 2.253074051176;
16547 aaBlosum[17][ 0] = 0.465839367725; aaBlosum[17][ 1] = 0.426382310122; aaBlosum[17][ 2] = 0.191482046247; aaBlosum[17][ 3] = 0.145345046279; aaBlosum[17][ 4] = 0.527664418872;
16548 aaBlosum[17][ 5] = 0.758653808642; aaBlosum[17][ 6] = 0.407635648938; aaBlosum[17][ 7] = 0.508358924638; aaBlosum[17][ 8] = 0.301248600780; aaBlosum[17][ 9] = 0.341985787540;
16549 aaBlosum[17][10] = 0.691474634600; aaBlosum[17][11] = 0.332243040634; aaBlosum[17][12] = 0.888101098152; aaBlosum[17][13] = 2.074324893497; aaBlosum[17][14] = 0.252214830027;
16550 aaBlosum[17][15] = 0.387925622098; aaBlosum[17][16] = 0.513128126891; aaBlosum[17][17] = 0.000000000000; aaBlosum[17][18] = 4.054419006558; aaBlosum[17][19] = 0.266508731426;
16551 aaBlosum[18][ 0] = 0.718206697586; aaBlosum[18][ 1] = 0.720517441216; aaBlosum[18][ 2] = 0.538222519037; aaBlosum[18][ 3] = 0.261422208965; aaBlosum[18][ 4] = 0.470237733696;
16552 aaBlosum[18][ 5] = 0.958989742850; aaBlosum[18][ 6] = 0.596719300346; aaBlosum[18][ 7] = 0.308055737035; aaBlosum[18][ 8] = 4.218953969389; aaBlosum[18][ 9] = 0.674617093228;
16553 aaBlosum[18][10] = 0.811245856323; aaBlosum[18][11] = 0.717993486900; aaBlosum[18][12] = 0.951682162246; aaBlosum[18][13] = 6.747260430801; aaBlosum[18][14] = 0.369405319355;
16554 aaBlosum[18][15] = 0.796751520761; aaBlosum[18][16] = 0.801010243199; aaBlosum[18][17] = 4.054419006558; aaBlosum[18][18] = 0.000000000000; aaBlosum[18][19] = 1.000000000000;
16555 aaBlosum[19][ 0] = 2.187774522005; aaBlosum[19][ 1] = 0.438388343772; aaBlosum[19][ 2] = 0.312858797993; aaBlosum[19][ 3] = 0.258129289418; aaBlosum[19][ 4] = 1.116352478606;
16556 aaBlosum[19][ 5] = 0.530785790125; aaBlosum[19][ 6] = 0.524253846338; aaBlosum[19][ 7] = 0.253340790190; aaBlosum[19][ 8] = 0.201555971750; aaBlosum[19][ 9] = 8.311839405458;
16557 aaBlosum[19][10] = 2.231405688913; aaBlosum[19][11] = 0.498138475304; aaBlosum[19][12] = 2.575850755315; aaBlosum[19][13] = 0.838119610178; aaBlosum[19][14] = 0.496908410676;
16558 aaBlosum[19][15] = 0.561925457442; aaBlosum[19][16] = 2.253074051176; aaBlosum[19][17] = 0.266508731426; aaBlosum[19][18] = 1.000000000000; aaBlosum[19][19] = 0.000000000000;
16560 blosPi[ 0] = 0.074;
16561 blosPi[ 1] = 0.052;
16562 blosPi[ 2] = 0.045;
16563 blosPi[ 3] = 0.054;
16564 blosPi[ 4] = 0.025;
16565 blosPi[ 5] = 0.034;
16566 blosPi[ 6] = 0.054;
16567 blosPi[ 7] = 0.074;
16568 blosPi[ 8] = 0.026;
16569 blosPi[ 9] = 0.068;
16570 blosPi[10] = 0.099;
16571 blosPi[11] = 0.058;
16572 blosPi[12] = 0.025;
16573 blosPi[13] = 0.047;
16574 blosPi[14] = 0.039;
16575 blosPi[15] = 0.057;
16576 blosPi[16] = 0.051;
16577 blosPi[17] = 0.013;
16578 blosPi[18] = 0.032;
16579 blosPi[19] = 0.073;
16582 aaLG[ 0][ 0] = 0.000000; aaLG[ 0][ 1] = 0.425093; aaLG[ 0][ 2] = 0.276818; aaLG[ 0][ 3] = 0.395144; aaLG[ 0][ 4] = 2.489084;
16583 aaLG[ 0][ 5] = 0.969894; aaLG[ 0][ 6] = 1.038545; aaLG[ 0][ 7] = 2.066040; aaLG[ 0][ 8] = 0.358858; aaLG[ 0][ 9] = 0.149830;
16584 aaLG[ 0][10] = 0.395337; aaLG[ 0][11] = 0.536518; aaLG[ 0][12] = 1.124035; aaLG[ 0][13] = 0.253701; aaLG[ 0][14] = 1.177651;
16585 aaLG[ 0][15] = 4.727182; aaLG[ 0][16] = 2.139501; aaLG[ 0][17] = 0.180717; aaLG[ 0][18] = 0.218959; aaLG[ 0][19] = 2.547870;
16586 aaLG[ 1][ 0] = 0.425093; aaLG[ 1][ 1] = 0.000000; aaLG[ 1][ 2] = 0.751878; aaLG[ 1][ 3] = 0.123954; aaLG[ 1][ 4] = 0.534551;
16587 aaLG[ 1][ 5] = 2.807908; aaLG[ 1][ 6] = 0.363970; aaLG[ 1][ 7] = 0.390192; aaLG[ 1][ 8] = 2.426601; aaLG[ 1][ 9] = 0.126991;
16588 aaLG[ 1][10] = 0.301848; aaLG[ 1][11] = 6.326067; aaLG[ 1][12] = 0.484133; aaLG[ 1][13] = 0.052722; aaLG[ 1][14] = 0.332533;
16589 aaLG[ 1][15] = 0.858151; aaLG[ 1][16] = 0.578987; aaLG[ 1][17] = 0.593607; aaLG[ 1][18] = 0.314440; aaLG[ 1][19] = 0.170887;
16590 aaLG[ 2][ 0] = 0.276818; aaLG[ 2][ 1] = 0.751878; aaLG[ 2][ 2] = 0.000000; aaLG[ 2][ 3] = 5.076149; aaLG[ 2][ 4] = 0.528768;
16591 aaLG[ 2][ 5] = 1.695752; aaLG[ 2][ 6] = 0.541712; aaLG[ 2][ 7] = 1.437645; aaLG[ 2][ 8] = 4.509238; aaLG[ 2][ 9] = 0.191503;
16592 aaLG[ 2][10] = 0.068427; aaLG[ 2][11] = 2.145078; aaLG[ 2][12] = 0.371004; aaLG[ 2][13] = 0.089525; aaLG[ 2][14] = 0.161787;
16593 aaLG[ 2][15] = 4.008358; aaLG[ 2][16] = 2.000679; aaLG[ 2][17] = 0.045376; aaLG[ 2][18] = 0.612025; aaLG[ 2][19] = 0.083688;
16594 aaLG[ 3][ 0] = 0.395144; aaLG[ 3][ 1] = 0.123954; aaLG[ 3][ 2] = 5.076149; aaLG[ 3][ 3] = 0.000000; aaLG[ 3][ 4] = 0.062556;
16595 aaLG[ 3][ 5] = 0.523386; aaLG[ 3][ 6] = 5.243870; aaLG[ 3][ 7] = 0.844926; aaLG[ 3][ 8] = 0.927114; aaLG[ 3][ 9] = 0.010690;
16596 aaLG[ 3][10] = 0.015076; aaLG[ 3][11] = 0.282959; aaLG[ 3][12] = 0.025548; aaLG[ 3][13] = 0.017416; aaLG[ 3][14] = 0.394456;
16597 aaLG[ 3][15] = 1.240275; aaLG[ 3][16] = 0.425860; aaLG[ 3][17] = 0.029890; aaLG[ 3][18] = 0.135107; aaLG[ 3][19] = 0.037967;
16598 aaLG[ 4][ 0] = 2.489084; aaLG[ 4][ 1] = 0.534551; aaLG[ 4][ 2] = 0.528768; aaLG[ 4][ 3] = 0.062556; aaLG[ 4][ 4] = 0.000000;
16599 aaLG[ 4][ 5] = 0.084808; aaLG[ 4][ 6] = 0.003499; aaLG[ 4][ 7] = 0.569265; aaLG[ 4][ 8] = 0.640543; aaLG[ 4][ 9] = 0.320627;
16600 aaLG[ 4][10] = 0.594007; aaLG[ 4][11] = 0.013266; aaLG[ 4][12] = 0.893680; aaLG[ 4][13] = 1.105251; aaLG[ 4][14] = 0.075382;
16601 aaLG[ 4][15] = 2.784478; aaLG[ 4][16] = 1.143480; aaLG[ 4][17] = 0.670128; aaLG[ 4][18] = 1.165532; aaLG[ 4][19] = 1.959291;
16602 aaLG[ 5][ 0] = 0.969894; aaLG[ 5][ 1] = 2.807908; aaLG[ 5][ 2] = 1.695752; aaLG[ 5][ 3] = 0.523386; aaLG[ 5][ 4] = 0.084808;
16603 aaLG[ 5][ 5] = 0.000000; aaLG[ 5][ 6] = 4.128591; aaLG[ 5][ 7] = 0.267959; aaLG[ 5][ 8] = 4.813505; aaLG[ 5][ 9] = 0.072854;
16604 aaLG[ 5][10] = 0.582457; aaLG[ 5][11] = 3.234294; aaLG[ 5][12] = 1.672569; aaLG[ 5][13] = 0.035855; aaLG[ 5][14] = 0.624294;
16605 aaLG[ 5][15] = 1.223828; aaLG[ 5][16] = 1.080136; aaLG[ 5][17] = 0.236199; aaLG[ 5][18] = 0.257336; aaLG[ 5][19] = 0.210332;
16606 aaLG[ 6][ 0] = 1.038545; aaLG[ 6][ 1] = 0.363970; aaLG[ 6][ 2] = 0.541712; aaLG[ 6][ 3] = 5.243870; aaLG[ 6][ 4] = 0.003499;
16607 aaLG[ 6][ 5] = 4.128591; aaLG[ 6][ 6] = 0.000000; aaLG[ 6][ 7] = 0.348847; aaLG[ 6][ 8] = 0.423881; aaLG[ 6][ 9] = 0.044265;
16608 aaLG[ 6][10] = 0.069673; aaLG[ 6][11] = 1.807177; aaLG[ 6][12] = 0.173735; aaLG[ 6][13] = 0.018811; aaLG[ 6][14] = 0.419409;
16609 aaLG[ 6][15] = 0.611973; aaLG[ 6][16] = 0.604545; aaLG[ 6][17] = 0.077852; aaLG[ 6][18] = 0.120037; aaLG[ 6][19] = 0.245034;
16610 aaLG[ 7][ 0] = 2.066040; aaLG[ 7][ 1] = 0.390192; aaLG[ 7][ 2] = 1.437645; aaLG[ 7][ 3] = 0.844926; aaLG[ 7][ 4] = 0.569265;
16611 aaLG[ 7][ 5] = 0.267959; aaLG[ 7][ 6] = 0.348847; aaLG[ 7][ 7] = 0.000000; aaLG[ 7][ 8] = 0.311484; aaLG[ 7][ 9] = 0.008705;
16612 aaLG[ 7][10] = 0.044261; aaLG[ 7][11] = 0.296636; aaLG[ 7][12] = 0.139538; aaLG[ 7][13] = 0.089586; aaLG[ 7][14] = 0.196961;
16613 aaLG[ 7][15] = 1.739990; aaLG[ 7][16] = 0.129836; aaLG[ 7][17] = 0.268491; aaLG[ 7][18] = 0.054679; aaLG[ 7][19] = 0.076701;
16614 aaLG[ 8][ 0] = 0.358858; aaLG[ 8][ 1] = 2.426601; aaLG[ 8][ 2] = 4.509238; aaLG[ 8][ 3] = 0.927114; aaLG[ 8][ 4] = 0.640543;
16615 aaLG[ 8][ 5] = 4.813505; aaLG[ 8][ 6] = 0.423881; aaLG[ 8][ 7] = 0.311484; aaLG[ 8][ 8] = 0.000000; aaLG[ 8][ 9] = 0.108882;
16616 aaLG[ 8][10] = 0.366317; aaLG[ 8][11] = 0.697264; aaLG[ 8][12] = 0.442472; aaLG[ 8][13] = 0.682139; aaLG[ 8][14] = 0.508851;
16617 aaLG[ 8][15] = 0.990012; aaLG[ 8][16] = 0.584262; aaLG[ 8][17] = 0.597054; aaLG[ 8][18] = 5.306834; aaLG[ 8][19] = 0.119013;
16618 aaLG[ 9][ 0] = 0.149830; aaLG[ 9][ 1] = 0.126991; aaLG[ 9][ 2] = 0.191503; aaLG[ 9][ 3] = 0.010690; aaLG[ 9][ 4] = 0.320627;
16619 aaLG[ 9][ 5] = 0.072854; aaLG[ 9][ 6] = 0.044265; aaLG[ 9][ 7] = 0.008705; aaLG[ 9][ 8] = 0.108882; aaLG[ 9][ 9] = 0.000000;
16620 aaLG[ 9][10] = 4.145067; aaLG[ 9][11] = 0.159069; aaLG[ 9][12] = 4.273607; aaLG[ 9][13] = 1.112727; aaLG[ 9][14] = 0.078281;
16621 aaLG[ 9][15] = 0.064105; aaLG[ 9][16] = 1.033739; aaLG[ 9][17] = 0.111660; aaLG[ 9][18] = 0.232523; aaLG[ 9][19] = 10.649107;
16622 aaLG[10][ 0] = 0.395337; aaLG[10][ 1] = 0.301848; aaLG[10][ 2] = 0.068427; aaLG[10][ 3] = 0.015076; aaLG[10][ 4] = 0.594007;
16623 aaLG[10][ 5] = 0.582457; aaLG[10][ 6] = 0.069673; aaLG[10][ 7] = 0.044261; aaLG[10][ 8] = 0.366317; aaLG[10][ 9] = 4.145067;
16624 aaLG[10][10] = 0.000000; aaLG[10][11] = 0.137500; aaLG[10][12] = 6.312358; aaLG[10][13] = 2.592692; aaLG[10][14] = 0.249060;
16625 aaLG[10][15] = 0.182287; aaLG[10][16] = 0.302936; aaLG[10][17] = 0.619632; aaLG[10][18] = 0.299648; aaLG[10][19] = 1.702745;
16626 aaLG[11][ 0] = 0.536518; aaLG[11][ 1] = 6.326067; aaLG[11][ 2] = 2.145078; aaLG[11][ 3] = 0.282959; aaLG[11][ 4] = 0.013266;
16627 aaLG[11][ 5] = 3.234294; aaLG[11][ 6] = 1.807177; aaLG[11][ 7] = 0.296636; aaLG[11][ 8] = 0.697264; aaLG[11][ 9] = 0.159069;
16628 aaLG[11][10] = 0.137500; aaLG[11][11] = 0.000000; aaLG[11][12] = 0.656604; aaLG[11][13] = 0.023918; aaLG[11][14] = 0.390322;
16629 aaLG[11][15] = 0.748683; aaLG[11][16] = 1.136863; aaLG[11][17] = 0.049906; aaLG[11][18] = 0.131932; aaLG[11][19] = 0.185202;
16630 aaLG[12][ 0] = 1.124035; aaLG[12][ 1] = 0.484133; aaLG[12][ 2] = 0.371004; aaLG[12][ 3] = 0.025548; aaLG[12][ 4] = 0.893680;
16631 aaLG[12][ 5] = 1.672569; aaLG[12][ 6] = 0.173735; aaLG[12][ 7] = 0.139538; aaLG[12][ 8] = 0.442472; aaLG[12][ 9] = 4.273607;
16632 aaLG[12][10] = 6.312358; aaLG[12][11] = 0.656604; aaLG[12][12] = 0.000000; aaLG[12][13] = 1.798853; aaLG[12][14] = 0.099849;
16633 aaLG[12][15] = 0.346960; aaLG[12][16] = 2.020366; aaLG[12][17] = 0.696175; aaLG[12][18] = 0.481306; aaLG[12][19] = 1.898718;
16634 aaLG[13][ 0] = 0.253701; aaLG[13][ 1] = 0.052722; aaLG[13][ 2] = 0.089525; aaLG[13][ 3] = 0.017416; aaLG[13][ 4] = 1.105251;
16635 aaLG[13][ 5] = 0.035855; aaLG[13][ 6] = 0.018811; aaLG[13][ 7] = 0.089586; aaLG[13][ 8] = 0.682139; aaLG[13][ 9] = 1.112727;
16636 aaLG[13][10] = 2.592692; aaLG[13][11] = 0.023918; aaLG[13][12] = 1.798853; aaLG[13][13] = 0.000000; aaLG[13][14] = 0.094464;
16637 aaLG[13][15] = 0.361819; aaLG[13][16] = 0.165001; aaLG[13][17] = 2.457121; aaLG[13][18] = 7.803902; aaLG[13][19] = 0.654683;
16638 aaLG[14][ 0] = 1.177651; aaLG[14][ 1] = 0.332533; aaLG[14][ 2] = 0.161787; aaLG[14][ 3] = 0.394456; aaLG[14][ 4] = 0.075382;
16639 aaLG[14][ 5] = 0.624294; aaLG[14][ 6] = 0.419409; aaLG[14][ 7] = 0.196961; aaLG[14][ 8] = 0.508851; aaLG[14][ 9] = 0.078281;
16640 aaLG[14][10] = 0.249060; aaLG[14][11] = 0.390322; aaLG[14][12] = 0.099849; aaLG[14][13] = 0.094464; aaLG[14][14] = 0.000000;
16641 aaLG[14][15] = 1.338132; aaLG[14][16] = 0.571468; aaLG[14][17] = 0.095131; aaLG[14][18] = 0.089613; aaLG[14][19] = 0.296501;
16642 aaLG[15][ 0] = 4.727182; aaLG[15][ 1] = 0.858151; aaLG[15][ 2] = 4.008358; aaLG[15][ 3] = 1.240275; aaLG[15][ 4] = 2.784478;
16643 aaLG[15][ 5] = 1.223828; aaLG[15][ 6] = 0.611973; aaLG[15][ 7] = 1.739990; aaLG[15][ 8] = 0.990012; aaLG[15][ 9] = 0.064105;
16644 aaLG[15][10] = 0.182287; aaLG[15][11] = 0.748683; aaLG[15][12] = 0.346960; aaLG[15][13] = 0.361819; aaLG[15][14] = 1.338132;
16645 aaLG[15][15] = 0.000000; aaLG[15][16] = 6.472279; aaLG[15][17] = 0.248862; aaLG[15][18] = 0.400547; aaLG[15][19] = 0.098369;
16646 aaLG[16][ 0] = 2.139501; aaLG[16][ 1] = 0.578987; aaLG[16][ 2] = 2.000679; aaLG[16][ 3] = 0.425860; aaLG[16][ 4] = 1.143480;
16647 aaLG[16][ 5] = 1.080136; aaLG[16][ 6] = 0.604545; aaLG[16][ 7] = 0.129836; aaLG[16][ 8] = 0.584262; aaLG[16][ 9] = 1.033739;
16648 aaLG[16][10] = 0.302936; aaLG[16][11] = 1.136863; aaLG[16][12] = 2.020366; aaLG[16][13] = 0.165001; aaLG[16][14] = 0.571468;
16649 aaLG[16][15] = 6.472279; aaLG[16][16] = 0.000000; aaLG[16][17] = 0.140825; aaLG[16][18] = 0.245841; aaLG[16][19] = 2.188158;
16650 aaLG[17][ 0] = 0.180717; aaLG[17][ 1] = 0.593607; aaLG[17][ 2] = 0.045376; aaLG[17][ 3] = 0.029890; aaLG[17][ 4] = 0.670128;
16651 aaLG[17][ 5] = 0.236199; aaLG[17][ 6] = 0.077852; aaLG[17][ 7] = 0.268491; aaLG[17][ 8] = 0.597054; aaLG[17][ 9] = 0.111660;
16652 aaLG[17][10] = 0.619632; aaLG[17][11] = 0.049906; aaLG[17][12] = 0.696175; aaLG[17][13] = 2.457121; aaLG[17][14] = 0.095131;
16653 aaLG[17][15] = 0.248862; aaLG[17][16] = 0.140825; aaLG[17][17] = 0.000000; aaLG[17][18] = 3.151815; aaLG[17][19] = 0.189510;
16654 aaLG[18][ 0] = 0.218959; aaLG[18][ 1] = 0.314440; aaLG[18][ 2] = 0.612025; aaLG[18][ 3] = 0.135107; aaLG[18][ 4] = 1.165532;
16655 aaLG[18][ 5] = 0.257336; aaLG[18][ 6] = 0.120037; aaLG[18][ 7] = 0.054679; aaLG[18][ 8] = 5.306834; aaLG[18][ 9] = 0.232523;
16656 aaLG[18][10] = 0.299648; aaLG[18][11] = 0.131932; aaLG[18][12] = 0.481306; aaLG[18][13] = 7.803902; aaLG[18][14] = 0.089613;
16657 aaLG[18][15] = 0.400547; aaLG[18][16] = 0.245841; aaLG[18][17] = 3.151815; aaLG[18][18] = 0.000000; aaLG[18][19] = 0.249313;
16658 aaLG[19][ 0] = 2.547870; aaLG[19][ 1] = 0.170887; aaLG[19][ 2] = 0.083688; aaLG[19][ 3] = 0.037967; aaLG[19][ 4] = 1.959291;
16659 aaLG[19][ 5] = 0.210332; aaLG[19][ 6] = 0.245034; aaLG[19][ 7] = 0.076701; aaLG[19][ 8] = 0.119013; aaLG[19][ 9] = 10.649107;
16660 aaLG[19][10] = 1.702745; aaLG[19][11] = 0.185202; aaLG[19][12] = 1.898718; aaLG[19][13] = 0.654683; aaLG[19][14] = 0.296501;
16661 aaLG[19][15] = 0.098369; aaLG[19][16] = 2.188158; aaLG[19][17] = 0.189510; aaLG[19][18] = 0.249313; aaLG[19][19] = 0.000000;
16663 lgPi[0] = 0.079066; lgPi[1] = 0.055941; lgPi[2] = 0.041977; lgPi[3] = 0.053052;
16664 lgPi[4] = 0.012937; lgPi[5] = 0.040767; lgPi[6] = 0.071586; lgPi[7] = 0.057337;
16665 lgPi[8] = 0.022355; lgPi[9] = 0.062157; lgPi[10] = 0.099081; lgPi[11] = 0.064600;
16666 lgPi[12] = 0.022951; lgPi[13] = 0.042302; lgPi[14] = 0.044040; lgPi[15] = 0.061197;
16667 lgPi[16] = 0.053287; lgPi[17] = 0.012066; lgPi[18] = 0.034155; lgPi[19] = 0.069147;
16669 /* now, check that the matrices are symmetrical */
16670 for (i=0; i<20; i++)
16672 for (j=i+1; j<20; j++)
16674 diff = aaJones[i][j] - aaJones[j][i];
16679 MrBayesPrint ("%s ERROR: Jones model is not symmetrical.\n");
16684 for (i=0; i<20; i++)
16686 for (j=i+1; j<20; j++)
16688 diff = aaDayhoff[i][j] - aaDayhoff[j][i];
16693 MrBayesPrint ("%s ERROR: Dayhoff model is not symmetrical.\n");
16698 for (i=0; i<20; i++)
16700 for (j=i+1; j<20; j++)
16702 diff = aaMtrev24[i][j] - aaMtrev24[j][i];
16707 MrBayesPrint ("%s ERROR: mtrev24 model is not symmetrical.\n");
16712 for (i=0; i<20; i++)
16714 for (j=i+1; j<20; j++)
16716 diff = aaMtmam[i][j] - aaMtmam[j][i];
16721 MrBayesPrint ("%s ERROR: mtmam model is not symmetrical.\n");
16726 for (i=0; i<20; i++)
16728 for (j=i+1; j<20; j++)
16730 diff = aartREV[i][j] - aartREV[j][i];
16735 MrBayesPrint ("%s ERROR: aartREV model is not symmetrical.\n");
16740 for (i=0; i<20; i++)
16742 for (j=i+1; j<20; j++)
16744 diff = aaWAG[i][j] - aaWAG[j][i];
16749 MrBayesPrint ("%s ERROR: aaWAG model is not symmetrical.\n");
16754 for (i=0; i<20; i++)
16756 for (j=i+1; j<20; j++)
16758 diff = aacpREV[i][j] - aacpREV[j][i];
16763 MrBayesPrint ("%s ERROR: cpREV model is not symmetrical.\n");
16768 for (i=0; i<20; i++)
16770 for (j=i+1; j<20; j++)
16772 diff = aaVt[i][j] - aaVt[j][i];
16777 MrBayesPrint ("%s ERROR: Vt model is not symmetrical.\n");
16782 for (i=0; i<20; i++)
16784 for (j=i+1; j<20; j++)
16786 diff = aaBlosum[i][j] - aaBlosum[j][i];
16791 MrBayesPrint ("%s ERROR: Blosum model is not symmetrical.\n");
16796 for (i=0; i<20; i++)
16798 for (j=i+1; j<20; j++)
16800 diff = aaLG[i][j] - aaLG[j][i];
16805 MrBayesPrint ("%s ERROR: LG model is not symmetrical.\n");
16811 /* rescale stationary frequencies, to make certain they sum to 1.0 */
16813 for (i=0; i<20; i++)
16815 for (i=0; i<20; i++)
16818 for (i=0; i<20; i++)
16819 sum += dayhoffPi[i];
16820 for (i=0; i<20; i++)
16821 dayhoffPi[i] /= sum;
16823 for (i=0; i<20; i++)
16824 sum += mtrev24Pi[i];
16825 for (i=0; i<20; i++)
16826 mtrev24Pi[i] /= sum;
16828 for (i=0; i<20; i++)
16830 for (i=0; i<20; i++)
16833 for (i=0; i<20; i++)
16835 for (i=0; i<20; i++)
16838 for (i=0; i<20; i++)
16840 for (i=0; i<20; i++)
16843 for (i=0; i<20; i++)
16845 for (i=0; i<20; i++)
16848 for (i=0; i<20; i++)
16850 for (i=0; i<20; i++)
16853 for (i=0; i<20; i++)
16855 for (i=0; i<20; i++)
16858 for (i=0; i<20; i++)
16860 for (i=0; i<20; i++)
16863 /* multiply entries by amino acid frequencies */
16864 for (i=0; i<20; i++)
16866 for (j=0; j<20; j++)
16868 aaJones[i][j] *= jonesPi[j];
16869 aaDayhoff[i][j] *= dayhoffPi[j];
16870 aaMtrev24[i][j] *= mtrev24Pi[j];
16871 aaMtmam[i][j] *= mtmamPi[j];
16872 aartREV[i][j] *= rtrevPi[j];
16873 aaWAG[i][j] *= wagPi[j];
16874 aacpREV[i][j] *= cprevPi[j];
16875 aaVt[i][j] *= vtPi[j];
16876 aaBlosum[i][j] *= blosPi[j];
16877 aaLG[i][j] *= lgPi[j];
16881 /* rescale, so branch lengths are in terms of expected number of
16882 amino acid substitutions per site */
16884 for (i=0; i<20; i++)
16886 for (j=i+1; j<20; j++)
16888 scaler += jonesPi[i] * aaJones[i][j];
16889 scaler += jonesPi[j] * aaJones[j][i];
16892 scaler = 1.0 / scaler;
16893 for (i=0; i<20; i++)
16894 for (j=0; j<20; j++)
16895 aaJones[i][j] *= scaler;
16897 for (i=0; i<20; i++)
16899 for (j=i+1; j<20; j++)
16901 scaler += dayhoffPi[i] * aaDayhoff[i][j];
16902 scaler += dayhoffPi[j] * aaDayhoff[j][i];
16905 scaler = 1.0 / scaler;
16906 for (i=0; i<20; i++)
16907 for (j=0; j<20; j++)
16908 aaDayhoff[i][j] *= scaler;
16910 for (i=0; i<20; i++)
16912 for (j=i+1; j<20; j++)
16914 scaler += mtrev24Pi[i] * aaMtrev24[i][j];
16915 scaler += mtrev24Pi[j] * aaMtrev24[j][i];
16918 scaler = 1.0 / scaler;
16919 for (i=0; i<20; i++)
16920 for (j=0; j<20; j++)
16921 aaMtrev24[i][j] *= scaler;
16923 for (i=0; i<20; i++)
16925 for (j=i+1; j<20; j++)
16927 scaler += mtmamPi[i] * aaMtmam[i][j];
16928 scaler += mtmamPi[j] * aaMtmam[j][i];
16931 scaler = 1.0 / scaler;
16932 for (i=0; i<20; i++)
16933 for (j=0; j<20; j++)
16934 aaMtmam[i][j] *= scaler;
16936 for (i=0; i<20; i++)
16938 for (j=i+1; j<20; j++)
16940 scaler += rtrevPi[i] * aartREV[i][j];
16941 scaler += rtrevPi[j] * aartREV[j][i];
16944 scaler = 1.0 / scaler;
16945 for (i=0; i<20; i++)
16946 for (j=0; j<20; j++)
16947 aartREV[i][j] *= scaler;
16949 for (i=0; i<20; i++)
16951 for (j=i+1; j<20; j++)
16953 scaler += wagPi[i] * aaWAG[i][j];
16954 scaler += wagPi[j] * aaWAG[j][i];
16957 scaler = 1.0 / scaler;
16958 for (i=0; i<20; i++)
16959 for (j=0; j<20; j++)
16960 aaWAG[i][j] *= scaler;
16962 for (i=0; i<20; i++)
16964 for (j=i+1; j<20; j++)
16966 scaler += cprevPi[i] * aacpREV[i][j];
16967 scaler += cprevPi[j] * aacpREV[j][i];
16970 scaler = 1.0 / scaler;
16971 for (i=0; i<20; i++)
16972 for (j=0; j<20; j++)
16973 aacpREV[i][j] *= scaler;
16975 for (i=0; i<20; i++)
16977 for (j=i+1; j<20; j++)
16979 scaler += vtPi[i] * aaVt[i][j];
16980 scaler += vtPi[j] * aaVt[j][i];
16983 scaler = 1.0 / scaler;
16984 for (i=0; i<20; i++)
16985 for (j=0; j<20; j++)
16986 aaVt[i][j] *= scaler;
16988 for (i=0; i<20; i++)
16990 for (j=i+1; j<20; j++)
16992 scaler += blosPi[i] * aaBlosum[i][j];
16993 scaler += blosPi[j] * aaBlosum[j][i];
16996 scaler = 1.0 / scaler;
16997 for (i=0; i<20; i++)
16998 for (j=0; j<20; j++)
16999 aaBlosum[i][j] *= scaler;
17001 for (i=0; i<20; i++)
17003 for (j=i+1; j<20; j++)
17005 scaler += lgPi[i] * aaLG[i][j];
17006 scaler += lgPi[j] * aaLG[j][i];
17009 scaler = 1.0 / scaler;
17010 for (i=0; i<20; i++)
17011 for (j=0; j<20; j++)
17012 aaLG[i][j] *= scaler;
17014 /* set diagonal of matrix */
17015 for (i=0; i<20; i++)
17018 for (j=0; j<20; j++)
17021 sum += aaJones[i][j];
17023 aaJones[i][i] = -sum;
17025 for (i=0; i<20; i++)
17028 for (j=0; j<20; j++)
17031 sum += aaDayhoff[i][j];
17033 aaDayhoff[i][i] = -sum;
17035 for (i=0; i<20; i++)
17038 for (j=0; j<20; j++)
17041 sum += aaMtrev24[i][j];
17043 aaMtrev24[i][i] = -sum;
17045 for (i=0; i<20; i++)
17048 for (j=0; j<20; j++)
17051 sum += aaMtmam[i][j];
17053 aaMtmam[i][i] = -sum;
17055 for (i=0; i<20; i++)
17058 for (j=0; j<20; j++)
17061 sum += aartREV[i][j];
17063 aartREV[i][i] = -sum;
17065 for (i=0; i<20; i++)
17068 for (j=0; j<20; j++)
17071 sum += aaWAG[i][j];
17073 aaWAG[i][i] = -sum;
17075 for (i=0; i<20; i++)
17078 for (j=0; j<20; j++)
17081 sum += aacpREV[i][j];
17083 aacpREV[i][i] = -sum;
17085 for (i=0; i<20; i++)
17088 for (j=0; j<20; j++)
17095 for (i=0; i<20; i++)
17098 for (j=0; j<20; j++)
17101 sum += aaBlosum[i][j];
17103 aaBlosum[i][i] = -sum;
17105 for (i=0; i<20; i++)
17108 for (j=0; j<20; j++)
17117 for (i=0; i<20; i++)
17119 MrBayesPrint ("%s ", spacer);
17120 for (j=0; j<20; j++)
17122 if (aaLG[i][j] < 0.0)
17123 MrBayesPrint ("%1.3lf ", aaLG[i][j]);
17125 MrBayesPrint (" %1.3lf ", aaLG[i][j]);
17127 MrBayesPrint ("\n");
17135 void SetCode (int part)
17137 int i, s, s1, s2, s3, ns;
17139 modelParams[part].codon[ 0] = 12; /* AAA Lys */
17140 modelParams[part].codon[ 1] = 3; /* AAC Asn */
17141 modelParams[part].codon[ 2] = 12; /* AAG Lys */
17142 modelParams[part].codon[ 3] = 3; /* AAT Asn */
17143 modelParams[part].codon[ 4] = 17; /* ACA Thr */
17144 modelParams[part].codon[ 5] = 17; /* ACC Thr */
17145 modelParams[part].codon[ 6] = 17; /* ACG Thr */
17146 modelParams[part].codon[ 7] = 17; /* ACT Thr */
17147 modelParams[part].codon[ 8] = 2; /* AGA Arg */
17148 modelParams[part].codon[ 9] = 16; /* AGC Ser */
17149 modelParams[part].codon[10] = 2; /* AGG Arg */
17150 modelParams[part].codon[11] = 16; /* AGT Ser */
17151 modelParams[part].codon[12] = 10; /* ATA Ile */
17152 modelParams[part].codon[13] = 10; /* ATC Ile */
17153 modelParams[part].codon[14] = 13; /* ATG Met */
17154 modelParams[part].codon[15] = 10; /* ATT Ile */
17155 modelParams[part].codon[16] = 6; /* CAA Gln */
17156 modelParams[part].codon[17] = 9; /* CAC His */
17157 modelParams[part].codon[18] = 6; /* CAG Gln */
17158 modelParams[part].codon[19] = 9; /* CAT His */
17159 modelParams[part].codon[20] = 15; /* CCA Pro */
17160 modelParams[part].codon[21] = 15; /* CCC Pro */
17161 modelParams[part].codon[22] = 15; /* CCG Pro */
17162 modelParams[part].codon[23] = 15; /* CCT Pro */
17163 modelParams[part].codon[24] = 2; /* CGA Arg */
17164 modelParams[part].codon[25] = 2; /* CGC Arg */
17165 modelParams[part].codon[26] = 2; /* CGG Arg */
17166 modelParams[part].codon[27] = 2; /* CGT Arg */
17167 modelParams[part].codon[28] = 11; /* CTA Leu */
17168 modelParams[part].codon[29] = 11; /* CTC Leu */
17169 modelParams[part].codon[30] = 11; /* CTG Leu */
17170 modelParams[part].codon[31] = 11; /* CTT Leu */
17171 modelParams[part].codon[32] = 7; /* GAA Glu */
17172 modelParams[part].codon[33] = 4; /* GAC Asp */
17173 modelParams[part].codon[34] = 7; /* GAG Glu */
17174 modelParams[part].codon[35] = 4; /* GAT Asp */
17175 modelParams[part].codon[36] = 1; /* GCA Ala */
17176 modelParams[part].codon[37] = 1; /* GCC Ala */
17177 modelParams[part].codon[38] = 1; /* GCG Ala */
17178 modelParams[part].codon[39] = 1; /* GCT Ala */
17179 modelParams[part].codon[40] = 8; /* GGA Gly */
17180 modelParams[part].codon[41] = 8; /* GGC Gly */
17181 modelParams[part].codon[42] = 8; /* GGG Gly */
17182 modelParams[part].codon[43] = 8; /* GGT Gly */
17183 modelParams[part].codon[44] = 20; /* GTA Val */
17184 modelParams[part].codon[45] = 20; /* GTC Val */
17185 modelParams[part].codon[46] = 20; /* GTG Val */
17186 modelParams[part].codon[47] = 20; /* GTT Val */
17187 modelParams[part].codon[48] = 21; /* TAA Stop*/
17188 modelParams[part].codon[49] = 19; /* TAC Tyr */
17189 modelParams[part].codon[50] = 21; /* TAG Stop*/
17190 modelParams[part].codon[51] = 19; /* TAT Tyr */
17191 modelParams[part].codon[52] = 16; /* TCA Ser */
17192 modelParams[part].codon[53] = 16; /* TCC Ser */
17193 modelParams[part].codon[54] = 16; /* TCG Ser */
17194 modelParams[part].codon[55] = 16; /* TCT Ser */
17195 modelParams[part].codon[56] = 21; /* TGA Stop*/
17196 modelParams[part].codon[57] = 5; /* TGC Cys */
17197 modelParams[part].codon[58] = 18; /* TGG Trp */
17198 modelParams[part].codon[59] = 5; /* TGT Cys */
17199 modelParams[part].codon[60] = 11; /* TTA Leu */
17200 modelParams[part].codon[61] = 14; /* TTC Phe */
17201 modelParams[part].codon[62] = 11; /* TTG Leu */
17202 modelParams[part].codon[63] = 14; /* TTT Phe */
17204 if (!strcmp(modelParams[part].geneticCode, "Vertmt"))
17210 modelParams[part].codon[ 8] = 21; /* AGA Stop */
17211 modelParams[part].codon[10] = 21; /* AGG Stop */
17212 modelParams[part].codon[12] = 13; /* ATA Met */
17213 modelParams[part].codon[56] = 18; /* TGA Trp */
17215 if (!strcmp(modelParams[part].geneticCode, "Invermt"))
17221 modelParams[part].codon[ 8] = 16; /* AGA Ser */
17222 modelParams[part].codon[10] = 16; /* AGG Ser */
17223 modelParams[part].codon[12] = 13; /* ATA Met */
17224 modelParams[part].codon[56] = 18; /* TGA Trp */
17226 else if (!strcmp(modelParams[part].geneticCode, "Mycoplasma"))
17228 /* UGA: Ter -> Trp */
17229 modelParams[part].codon[56] = 18; /* TGA Trp */
17231 else if (!strcmp(modelParams[part].geneticCode, "Yeast"))
17239 modelParams[part].codon[12] = 13; /* ATA Met */
17240 modelParams[part].codon[28] = 17; /* CTA Thr */
17241 modelParams[part].codon[29] = 17; /* CTC Thr */
17242 modelParams[part].codon[30] = 17; /* CTG Thr */
17243 modelParams[part].codon[31] = 17; /* CTT Thr */
17244 modelParams[part].codon[56] = 18; /* TGA Trp */
17246 else if (!strcmp(modelParams[part].geneticCode, "Ciliate"))
17250 modelParams[part].codon[48] = 6; /* TAA Gln */
17251 modelParams[part].codon[50] = 6; /* TAG Gln */
17253 else if (!strcmp(modelParams[part].geneticCode, "Echinoderm"))
17259 modelParams[part].codon[ 0] = 3; /* AAA Asn */
17260 modelParams[part].codon[ 8] = 16; /* AGA Ser */
17261 modelParams[part].codon[10] = 16; /* AGG Ser */
17262 modelParams[part].codon[56] = 18; /* TGA Trp */
17264 else if (!strcmp(modelParams[part].geneticCode, "Euplotid"))
17266 /* UGA: Ter -> Cys */
17267 modelParams[part].codon[56] = 5; /* TGA Cys */
17269 else if (!strcmp(modelParams[part].geneticCode, "Metmt"))
17275 modelParams[part].codon[ 8] = 16; /* AGA Ser */
17276 modelParams[part].codon[10] = 16; /* AGG Ser */
17277 modelParams[part].codon[12] = 13; /* ATA Met */
17278 modelParams[part].codon[56] = 18; /* TGA Trp */
17285 for (i=0; i<64; i++)
17287 if (modelParams[part].codon[i] != 21)
17290 /* printf ("ns = %d\n", ns); */
17293 for (s1=0; s1<4; s1++)
17294 for (s2=0; s2<4; s2++)
17295 for (s3=0; s3<4; s3++)
17296 if (modelParams[part].codon[s1*16 + s2*4 + s3] != 21)
17298 modelParams[part].codonNucs[s][0] = s1;
17299 modelParams[part].codonNucs[s][1] = s2;
17300 modelParams[part].codonNucs[s][2] = s3;
17301 modelParams[part].codonAAs[s] = modelParams[part].codon[s1*16 + s2*4 + s3];
17307 int SetLocalTaxa (void)
17311 /* free memory if allocated */
17312 if (memAllocs[ALLOC_LOCTAXANAMES] == YES)
17314 free (localTaxonNames);
17315 localTaxonNames = NULL;
17316 memAllocs[ALLOC_LOCTAXANAMES] = NO;
17318 if (memAllocs[ALLOC_LOCALTAXONCALIBRATION] == YES)
17320 free (localTaxonCalibration);
17321 localTaxonCalibration = NULL;
17322 memAllocs[ALLOC_LOCALTAXONCALIBRATION] = NO;
17325 /* count number of non-excluded taxa */
17327 for (i=0; i<numTaxa; i++)
17329 if (taxaInfo[i].isDeleted == NO)
17333 /* allocate memory */
17334 localTaxonNames = (char **)SafeCalloc((size_t)numLocalTaxa, sizeof(char *));
17335 if (!localTaxonNames)
17337 memAllocs[ALLOC_LOCTAXANAMES] = YES;
17339 localTaxonCalibration = (Calibration **)SafeCalloc((size_t)numLocalTaxa, sizeof(Calibration *));
17340 if (!localTaxonCalibration)
17342 memAllocs[ALLOC_LOCALTAXONCALIBRATION] = YES;
17344 /* point to names and calibrations of non-excluded taxa */
17346 for (i=j=0; i<numTaxa; i++)
17348 if (taxaInfo[i].isDeleted == NO)
17350 localTaxonNames[j] = taxaNames[i];
17351 localTaxonCalibration[j] = &tipCalibration[i];
17352 if (i == outGroupNum)
17359 /* show non-excluded taxa */
17360 for (i=0; i<numLocalTaxa; i++)
17361 MrBayesPrint ("%s %4d %s\n", spacer, i+1, localTaxonNames[i]);
17368 /*----------------------------------------------------------------------------
17370 | SetModelDefaults: This function will set up model defaults in modelParams.
17371 | It will also initialize parameters and moves by calling SetUpAnalysis.
17373 -----------------------------------------------------------------------------*/
17374 int SetModelDefaults (void)
17378 MrBayesPrint ("%s Setting model defaults\n", spacer);
17379 MrBayesPrint ("%s Seed (for generating default start values) = %d\n", spacer, globalSeed);
17381 if (InitializeLinks () == ERROR)
17383 MrBayesPrint ("%s Problem initializing link table\n", spacer);
17387 /* Check that models are allocated */
17388 if (memAllocs[ALLOC_MODEL] == NO)
17390 MrBayesPrint ("%s Model not allocated in SetModelDefaults\n", spacer);
17394 /* model parameters */
17395 for (j=0; j<numCurrentDivisions; j++)
17397 modelParams[j] = defaultModel; /* start with default settings */
17399 modelParams[j].dataType = DataType (j); /* data type for partition */
17401 if (modelParams[j].dataType == STANDARD)
17402 { /* set default ascertainment bias for partition */
17403 modelParams[j].coding = VARIABLE;
17404 strcpy(modelParams[j].codingString, "Variable");
17406 else if (modelParams[j].dataType == RESTRICTION)
17408 modelParams[j].coding = NOABSENCESITES;
17409 strcpy(modelParams[j].codingString, "Noabsencesites");
17413 modelParams[j].coding = ALL;
17414 strcpy(modelParams[j].codingString, "All");
17418 modelParams[j].nStates = NumStates (j); /* number of states for partition */
17420 modelParams[j].activeConstraints = (int *) SafeCalloc(numDefinedConstraints, sizeof(int)); /* allocate space for active constraints (yes/no) */
17427 /*----------------------------------------------------------------------------
17429 | SetModelInfo: This function will set up model info using model
17432 -----------------------------------------------------------------------------*/
17433 int SetModelInfo (void)
17439 /* wipe all model settings */
17440 inferSiteRates = NO;
17441 inferAncStates = NO;
17442 inferSiteOmegas = NO;
17444 for (i=0; i<numCurrentDivisions; i++)
17446 m = &modelSettings[i];
17448 /* make certain that we set this intentionally to "NO" so we
17449 calculate cijk information and calculate cond likes when needed */
17450 m->upDateCijk = YES;
17452 m->upDateAll = YES;
17454 /* make certain that we start with a parsimony branch length of zero */
17455 for (j=0; j<MAX_CHAINS; j++)
17456 m->parsTreeLength[j*2] = m->parsTreeLength[j*2+1] = 0.0;
17461 m->stateFreq = NULL;
17464 m->correlation = NULL;
17465 m->switchRates = NULL;
17466 m->rateMult = NULL;
17467 m->topology = NULL;
17469 m->speciationRates = NULL;
17470 m->extinctionRates = NULL;
17471 m->fossilizationRates = NULL;
17475 m->cppEvents = NULL;
17476 m->cppMultDev = NULL;
17478 m->tk02BranchRates = NULL;
17480 m->igrBranchRates = NULL;
17481 m->mixedvar = NULL;
17482 m->mixedBrchRates = NULL;
17483 m->clockRate = NULL;
17485 m->CondLikeDown = NULL;
17486 m->CondLikeRoot = NULL;
17487 m->CondLikeScaler = NULL;
17488 m->Likelihood = NULL;
17491 m->CondLikeUp = NULL;
17492 m->StateCode = NULL;
17493 m->PrintAncStates = NULL;
17494 m->PrintSiteRates = NULL;
17496 m->printPosSel = NO;
17497 m->printAncStates = NO;
17498 m->printSiteRates = NO;
17505 m->gibbsGamma = NO;
17508 m->parsimonyBasedMove = NO;
17510 # if defined (BEAGLE_ENABLED)
17511 m->beagleInstance = -1; /* beagle instance */
17512 m->logLikelihoods = NULL; /* array of log likelihoods from Beagle */
17513 m->inRates = NULL; /* array of category rates for Beagle */
17514 m->branchLengths = NULL; /* array of branch lengths for Beagle */
17515 m->tiProbIndices = NULL; /* array of trans prob indices for Beagle */
17516 m->inWeights = NULL; /* array of weights for Beagle root likelihood */
17517 m->bufferIndices = NULL; /* array of partial indices for root likelihood */
17518 m->childBufferIndices = NULL; /* array of child partial indices (unrooted) */
17519 m->childTiProbIndices = NULL; /* array of child ti prob indices (unrooted) */
17520 m->cumulativeScaleIndices = NULL; /* array of cumulative scale indices */
17523 /* likelihood calculator flags */
17524 m->useSSE = NO; /* use SSE code for this partition? */
17525 m->useBeagle = NO; /* use Beagle for this partition? */
17527 /* set all memory pointers to NULL */
17528 m->parsSets = NULL;
17529 m->numParsSets = 0;
17530 m->parsNodeLens = NULL;
17531 m->numParsNodeLens = 0;
17533 m->condLikes = NULL;
17536 m->numCondLikes = 0;
17540 m->condLikeIndex = NULL;
17541 m->condLikeScratchIndex = NULL;
17542 m->tiProbsIndex = NULL;
17543 m->tiProbsScratchIndex = NULL;
17544 m->nodeScalerIndex = NULL;
17545 m->nodeScalerScratchIndex = NULL;
17546 m->siteScalerIndex = NULL;
17547 m->siteScalerScratchIndex = -1;
17551 m->cijkIndex = NULL;
17552 m->cijkScratchIndex = -1;
17555 /* set state of all chains to zero */
17556 for (chn=0; chn<numGlobalChains; chn++)
17559 /* fill in modelSettings info with some basic model characteristics */
17560 for (i=0; i<numCurrentDivisions; i++)
17562 mp = &modelParams[i];
17563 m = &modelSettings[i];
17565 if (!strcmp(mp->nucModel,"Protein") && (mp->dataType == DNA || mp->dataType == RNA))
17566 m->dataType = PROTEIN;
17568 m->dataType = mp->dataType;
17570 /* nuc model structure */
17571 if (!strcmp(mp->nucModel, "4by4"))
17572 m->nucModelId = NUCMODEL_4BY4;
17573 else if (!strcmp(mp->nucModel, "Doublet"))
17574 m->nucModelId = NUCMODEL_DOUBLET;
17575 else if (!strcmp(mp->nucModel, "Protein"))
17576 m->nucModelId = NUCMODEL_AA;
17577 else /* if (!strcmp(mp->nucModelId, "Codon")) */
17578 m->nucModelId = NUCMODEL_CODON;
17581 if (!strcmp(mp->nst, "1"))
17583 else if (!strcmp(mp->nst, "2"))
17585 else if (!strcmp(mp->nst, "6"))
17588 m->nst = NST_MIXED;
17590 /* We set the aa model here. We have two options. First, the model
17591 could be fixed, in which case mp->aaModel has been set. We then
17592 go ahead and also set the model settings. Second, the model
17593 could be mixed. In this case, the amino acid matrix is considered
17594 a parameter, and we will deal with it below. It doesn't hurt
17595 to set it here anyway (it will be overwritten later). */
17596 if (!strcmp(mp->aaModelPr, "Fixed"))
17598 if (!strcmp(mp->aaModel, "Poisson"))
17599 m->aaModelId = AAMODEL_POISSON;
17600 else if (!strcmp(mp->aaModel, "Equalin"))
17601 m->aaModelId = AAMODEL_EQ;
17602 else if (!strcmp(mp->aaModel, "Jones"))
17603 m->aaModelId = AAMODEL_JONES;
17604 else if (!strcmp(mp->aaModel, "Dayhoff"))
17605 m->aaModelId = AAMODEL_DAY;
17606 else if (!strcmp(mp->aaModel, "Mtrev"))
17607 m->aaModelId = AAMODEL_MTREV;
17608 else if (!strcmp(mp->aaModel, "Mtmam"))
17609 m->aaModelId = AAMODEL_MTMAM;
17610 else if (!strcmp(mp->aaModel, "Wag"))
17611 m->aaModelId = AAMODEL_WAG;
17612 else if (!strcmp(mp->aaModel, "Rtrev"))
17613 m->aaModelId = AAMODEL_RTREV;
17614 else if (!strcmp(mp->aaModel, "Cprev"))
17615 m->aaModelId = AAMODEL_CPREV;
17616 else if (!strcmp(mp->aaModel, "Vt"))
17617 m->aaModelId = AAMODEL_VT;
17618 else if (!strcmp(mp->aaModel, "Blosum"))
17619 m->aaModelId = AAMODEL_BLOSUM;
17620 else if (!strcmp(mp->aaModel, "LG"))
17621 m->aaModelId = AAMODEL_LG;
17622 else if (!strcmp(mp->aaModel, "Gtr"))
17623 m->aaModelId = AAMODEL_GTR;
17626 MrBayesPrint ("%s Uncertain amino acid model\n", spacer);
17633 /* parsimony model? */
17634 if (!strcmp(mp->parsModel, "Yes"))
17635 m->parsModelId = YES;
17637 m->parsModelId = NO;
17639 /* number of gamma categories */
17640 if (activeParams[P_SHAPE][i] > 0)
17641 m->numGammaCats = mp->numGammaCats;
17643 m->numGammaCats = 1;
17645 /* number of beta categories */
17646 if (mp->dataType == STANDARD && !(AreDoublesEqual(mp->symBetaFix, -1.0, 0.00001) == YES && !strcmp(mp->symPiPr,"Fixed")))
17647 m->numBetaCats = mp->numBetaCats;
17649 m->numBetaCats = 1;
17651 /* number of omega categories */
17652 if ((mp->dataType == DNA || mp->dataType == RNA) && (!strcmp(mp->omegaVar, "Ny98") || !strcmp(mp->omegaVar, "M3")) && !strcmp(mp->nucModel, "Codon"))
17654 m->numOmegaCats = 3;
17655 m->numGammaCats = 1; /* if we are here, then we cannot have gamma or beta variation */
17656 m->numBetaCats = 1;
17658 else if ((mp->dataType == DNA || mp->dataType == RNA) && !strcmp(mp->omegaVar, "M10") && !strcmp(mp->nucModel, "Codon"))
17660 m->numOmegaCats = mp->numM10BetaCats + mp->numM10GammaCats;
17661 m->numGammaCats = 1; /* if we are here, then we cannot have gamma or beta variation */
17662 m->numBetaCats = 1;
17665 m->numOmegaCats = 1;
17667 /* number of transition matrices depends on numGammaCats, numBetaCats, and numOmegaCats */
17668 m->numTiCats = m->numGammaCats * m->numBetaCats * m->numOmegaCats;
17670 /* TODO: check that numStates and numModelStates are set
17671 appropriately for codon and doublet models */
17673 /* number of observable states */
17674 if (m->dataType == STANDARD)
17675 m->numStates = 0; /* zero, meaining variable */
17676 else if (!strcmp(mp->nucModel,"Protein") && (mp->dataType == DNA || mp->dataType == RNA))
17679 m->numStates = mp->nStates;
17681 /* number of model states including hidden ones */
17682 if ((mp->dataType == DNA || mp->dataType == RNA) && !strcmp (mp->covarionModel, "Yes") && !strcmp(mp->nucModel, "4by4"))
17683 m->numModelStates = mp->nStates * 2;
17684 else if (m->dataType == PROTEIN && !strcmp (mp->covarionModel, "Yes"))
17685 m->numModelStates = mp->nStates * 2;
17686 else if ((mp->dataType == DNA || mp->dataType == RNA) && !strcmp(mp->nucModel,"Protein") && !strcmp (mp->covarionModel, "Yes"))
17687 m->numModelStates = 20 * 2;
17688 else if (mp->dataType == CONTINUOUS)
17689 m->numModelStates = 0;
17690 else if (mp->dataType == STANDARD)
17692 /* use max possible for now; we don't know what chars will be included */
17693 m->numModelStates = 10;
17696 m->numModelStates = m->numStates;
17698 /* Fill in some information for calculating cijk. We will use m->cijkLength to
17699 figure out if we need to diagonalize Q to calculate transition probabilities.
17700 If cijkLength = 0, then we won't bother. We use cijkLength later in this function. */
17703 if (m->dataType == PROTEIN)
17705 ts = m->numModelStates;
17706 m->cijkLength = (ts * ts * ts) + (2 * ts);
17707 if (!strcmp (mp->covarionModel, "Yes"))
17709 m->cijkLength *= m->numGammaCats;
17710 m->nCijkParts = m->numGammaCats;
17713 else if (m->dataType == STANDARD)
17715 /* set to 0 for now, update in ProcessStdChars */
17718 else if (m->dataType == DNA || m->dataType == RNA)
17720 if (m->nucModelId == NUCMODEL_4BY4)
17722 if (!strcmp (mp->covarionModel, "No") && m->nst != 6 && m->nst != 203)
17726 ts = m->numModelStates;
17727 m->cijkLength = (ts * ts * ts) + (2 * ts);
17729 if (!strcmp (mp->covarionModel, "Yes"))
17731 m->cijkLength *= m->numGammaCats;
17732 m->nCijkParts = m->numGammaCats;
17735 else if (m->nucModelId == NUCMODEL_DOUBLET)
17737 ts = m->numModelStates;
17738 m->cijkLength = (ts * ts * ts) + (2 * ts);
17740 else if (m->nucModelId == NUCMODEL_CODON)
17742 ts = m->numModelStates;
17743 m->cijkLength = (ts * ts * ts) + (2 * ts);
17744 m->cijkLength *= m->numOmegaCats;
17745 m->nCijkParts = m->numOmegaCats;
17749 MrBayesPrint ("%s BUG: Inconsistent model. Please report this as a bug.\n");
17754 /* check if we should calculate ancestral states */
17755 if (!strcmp(mp->inferAncStates,"Yes"))
17757 if (m->dataType == PROTEIN && !strcmp(mp->covarionModel, "No"))
17758 m->printAncStates = YES;
17759 else if (m->dataType == DNA || m->dataType == RNA)
17761 if (!strcmp(mp->nucModel,"4by4") && !strcmp(mp->covarionModel, "No"))
17762 m->printAncStates = YES;
17763 if (!strcmp(mp->nucModel,"Doublet"))
17764 m->printAncStates = YES;
17765 if (!strcmp(mp->nucModel,"Codon") && !strcmp(mp->omegaVar,"Equal"))
17766 m->printAncStates = YES;
17768 else if (m->dataType == STANDARD || m->dataType == RESTRICTION)
17769 m->printAncStates = YES;
17770 if (m->printAncStates == YES)
17771 inferAncStates = YES;
17773 MrBayesPrint ("%s Print out of ancestral states is not applicable for devision %d.\n",spacer,i);
17776 /* check if we should calculate site rates */
17777 if (!strcmp(mp->inferSiteRates,"Yes"))
17779 if (m->numGammaCats > 1)
17781 m->printSiteRates = YES;
17782 inferSiteRates = YES;
17786 /* check if we should calculate positive selection */
17787 if (!strcmp(mp->inferPosSel, "Yes"))
17789 if (m->numOmegaCats > 1)
17791 m->printPosSel = YES;
17796 /* check if we should calculate site omegas */
17797 if (!strcmp(mp->inferSiteOmegas, "Yes"))
17799 if (m->numOmegaCats > 1)
17801 m->printSiteOmegas = YES;
17802 inferSiteOmegas = YES;
17805 /* check if we should use gibbs sampling of gamma (don't use it with pinvar or invgamma) */
17806 if (!strcmp(mp->useGibbs,"Yes") && (m->numGammaCats > 1))
17808 if (m->dataType == DNA || m->dataType == RNA || m->dataType == PROTEIN)
17810 if (activeParams[P_CORREL][i] <= 0 && m->printSiteRates == NO && activeParams[P_PINVAR][i] <= 0)
17812 m->gibbsGamma = YES;
17813 m->gibbsFreq = mp->gibbsFreq;
17823 /*-----------------------------------------------------------------
17825 | SetModelParams: Set up parameter structs for all model
17826 | parameters, including trees
17828 |----------------------------------------------------------------*/
17829 int SetModelParams (void)
17831 int c, i, j, k, n, n1, n2, *isPartTouched, numRelParts, nRelParts, areAllPartsParsimony,
17832 nClockBrlens, nRelaxedBrlens, nCalibratedBrlens;
17833 char tempCodon[15], tempMult[15], *tempStr,temp[30];
17834 char static *partString=NULL; /* mad static to avoid posible memory leak on return ERROR if it would be introduced later */
17838 int tempStrSize = 300;
17840 tempStr = (char *) SafeMalloc((size_t)tempStrSize * sizeof(char));
17841 isPartTouched = (int *) SafeMalloc ((size_t)numCurrentDivisions * sizeof (int));
17842 if (!tempStr || !isPartTouched)
17844 MrBayesPrint ("%s Problem allocating tempString (%d) or isPartTouched (%d)\n", spacer,
17845 tempStrSize * sizeof(char), numCurrentDivisions * sizeof(int));
17849 # if defined DEBUG_SETCHAINPARAMS
17850 /* only for debugging */
17851 MrBFlt lnPriorRatio = 0.0, lnProposalRatio = 0.0;
17854 /* allocate space for parameters */
17855 if (memAllocs[ALLOC_PARAMS] == YES)
17857 for (i=0; i<numParams; i++)
17859 SafeFree ((void **)¶ms[i].name);
17860 if (params[i].paramHeader)
17862 free (params[i].paramHeader);
17863 params[i].paramHeader = NULL;
17867 free (relevantParts);
17869 relevantParts = NULL;
17870 memAllocs[ALLOC_PARAMS] = NO;
17873 /* wipe all chain parameter information */
17876 chainHasAdgamma = NO;
17878 /* figure out number of parameters */
17879 /* this relies on activeParams[j][i] being set to 1, 2, ..., numParams */
17880 /* which is taken care of in SetUpLinkTable () */
17882 for (j=0; j<NUM_LINKED; j++)
17884 for (i=0; i<numCurrentDivisions; i++)
17886 if (activeParams[j][i] > numParams)
17887 numParams = activeParams[j][i];
17888 if (activeParams[j][i] > 0)
17893 params = (Param *) SafeMalloc (numParams * sizeof(Param));
17894 relevantParts = (int *) SafeMalloc (nRelParts * sizeof(int));
17895 if (!params || !relevantParts)
17897 MrBayesPrint ("%s Problem allocating params and relevantParts\n", spacer);
17901 free (relevantParts);
17906 memAllocs[ALLOC_PARAMS] = YES;
17908 /* fill in info on each parameter */
17909 nRelParts = 0; /* now cumulative number of relevant partitions */
17910 for (k=0; k<numParams; k++)
17914 /* find affected partitions */
17916 for (j=0; j<NUM_LINKED; j++)
17918 for (i=0; i<numCurrentDivisions; i++)
17920 if (activeParams[j][i] == k + 1)
17923 isPartTouched[i] = YES;
17926 isPartTouched[i] = NO;
17928 if (numRelParts > 0)
17932 /* find pointer to modelParams and modelSettings of first relevant partition */
17933 /* this will be handy later on */
17934 for (i=0; i<numCurrentDivisions; i++)
17935 if (isPartTouched[i] == YES)
17937 mp = &modelParams[i];
17938 m = &modelSettings[i];
17940 /* Set default min and max */
17941 p->min = p->max = NEG_INFINITY;
17943 /* Parameter nValues and nSubValues, which are needed for memory allocation
17944 are calculated for each case in the code below. nSympi, however, is
17945 only used for one special type of parameter and it therefore makes
17946 sense to initialize it to 0 here. The same applies to hasBinaryStd
17947 and nIntValues. To be safe, we set all to 0 here. */
17952 p->hasBinaryStd = NO;
17954 /* should this parameter be printed to a file? */
17955 p->printParam = NO;
17957 /* set print subparams to 0 */
17958 p->nPrintSubParams = 0;
17960 /* check constraints for tree parameter ? */
17961 p->checkConstraints = NO;
17963 /* set index number of parameter */
17966 /* set prior function to NULL */
17967 p->LnPriorRatio = NULL;
17969 /* set prior paramters to NULL */
17970 p->priorParams = NULL;
17972 /* set affectsLikelihood to NO */
17973 p->affectsLikelihood = NO;
17975 /* set cpp event pointers to NULL */
17977 p->position = NULL;
17978 p->rateMult = NULL;
17980 /* set header and name to NULL */
17981 p->paramHeader = NULL;
17984 /* set up relevant partitions */
17985 p->nRelParts = numRelParts;
17986 p->relParts = relevantParts + nRelParts;
17987 nRelParts += numRelParts;
17988 for (i=n=0; i<numCurrentDivisions; i++)
17989 if (isPartTouched[i] == YES)
17990 p->relParts[n++] = i;
17992 /* get partition descriptor */
17993 SafeStrcat(&partString,"");
17994 FillRelPartsString (p, &partString);
17996 /* set up information for parameter */
17999 /* Set up tratio ****************************************************************************************/
18000 p->paramType = P_TRATIO;
18001 p->nValues = 1; /* we store only the ratio */
18004 p->max = POS_INFINITY;
18005 for (i=0; i<numCurrentDivisions; i++)
18006 if (isPartTouched[i] == YES)
18007 modelSettings[i].tRatio = p;
18009 p->paramTypeName = "Transition and transversion rates";
18010 SafeStrcat(&p->name, "Tratio");
18011 SafeStrcat(&p->name, partString);
18013 /* find the parameter x prior type */
18014 if (!strcmp(mp->tRatioPr,"Beta"))
18016 p->paramId = TRATIO_DIR;
18019 p->paramId = TRATIO_FIX;
18021 if (p->paramId != TRATIO_FIX)
18022 p->printParam = YES;
18023 if (!strcmp(mp->tratioFormat,"Ratio"))
18025 /* report ti/tv ratio */
18026 SafeStrcat (&p->paramHeader,"kappa");
18027 SafeStrcat (&p->paramHeader, partString);
18031 /* report prop. of ratesum (Dirichlet) */
18032 SafeStrcat (&p->paramHeader,"ti");
18033 SafeStrcat (&p->paramHeader, partString);
18034 SafeStrcat (&p->paramHeader, "\ttv");
18035 SafeStrcat (&p->paramHeader, partString);
18038 else if (j == P_REVMAT)
18040 /* Set up revMat ****************************************************************************************/
18041 p->paramType = P_REVMAT;
18042 if (m->dataType == PROTEIN)
18047 if (!strcmp(mp->nst, "Mixed"))
18052 p->max = 1.0; /* adjust later for REVMAT_MIX, see a few lines below */
18053 for (i=0; i<numCurrentDivisions; i++)
18054 if (isPartTouched[i] == YES)
18055 modelSettings[i].revMat = p;
18057 p->paramTypeName = "Rates of reversible rate matrix";
18058 SafeStrcat(&p->name, "Revmat");
18059 SafeStrcat(&p->name, partString);
18061 /* find the parameter x prior type */
18062 if (m->dataType == PROTEIN)
18064 if (!strcmp(mp->aaRevMatPr,"Dirichlet"))
18065 p->paramId = REVMAT_DIR;
18067 p->paramId = REVMAT_FIX;
18068 if (p->paramId != REVMAT_FIX)
18069 p->printParam = YES;
18071 for (n1=0; n1<20; n1++)
18073 for (n2=n1+1; n2<20; n2++)
18075 if (n1==0 && n2==1)
18077 sprintf (temp, "r(%c<->%c)", StateCode_AA(n1), StateCode_AA(n2));
18078 SafeStrcat (&p->paramHeader, temp);
18079 SafeStrcat (&p->paramHeader, partString);
18083 sprintf (temp, "\tr(%c<->%c)", StateCode_AA(n1), StateCode_AA(n2));
18084 SafeStrcat (&p->paramHeader, temp);
18085 SafeStrcat (&p->paramHeader, partString);
18092 if (!strcmp(mp->nst, "Mixed"))
18094 p->paramId = REVMAT_MIX;
18095 p->max = 1E6; /* some large value */
18097 else if (!strcmp(mp->revMatPr,"Dirichlet"))
18098 p->paramId = REVMAT_DIR;
18100 p->paramId = REVMAT_FIX;
18101 if (p->paramId != REVMAT_FIX)
18102 p->printParam = YES;
18104 for (n1=0; n1<4; n1++)
18106 for (n2=n1+1; n2<4; n2++)
18108 if (n1==0 && n2==1)
18110 sprintf (temp, "r(%c<->%c)", StateCode_NUC4(n1), StateCode_NUC4(n2));
18111 SafeStrcat (&p->paramHeader, temp);
18112 SafeStrcat (&p->paramHeader, partString);
18116 sprintf (temp, "\tr(%c<->%c)", StateCode_NUC4(n1), StateCode_NUC4(n2));
18117 SafeStrcat (&p->paramHeader, temp);
18118 SafeStrcat (&p->paramHeader, partString);
18122 if (p->paramId == REVMAT_MIX)
18124 sprintf (temp, "\tgtrsubmodel");
18125 SafeStrcat (&p->paramHeader, temp);
18126 SafeStrcat (&p->paramHeader, partString);
18127 sprintf (temp, "\tk_revmat");
18128 SafeStrcat (&p->paramHeader, temp);
18129 SafeStrcat (&p->paramHeader, partString);
18133 else if (j == P_OMEGA)
18135 /* Set up omega *****************************************************************************************/
18136 p->paramType = P_OMEGA;
18138 p->max = POS_INFINITY;
18139 if (!strcmp(mp->omegaVar, "M3"))
18141 p->nValues = 3; /* omega values */
18142 p->nSubValues = 6; /* category frequencies plus cache */
18143 for (i=0; i<numCurrentDivisions; i++)
18144 if (isPartTouched[i] == YES)
18145 modelSettings[i].omega = p;
18147 /* find the parameter x prior type */
18148 if (!strcmp(mp->m3omegapr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18149 p->paramId = OMEGA_EF;
18150 else if (!strcmp(mp->m3omegapr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18151 p->paramId = OMEGA_ED;
18152 else if (!strcmp(mp->m3omegapr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18153 p->paramId = OMEGA_FF;
18154 else if (!strcmp(mp->m3omegapr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18155 p->paramId = OMEGA_FD;
18157 if (p->paramId != OMEGA_FF)
18158 p->printParam = YES;
18160 SafeStrcat (&p->paramHeader, "omega(1)");
18161 SafeStrcat (&p->paramHeader, partString);
18162 SafeStrcat (&p->paramHeader, "\tomega(2)");
18163 SafeStrcat (&p->paramHeader, partString);
18164 SafeStrcat (&p->paramHeader, "\tomega(3)");
18165 SafeStrcat (&p->paramHeader, partString);
18167 SafeStrcat (&p->paramHeader, "\tpi(1)");
18168 SafeStrcat (&p->paramHeader, partString);
18169 SafeStrcat (&p->paramHeader, "\tpi(2)");
18170 SafeStrcat (&p->paramHeader, partString);
18171 SafeStrcat (&p->paramHeader, "\tpi(3)");
18172 SafeStrcat (&p->paramHeader, partString);
18174 else if (!strcmp(mp->omegaVar, "M10"))
18176 p->nValues = mp->numM10BetaCats + mp->numM10GammaCats;
18177 p->nSubValues = mp->numM10BetaCats + mp->numM10GammaCats + 8;
18178 for (i=0; i<numCurrentDivisions; i++)
18179 if (isPartTouched[i] == YES)
18180 modelSettings[i].omega = p;
18182 /* find the parameter x prior type */
18183 if (!strcmp(mp->m10betapr, "Uniform") && !strcmp(mp->m10gammapr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18184 p->paramId = OMEGA_10UUB;
18185 else if (!strcmp(mp->m10betapr, "Uniform") && !strcmp(mp->m10gammapr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18186 p->paramId = OMEGA_10UUF;
18187 else if (!strcmp(mp->m10betapr, "Uniform") && !strcmp(mp->m10gammapr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18188 p->paramId = OMEGA_10UEB;
18189 else if (!strcmp(mp->m10betapr, "Uniform") && !strcmp(mp->m10gammapr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18190 p->paramId = OMEGA_10UEF;
18191 else if (!strcmp(mp->m10betapr, "Uniform") && !strcmp(mp->m10gammapr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18192 p->paramId = OMEGA_10UFB;
18193 else if (!strcmp(mp->m10betapr, "Uniform") && !strcmp(mp->m10gammapr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18194 p->paramId = OMEGA_10UFF;
18195 else if (!strcmp(mp->m10betapr, "Exponential") && !strcmp(mp->m10gammapr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18196 p->paramId = OMEGA_10EUB;
18197 else if (!strcmp(mp->m10betapr, "Exponential") && !strcmp(mp->m10gammapr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18198 p->paramId = OMEGA_10EUF;
18199 else if (!strcmp(mp->m10betapr, "Exponential") && !strcmp(mp->m10gammapr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18200 p->paramId = OMEGA_10EEB;
18201 else if (!strcmp(mp->m10betapr, "Exponential") && !strcmp(mp->m10gammapr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18202 p->paramId = OMEGA_10EEF;
18203 else if (!strcmp(mp->m10betapr, "Exponential") && !strcmp(mp->m10gammapr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18204 p->paramId = OMEGA_10EFB;
18205 else if (!strcmp(mp->m10betapr, "Exponential") && !strcmp(mp->m10gammapr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18206 p->paramId = OMEGA_10EFF;
18207 else if (!strcmp(mp->m10betapr, "Fixed") && !strcmp(mp->m10gammapr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18208 p->paramId = OMEGA_10FUB;
18209 else if (!strcmp(mp->m10betapr, "Fixed") && !strcmp(mp->m10gammapr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18210 p->paramId = OMEGA_10FUF;
18211 else if (!strcmp(mp->m10betapr, "Fixed") && !strcmp(mp->m10gammapr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18212 p->paramId = OMEGA_10FEB;
18213 else if (!strcmp(mp->m10betapr, "Fixed") && !strcmp(mp->m10gammapr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18214 p->paramId = OMEGA_10FEF;
18215 else if (!strcmp(mp->m10betapr, "Fixed") && !strcmp(mp->m10gammapr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18216 p->paramId = OMEGA_10FFB;
18217 else if (!strcmp(mp->m10betapr, "Fixed") && !strcmp(mp->m10gammapr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18218 p->paramId = OMEGA_10FFF;
18220 if (p->paramId != OMEGA_10FFF)
18221 p->printParam = YES;
18222 for (i=0; i<p->nValues; i++)
18225 sprintf (temp, "omega(%d)", i+1);
18227 sprintf (temp, "\tomega(%d)", i+1);
18228 SafeStrcat (&p->paramHeader, temp);
18229 SafeStrcat (&p->paramHeader, partString);
18231 SafeStrcat (&p->paramHeader, "\tbeta(alpha)");
18232 SafeStrcat (&p->paramHeader, partString);
18233 SafeStrcat (&p->paramHeader, "\tbeta(beta)");
18234 SafeStrcat (&p->paramHeader, partString);
18235 SafeStrcat (&p->paramHeader, "\tgamma(alpha)");
18236 SafeStrcat (&p->paramHeader, partString);
18237 SafeStrcat (&p->paramHeader, "\tgamma(beta)");
18238 SafeStrcat (&p->paramHeader, partString);
18239 SafeStrcat (&p->paramHeader, "\tpi(1)");
18240 SafeStrcat (&p->paramHeader, partString);
18241 SafeStrcat (&p->paramHeader, "\tpi(2)");
18242 SafeStrcat (&p->paramHeader, partString);
18244 else if (!strcmp(mp->omegaVar, "Ny98"))
18246 p->nValues = 3; /* omega values */
18247 p->nSubValues = 6; /* omega category frequencies plus cache */
18248 for (i=0; i<numCurrentDivisions; i++)
18249 if (isPartTouched[i] == YES)
18250 modelSettings[i].omega = p;
18252 /* find the parameter x prior type */
18253 if (!strcmp(mp->ny98omega1pr, "Beta") && !strcmp(mp->ny98omega3pr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18254 p->paramId = OMEGA_BUD;
18255 else if (!strcmp(mp->ny98omega1pr, "Beta") && !strcmp(mp->ny98omega3pr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18256 p->paramId = OMEGA_BUF;
18257 else if (!strcmp(mp->ny98omega1pr, "Beta") && !strcmp(mp->ny98omega3pr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18258 p->paramId = OMEGA_BED;
18259 else if (!strcmp(mp->ny98omega1pr, "Beta") && !strcmp(mp->ny98omega3pr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18260 p->paramId = OMEGA_BEF;
18261 else if (!strcmp(mp->ny98omega1pr, "Beta") && !strcmp(mp->ny98omega3pr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18262 p->paramId = OMEGA_BFD;
18263 else if (!strcmp(mp->ny98omega1pr, "Beta") && !strcmp(mp->ny98omega3pr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18264 p->paramId = OMEGA_BFF;
18265 else if (!strcmp(mp->ny98omega1pr, "Fixed") && !strcmp(mp->ny98omega3pr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18266 p->paramId = OMEGA_FUD;
18267 else if (!strcmp(mp->ny98omega1pr, "Fixed") && !strcmp(mp->ny98omega3pr, "Uniform") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18268 p->paramId = OMEGA_FUF;
18269 else if (!strcmp(mp->ny98omega1pr, "Fixed") && !strcmp(mp->ny98omega3pr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18270 p->paramId = OMEGA_FED;
18271 else if (!strcmp(mp->ny98omega1pr, "Fixed") && !strcmp(mp->ny98omega3pr, "Exponential") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18272 p->paramId = OMEGA_FEF;
18273 else if (!strcmp(mp->ny98omega1pr, "Fixed") && !strcmp(mp->ny98omega3pr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Dirichlet"))
18274 p->paramId = OMEGA_FFD;
18275 else if (!strcmp(mp->ny98omega1pr, "Fixed") && !strcmp(mp->ny98omega3pr, "Fixed") && !strcmp(mp->codonCatFreqPr, "Fixed"))
18276 p->paramId = OMEGA_FFF;
18278 if (p->paramId != OMEGA_FFF)
18279 p->printParam = YES;
18280 SafeStrcat (&p->paramHeader, "omega(-)");
18281 SafeStrcat (&p->paramHeader, partString);
18282 SafeStrcat (&p->paramHeader, "\tomega(N)");
18283 SafeStrcat (&p->paramHeader, partString);
18284 SafeStrcat (&p->paramHeader, "\tomega(+)");
18285 SafeStrcat (&p->paramHeader, partString);
18287 SafeStrcat (&p->paramHeader, "\tpi(-)");
18288 SafeStrcat (&p->paramHeader, partString);
18289 SafeStrcat (&p->paramHeader, "\tpi(N)");
18290 SafeStrcat (&p->paramHeader, partString);
18291 SafeStrcat (&p->paramHeader, "\tpi(+)");
18292 SafeStrcat (&p->paramHeader, partString);
18298 for (i=0; i<numCurrentDivisions; i++)
18299 if (isPartTouched[i] == YES)
18300 modelSettings[i].omega = p;
18302 /* find the parameter x prior type */
18303 if (!strcmp(mp->omegaPr,"Dirichlet"))
18304 p->paramId = OMEGA_DIR;
18306 p->paramId = OMEGA_FIX;
18308 if (p->paramId != OMEGA_FIX)
18309 p->printParam = YES;
18310 SafeStrcat (&p->paramHeader, "omega");
18311 SafeStrcat (&p->paramHeader, partString);
18313 p->paramTypeName = "Positive selection (omega) model";
18314 SafeStrcat(&p->name, "Omega");
18315 SafeStrcat(&p->name, partString);
18317 else if (j == P_PI)
18319 /* Set up state frequencies *****************************************************************************/
18320 p->paramType = P_PI;
18323 for (i=0; i<numCurrentDivisions; i++)
18324 if (isPartTouched[i] == YES)
18325 modelSettings[i].stateFreq = p;
18327 if (mp->dataType == STANDARD)
18329 p->paramTypeName = "Symmetric diricihlet/beta distribution alpha_i parameter";
18330 SafeStrcat(&p->name, "Alpha_symdir");
18331 /* boundaries for alpha_i */
18333 p->max = POS_INFINITY;
18337 p->paramTypeName = "Stationary state frequencies";
18338 SafeStrcat(&p->name, "Pi");
18340 SafeStrcat(&p->name, partString);
18342 /* find the parameter x prior type */
18343 /* and the number of values and subvalues needed */
18344 if (mp->dataType == STANDARD)
18346 /* find number of model states */
18347 m->numModelStates = 2;
18348 for (c=0; c<numChar; c++)
18350 for (i=0; i<p->nRelParts; i++)
18352 if (partitionId[c][partitionNum] == p->relParts[i] + 1 && charInfo[c].numStates > m->numModelStates)
18353 m->numModelStates = charInfo[c].numStates;
18356 for (i=0; i<p->nRelParts; i++)
18357 modelSettings[p->relParts[i]].numModelStates = m->numModelStates;
18359 /* symmetric hyperprior with only one variable (0 if equal) */
18360 p->nValues = 1; /* set to 0 below for the SYMPI_EQUAL model */
18361 if (!strcmp(mp->symPiPr,"Uniform"))
18363 if (m->numModelStates > 2)
18364 p->paramId = SYMPI_UNI_MS;
18366 p->paramId = SYMPI_UNI;
18368 else if (!strcmp(mp->symPiPr,"Exponential"))
18370 if (m->numModelStates > 2)
18371 p->paramId = SYMPI_EXP_MS;
18373 p->paramId = SYMPI_EXP;
18375 else if (!strcmp(mp->symPiPr,"Fixed"))
18377 if (AreDoublesEqual(mp->symBetaFix, -1.0, 0.00001) == YES)
18379 p->paramId = SYMPI_EQUAL;
18384 if (m->numModelStates > 2)
18385 p->paramId = SYMPI_FIX_MS;
18387 p->paramId = SYMPI_FIX;
18390 p->nSubValues = 0; /* store state frequencies in p->stdStateFreqs */
18391 if (p->paramId == SYMPI_EXP || p->paramId == SYMPI_EXP_MS || p->paramId == SYMPI_UNI || p->paramId == SYMPI_UNI_MS)
18392 p->printParam = YES;
18393 SafeStrcat (&p->paramHeader, "alpha_symdir");
18394 SafeStrcat (&p->paramHeader, partString);
18395 /* further processing done in ProcessStdChars */
18399 /* deal with all models except standard */
18400 /* no hyperprior or fixed to one value, set default to 0 */
18402 /* one subvalue for each state */
18403 p->nSubValues = mp->nStates; /* mp->nStates is set to 20 if DNA || RNA && nucmodel==PROTEIN */
18404 if (!strcmp(mp->stateFreqPr, "Dirichlet"))
18406 p->paramId = PI_DIR;
18407 p->nValues = mp->nStates;
18409 else if (!strcmp(mp->stateFreqPr, "Fixed") && !strcmp(mp->stateFreqsFixType,"User"))
18410 p->paramId = PI_USER;
18411 else if (!strcmp(mp->stateFreqPr, "Fixed") && !strcmp(mp->stateFreqsFixType,"Empirical"))
18412 p->paramId = PI_EMPIRICAL;
18413 else if (!strcmp(mp->stateFreqPr, "Fixed") && !strcmp(mp->stateFreqsFixType,"Equal"))
18415 p->paramId = PI_EQUAL;
18418 if (m->dataType == PROTEIN)
18420 if (!strcmp(mp->aaModelPr, "Fixed"))
18422 if (!strcmp(mp->aaModel, "Poisson"))
18423 p->paramId = PI_EQUAL;
18424 else if (!strcmp(mp->aaModel, "Equalin") || !strcmp(mp->aaModel, "Gtr"))
18426 /* p->paramId stays to what it was set to above */
18429 p->paramId = PI_FIXED;
18432 p->paramId = PI_FIXED;
18435 if (p->paramId == PI_DIR)
18436 p->printParam = YES;
18437 if (m->dataType == DNA || m->dataType == RNA)
18439 if (!strcmp(mp->nucModel, "4by4"))
18441 sprintf (temp, "pi(%c)", StateCode_NUC4(0));
18442 SafeStrcat (&p->paramHeader,temp);
18443 SafeStrcat (&p->paramHeader,partString);
18444 for (n1=1; n1<4; n1++)
18446 sprintf (temp, "\tpi(%c)", StateCode_NUC4(n1));
18447 SafeStrcat (&p->paramHeader,temp);
18448 SafeStrcat (&p->paramHeader,partString);
18451 else if (!strcmp(mp->nucModel, "Doublet"))
18453 State_DOUBLET(tempCodon,0);
18454 sprintf (temp, "pi(%s)", tempCodon);
18455 SafeStrcat (&p->paramHeader,temp);
18456 SafeStrcat (&p->paramHeader,partString);
18457 for (n1=1; n1<16; n1++)
18459 State_DOUBLET(tempCodon,n1);
18460 sprintf (temp, "\tpi(%s)", tempCodon);
18461 SafeStrcat (&p->paramHeader,temp);
18462 SafeStrcat (&p->paramHeader,partString);
18465 else if (!strcmp(mp->nucModel, "Codon"))
18467 for (c=0; c<p->nSubValues; c++)
18469 if (mp->codonNucs[c][0] == 0)
18470 strcpy (tempCodon, "pi(A");
18471 else if (mp->codonNucs[c][0] == 1)
18472 strcpy (tempCodon, "pi(C");
18473 else if (mp->codonNucs[c][0] == 2)
18474 strcpy (tempCodon, "pi(G");
18476 strcpy (tempCodon, "pi(T");
18477 if (mp->codonNucs[c][1] == 0)
18478 strcat (tempCodon, "A");
18479 else if (mp->codonNucs[c][1] == 1)
18480 strcat (tempCodon, "C");
18481 else if (mp->codonNucs[c][1] == 2)
18482 strcat (tempCodon, "G");
18484 strcat (tempCodon, "T");
18485 if (mp->codonNucs[c][2] == 0)
18486 strcat (tempCodon, "A)");
18487 else if (mp->codonNucs[c][2] == 1)
18488 strcat (tempCodon, "C)");
18489 else if (mp->codonNucs[c][2] == 2)
18490 strcat (tempCodon, "G)");
18492 strcat (tempCodon, "T)");
18495 SafeStrcat (&p->paramHeader, tempCodon);
18496 SafeStrcat (&p->paramHeader, partString);
18500 SafeStrcat (&p->paramHeader, "\t");
18501 SafeStrcat (&p->paramHeader, tempCodon);
18502 SafeStrcat (&p->paramHeader, partString);
18507 else if (m->dataType == PROTEIN)
18509 if (FillRelPartsString (p, &partString) == YES)
18511 SafeSprintf (&tempStr, &tempStrSize, "pi(Ala)%s\tpi(Arg)%s\tpi(Asn)%s\tpi(Asp)%s\tpi(Cys)%s\tpi(Gln)%s\tpi(Glu)%s\tpi(Gly)%s\tpi(His)%s\tpi(Ile)%s\tpi(Leu)%s\tpi(Lys)%s\tpi(Met)%s\tpi(Phe)%s\tpi(Pro)%s\tpi(Ser)%s\tpi(Thr)%s\tpi(Trp)%s\tpi(Tyr)%s\tpi(Val)%s",
18512 partString, partString, partString, partString, partString, partString, partString, partString, partString, partString,
18513 partString, partString, partString, partString, partString, partString, partString, partString, partString, partString);
18514 SafeStrcat (&p->paramHeader, tempStr);
18517 SafeStrcat (&p->paramHeader, "pi(Ala)\tpi(Arg)\tpi(Asn)\tpi(Asp)\tpi(Cys)\tpi(Gln)\tpi(Glu)\tpi(Gly)\tpi(His)\tpi(Ile)\tpi(Leu)\tpi(Lys)\tpi(Met)\tpi(Phe)\tpi(Pro)\tpi(Ser)\tpi(Thr)\tpi(Trp)\tpi(Tyr)\tpi(Val)");
18519 else if (mp->dataType == RESTRICTION)
18521 if (FillRelPartsString (p, &partString) == YES)
18523 SafeSprintf (&tempStr, &tempStrSize, "pi(0)%s\tpi(1)%s", partString, partString);
18524 SafeStrcat (&p->paramHeader, tempStr);
18527 SafeStrcat (&p->paramHeader, "pi(0)\tpi(1)");
18531 MrBayesPrint ("%s Unknown data type in SetModelParams\n", spacer);
18535 else if (j == P_SHAPE)
18537 /* Set up shape parameter of gamma/lnorm *****************************************************************/
18538 p->paramType = P_SHAPE;
18540 p->nSubValues = mp->numGammaCats;
18543 for (i=0; i<numCurrentDivisions; i++)
18544 if (isPartTouched[i] == YES)
18545 modelSettings[i].shape = p;
18546 if(!strcmp(mp->ratesModel, "LNorm"))
18548 p->paramTypeName = "SD of scaled lognormal distribution of site rates";
18549 SafeStrcat(&p->name, "Sigma");
18550 SafeStrcat (&p->paramHeader, "sigma");
18554 p->paramTypeName = "Shape of scaled gamma distribution of site rates";
18555 SafeStrcat(&p->name, "Alpha");
18556 SafeStrcat (&p->paramHeader, "alpha");
18558 SafeStrcat(&p->name, partString);
18559 SafeStrcat (&p->paramHeader, partString);
18561 /* find the parameter x prior type */
18562 mp = &modelParams[p->relParts[0]];
18563 if (!strcmp(mp->shapePr,"Uniform"))
18564 p->paramId = SHAPE_UNI;
18565 else if (!strcmp(mp->shapePr,"Exponential"))
18566 p->paramId = SHAPE_EXP;
18568 p->paramId = SHAPE_FIX;
18570 if (p->paramId != SHAPE_FIX)
18571 p->printParam = YES;
18573 else if (j == P_PINVAR)
18575 /* Set up proportion of invariable sites ****************************************************************/
18576 p->paramType = P_PINVAR;
18581 for (i=0; i<numCurrentDivisions; i++)
18582 if (isPartTouched[i] == YES)
18583 modelSettings[i].pInvar = p;
18585 p->paramTypeName = "Proportion of invariable sites";
18586 SafeStrcat(&p->name, "Pinvar");
18587 SafeStrcat(&p->name, partString);
18589 /* find the parameter x prior type */
18590 if (!strcmp(mp->pInvarPr,"Uniform"))
18591 p->paramId = PINVAR_UNI;
18593 p->paramId = PINVAR_FIX;
18595 if (p->paramId != PINVAR_FIX)
18596 p->printParam = YES;
18597 SafeStrcat (&p->paramHeader, "pinvar");
18598 SafeStrcat (&p->paramHeader, partString);
18600 else if (j == P_CORREL)
18602 /* Set up correlation parameter of adgamma model ********************************************************/
18603 p->paramType = P_CORREL;
18605 p->nSubValues = mp->numGammaCats * mp->numGammaCats;
18608 for (i=0; i<numCurrentDivisions; i++)
18609 if (isPartTouched[i] == YES)
18610 modelSettings[i].correlation = p;
18612 p->paramTypeName = "Autocorrelation of gamma distribution of site rates";
18613 SafeStrcat(&p->name, "Rho");
18614 SafeStrcat(&p->name, partString);
18615 chainHasAdgamma = YES;
18617 /* find the parameter x prior type */
18618 if (!strcmp(mp->adGammaCorPr,"Uniform"))
18619 p->paramId = CORREL_UNI;
18621 p->paramId = CORREL_FIX;
18623 if (p->paramId != CORREL_FIX)
18624 p->printParam = YES;
18625 SafeStrcat (&p->paramHeader, "rho");
18626 SafeStrcat (&p->paramHeader, partString);
18628 else if (j == P_SWITCH)
18630 /* Set up switchRates for covarion model ****************************************************************/
18631 p->paramType = P_SWITCH;
18633 p->nSubValues = mp->numGammaCats * mp->numGammaCats;
18635 p->max = POS_INFINITY;
18636 for (i=0; i<numCurrentDivisions; i++)
18637 if (isPartTouched[i] == YES)
18638 modelSettings[i].switchRates = p;
18640 p->paramTypeName = "Switch rates of covarion model";
18641 SafeStrcat(&p->name, "s_cov");
18642 SafeStrcat(&p->name, partString);
18644 /* find the parameter x prior type */
18645 if (!strcmp(mp->covSwitchPr,"Uniform"))
18646 p->paramId = SWITCH_UNI;
18647 else if (!strcmp(mp->covSwitchPr,"Exponential"))
18648 p->paramId = SWITCH_EXP;
18650 p->paramId = SWITCH_FIX;
18652 if (p->paramId != SWITCH_FIX)
18653 p->printParam = YES;
18655 SafeStrcat (&p->paramHeader, "s(off->on)");
18656 SafeStrcat (&p->paramHeader, partString);
18657 SafeStrcat (&p->paramHeader, "\ts(on->off)");
18658 SafeStrcat (&p->paramHeader, partString);
18660 else if (j == P_RATEMULT)
18662 /* Set up rateMult for partition specific rates ***********************************************************/
18663 p->paramType = P_RATEMULT;
18664 if (!strcmp(mp->ratePr,"Fixed"))
18671 p->nValues = p->nRelParts = numRelParts; /* keep scaled division rates in value */
18672 p->nSubValues = p->nValues * 2; /* keep number of uncompressed chars for scaling in subValue */
18673 } /* also keep Dirichlet prior parameters here */
18675 p->max = POS_INFINITY;
18676 for (i=0; i<numCurrentDivisions; i++)
18677 if (isPartTouched[i] == YES)
18678 modelSettings[i].rateMult = p;
18680 p->paramTypeName = "Partition-specific rate multiplier";
18681 SafeStrcat(&p->name, "Ratemultiplier");
18682 SafeStrcat(&p->name, partString);
18684 /* find the parameter x prior type */
18685 if (p->nSubValues == 0)
18686 p->paramId = RATEMULT_FIX;
18688 p->paramId = RATEMULT_DIR;
18690 if (p->paramId != RATEMULT_FIX)
18691 p->printParam = YES;
18692 for (i=0; i<numCurrentDivisions; i++)
18694 if (isPartTouched[i] == YES)
18696 sprintf (tempMult, "m{%d}", i+1);
18698 SafeStrcat (&p->paramHeader, tempMult);
18701 SafeStrcat (&p->paramHeader, "\t");
18702 SafeStrcat (&p->paramHeader, tempMult);
18707 else if (j == P_GENETREERATE)
18709 /* Set up rateMult for gene specific rates ****************************************************************/
18710 p->paramType = P_GENETREERATE;
18711 p->nValues = p->nRelParts = numRelParts; /* keep scaled division rates in value */
18712 p->nSubValues = p->nValues * 2; /* keep number of uncompressed chars for scaling in subValue */
18713 /* also keep Dirichlet prior parameters here */
18715 p->max = POS_INFINITY;
18716 for (i=0; i<numCurrentDivisions; i++)
18717 if (isPartTouched[i] == YES)
18718 modelSettings[i].geneTreeRateMult = p;
18720 p->paramTypeName = "Gene-specific rate multiplier";
18721 SafeStrcat(&p->name, "Generatemult");
18722 SafeStrcat(&p->name, partString);
18724 /* find the parameter x prior type */
18725 if (strcmp(mp->generatePr,"Fixed") == 0)
18726 p->paramId = GENETREERATEMULT_FIX;
18728 p->paramId = GENETREERATEMULT_DIR;
18730 if (p->paramId == GENETREERATEMULT_FIX)
18731 p->printParam = NO;
18733 p->printParam = YES;
18735 for (i=0; i<numCurrentDivisions; i++)
18737 if (isPartTouched[i] == YES)
18739 sprintf (tempMult, "g_m{%d}", i+1);
18741 SafeStrcat (&p->paramHeader, tempMult);
18744 SafeStrcat (&p->paramHeader, "\t");
18745 SafeStrcat (&p->paramHeader, tempMult);
18750 else if (j == P_TOPOLOGY)
18752 /* Set up topology **************************************************************************************/
18753 p->paramType = P_TOPOLOGY;
18756 p->min = NEG_INFINITY; /* NA */
18757 p->max = NEG_INFINITY; /* NA */
18758 for (i=0; i<numCurrentDivisions; i++)
18759 if (isPartTouched[i] == YES)
18760 modelSettings[i].topology = p;
18762 p->paramTypeName = "Topology";
18763 SafeStrcat(&p->name, "Tau");
18764 SafeStrcat(&p->name, partString);
18766 /* check that the model is not parsimony for all of the relevant partitions */
18767 areAllPartsParsimony = YES;
18768 for (i=0; i<p->nRelParts; i++)
18770 if (modelSettings[p->relParts[i]].parsModelId == NO)
18771 areAllPartsParsimony = NO;
18774 /* check if topology is clock or nonclock */
18776 nCalibratedBrlens = 0;
18777 nRelaxedBrlens = 0;
18778 if (areAllPartsParsimony == NO)
18780 for (i=0; i<p->nRelParts; i++)
18782 if (!strcmp(modelParams[p->relParts[i]].brlensPr, "Clock"))
18785 if (strcmp(modelParams[p->relParts[i]].clockVarPr,"Strict") != 0) /* not strict */
18787 if (!strcmp(modelParams[p->relParts[i]].nodeAgePr,"Calibrated"))
18788 nCalibratedBrlens++;
18793 /* now find the parameter x prior type */
18794 if (areAllPartsParsimony == YES)
18796 if (!strcmp(mp->topologyPr, "Uniform"))
18797 p->paramId = TOPOLOGY_PARSIMONY_UNIFORM;
18798 else if (!strcmp(mp->topologyPr,"Constraints"))
18799 p->paramId = TOPOLOGY_PARSIMONY_CONSTRAINED;
18801 p->paramId = TOPOLOGY_PARSIMONY_FIXED;
18802 /* For this case, we also need to set the brlens ptr of the relevant partitions
18803 so that it points to the topology parameter, since the rest of the
18804 program will try to access the tree through this pointer. In FillTreeParams,
18805 we will make sure that a pure parsimony topology parameter contains a pointer
18806 to the relevant tree (like a brlens parameter would normally) */
18807 for (i=0; i<p->nRelParts; i++)
18808 modelSettings[p->relParts[i]].brlens = p;
18812 /* we assume for now that there is only one branch length; we will correct this
18813 later in AllocateTreeParams if there are more than one set of branch lengths,
18814 which is only possible for non-clock trees */
18815 if (!strcmp(mp->topologyPr, "Speciestree"))
18816 p->paramId = TOPOLOGY_SPECIESTREE;
18817 else if (!strcmp(mp->topologyPr, "Uniform") && nClockBrlens == 0)
18818 p->paramId = TOPOLOGY_NCL_UNIFORM_HOMO;
18819 else if (!strcmp(mp->topologyPr,"Constraints") && nClockBrlens == 0)
18820 p->paramId = TOPOLOGY_NCL_CONSTRAINED_HOMO;
18821 else if (!strcmp(mp->topologyPr,"Fixed") && nClockBrlens == 0)
18822 p->paramId = TOPOLOGY_NCL_FIXED_HOMO;
18823 /* all below have clock branch lengths */
18824 else if (!strcmp(mp->topologyPr, "Uniform") && nRelaxedBrlens == 0)
18826 if (nCalibratedBrlens >= 1)
18827 p->paramId = TOPOLOGY_CCL_UNIFORM;
18829 p->paramId = TOPOLOGY_CL_UNIFORM;
18831 else if (!strcmp(mp->topologyPr,"Constraints") && nRelaxedBrlens == 0)
18833 if (nCalibratedBrlens >= 1)
18834 p->paramId = TOPOLOGY_CCL_CONSTRAINED;
18836 p->paramId = TOPOLOGY_CL_CONSTRAINED;
18838 else if (!strcmp(mp->topologyPr,"Fixed") && nRelaxedBrlens == 0)
18840 if (nCalibratedBrlens >= 1)
18841 p->paramId = TOPOLOGY_CCL_FIXED;
18843 p->paramId = TOPOLOGY_CL_FIXED;
18845 /* all below have relaxed clock branch lengths */
18846 else if (!strcmp(mp->topologyPr, "Uniform"))
18848 if (nCalibratedBrlens >= 1)
18849 p->paramId = TOPOLOGY_RCCL_UNIFORM;
18851 p->paramId = TOPOLOGY_RCL_UNIFORM;
18853 else if (!strcmp(mp->topologyPr,"Constraints"))
18855 if (nCalibratedBrlens >= 1)
18856 p->paramId = TOPOLOGY_RCCL_CONSTRAINED;
18858 p->paramId = TOPOLOGY_RCL_CONSTRAINED;
18860 else if (!strcmp(mp->topologyPr,"Fixed"))
18862 if (nCalibratedBrlens >= 1)
18863 p->paramId = TOPOLOGY_RCCL_FIXED;
18865 p->paramId = TOPOLOGY_RCL_FIXED;
18869 /* should we print the topology? */
18870 for (i=0; i<p->nRelParts; i++)
18871 if (strcmp(modelParams[p->relParts[i]].treeFormat,"Topology") != 0)
18873 if (i == p->nRelParts)
18874 p->printParam = YES;
18876 p->printParam = NO;
18877 /* but always print parsimony topology */
18878 if (areAllPartsParsimony == YES)
18879 p->printParam = YES;
18880 /* and never print fixed topologies */
18881 if (p->paramId == TOPOLOGY_RCL_FIXED ||
18882 p->paramId == TOPOLOGY_RCCL_FIXED ||
18883 p->paramId == TOPOLOGY_CL_FIXED ||
18884 p->paramId == TOPOLOGY_CCL_FIXED ||
18885 p->paramId == TOPOLOGY_NCL_FIXED ||
18886 p->paramId == TOPOLOGY_PARSIMONY_FIXED)
18887 p->printParam = NO;
18889 else if (j == P_BRLENS)
18891 /* Set up branch lengths ********************************************************************************/
18892 p->paramType = P_BRLENS;
18896 p->max = POS_INFINITY;
18897 for (i=0; i<numCurrentDivisions; i++)
18898 if (isPartTouched[i] == YES)
18899 modelSettings[i].brlens = p;
18901 p->paramTypeName = "Branch lengths";
18902 SafeStrcat(&p->name, "V");
18903 SafeStrcat(&p->name, partString);
18905 /* find the parameter x prior type */
18906 if (modelSettings[p->relParts[0]].parsModelId == YES)
18907 p->paramId = BRLENS_PARSIMONY;
18910 if (!strcmp(mp->brlensPr, "Clock"))
18912 if (!strcmp(mp->clockPr,"Uniform"))
18913 p->paramId = BRLENS_CLOCK_UNI;
18914 else if (!strcmp(mp->clockPr,"Coalescence"))
18915 p->paramId = BRLENS_CLOCK_COAL;
18916 else if (!strcmp(mp->clockPr,"Birthdeath"))
18917 p->paramId = BRLENS_CLOCK_BD;
18918 else if (!strcmp(mp->clockPr,"Speciestreecoalescence"))
18919 p->paramId = BRLENS_CLOCK_SPCOAL;
18920 else if (!strcmp(mp->clockPr,"Fossilization"))
18921 p->paramId = BRLENS_CLOCK_FOSSIL;
18922 else if (!strcmp(mp->clockPr,"Fixed"))
18923 p->paramId = BRLENS_CLOCK_FIXED;
18925 else if (!strcmp(mp->brlensPr, "Unconstrained"))
18927 if (!strcmp(mp->unconstrainedPr,"Uniform"))
18928 p->paramId = BRLENS_UNI;
18929 else if (!strcmp(mp->unconstrainedPr,"Exponential"))
18930 p->paramId = BRLENS_EXP;
18931 else if (!strcmp(mp->unconstrainedPr,"GammaDir"))
18932 p->paramId = BRLENS_GamDir;
18933 else if (!strcmp(mp->unconstrainedPr,"invGamDir"))
18934 p->paramId = BRLENS_iGmDir;
18935 else if (!strcmp(mp->unconstrainedPr,"twoExp"))
18936 p->paramId = BRLENS_twoExp;
18938 else if (!strcmp(mp->brlensPr,"Fixed"))
18940 p->paramId = BRLENS_FIXED;
18944 /* should we print the branch lengths? */
18945 for (i=0; i<p->nRelParts; i++)
18946 if (strcmp(modelParams[p->relParts[i]].treeFormat,"Topology") != 0)
18948 if (i < p->nRelParts)
18949 p->printParam = YES;
18951 p->printParam = NO;
18953 else if (j == P_SPECIESTREE)
18955 /* Set up species tree **************************************************************************************/
18956 p->paramType = P_SPECIESTREE;
18959 p->min = NEG_INFINITY; /* NA */
18960 p->max = NEG_INFINITY; /* NA */
18961 for (i=0; i<numCurrentDivisions; i++)
18962 if (isPartTouched[i] == YES)
18963 modelSettings[i].speciesTree = p;
18965 p->paramTypeName = "Species tree";
18966 SafeStrcat(&p->name, "Spt");
18967 SafeStrcat(&p->name, partString);
18969 /* check that the model is not parsimony for all of the relevant partitions */
18970 areAllPartsParsimony = YES;
18971 for (i=0; i<p->nRelParts; i++)
18973 if (modelSettings[p->relParts[i]].parsModelId == NO)
18974 areAllPartsParsimony = NO;
18977 /* find the parameter x prior type */
18978 p->paramId = SPECIESTREE_UNIFORM;
18980 /* should we print the tree? */
18981 p->printParam = YES;
18983 else if (j == P_SPECRATE)
18985 /* Set up speciation rate ******************************************************************************/
18986 p->paramType = P_SPECRATE;
18987 if (!strcmp(mp->clockPr,"Fossilization"))
18988 p->nValues = mp->sampleFSNum +1; // rate in each time interval
18993 p->max = POS_INFINITY;
18994 for (i=0; i<numCurrentDivisions; i++)
18995 if (isPartTouched[i] == YES)
18996 modelSettings[i].speciationRates = p;
18998 p->paramTypeName = "Speciation rate";
18999 SafeStrcat(&p->name, "Net_speciation");
19000 SafeStrcat(&p->name, partString);
19002 /* find the parameter x prior type */
19003 if (!strcmp(mp->speciationPr,"Uniform"))
19004 p->paramId = SPECRATE_UNI;
19005 else if (!strcmp(mp->speciationPr,"Exponential"))
19006 p->paramId = SPECRATE_EXP;
19008 p->paramId = SPECRATE_FIX;
19010 if (p->paramId != SPECRATE_FIX)
19011 p->printParam = YES;
19013 if (p->nValues == 1)
19015 SafeStrcat (&p->paramHeader, "net_speciation");
19016 SafeStrcat (&p->paramHeader, partString);
19018 else for (i = 0; i < p->nValues; i++)
19020 sprintf (tempStr, "\tnet_speciation_%d", i+1);
19021 SafeStrcat (&p->paramHeader, tempStr);
19022 SafeStrcat (&p->paramHeader, partString);
19025 else if (j == P_EXTRATE)
19027 /* Set up extinction rates ******************************************************************************/
19028 p->paramType = P_EXTRATE;
19029 if (!strcmp(mp->clockPr,"Fossilization"))
19030 p->nValues = mp->sampleFSNum +1; // rate in each time interval
19036 for (i=0; i<numCurrentDivisions; i++)
19037 if (isPartTouched[i] == YES)
19038 modelSettings[i].extinctionRates = p;
19040 p->paramTypeName = "Extinction rate";
19041 SafeStrcat(&p->name, "Relative_extinction");
19042 SafeStrcat(&p->name, partString);
19044 /* find the parameter x prior type */
19045 if (!strcmp(mp->extinctionPr,"Beta"))
19046 p->paramId = EXTRATE_BETA;
19048 p->paramId = EXTRATE_FIX;
19050 if (p->paramId != EXTRATE_FIX)
19051 p->printParam = YES;
19053 if (p->nValues == 1)
19055 SafeStrcat (&p->paramHeader, "relative_extinction");
19056 SafeStrcat (&p->paramHeader, partString);
19058 else for (i = 0; i < p->nValues; i++)
19060 sprintf (tempStr, "\trelative_extinction_%d", i+1);
19061 SafeStrcat (&p->paramHeader, tempStr);
19062 SafeStrcat (&p->paramHeader, partString);
19065 else if (j == P_FOSLRATE)
19067 /* Set up fossilization rates */
19068 p->paramType = P_FOSLRATE;
19069 p->nValues = mp->sampleFSNum +1; // rate in each time interval
19073 for (i=0; i<numCurrentDivisions; i++)
19074 if (isPartTouched[i] == YES)
19075 modelSettings[i].fossilizationRates = p;
19077 p->paramTypeName = "Fossilization rate";
19078 SafeStrcat(&p->name, "Relative_fossilization");
19079 SafeStrcat(&p->name, partString);
19081 /* find the parameter x prior type */
19082 if (!strcmp(mp->fossilizationPr,"Beta"))
19083 p->paramId = FOSLRATE_BETA;
19085 p->paramId = FOSLRATE_FIX;
19087 if (p->paramId != FOSLRATE_FIX)
19088 p->printParam = YES;
19090 if (p->nValues == 1)
19092 SafeStrcat (&p->paramHeader, "relative_fossilization");
19093 SafeStrcat (&p->paramHeader, partString);
19095 else for (i = 0; i < p->nValues; i++)
19097 sprintf (tempStr, "\trelative_fossilization_%d", i+1);
19098 SafeStrcat (&p->paramHeader, tempStr);
19099 SafeStrcat (&p->paramHeader, partString);
19102 else if (j == P_POPSIZE)
19104 /* Set up population size *****************************************************************************************/
19105 p->paramType = P_POPSIZE;
19106 if (!strcmp(mp->topologyPr,"Speciestree") && !strcmp(mp->popVarPr, "Variable"))
19107 p->nValues = 2 * numSpecies;
19112 p->max = POS_INFINITY;
19113 for (i=0; i<numCurrentDivisions; i++)
19114 if (isPartTouched[i] == YES)
19115 modelSettings[i].popSize = p;
19117 p->paramTypeName = "Coalescent process population size parameter";
19118 SafeStrcat(&p->name, "Popsize");
19119 SafeStrcat(&p->name, partString);
19121 /* find the parameter x prior type */
19122 if (!strcmp(mp->popSizePr,"Uniform"))
19124 p->paramId = POPSIZE_UNI;
19125 p->LnPriorRatio = &LnProbRatioUniform;
19126 p->priorParams = mp->popSizeUni;
19127 p->LnPriorProb = &LnPriorProbUniform;
19129 else if (!strcmp(mp->popSizePr,"Normal"))
19131 p->paramId = POPSIZE_NORMAL;
19132 p->LnPriorRatio = &LnProbRatioTruncatedNormal;
19133 p->priorParams = mp->popSizeNormal;
19134 p->LnPriorProb = &LnPriorProbTruncatedNormal;
19136 else if (!strcmp(mp->popSizePr,"Lognormal"))
19138 p->paramId = POPSIZE_LOGNORMAL;
19139 p->LnPriorRatio = &LnProbRatioLognormal;
19140 p->priorParams = mp->popSizeLognormal;
19141 p->LnPriorProb = &LnPriorProbLognormal;
19143 else if (!strcmp(mp->popSizePr,"Gamma"))
19145 p->paramId = POPSIZE_GAMMA;
19146 p->LnPriorRatio = &LnProbRatioGamma;
19147 p->priorParams = mp->popSizeGamma;
19148 p->LnPriorProb = &LnPriorProbGamma;
19152 p->paramId = POPSIZE_FIX;
19153 p->LnPriorRatio = NULL;
19154 p->priorParams = &mp->popSizeFix;
19155 p->LnPriorProb = &LnPriorProbFix;
19158 if (p->paramId != POPSIZE_FIX && p->nValues == 1)
19159 p->printParam = YES;
19160 SafeStrcat (&p->paramHeader, "popsize");
19161 SafeStrcat (&p->paramHeader, partString);
19163 else if (j == P_GROWTH)
19165 /* Set up growth rate ************************************************************************************/
19166 p->paramType = P_GROWTH;
19170 p->max = POS_INFINITY;
19171 for (i=0; i<numCurrentDivisions; i++)
19172 if (isPartTouched[i] == YES)
19173 modelSettings[i].growthRate = p;
19175 p->paramTypeName = "Population growth rate";
19176 SafeStrcat(&p->name, "R_pop");
19177 SafeStrcat(&p->name, partString);
19179 /* find the parameter x prior type */
19180 if (!strcmp(mp->growthPr,"Uniform"))
19182 p->paramId = GROWTH_UNI;
19183 p->priorParams = mp->growthUni;
19184 p->min = mp->growthUni[0];
19185 p->max = mp->growthUni[1];
19186 p->LnPriorRatio = &LnProbRatioUniform;
19187 p->LnPriorProb = &LnPriorProbUniform;
19189 else if (!strcmp(mp->growthPr,"Exponential"))
19191 p->paramId = GROWTH_EXP;
19192 p->priorParams = &mp->growthExp;
19193 p->min = GROWTH_MIN;
19194 p->max = GROWTH_MAX;
19195 p->LnPriorRatio = &LnProbRatioExponential;
19196 p->LnPriorProb = &LnPriorProbExponential;
19198 else if (!strcmp(mp->growthPr,"Normal"))
19200 p->paramId = GROWTH_NORMAL;
19201 p->priorParams = mp->growthNorm;
19202 p->min = GROWTH_MIN;
19203 p->max = GROWTH_MAX;
19204 p->LnPriorRatio = &LnProbRatioTruncatedNormal;
19205 p->LnPriorProb = &LnPriorProbTruncatedNormal;
19208 p->paramId = GROWTH_FIX;
19210 p->paramId = GROWTH_FIX;
19211 p->priorParams = &mp->growthFix;
19212 p->min = p->max = mp->growthFix;
19213 p->LnPriorRatio = &LnProbRatioFix;
19214 p->LnPriorProb = &LnPriorProbFix;
19217 if (p->paramId != GROWTH_FIX)
19218 p->printParam = YES;
19219 SafeStrcat (&p->paramHeader, "growthRate");
19220 SafeStrcat (&p->paramHeader, partString);
19222 else if (j == P_AAMODEL)
19224 /* Set up aamodel *****************************************************************************************/
19225 p->paramType = P_AAMODEL;
19227 p->nSubValues = 10;
19230 for (i=0; i<numCurrentDivisions; i++)
19231 if (isPartTouched[i] == YES)
19232 modelSettings[i].aaModel = p;
19234 p->paramTypeName = "Aminoacid model";
19235 SafeStrcat(&p->name, "Aamodel");
19236 SafeStrcat(&p->name, partString);
19238 /* find the parameter x prior type */
19239 if (!strcmp(mp->aaModelPr,"Mixed"))
19240 p->paramId = AAMODEL_MIX;
19242 p->paramId = AAMODEL_FIX;
19244 if (p->paramId != AAMODEL_FIX)
19245 p->printParam = YES;
19246 SafeStrcat (&p->paramHeader, "aamodel");
19247 SafeStrcat (&p->paramHeader, partString);
19249 else if (j == P_CPPRATE)
19251 /* Set up cpprate *****************************************************************************************/
19252 p->paramType = P_CPPRATE;
19256 p->max = POS_INFINITY;
19257 for (i=0; i<numCurrentDivisions; i++)
19258 if (isPartTouched[i] == YES)
19259 modelSettings[i].cppRate = p;
19261 p->paramTypeName = "Rate of rate-multiplying compound Poisson process";
19262 SafeStrcat(&p->name, "Lambda_cpp");
19263 SafeStrcat(&p->name, partString);
19265 /* find the parameter x prior type */
19266 if (!strcmp(mp->cppRatePr,"Exponential"))
19267 p->paramId = CPPRATE_EXP;
19269 p->paramId = CPPRATE_FIX;
19271 if (p->paramId != CPPRATE_FIX)
19272 p->printParam = YES;
19273 SafeStrcat (&p->paramHeader, "cppRate");
19274 SafeStrcat (&p->paramHeader, partString);
19276 else if (j == P_CPPMULTDEV)
19278 /* Set up sigma of cpp rate multipliers *****************************************************************************************/
19279 p->paramType = P_CPPMULTDEV;
19283 p->max = POS_INFINITY;
19284 for (i=0; i<numCurrentDivisions; i++)
19285 if (isPartTouched[i] == YES)
19286 modelSettings[i].cppMultDev = p;
19288 p->paramTypeName = "Standard deviation (log) of CPP rate multipliers";
19289 SafeStrcat(&p->name, "Sigma_cpp");
19290 SafeStrcat(&p->name, partString);
19292 /* find the parameter x prior type */
19293 if (!strcmp(mp->cppMultDevPr,"Fixed"))
19294 p->paramId = CPPMULTDEV_FIX;
19296 if (p->paramId != CPPMULTDEV_FIX)
19297 p->printParam = YES;
19298 SafeStrcat (&p->paramHeader, "sigma_cpp");
19299 SafeStrcat (&p->paramHeader, partString);
19301 else if (j == P_CPPEVENTS)
19303 /* Set up cpp events parameter *****************************************************************************************/
19304 p->paramType = P_CPPEVENTS;
19306 p->nSubValues = 2*numLocalTaxa; /* keep effective branch lengths here (for all nodes to be on the safe side) */
19308 p->max = POS_INFINITY;
19309 for (i=0; i<numCurrentDivisions; i++)
19310 if (isPartTouched[i] == YES)
19311 modelSettings[i].cppEvents = p;
19313 p->paramTypeName = "Events of rate-multiplying compound Poisson process";
19314 SafeStrcat(&p->name, "CppEvents");
19315 SafeStrcat(&p->name, partString);
19317 /* find the parameter x prior type */
19318 p->paramId = CPPEVENTS;
19320 /* should we print values to .p file? */
19321 p->printParam = NO;
19323 SafeStrcat (&p->paramHeader, "cppEvents");
19324 SafeStrcat (&p->paramHeader, partString);
19326 else if (j == P_TK02VAR)
19328 /* Set up tk02 relaxed clock variance parameter *****************************************************************************************/
19329 p->paramType = P_TK02VAR;
19333 p->max = POS_INFINITY;
19334 for (i=0; i<numCurrentDivisions; i++)
19335 if (isPartTouched[i] == YES)
19336 modelSettings[i].tk02var = p;
19338 p->paramTypeName = "Variance of lognormal distribution of branch rates";
19339 SafeStrcat(&p->name, "TK02var");
19340 SafeStrcat(&p->name, partString);
19342 /* find the parameter x prior type */
19343 if (!strcmp(mp->tk02varPr,"Uniform"))
19344 p->paramId = TK02VAR_UNI;
19345 else if (!strcmp(mp->tk02varPr,"Exponential"))
19346 p->paramId = TK02VAR_EXP;
19348 p->paramId = TK02VAR_FIX;
19350 if (p->paramId != TK02VAR_FIX)
19351 p->printParam = YES;
19352 SafeStrcat (&p->paramHeader, "tk02var");
19353 SafeStrcat (&p->paramHeader, partString);
19355 else if (j == P_TK02BRANCHRATES)
19357 /* Set up tk02 relaxed clock rates parameter *****************************************************************************************/
19358 p->paramType = P_TK02BRANCHRATES;
19359 p->nValues = 2*numLocalTaxa; /* use to hold the branch rates; we need one rate for the root */
19360 p->nSubValues = 2*numLocalTaxa; /* use to hold the effective branch lengths */
19363 for (i=0; i<numCurrentDivisions; i++)
19364 if (isPartTouched[i] == YES)
19365 modelSettings[i].tk02BranchRates = p;
19367 p->paramTypeName = "Branch rates of TK02 relaxed clock";
19368 SafeStrcat(&p->name, "TK02Brlens");
19369 SafeStrcat(&p->name, partString);
19371 /* find the parameter x prior type */
19372 p->paramId = TK02BRANCHRATES;
19374 /* should we print values to .p file? */
19375 p->printParam = NO;
19377 SafeStrcat (&p->paramHeader, "tk02_brlens");
19378 SafeStrcat (&p->paramHeader, partString);
19380 else if (j == P_IGRVAR)
19382 /* Set up igr relaxed clock variance parameter *****************************************************************************************/
19383 p->paramType = P_IGRVAR;
19387 p->max = POS_INFINITY;
19388 for (i=0; i<numCurrentDivisions; i++)
19389 if (isPartTouched[i] == YES)
19390 modelSettings[i].igrvar = p;
19392 p->paramTypeName = "Variance increase of igr model branch lenths";
19393 SafeStrcat(&p->name, "Igrvar");
19394 SafeStrcat(&p->name, partString);
19396 /* find the parameter x prior type */
19397 if (!strcmp(mp->igrvarPr,"Uniform"))
19398 p->paramId = IGRVAR_UNI;
19399 else if (!strcmp(mp->igrvarPr,"Exponential"))
19400 p->paramId = IGRVAR_EXP;
19402 p->paramId = IGRVAR_FIX;
19404 if (p->paramId != IGRVAR_FIX)
19405 p->printParam = YES;
19406 SafeStrcat (&p->paramHeader, "igrvar");
19407 SafeStrcat (&p->paramHeader, partString);
19409 else if (j == P_IGRBRANCHRATES)
19411 /* Set up igr relaxed clock rates parameter *****************************************************************************************/
19412 p->paramType = P_IGRBRANCHRATES;
19413 p->nValues = 2*numLocalTaxa; /* use to hold the branch rates; we need one rate for the root */
19414 p->nSubValues = 2*numLocalTaxa; /* use to hold the effective branch lengths */
19417 for (i=0; i<numCurrentDivisions; i++)
19418 if (isPartTouched[i] == YES)
19419 modelSettings[i].igrBranchRates = p;
19421 p->paramTypeName = "Branch lengths of IGR relaxed clock";
19422 SafeStrcat(&p->name, "IgrBrlens");
19423 SafeStrcat(&p->name, partString);
19425 /* find the parameter x prior type */
19426 p->paramId = IGRBRANCHRATES;
19428 /* should we print values to .p file? */
19429 p->printParam = NO;
19431 SafeStrcat (&p->paramHeader, "igr_brlens");
19432 SafeStrcat (&p->paramHeader, partString);
19434 else if (j == P_MIXEDVAR)
19436 /* Set up mixed relaxed clock variance parameter *****************************************************************************************/
19437 p->paramType = P_MIXEDVAR;
19441 p->max = POS_INFINITY;
19442 for (i=0; i<numCurrentDivisions; i++)
19443 if (isPartTouched[i] == YES)
19444 modelSettings[i].mixedvar = p;
19446 p->paramTypeName = "Variance shared for mixed relaxed clock moodel";
19447 SafeStrcat(&p->name, "Mixedvar");
19448 SafeStrcat(&p->name, partString);
19450 /* find the parameter x prior type */
19451 if (!strcmp(mp->mixedvarPr,"Uniform"))
19452 p->paramId = MIXEDVAR_UNI;
19453 else if (!strcmp(mp->mixedvarPr,"Exponential"))
19454 p->paramId = MIXEDVAR_EXP;
19456 p->paramId = MIXEDVAR_FIX;
19458 if (p->paramId != MIXEDVAR_FIX)
19459 p->printParam = YES;
19460 SafeStrcat (&p->paramHeader, "mixedvar");
19461 SafeStrcat (&p->paramHeader, partString);
19463 else if (j == P_MIXEDBRCHRATES)
19465 /* Set up mixed relaxed clock rates parameter *****************************************************************************************/
19466 p->paramType = P_MIXEDBRCHRATES;
19467 p->nValues = 2*numLocalTaxa; /* use to hold the branch rates; we need one rate for the root */
19468 p->nSubValues = 2*numLocalTaxa; /* use to hold the effective branch lengths */
19469 p->nIntValues = 1; /* use to hold the model indicator: TK02 or IGR */
19472 for (i=0; i<numCurrentDivisions; i++)
19473 if (isPartTouched[i] == YES)
19474 modelSettings[i].mixedBrchRates = p;
19476 p->paramTypeName = "Branch rates of mixed relaxed clock";
19477 SafeStrcat(&p->name, "MixedBrlens");
19478 SafeStrcat(&p->name, partString);
19480 /* find the parameter x prior type */
19481 p->paramId = MIXEDBRCHRATES;
19483 /* how to print model indicator (0 or 1) to .p file? */
19484 p->printParam = NO;
19486 SafeStrcat (&p->paramHeader, "mixed_brlens");
19487 SafeStrcat (&p->paramHeader, partString);
19489 else if (j == P_CLOCKRATE)
19491 /* Set up clockRate ****************************************************************************************/
19492 p->paramType = P_CLOCKRATE;
19496 p->max = POS_INFINITY;
19497 for (i=0; i<numCurrentDivisions; i++)
19498 if (isPartTouched[i] == YES)
19499 modelSettings[i].clockRate = p;
19501 p->paramTypeName = "Base rate of clock";
19502 SafeStrcat(&p->name, "Clockrate");
19503 SafeStrcat(&p->name, partString);
19505 /* parameter does affect likelihoods */
19506 p->affectsLikelihood = YES;
19508 /* find the parameter x prior type */
19509 if (!strcmp(mp->clockRatePr,"Normal"))
19511 p->paramId = CLOCKRATE_NORMAL;
19512 p->LnPriorRatio = &LnProbRatioTruncatedNormal;
19513 p->priorParams = mp->clockRateNormal;
19514 p->LnPriorProb = &LnPriorProbTruncatedNormal;
19516 else if (!strcmp(mp->clockRatePr,"Lognormal"))
19518 p->paramId = CLOCKRATE_LOGNORMAL;
19519 p->LnPriorRatio = &LnProbRatioLognormal;
19520 p->priorParams = mp->clockRateLognormal;
19521 p->LnPriorProb = &LnPriorProbLognormal;
19523 else if (!strcmp(mp->clockRatePr,"Exponential"))
19525 p->paramId = CLOCKRATE_EXP;
19526 p->LnPriorRatio = &LnProbRatioExponential;
19527 p->priorParams = &mp->clockRateExp;
19528 p->LnPriorProb = &LnPriorProbExponential;
19530 else if (!strcmp(mp->clockRatePr,"Gamma"))
19532 p->paramId = CLOCKRATE_GAMMA;
19533 p->LnPriorRatio = &LnProbRatioGamma;
19534 p->priorParams = mp->clockRateGamma;
19535 p->LnPriorProb = &LnPriorProbGamma;
19539 p->paramId = CLOCKRATE_FIX;
19540 p->LnPriorRatio = NULL;
19541 p->priorParams = &mp->clockRateFix;
19542 p->LnPriorProb = &LnPriorProbFix;
19545 SafeStrcat (&p->paramHeader, "clockrate");
19546 SafeStrcat (&p->paramHeader, partString);
19547 if (p->paramId != CLOCKRATE_FIX)
19548 p->printParam = YES;
19552 free (isPartTouched);
19553 SafeFree ((void **)&partString);
19559 /*----------------------------------------------------------------------------
19561 | SetMoves: This function will set up the applicable moves that could
19562 | potentially be used in updating the model parameters
19564 -----------------------------------------------------------------------------*/
19565 int SetMoves (void)
19567 int i, j, k, moveIndex;
19570 /* free up previous moves if any */
19571 if (memAllocs[ALLOC_MOVES] == YES)
19573 for (i=0; i<numApplicableMoves; i++)
19574 FreeMove (moves[i]);
19577 memAllocs[ALLOC_MOVES] = NO;
19580 /* set up applicable moves */
19581 /* each combination of moveType and param is a separate move */
19583 /* first count applicable moves */
19584 numApplicableMoves = 0;
19585 for (k=0; k<numParams; k++)
19587 param = ¶ms[k];
19588 for (i=0; i<NUM_MOVE_TYPES; i++)
19590 if (moveTypes[i].level > userLevel)
19592 if (moveTypes[i].isApplicable(param) == NO)
19594 for (j=0; j<moveTypes[i].nApplicable; j++)
19595 if (moveTypes[i].applicableTo[j] == param->paramId)
19597 numApplicableMoves++;
19603 /* then allocate space for move pointers */
19604 moves = (MCMCMove **) SafeMalloc (numApplicableMoves * sizeof (MCMCMove *));
19607 MrBayesPrint ("%s Problem allocating moves\n", spacer);
19610 memAllocs[ALLOC_MOVES] = YES;
19612 /* finally allocate space for and set move defaults */
19614 for (k=0; k<numParams; k++)
19616 param = ¶ms[k];
19617 for (i=0; i<NUM_MOVE_TYPES; i++)
19619 if (moveTypes[i].level > userLevel)
19621 if (moveTypes[i].isApplicable(param) == NO)
19623 for (j=0; j<moveTypes[i].nApplicable; j++)
19625 if (moveTypes[i].applicableTo[j] == param->paramId)
19627 if ((moves[moveIndex] = AllocateMove (&moveTypes[i], param)) == NULL)
19631 moves[moveIndex]->parm = param;
19640 if (moveIndex < numApplicableMoves)
19642 for (i=0; i<moveIndex; i++)
19643 FreeMove (moves[i]);
19645 memAllocs[ALLOC_MOVES] = NO;
19646 MrBayesPrint ("%s Problem setting moves\n", spacer);
19654 /** SetPopSizeParam: Set population size values for a species tree from an input tree */
19655 int SetPopSizeParam (Param *param, int chn, int state, PolyTree *pt)
19657 int i, j, k, nLongsNeeded;
19663 nLongsNeeded = 1 + (pt->nNodes - pt->nIntNodes - 1) / nBitsInALong;
19665 /* Get pointer to values to be set */
19666 values = GetParamVals (param, chn, state);
19668 /* Get species tree */
19669 speciesTree = GetTree (modelSettings[param->relParts[0]].speciesTree, chn, state);
19671 /* Set them based on index of matching partitions */
19672 AllocatePolyTreePartitions(pt);
19673 AllocateTreePartitions(speciesTree);
19674 for (i=0; i<pt->nNodes; i++)
19676 pp = pt->allDownPass[i];
19677 for (j=0; j<speciesTree->nNodes-1; j++)
19679 p = speciesTree->allDownPass[j];
19680 for (k=0; k<nLongsNeeded; k++)
19682 if (pp->partition[k] != p->partition[k])
19685 if (k == nLongsNeeded)
19688 if (j == speciesTree->nNodes - 1)
19690 MrBayesPrint ("%s Non-matching partitions when setting population size parameter", spacer);
19691 FreePolyTreePartitions(pt);
19692 FreeTreePartitions(speciesTree);
19695 values[p->index] = pt->popSize[pp->index];
19698 FreePolyTreePartitions(pt);
19699 FreeTreePartitions(speciesTree);
19705 /* SetRelaxedClockParam: set values for a relaxed clock param from an input tree */
19706 int SetRelaxedClockParam (Param *param, int chn, int state, PolyTree *pt)
19708 int i, j, k, *nEvents=NULL, *nEventsP=NULL, nLongsNeeded, isEventSet;
19709 MrBFlt *effectiveBranchLengthP=NULL, *branchRate=NULL,
19710 **position=NULL, **rateMult=NULL, **positionP=NULL, **rateMultP=NULL,
19714 TreeNode *p=NULL, *q;
19716 nLongsNeeded = 1 + (numLocalTaxa - 1) / nBitsInALong;
19718 /* set pointers to the right set of values */
19720 if (param->paramType == P_CPPEVENTS)
19722 /* find the right event set */
19723 for (i=0; i<pt->nESets; i++)
19725 if (!strcmp(param->name,pt->eSetName[i]))
19728 if (i == pt->nESets)
19730 for (i=0; i<pt->nBSets; i++)
19731 if (!strcmp(param->name,pt->bSetName[i]))
19734 if (i == pt->nBSets)
19742 if (isEventSet == YES)
19744 nEventsP = pt->nEvents[i];
19745 positionP = pt->position[i];
19746 rateMultP = pt->rateMult[i];
19749 effectiveBranchLengthP = pt->effectiveBrLen[i];
19751 nEvents = param->nEvents[2*chn+state];
19752 position = param->position[2*chn+state];
19753 rateMult = param->rateMult[2*chn+state];
19755 else if (param->paramType == P_TK02BRANCHRATES || param->paramType == P_IGRBRANCHRATES || param->paramType == P_MIXEDBRCHRATES)
19757 /* find the right effective branch length set */
19758 for (i=0; i<pt->nBSets; i++)
19759 if (!strcmp(param->name,pt->bSetName[i]))
19761 if (i == pt->nBSets)
19764 effectiveBranchLengthP = pt->effectiveBrLen[i];
19765 branchRate = GetParamVals (param, chn, state);
19768 t = GetTree (param, chn, state);
19769 AllocatePolyTreePartitions (pt);
19770 AllocateTreePartitions (t);
19772 for (i=pt->nNodes-1; i>=0; i--)
19774 pp = pt->allDownPass[i];
19775 for (j=0; j<t->nNodes; j++)
19777 p = t->allDownPass[j];
19778 for (k=0; k<nLongsNeeded; k++)
19779 if (p->partition[k] != pp->partition[k])
19781 if (k == nLongsNeeded)
19784 if (param->paramType == P_CPPEVENTS)
19786 if (isEventSet == NO)
19788 if (nEvents[p->index] != 1)
19790 position[p->index] = (MrBFlt *) SafeRealloc ((void *) position[p->index], 1*sizeof(MrBFlt));
19791 rateMult[p->index] = (MrBFlt *) SafeRealloc ((void *) rateMult[p->index], 1*sizeof(MrBFlt));
19792 nEvents [p->index] = 1;
19794 position[p->index][0] = 0.5;
19795 if (p->anc->anc == NULL)
19796 rateMult[p->index][0] = 1.0;
19801 while (q->anc != NULL)
19803 baseRate *= rateMult[q->index][0];
19806 rateMult[p->index][0] = 2.0 * effectiveBranchLengthP[pp->index] / (p->length * baseRate) - 1.0;
19811 if (nEvents[p->index] != nEventsP[pp->index])
19813 if (nEventsP[pp->index] == 0)
19815 free (position[p->index]);
19816 free (rateMult[p->index]);
19820 position[p->index] = (MrBFlt *) SafeRealloc ((void *) position[p->index], nEventsP[pp->index]*sizeof(MrBFlt));
19821 rateMult[p->index] = (MrBFlt *) SafeRealloc ((void *) rateMult[p->index], nEventsP[pp->index]*sizeof(MrBFlt));
19823 nEvents[p->index] = nEventsP[pp->index];
19825 for (j=0; j<nEventsP[pp->index]; j++)
19827 position[p->index][j] = positionP[pp->index][j];
19828 rateMult[p->index][j] = rateMultP[pp->index][j];
19832 else if (param->paramType == P_TK02BRANCHRATES ||
19833 (param->paramType == P_MIXEDBRCHRATES && *GetParamIntVals(param, chn, state) == RCL_TK02))
19835 if (p->anc->anc == NULL)
19836 branchRate[p->index] = 1.0;
19837 else if (p->length > 0.0)
19838 branchRate[p->index] = 2.0 * effectiveBranchLengthP[pp->index] / p->length - branchRate[p->anc->index];
19840 branchRate[p->index] = branchRate[p->anc->index];
19842 else if (param->paramType == P_IGRBRANCHRATES ||
19843 (param->paramType == P_MIXEDBRCHRATES && *GetParamIntVals(param, chn, state) == RCL_IGR))
19845 if (p->length > 0.0)
19846 branchRate[p->index] = effectiveBranchLengthP[pp->index] / p->length;
19848 branchRate[p->index] = branchRate[p->anc->index];
19849 } // we are now reading effective branch length for TK02 and IGR
19852 if (param->paramType == P_CPPEVENTS)
19854 if (UpdateCppEvolLengths (param, t->root->left, chn) == ERROR)
19857 else if (param->paramType == P_TK02BRANCHRATES ||
19858 (param->paramType == P_MIXEDBRCHRATES && *GetParamIntVals(param, chn, state) == RCL_TK02))
19860 if (UpdateTK02EvolLengths (param, t, chn) == ERROR)
19863 else if (param->paramType == P_IGRBRANCHRATES ||
19864 (param->paramType == P_MIXEDBRCHRATES && *GetParamIntVals(param, chn, state) == RCL_IGR))
19866 if (UpdateIgrBrachLengths (param, t, chn) == ERROR)
19870 FreePolyTreePartitions (pt);
19871 FreeTreePartitions (t);
19877 /*------------------------------------------------------------------------
19879 | SetUpAnalysis: Set parameters and moves
19881 ------------------------------------------------------------------------*/
19882 int SetUpAnalysis (RandLong *seed)
19884 setUpAnalysisSuccess=NO;
19886 /* calculate number of characters and taxa */
19887 numLocalChar = NumNonExcludedChar ();
19889 /* we are checking later to make sure no partition is without characters */
19891 if (numLocalTaxa <= 2)
19893 MrBayesPrint ("%s There must be at least two included taxa, now there is %s\n", spacer,
19894 numLocalTaxa == 0 ? "none" : "only one");
19898 /* calculate number of global chains */
19899 numGlobalChains = chainParams.numRuns * chainParams.numChains;
19901 /* Set up link table */
19902 if (SetUpLinkTable () == ERROR)
19905 /* Check that the settings for doublet or codon models are correct. */
19906 if (CheckExpandedModels() == ERROR)
19909 /* Set up model info */
19910 if (SetModelInfo() == ERROR)
19913 /* Calculate number of (uncompressed) characters for each division */
19914 if (GetNumDivisionChars() == ERROR)
19917 /* Compress data and calculate some things needed for setting up params. */
19918 if (CompressData() == ERROR)
19921 /* Add dummy characters, if needed. */
19922 if (AddDummyChars() == ERROR)
19925 /* Set up parameters for the chain. */
19926 if (SetModelParams () == ERROR)
19929 /* Allocate normal params */
19930 if (AllocateNormalParams () == ERROR)
19933 /* Allocate tree params */
19934 if (AllocateTreeParams () == ERROR)
19937 /* Set default number of trees for sumt to appropriate number */
19938 sumtParams.numTrees = numTrees;
19940 /* Fill in normal parameters */
19941 if (FillNormalParams (seed, 0, numGlobalChains) == ERROR)
19944 /* Process standard characters (calculates bsIndex, tiIndex, and more). */
19945 if (ProcessStdChars(seed) == ERROR)
19948 /* Fill in trees */
19949 if (FillTreeParams (seed, 0, numGlobalChains) == ERROR)
19952 /* Set the applicable moves that could be used by the chain. */
19953 if (SetMoves () == ERROR)
19956 setUpAnalysisSuccess=YES;
19962 int SetUpLinkTable (void)
19964 int i, j, k, m, paramCount, isApplicable1, isApplicable2,
19966 int *check, *modelId;
19968 check = (int *) SafeMalloc (2 * (size_t)numCurrentDivisions * sizeof (int));
19971 MrBayesPrint ("%s Problem allocating check (%d)\n", spacer, 2 * numCurrentDivisions * sizeof(int));
19974 modelId = check + numCurrentDivisions;
19976 for (j=0; j<NUM_LINKED; j++)
19977 for (i=0; i<numCurrentDivisions; i++)
19978 activeParams[j][i] = 0;
19980 if (numCurrentDivisions > 1)
19983 for (j=0; j<NUM_LINKED; j++) /* loop over parameters */
19986 for (i=0; i<numCurrentDivisions; i++)
19988 for (i=0; i<numCurrentDivisions-1; i++) /* loop over partitions */
19990 for (k=i+1; k<numCurrentDivisions; k++)
19992 if (IsModelSame (j, i, k, &isApplicable1, &isApplicable2) == NO || linkTable[j][i] != linkTable[j][k])
19994 /* we cannot link the parameters */
19995 if (isApplicable1 == NO)
19997 if (isApplicable2 == NO)
19999 if (isApplicable1 == YES)
20001 if (isFirst == YES && modelId[i] == 0)
20003 modelId[i] = ++paramCount;
20008 if (modelId[i] == 0)
20009 modelId[i] = ++paramCount;
20012 if (modelId[k] == 0 && isApplicable2 == YES)
20013 modelId[k] = ++paramCount;
20017 /* we can link the parameters */
20018 if (isFirst == YES)
20020 if (modelId[i] == 0)
20021 modelId[i] = ++paramCount;
20026 if (modelId[i] == 0)
20027 modelId[i] = ++paramCount;
20029 modelId[k] = modelId[i];
20033 for (i=0; i<numCurrentDivisions; i++)
20034 activeParams[j][i] = modelId[i];
20039 /* if we have only one partition, then we do things a bit differently */
20041 for (j=0; j<NUM_LINKED; j++) /* loop over parameters */
20043 IsModelSame (j, 0, 0, &isApplicable1, &isApplicable2);
20044 if (isApplicable1 == YES)
20045 activeParams[j][0] = ++paramCount;
20047 activeParams[j][0] = -1;
20051 /* Check that the same report format is specified for all partitions with the same rate multiplier */
20052 for (i=0; i<numCurrentDivisions; i++)
20054 for (i=0; i<numCurrentDivisions; i++)
20056 m = activeParams[P_RATEMULT][i];
20057 if (m == -1 || check[i] == YES)
20060 for (j=i+1; j<numCurrentDivisions; j++)
20062 if (activeParams[P_RATEMULT][j] == m)
20065 if (strcmp(modelParams[i].ratemultFormat,modelParams[j].ratemultFormat)!= 0)
20068 strcpy (modelParams[j].ratemultFormat, modelParams[i].ratemultFormat);
20074 MrBayesPrint ("%s WARNING: Report format for ratemult (parameter %d) varies across partitions.\n", spacer);
20075 MrBayesPrint ("%s MrBayes will use the format for the first partition, which is %s.\n", spacer, modelParams[i].ratemultFormat);
20079 /* probably a good idea to clean up link table here */
20081 for (j=0; j<NUM_LINKED; j++)
20083 for (i=0; i<numCurrentDivisions; i++)
20085 for (i=0; i<numCurrentDivisions; i++)
20087 if (check[i] == NO && activeParams[j][i] > 0)
20089 m = activeParams[j][i];
20091 for (k=i; k<numCurrentDivisions; k++)
20093 if (check[k] == NO && activeParams[j][k] == m)
20095 activeParams[j][k] = paramCount;
20109 /*------------------------------------------------------------------------
20111 | SetUpMoveTypes: Set up structs holding info on each move type
20113 ------------------------------------------------------------------------*/
20114 void SetUpMoveTypes (void)
20116 /* Register the move type here when new move functions are added
20117 Remember to check that the number of move types does not exceed NUM_MOVE_TYPES
20118 defined in bayes.h. */
20122 /* reset move types */
20123 for (i=0; i<NUM_MOVE_TYPES; i++)
20125 mt = &moveTypes[i];
20126 mt->level = DEVELOPER;
20127 mt->numTuningParams = 0;
20128 mt->minimum[0] = mt->minimum[1] = -1000000000.0;
20129 mt->maximum[0] = mt->maximum[1] = 1000000000.0;
20130 mt->tuningParam[0] = mt->tuningParam[1] = 0.0;
20131 mt->nApplicable = 0;
20132 mt->name = mt->tuningName[0] = mt->tuningName[1] = "";
20133 mt->paramName = "";
20134 mt->subParams = NO;
20135 mt->relProposalProb = 0.0;
20136 mt->parsimonyBased = NO;
20137 mt->isApplicable = &IsApplicable;
20138 mt->Autotune = NULL;
20139 mt->targetRate = -1.0;
20142 /* Moves are in alphabetic order after parameter name, which matches the name of a move function if
20143 there is a separate move function for the parameter. See proposal.h for declaration of move functions.
20144 Since 2010-10-04, some parameters use generalized move functions and do not have their own. */
20149 mt = &moveTypes[i++];
20150 mt->name = "Uniform random pick";
20151 mt->shortName = "Uniform";
20152 mt->applicableTo[0] = AAMODEL_MIX;
20153 mt->nApplicable = 1;
20154 mt->moveFxn = &Move_Aamodel;
20155 mt->relProposalProb = 1.0;
20156 mt->numTuningParams = 0;
20157 mt->parsimonyBased = NO;
20158 mt->level = STANDARD_USER;
20161 mt = &moveTypes[i++];
20162 mt->name = "Sliding window";
20163 mt->shortName = "Slider";
20164 mt->tuningName[0] = "Sliding window size";
20165 mt->shortTuningName[0] = "delta";
20166 mt->applicableTo[0] = CORREL_UNI;
20167 mt->nApplicable = 1;
20168 mt->moveFxn = &Move_Adgamma;
20169 mt->relProposalProb = 1.0;
20170 mt->numTuningParams = 1;
20171 mt->tuningParam[0] = 0.5; /* window size */
20172 mt->minimum[0] = 0.001;
20173 mt->maximum[0] = 1.999;
20174 mt->parsimonyBased = NO;
20175 mt->level = STANDARD_USER;
20176 mt->Autotune = &AutotuneSlider;
20177 mt->targetRate = 0.25;
20180 mt = &moveTypes[i++];
20181 mt->name = "Multiplier";
20182 mt->shortName = "Multiplier";
20183 mt->tuningName[0] = "Multiplier tuning parameter";
20184 mt->shortTuningName[0] = "lambda";
20185 mt->applicableTo[0] = SYMPI_UNI;
20186 mt->applicableTo[1] = SYMPI_EXP;
20187 mt->applicableTo[2] = SYMPI_UNI_MS;
20188 mt->applicableTo[3] = SYMPI_EXP_MS;
20189 mt->nApplicable = 4;
20190 mt->moveFxn = &Move_Beta;
20191 mt->relProposalProb = 1.0;
20192 mt->numTuningParams = 1;
20193 mt->tuningParam[0] = 2.0 * log (1.5); /* so-called lambda */
20194 mt->minimum[0] = 0.0001;
20195 mt->maximum[0] = 20.0;
20196 mt->parsimonyBased = NO;
20197 mt->level = STANDARD_USER;
20198 mt->Autotune = &AutotuneMultiplier;
20199 mt->targetRate = 0.25;
20202 mt = &moveTypes[i++];
20203 mt->name = "Random brlen hit with multiplier";
20204 mt->shortName = "Multiplier";
20205 mt->tuningName[0] = "Multiplier tuning parameter";
20206 mt->shortTuningName[0] = "lambda";
20207 mt->applicableTo[0] = BRLENS_UNI;
20208 mt->applicableTo[1] = BRLENS_EXP;
20209 mt->applicableTo[2] = BRLENS_GamDir;
20210 mt->applicableTo[3] = BRLENS_iGmDir;
20211 mt->applicableTo[4] = BRLENS_twoExp;
20212 mt->nApplicable = 5; // was 2
20213 mt->moveFxn = &Move_BrLen;
20214 mt->relProposalProb = 20.0;
20215 mt->numTuningParams = 1;
20216 mt->tuningParam[0] = 2.0 * log (2.0); /* lambda */
20217 mt->minimum[0] = 0.0001;
20218 mt->maximum[0] = 20.0; /* change it smaller to avoid overflow in the exp function, same for following "smaller" */
20219 mt->parsimonyBased = NO;
20220 mt->level = STANDARD_USER;
20221 mt->Autotune = &AutotuneMultiplier;
20222 mt->targetRate = 0.25;
20224 /* Move_ClockRate_M */
20225 mt = &moveTypes[i++];
20226 mt->name = "Multiplier";
20227 mt->shortName = "Multiplier";
20228 mt->tuningName[0] = "Multiplier tuning parameter";
20229 mt->shortTuningName[0] = "lambda";
20230 mt->applicableTo[0] = CLOCKRATE_NORMAL;
20231 mt->applicableTo[1] = CLOCKRATE_LOGNORMAL;
20232 mt->applicableTo[2] = CLOCKRATE_GAMMA;
20233 mt->applicableTo[3] = CLOCKRATE_EXP;
20234 mt->nApplicable = 4;
20235 mt->moveFxn = &Move_ClockRate_M;
20236 mt->relProposalProb = 2.0;
20237 mt->numTuningParams = 1;
20238 mt->tuningParam[0] = 2.0 * log (1.5); /* lambda */
20239 mt->minimum[0] = 0.0001;
20240 mt->maximum[0] = 20.0; /* smaller */
20241 mt->parsimonyBased = NO;
20242 mt->level = STANDARD_USER;
20243 mt->Autotune = &AutotuneMultiplier;
20244 mt->targetRate = 0.25;
20246 /* Move_Extinction */
20247 mt = &moveTypes[i++];
20248 mt->name = "Sliding window";
20249 mt->shortName = "Slider";
20250 mt->tuningName[0] = "Sliding window size";
20251 mt->shortTuningName[0] = "delta";
20252 mt->applicableTo[0] = EXTRATE_BETA;
20253 mt->nApplicable = 1;
20254 mt->moveFxn = &Move_Extinction;
20255 mt->relProposalProb = 3.0;
20256 mt->numTuningParams = 1;
20257 mt->tuningParam[0] = 0.1; /* window size */
20258 mt->minimum[0] = 0.00001;
20259 mt->maximum[0] = 20.0;
20260 mt->parsimonyBased = NO;
20261 mt->level = STANDARD_USER;
20262 mt->Autotune = &AutotuneSlider;
20263 mt->targetRate = 0.25;
20265 /* Move_Fossilization */
20266 mt = &moveTypes[i++];
20267 mt->name = "Sliding window";
20268 mt->shortName = "Slider";
20269 mt->tuningName[0] = "Sliding window size";
20270 mt->shortTuningName[0] = "delta";
20271 mt->applicableTo[0] = FOSLRATE_BETA;
20272 mt->nApplicable = 1;
20273 mt->moveFxn = &Move_Fossilization;
20274 mt->relProposalProb = 3.0;
20275 mt->numTuningParams = 1;
20276 mt->tuningParam[0] = 0.1; /* window size */
20277 mt->minimum[0] = 0.00001;
20278 mt->maximum[0] = 20.0;
20279 mt->parsimonyBased = NO;
20280 mt->level = STANDARD_USER;
20281 mt->Autotune = &AutotuneSlider;
20282 mt->targetRate = 0.25;
20284 /* Move_AddBranch, for fossilization prior */
20285 mt = &moveTypes[i++];
20286 mt->name = "Add branch for FossilizedBD";
20287 mt->shortName = "AddBranch";
20288 // mt->subParams = YES;
20289 mt->applicableTo[0] = BRLENS_CLOCK_FOSSIL;
20290 mt->nApplicable = 1;
20291 mt->moveFxn = &Move_AddBranch;
20292 mt->relProposalProb = 10.0;
20293 mt->numTuningParams = 0;
20294 mt->parsimonyBased = NO;
20295 mt->level =STANDARD_USER;
20296 mt->isApplicable = &IsApplicable_AncestralFossil;
20298 /* Move_DelBranch, for fossilization prior */
20299 mt = &moveTypes[i++];
20300 mt->name = "Delete branch for FossilizedBD";
20301 mt->shortName = "DelBranch";
20302 // mt->subParams = YES;
20303 mt->applicableTo[0] = BRLENS_CLOCK_FOSSIL;
20304 mt->nApplicable = 1;
20305 mt->moveFxn = &Move_DelBranch;
20306 mt->relProposalProb = 10.0;
20307 mt->numTuningParams = 0;
20308 mt->parsimonyBased = NO;
20309 mt->level =STANDARD_USER;
20310 mt->isApplicable = &IsApplicable_AncestralFossil;
20313 mt = &moveTypes[i++];
20314 mt->name = "Extending SPR";
20315 mt->shortName = "ExtSPR";
20316 mt->subParams = YES;
20317 mt->tuningName[0] = "Extension probability";
20318 mt->shortTuningName[0] = "p_ext";
20319 mt->tuningName[1] = "Multiplier tuning parameter";
20320 mt->shortTuningName[1] = "lambda";
20321 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
20322 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
20323 mt->nApplicable = 2;
20324 mt->moveFxn = &Move_ExtSPR;
20325 mt->relProposalProb = 5.0;
20326 mt->numTuningParams = 2;
20327 mt->tuningParam[0] = 0.5; /* extension probability */
20328 mt->tuningParam[1] = 2.0 * log (1.05); /* lambda */
20329 mt->minimum[0] = 0.00001;
20330 mt->maximum[0] = 0.99999;
20331 mt->minimum[1] = 0.00001;
20332 mt->maximum[1] = 100.0;
20333 mt->parsimonyBased = NO;
20334 mt->level = STANDARD_USER;
20335 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
20338 mt = &moveTypes[i++];
20339 mt->name = "Extending SPR variant 1";
20340 mt->shortName = "ExtSPR1";
20341 mt->subParams = YES;
20342 mt->tuningName[0] = "Extension probability";
20343 mt->shortTuningName[0] = "p_ext";
20344 mt->tuningName[1] = "Multiplier tuning parameter";
20345 mt->shortTuningName[1] = "lambda";
20346 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
20347 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
20348 mt->nApplicable = 2;
20349 mt->moveFxn = &Move_ExtSPR1;
20350 mt->relProposalProb = 0.0;
20351 mt->numTuningParams = 2;
20352 mt->tuningParam[0] = 0.5; /* extension probability */
20353 mt->tuningParam[1] = 2.0 * log (1.05); /* lambda */
20354 mt->minimum[0] = 0.00001;
20355 mt->maximum[0] = 0.99999;
20356 mt->minimum[1] = 0.00001;
20357 mt->maximum[1] = 100.0;
20358 mt->parsimonyBased = NO;
20359 mt->level = DEVELOPER;
20360 mt->isApplicable = &IsApplicable_FiveTaxaOrMore;
20362 /* Move_ExtSPRClock */
20363 mt = &moveTypes[i++];
20364 mt->name = "Extending SPR for clock trees";
20365 mt->shortName = "ExtSprClock";
20366 mt->subParams = YES;
20367 mt->tuningName[0] = "Extension probability";
20368 mt->shortTuningName[0] = "p_ext";
20369 mt->applicableTo[0] = TOPOLOGY_CL_UNIFORM;
20370 mt->applicableTo[1] = TOPOLOGY_CCL_UNIFORM;
20371 mt->applicableTo[2] = TOPOLOGY_CL_CONSTRAINED;
20372 mt->applicableTo[3] = TOPOLOGY_CCL_CONSTRAINED;
20373 mt->applicableTo[4] = TOPOLOGY_RCL_UNIFORM;
20374 mt->applicableTo[5] = TOPOLOGY_RCL_CONSTRAINED;
20375 mt->applicableTo[6] = TOPOLOGY_RCCL_UNIFORM;
20376 mt->applicableTo[7] = TOPOLOGY_RCCL_CONSTRAINED;
20377 mt->nApplicable = 8;
20378 mt->moveFxn = &Move_ExtSPRClock;
20379 mt->relProposalProb = 10.0;
20380 mt->numTuningParams = 1;
20381 mt->tuningParam[0] = 0.5; /* extension probability */
20382 mt->minimum[0] = 0.00001;
20383 mt->maximum[0] = 0.99999;
20384 mt->parsimonyBased = NO;
20385 mt->level = STANDARD_USER;
20386 mt->isApplicable = &IsApplicable_ThreeTaxaOrMore;
20389 mt = &moveTypes[i++];
20390 mt->name = "Extending subtree swapper";
20391 mt->shortName = "ExtSS";
20392 mt->subParams = YES;
20393 mt->tuningName[0] = "Extension probability";
20394 mt->shortTuningName[0] = "p_ext";
20395 mt->tuningName[1] = "Multiplier tuning parameter";
20396 mt->shortTuningName[1] = "lambda";
20397 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
20398 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
20399 mt->nApplicable = 2;
20400 mt->moveFxn = &Move_ExtSS;
20401 mt->relProposalProb = 0.0;
20402 mt->numTuningParams = 2;
20403 mt->tuningParam[0] = 0.5; /* extension probability */
20404 mt->tuningParam[1] = 2.0 * log (1.05); /* lambda */
20405 mt->minimum[0] = 0.00001;
20406 mt->maximum[0] = 0.99999;
20407 mt->minimum[1] = 0.00001;
20408 mt->maximum[1] = 100.0;
20409 mt->parsimonyBased = NO;
20410 mt->level = STANDARD_USER;
20411 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
20413 /* Move_ExtSSClock */
20414 mt = &moveTypes[i++];
20415 mt->name = "Extending subtree swapper";
20416 mt->shortName = "ExtSsClock";
20417 mt->subParams = YES;
20418 mt->tuningName[0] = "Extension probability";
20419 mt->shortTuningName[0] = "p_ext";
20420 mt->applicableTo[0] = TOPOLOGY_CL_UNIFORM;
20421 mt->applicableTo[1] = TOPOLOGY_CCL_UNIFORM;
20422 mt->applicableTo[2] = TOPOLOGY_CL_CONSTRAINED;
20423 mt->applicableTo[3] = TOPOLOGY_CCL_CONSTRAINED;
20424 mt->applicableTo[4] = TOPOLOGY_RCL_UNIFORM;
20425 mt->applicableTo[5] = TOPOLOGY_RCL_CONSTRAINED;
20426 mt->applicableTo[6] = TOPOLOGY_RCCL_UNIFORM;
20427 mt->applicableTo[7] = TOPOLOGY_RCCL_CONSTRAINED;
20428 mt->nApplicable = 8;
20429 mt->moveFxn = &Move_ExtSSClock;
20430 mt->relProposalProb = 0.0;
20431 mt->numTuningParams = 1;
20432 mt->tuningParam[0] = 0.5; /* extension probability */
20433 mt->minimum[0] = 0.00001;
20434 mt->maximum[0] = 0.99999;
20435 mt->parsimonyBased = NO;
20436 mt->level = STANDARD_USER;
20437 mt->isApplicable = &IsApplicable_ThreeTaxaOrMore;
20440 mt = &moveTypes[i++];
20441 mt->name = "Extending TBR";
20442 mt->shortName = "ExtTBR";
20443 mt->subParams = YES;
20444 mt->tuningName[0] = "Extension probability";
20445 mt->shortTuningName[0] = "p_ext";
20446 mt->tuningName[1] = "Multiplier tuning parameter";
20447 mt->shortTuningName[1] = "lambda";
20448 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
20449 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
20450 mt->nApplicable = 2;
20451 mt->moveFxn = &Move_ExtTBR;
20452 mt->relProposalProb = 5.0;
20453 mt->numTuningParams = 2;
20454 mt->tuningParam[0] = 0.5; /* extension probability */
20455 mt->tuningParam[1] = 2.0 * log (1.05); /* lambda */
20456 mt->minimum[0] = 0.00001;
20457 mt->maximum[0] = 0.99999;
20458 mt->minimum[1] = 0.00001;
20459 mt->maximum[1] = 100.0;
20460 mt->parsimonyBased = NO;
20461 mt->level = STANDARD_USER;
20462 mt->isApplicable = &IsApplicable_FiveTaxaOrMore;
20464 /* Move_RateShape_M */
20465 mt = &moveTypes[i++];
20466 mt->name = "Multiplier";
20467 mt->shortName = "Multiplier";
20468 mt->tuningName[0] = "Multiplier tuning parameter";
20469 mt->shortTuningName[0] = "lambda";
20470 mt->applicableTo[0] = SHAPE_UNI;
20471 mt->applicableTo[1] = SHAPE_EXP;
20472 mt->nApplicable = 2;
20473 mt->moveFxn = &Move_RateShape_M;
20474 mt->relProposalProb = 1.0;
20475 mt->numTuningParams = 1;
20476 mt->tuningParam[0] = 2.0 * log (1.5); /* lambda */
20477 mt->minimum[0] = 0.0001;
20478 mt->maximum[0] = 10.0; /* smaller */
20479 mt->parsimonyBased = NO;
20480 mt->level = STANDARD_USER;
20481 mt->Autotune = &AutotuneMultiplier;
20482 mt->targetRate = 0.25;
20484 /* Move_GeneRate_Dir */
20485 mt = &moveTypes[i++];
20486 mt->name = "Dirichlet proposal";
20487 mt->shortName = "Dirichlet";
20488 mt->tuningName[0] = "Dirichlet parameter";
20489 mt->shortTuningName[0] = "alpha";
20490 mt->applicableTo[0] = GENETREERATEMULT_DIR;
20491 mt->nApplicable = 1;
20492 mt->moveFxn = &Move_GeneRate_Dir;
20493 mt->relProposalProb = 1.0;
20494 mt->numTuningParams = 1;
20495 mt->tuningParam[0] = 1000.0; /* alphaPi */
20496 mt->minimum[0] = 0.001;
20497 mt->maximum[0] = 1000000.0;
20498 mt->parsimonyBased = NO;
20499 mt->level = STANDARD_USER;
20500 mt->Autotune = &AutotuneDirichlet;
20501 mt->targetRate = 0.25;
20503 /* Move_GeneTree1 */
20504 mt = &moveTypes[i++];
20505 mt->name = "Extending SPR move for gene trees in species trees";
20506 mt->shortName = "ExtSPRClockGS";
20507 mt->tuningName[0] = "Extension probability";
20508 mt->shortTuningName[0] = "prob";
20509 mt->applicableTo[0] = TOPOLOGY_SPECIESTREE;
20510 mt->nApplicable = 1;
20511 mt->moveFxn = &Move_GeneTree1;
20512 mt->relProposalProb = 10.0;
20513 mt->numTuningParams = 1;
20514 mt->tuningParam[0] = 0.5; /* Tuning parameter value */
20515 mt->minimum[0] = 0.00001; /* Minimum value of tuning param */
20516 mt->maximum[0] = 0.99999; /* Maximum value of tuning param */
20517 mt->parsimonyBased = NO; /* It does not use parsimony scores */
20518 mt->level = STANDARD_USER;
20520 /* Move_GeneTree2 */
20521 mt = &moveTypes[i++];
20522 mt->name = "NNI move for gene trees in species trees";
20523 mt->shortName = "NNIClockGS";
20524 mt->applicableTo[0] = TOPOLOGY_SPECIESTREE;
20525 mt->nApplicable = 1;
20526 mt->moveFxn = &Move_GeneTree2;
20527 mt->relProposalProb = 10.0;
20528 mt->numTuningParams = 0; /* No tuning parameters */
20529 mt->parsimonyBased = NO; /* It does not use parsimony scores */
20530 mt->level = STANDARD_USER;
20532 /* Move_GeneTree3 */
20533 mt = &moveTypes[i++];
20534 mt->name = "Parsimony-biased SPR for gene trees in species trees";
20535 mt->shortName = "ParsSPRClockGS";
20536 mt->subParams = YES;
20537 mt->tuningName[0] = "parsimony warp factor";
20538 mt->shortTuningName[0] = "warp";
20539 mt->tuningName[1] = "reweighting probability";
20540 mt->shortTuningName[1] = "r";
20541 mt->tuningName[2] = "typical branch length";
20542 mt->shortTuningName[2] = "v_t";
20543 mt->applicableTo[0] = TOPOLOGY_SPECIESTREE;
20544 mt->nApplicable = 1;
20545 mt->moveFxn = &Move_GeneTree3;
20546 mt->relProposalProb = 5.0;
20547 mt->numTuningParams = 3;
20548 mt->tuningParam[0] = 0.1; /* warp */
20549 mt->tuningParam[1] = 0.05; /* upweight and downweight probability */
20550 mt->tuningParam[2] = 0.05; /* typical branch length */
20551 mt->minimum[0] = 0.0;
20552 mt->maximum[0] = 1.0;
20553 mt->minimum[1] = 0.0;
20554 mt->maximum[1] = 0.3;
20555 mt->minimum[2] = 0.0001;
20556 mt->maximum[2] = 0.5;
20557 mt->parsimonyBased = YES;
20558 mt->level = STANDARD_USER;
20560 /* Move_Growth_M */
20561 mt = &moveTypes[i++];
20562 mt->name = "Multiplier";
20563 mt->shortName = "Multiplier";
20564 mt->tuningName[0] = "Multiplier tuning parameter";
20565 mt->shortTuningName[0] = "lambda";
20566 mt->applicableTo[0] = GROWTH_UNI;
20567 mt->applicableTo[1] = GROWTH_EXP;
20568 mt->applicableTo[2] = GROWTH_NORMAL;
20569 mt->nApplicable = 3;
20570 mt->moveFxn = &Move_Growth_M;
20571 mt->relProposalProb = 1.0;
20572 mt->numTuningParams = 1;
20573 mt->tuningParam[0] = 2.0 * log(1.5); /* lambda */
20574 mt->minimum[0] = 0.0001;
20575 mt->maximum[0] = 20.0;
20576 mt->parsimonyBased = NO;
20577 mt->level = STANDARD_USER;
20578 mt->Autotune = &AutotuneMultiplier;
20579 mt->targetRate = 0.25;
20582 mt = &moveTypes[i++];
20583 mt->name = "BAMBE's LOCAL";
20584 mt->shortName = "Local";
20585 mt->subParams = YES;
20586 mt->tuningName[0] = "Multiplier tuning parameter";
20587 mt->shortTuningName[0] = "lambda";
20588 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
20589 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
20590 mt->nApplicable = 2;
20591 mt->moveFxn = &Move_Local;
20592 mt->relProposalProb = 0.0;
20593 mt->numTuningParams = 1;
20594 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
20595 mt->minimum[0] = 0.00001;
20596 mt->maximum[0] = 100.0;
20597 mt->parsimonyBased = NO;
20598 mt->level = STANDARD_USER;
20599 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
20601 /* Move_LocalClock */
20602 mt = &moveTypes[i++];
20603 mt->name = "Modified LOCAL for clock trees";
20604 mt->shortName = "LocalClock";
20605 mt->subParams = YES;
20606 mt->tuningName[0] = "Multiplier tuning parameter";
20607 mt->shortTuningName[0] = "lambda";
20608 mt->applicableTo[0] = TOPOLOGY_CL_UNIFORM;
20609 mt->applicableTo[1] = TOPOLOGY_CCL_UNIFORM;
20610 mt->applicableTo[2] = TOPOLOGY_CL_CONSTRAINED;
20611 mt->applicableTo[3] = TOPOLOGY_CCL_CONSTRAINED;
20612 mt->nApplicable = 4;
20613 mt->moveFxn = &Move_LocalClock;
20614 mt->relProposalProb = 0.0;
20615 mt->numTuningParams = 1;
20616 mt->tuningParam[0] = 2.0 * log (2.0); /* lambda */
20617 mt->minimum[0] = 0.00001;
20618 mt->maximum[0] = 100.0;
20619 mt->parsimonyBased = NO;
20620 mt->level = STANDARD_USER;
20621 mt->isApplicable = &IsApplicable_ThreeTaxaOrMore;
20624 mt = &moveTypes[i++];
20625 mt->name = "NNI move for parsimony trees";
20626 mt->shortName = "ParsNNI";
20627 mt->applicableTo[0] = TOPOLOGY_PARSIMONY_UNIFORM;
20628 mt->applicableTo[1] = TOPOLOGY_PARSIMONY_CONSTRAINED;
20629 mt->nApplicable = 2;
20630 mt->moveFxn = &Move_NNI;
20631 mt->relProposalProb = 10.0;
20632 mt->numTuningParams = 0;
20633 mt->parsimonyBased = NO; /* no extra parsimony scores are needed */
20634 mt->level = STANDARD_USER;
20635 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
20637 /* Move_NNIClock */
20638 mt = &moveTypes[i++];
20639 mt->name = "NNI move for clock trees";
20640 mt->shortName = "NNIClock";
20641 mt->subParams = YES;
20642 mt->applicableTo[0] = TOPOLOGY_CL_UNIFORM;
20643 mt->applicableTo[1] = TOPOLOGY_CCL_UNIFORM;
20644 mt->applicableTo[2] = TOPOLOGY_CL_CONSTRAINED;
20645 mt->applicableTo[3] = TOPOLOGY_CCL_CONSTRAINED;
20646 mt->applicableTo[4] = TOPOLOGY_RCL_UNIFORM;
20647 mt->applicableTo[5] = TOPOLOGY_RCL_CONSTRAINED;
20648 mt->applicableTo[6] = TOPOLOGY_RCCL_UNIFORM;
20649 mt->applicableTo[7] = TOPOLOGY_RCCL_CONSTRAINED;
20650 mt->nApplicable = 8;
20651 mt->moveFxn = &Move_NNIClock;
20652 mt->relProposalProb = 12.0;
20653 mt->numTuningParams = 0;
20654 mt->parsimonyBased = NO;
20655 mt->level = STANDARD_USER;
20656 mt->isApplicable = &IsApplicable_ThreeTaxaOrMore;
20659 mt = &moveTypes[i++];
20660 mt->name = "NNI move";
20661 mt->shortName = "NNI";
20662 mt->subParams = YES;
20663 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
20664 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
20665 mt->nApplicable = 2;
20666 mt->moveFxn = &Move_NNI;
20667 mt->relProposalProb = 5.0;
20668 mt->numTuningParams = 0;
20669 mt->minimum[0] = 0.00001;
20670 mt->maximum[0] = 100.0;
20671 mt->parsimonyBased = NO;
20672 mt->level = STANDARD_USER;
20673 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
20675 /* Move_NNI_Hetero */
20676 mt = &moveTypes[i++];
20677 mt->name = "NNI move for trees with independent brlens";
20678 mt->shortName = "MultNNI";
20679 mt->subParams = YES;
20680 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HETERO;
20681 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HETERO;
20682 mt->nApplicable = 2; /* 3; */
20683 mt->moveFxn = &Move_NNI_Hetero;
20684 mt->relProposalProb = 15.0;
20685 mt->numTuningParams = 0;
20686 mt->minimum[0] = 0.00001;
20687 mt->maximum[0] = 100.0;
20688 mt->parsimonyBased = NO;
20689 mt->level = STANDARD_USER;
20690 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
20692 /* Move_NodeSlider */
20693 mt = &moveTypes[i++];
20694 mt->name = "Node slider (uniform on possible positions)";
20695 mt->shortName = "Nodeslider";
20696 mt->tuningName[0] = "Multiplier tuning parameter";
20697 mt->shortTuningName[0] = "lambda";
20698 mt->applicableTo[0] = BRLENS_UNI;
20699 mt->applicableTo[1] = BRLENS_EXP;
20700 mt->applicableTo[2] = BRLENS_GamDir;
20701 mt->applicableTo[3] = BRLENS_iGmDir;
20702 mt->applicableTo[4] = BRLENS_twoExp;
20703 mt->nApplicable = 5; // was 2
20704 mt->moveFxn = &Move_NodeSlider;
20705 mt->relProposalProb = 7.0;
20706 mt->numTuningParams = 1;
20707 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
20708 mt->minimum[0] = 0.00001;
20709 mt->maximum[0] = 100.0;
20710 mt->parsimonyBased = NO;
20711 mt->level = STANDARD_USER;
20713 /* Move_NodeSliderClock */
20714 mt = &moveTypes[i++];
20715 mt->name = "Node depth window slider (clock-constrained)";
20716 mt->shortName = "NodesliderClock";
20717 mt->tuningName[0] = "Window size";
20718 mt->shortTuningName[0] = "delta";
20719 mt->applicableTo[0] = BRLENS_CLOCK_UNI;
20720 mt->applicableTo[1] = BRLENS_CLOCK_COAL;
20721 mt->applicableTo[2] = BRLENS_CLOCK_BD;
20722 mt->applicableTo[3] = BRLENS_CLOCK_FOSSIL;
20723 mt->nApplicable = 4;
20724 mt->moveFxn = &Move_NodeSliderClock;
20725 mt->relProposalProb = 20.0;
20726 mt->numTuningParams = 1;
20727 mt->tuningParam[0] = 0.05; /* window size */
20728 mt->minimum[0] = 0.000001;
20729 mt->maximum[0] = 1.0;
20730 mt->parsimonyBased = NO;
20731 mt->level = STANDARD_USER;
20732 mt->Autotune = &AutotuneSlider;
20733 mt->targetRate = 0.25;
20735 /* Move_NodeSliderGeneTree */
20736 mt = &moveTypes[i++];
20737 mt->name = "Node depth slider for gene trees";
20738 mt->shortName = "NodesliderGenetree";
20739 mt->tuningName[0] = "Window size";
20740 mt->shortTuningName[0] = "delta";
20741 mt->applicableTo[0] = BRLENS_CLOCK_SPCOAL;
20742 mt->nApplicable = 1;
20743 mt->moveFxn = &Move_NodeSliderGeneTree;
20744 mt->relProposalProb = 20.0;
20745 mt->numTuningParams = 1;
20746 mt->tuningParam[0] = 0.05; /* window size */
20747 mt->minimum[0] = 0.000001;
20748 mt->maximum[0] = 100.0;
20749 mt->parsimonyBased = NO;
20750 mt->level = STANDARD_USER;
20751 mt->Autotune = &AutotuneSlider;
20752 mt->targetRate = 0.25;
20755 mt = &moveTypes[i++];
20756 mt->name = "Sliding window";
20757 mt->shortName = "Slider";
20758 mt->tuningName[0] = "Sliding window size";
20759 mt->shortTuningName[0] = "delta";
20760 mt->applicableTo[0] = OMEGA_DIR;
20761 mt->nApplicable = 1;
20762 mt->moveFxn = &Move_Omega;
20763 mt->relProposalProb = 1.0;
20764 mt->numTuningParams = 1;
20765 mt->tuningParam[0] = 1.0; /* sliding window size */
20766 mt->minimum[0] = 0.000001;
20767 mt->maximum[0] = 100.0;
20768 mt->parsimonyBased = NO;
20769 mt->level = STANDARD_USER;
20770 mt->Autotune = &AutotuneSlider;
20771 mt->targetRate = 0.25;
20774 mt = &moveTypes[i++];
20775 mt->name = "Multiplier";
20776 mt->shortName = "Multiplier";
20777 mt->tuningName[0] = "Multiplier tuning parameter";
20778 mt->shortTuningName[0] = "lambda";
20779 mt->applicableTo[0] = OMEGA_DIR;
20780 mt->nApplicable = 1;
20781 mt->moveFxn = &Move_Omega_M;
20782 mt->relProposalProb = 0.0;
20783 mt->numTuningParams = 1;
20784 mt->tuningParam[0] = 2.0 * log (1.5); /* lambda */
20785 mt->minimum[0] = 0.0001;
20786 mt->maximum[0] = 20.0; /* smaller */
20787 mt->parsimonyBased = NO;
20788 mt->level = STANDARD_USER;
20789 mt->Autotune = &AutotuneMultiplier;
20790 mt->targetRate = 0.25;
20792 /* Move_OmegaBeta_M */
20793 mt = &moveTypes[i++];
20794 mt->name = "Multiplier";
20795 mt->shortName = "Multiplier";
20796 mt->paramName = "Omega_beta_M10";
20797 mt->tuningName[0] = "Multiplier tuning parameter";
20798 mt->shortTuningName[0] = "lambda";
20799 mt->applicableTo[0] = OMEGA_10UUB;
20800 mt->applicableTo[1] = OMEGA_10UUF;
20801 mt->applicableTo[2] = OMEGA_10UEB;
20802 mt->applicableTo[3] = OMEGA_10UEF;
20803 mt->applicableTo[4] = OMEGA_10UFB;
20804 mt->applicableTo[5] = OMEGA_10UFF;
20805 mt->applicableTo[6] = OMEGA_10EUB;
20806 mt->applicableTo[7] = OMEGA_10EUF;
20807 mt->applicableTo[8] = OMEGA_10EEB;
20808 mt->applicableTo[9] = OMEGA_10EEF;
20809 mt->applicableTo[10] = OMEGA_10EFB;
20810 mt->applicableTo[11] = OMEGA_10EFF;
20811 mt->nApplicable = 12;
20812 mt->moveFxn = &Move_OmegaBeta_M;
20813 mt->relProposalProb = 1.0;
20814 mt->numTuningParams = 1;
20815 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
20816 mt->minimum[0] = 0.0001;
20817 mt->maximum[0] = 20.0; /* smaller */
20818 mt->parsimonyBased = NO;
20819 mt->level = STANDARD_USER;
20820 mt->Autotune = &AutotuneMultiplier;
20821 mt->targetRate = 0.25;
20823 /* Move_OmegaCat */
20824 mt = &moveTypes[i++];
20825 mt->name = "Dirichlet proposal";
20826 mt->shortName = "Dirichlet";
20827 mt->paramName = "Omega_pi";
20828 mt->tuningName[0] = "Dirichlet parameter";
20829 mt->shortTuningName[0] = "alpha";
20830 mt->applicableTo[0] = OMEGA_BUD;
20831 mt->applicableTo[1] = OMEGA_BED;
20832 mt->applicableTo[2] = OMEGA_BFD;
20833 mt->applicableTo[3] = OMEGA_FUD;
20834 mt->applicableTo[4] = OMEGA_FED;
20835 mt->applicableTo[5] = OMEGA_FFD;
20836 mt->applicableTo[6] = OMEGA_ED;
20837 mt->applicableTo[7] = OMEGA_FD;
20838 mt->applicableTo[8] = OMEGA_10UUB;
20839 mt->applicableTo[9] = OMEGA_10UEB;
20840 mt->applicableTo[10] = OMEGA_10UFB;
20841 mt->applicableTo[11] = OMEGA_10EUB;
20842 mt->applicableTo[12] = OMEGA_10EEB;
20843 mt->applicableTo[13] = OMEGA_10EFB;
20844 mt->applicableTo[14] = OMEGA_10FUB;
20845 mt->applicableTo[15] = OMEGA_10FEB;
20846 mt->applicableTo[16] = OMEGA_10FFB;
20847 mt->nApplicable = 17;
20848 mt->moveFxn = &Move_OmegaCat;
20849 mt->relProposalProb = 1.0;
20850 mt->numTuningParams = 1;
20851 mt->tuningParam[0] = 300.0; /* alpha-pi */
20852 mt->minimum[0] = 0.001;
20853 mt->maximum[0] = 10000.0;
20854 mt->parsimonyBased = NO;
20855 mt->level = STANDARD_USER;
20856 mt->Autotune = &AutotuneDirichlet;
20857 mt->targetRate = 0.25;
20859 /* Move_OmegaGamma_M */
20860 mt = &moveTypes[i++];
20861 mt->name = "Multiplier";
20862 mt->shortName = "Multiplier";
20863 mt->paramName = "Omega_shape_M10";
20864 mt->tuningName[0] = "Multiplier tuning parameter";
20865 mt->shortTuningName[0] = "lambda";
20866 mt->applicableTo[0] = OMEGA_10UUB;
20867 mt->applicableTo[1] = OMEGA_10UUF;
20868 mt->applicableTo[2] = OMEGA_10UEB;
20869 mt->applicableTo[3] = OMEGA_10UEF;
20870 mt->applicableTo[4] = OMEGA_10EUB;
20871 mt->applicableTo[5] = OMEGA_10EUF;
20872 mt->applicableTo[6] = OMEGA_10EEB;
20873 mt->applicableTo[7] = OMEGA_10EEF;
20874 mt->applicableTo[8] = OMEGA_10FUB;
20875 mt->applicableTo[9] = OMEGA_10FUF;
20876 mt->applicableTo[10] = OMEGA_10FEB;
20877 mt->applicableTo[11] = OMEGA_10FEF;
20878 mt->nApplicable = 12;
20879 mt->moveFxn = &Move_OmegaGamma_M;
20880 mt->relProposalProb = 1.0;
20881 mt->numTuningParams = 1;
20882 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
20883 mt->minimum[0] = 0.0001;
20884 mt->maximum[0] = 20.0; /* smaller */
20885 mt->parsimonyBased = NO;
20886 mt->level = STANDARD_USER;
20887 mt->Autotune = &AutotuneMultiplier;
20888 mt->targetRate = 0.25;
20891 mt = &moveTypes[i++];
20892 mt->name = "Sliding window";
20893 mt->shortName = "Slider";
20894 mt->tuningName[0] = "Sliding window size";
20895 mt->shortTuningName[0] = "delta";
20896 mt->applicableTo[0] = OMEGA_ED;
20897 mt->applicableTo[1] = OMEGA_EF;
20898 mt->nApplicable = 2;
20899 mt->moveFxn = &Move_OmegaM3;
20900 mt->relProposalProb = 1.0;
20901 mt->numTuningParams = 1;
20902 mt->tuningParam[0] = 0.1; /* window size */
20903 mt->minimum[0] = 0.00001;
20904 mt->maximum[0] = 1.0;
20905 mt->parsimonyBased = NO;
20906 mt->level = STANDARD_USER;
20907 mt->Autotune = &AutotuneSlider;
20908 mt->targetRate = 0.25;
20910 /* Move_OmegaPur : Let it be here so that omega moves are listed in logical order! */
20911 mt = &moveTypes[i++];
20912 mt->name = "Sliding window";
20913 mt->shortName = "Slider";
20914 mt->paramName = "Omega_pur";
20915 mt->tuningName[0] = "Sliding window size";
20916 mt->shortTuningName[0] = "delta";
20917 mt->applicableTo[0] = OMEGA_BUD;
20918 mt->applicableTo[1] = OMEGA_BUF;
20919 mt->applicableTo[2] = OMEGA_BED;
20920 mt->applicableTo[3] = OMEGA_BEF;
20921 mt->applicableTo[4] = OMEGA_BFD;
20922 mt->applicableTo[5] = OMEGA_BFF;
20923 mt->nApplicable = 6;
20924 mt->moveFxn = &Move_OmegaPur;
20925 mt->relProposalProb = 1.0;
20926 mt->numTuningParams = 1;
20927 mt->tuningParam[0] = 0.1; /* window size */
20928 mt->minimum[0] = 0.00001;
20929 mt->maximum[0] = 1.0;
20930 mt->parsimonyBased = NO;
20931 mt->level = STANDARD_USER;
20932 mt->Autotune = &AutotuneSlider;
20933 mt->targetRate = 0.25;
20935 /* Move_OmegaPos */
20936 mt = &moveTypes[i++];
20937 mt->name = "Sliding window";
20938 mt->shortName = "Slider";
20939 mt->paramName = "Omega_pos";
20940 mt->tuningName[0] = "Sliding window size";
20941 mt->shortTuningName[0] = "delta";
20942 mt->applicableTo[0] = OMEGA_BUD;
20943 mt->applicableTo[1] = OMEGA_BUF;
20944 mt->applicableTo[2] = OMEGA_BED;
20945 mt->applicableTo[3] = OMEGA_BEF;
20946 mt->applicableTo[4] = OMEGA_FUD;
20947 mt->applicableTo[5] = OMEGA_FUF;
20948 mt->applicableTo[6] = OMEGA_FED;
20949 mt->applicableTo[7] = OMEGA_FEF;
20950 mt->nApplicable = 8;
20951 mt->moveFxn = &Move_OmegaPos;
20952 mt->relProposalProb = 1.0;
20953 mt->numTuningParams = 1;
20954 mt->tuningParam[0] = 1.0; /* window size */
20955 mt->minimum[0] = 0.00001;
20956 mt->maximum[0] = 100.0;
20957 mt->parsimonyBased = NO;
20958 mt->level = STANDARD_USER;
20959 mt->Autotune = &AutotuneSlider;
20960 mt->targetRate = 0.25;
20962 /* Move_ParsEraser1 */
20963 mt = &moveTypes[i++];
20964 mt->name = "Parsimony-biased eraser version 1";
20965 mt->shortName = "pEraser1";
20966 mt->subParams = YES;
20967 mt->tuningName[0] = "Dirichlet parameter";
20968 mt->shortTuningName[0] = "alpha";
20969 mt->tuningName[1] = "parsimony warp factor";
20970 mt->shortTuningName[1] = "warp";
20971 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
20972 mt->nApplicable = 1;
20973 mt->moveFxn = &Move_ParsEraser1;
20974 mt->relProposalProb = 0.0;
20975 mt->numTuningParams = 2;
20976 mt->tuningParam[0] = 0.5; /* alphaPi */
20977 mt->tuningParam[1] = 0.1; /* warp */
20978 mt->minimum[0] = 0.00001;
20979 mt->maximum[0] = 10000.0;
20980 mt->minimum[1] = 0.00001;
20981 mt->maximum[1] = 0.99999;
20982 mt->parsimonyBased = YES;
20983 mt->level = DEVELOPER;
20984 mt->isApplicable = &IsApplicable_FiveTaxaOrMore;
20986 /* Move_ParsSPR asym */
20987 mt = &moveTypes[i++];
20988 mt->name = "Parsimony-biased SPR";
20989 mt->shortName = "ParsSPR";
20990 mt->subParams = YES;
20991 mt->tuningName[0] = "parsimony warp factor";
20992 mt->shortTuningName[0] = "warp";
20993 mt->tuningName[1] = "reweighting probability";
20994 mt->shortTuningName[1] = "r";
20995 mt->tuningName[2] = "typical branch length";
20996 mt->shortTuningName[2] = "v_t";
20997 mt->tuningName[3] = "multiplier tuning parameter";
20998 mt->shortTuningName[3] = "lambda";
20999 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
21000 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
21001 mt->nApplicable = 2;
21002 mt->moveFxn = &Move_ParsSPR;
21003 mt->relProposalProb = 5.0;
21004 mt->numTuningParams = 4;
21005 mt->tuningParam[0] = 0.1; /* warp */
21006 mt->tuningParam[1] = 0.05; /* upweight and downweight probability */
21007 mt->tuningParam[2] = 0.03; /* typical branch length */
21008 mt->tuningParam[3] = 2.0 * log (1.05); /* multiplier tuning parameter lambda */
21009 mt->minimum[0] = 0.0;
21010 mt->maximum[0] = 1.0;
21011 mt->minimum[1] = 0.0;
21012 mt->maximum[1] = 0.3;
21013 mt->minimum[2] = 0.0001;
21014 mt->maximum[2] = 0.5;
21015 mt->minimum[3] = 2.0 * log (0.001);
21016 mt->maximum[3] = 2.0 * log (1000.);
21017 mt->parsimonyBased = YES;
21018 mt->level = STANDARD_USER;
21019 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
21021 /* Move_ParsSPR1 e^{-S} */
21022 mt = &moveTypes[i++];
21023 mt->name = "Parsimony-biased SPR variant 1";
21024 mt->shortName = "ParsSPR1";
21025 mt->subParams = YES;
21026 mt->tuningName[0] = "parsimony warp factor";
21027 mt->shortTuningName[0] = "warp";
21028 mt->tuningName[1] = "reweighting probability";
21029 mt->shortTuningName[1] = "r";
21030 mt->tuningName[2] = "typical branch length";
21031 mt->shortTuningName[2] = "v_t";
21032 mt->tuningName[3] = "multiplier tuning parameter";
21033 mt->shortTuningName[3] = "lambda";
21034 mt->tuningName[4] = "moving distance";
21035 mt->shortTuningName[4] = "d";
21036 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
21037 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
21038 mt->nApplicable = 2;
21039 mt->moveFxn = &Move_ParsSPR1;
21040 mt->relProposalProb = 0.0;
21041 mt->numTuningParams = 5;
21042 mt->tuningParam[0] = 0.5; /* warp */
21043 mt->tuningParam[1] = 0.05; /* upweight and downweight probability */
21044 mt->tuningParam[2] = 0.03; /* typical branch length */
21045 mt->tuningParam[3] = 2.0 * log (1.05); /* multiplier tuning parameter lambda */
21046 mt->tuningParam[4] = 10.0; /* distance to move picked branch */
21047 mt->minimum[0] = 0.0;
21048 mt->maximum[0] = 5.0;
21049 mt->minimum[1] = 0.0;
21050 mt->maximum[1] = 0.3;
21051 mt->minimum[2] = 0.0001;
21052 mt->maximum[2] = 0.5;
21053 mt->minimum[3] = 2.0 * log (0.001);
21054 mt->maximum[3] = 2.0 * log (1000.);
21055 mt->minimum[4] = 2.0;
21056 mt->maximum[4] = 1000.0;
21057 mt->parsimonyBased = YES;
21058 mt->level = DEVELOPER;
21059 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
21061 /* Move_ParsSPR2 S/N */
21062 mt = &moveTypes[i++];
21063 mt->name = "Parsimony-biased SPR variant 2";
21064 mt->shortName = "ParsSPR2";
21065 mt->subParams = YES;
21066 mt->tuningName[0] = "parsimony warp factor";
21067 mt->shortTuningName[0] = "warp";
21068 mt->tuningName[1] = "reweighting probability";
21069 mt->shortTuningName[1] = "r";
21070 mt->tuningName[2] = "typical branch length";
21071 mt->shortTuningName[2] = "v_t";
21072 mt->tuningName[3] = "multiplier tuning parameter";
21073 mt->shortTuningName[3] = "lambda";
21074 mt->tuningName[4] = "moving distance";
21075 mt->shortTuningName[4] = "d";
21076 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
21077 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
21078 mt->nApplicable = 2;
21079 mt->moveFxn = &Move_ParsSPR2;
21080 mt->relProposalProb = 0.0;
21081 mt->numTuningParams = 5;
21082 mt->tuningParam[0] = 0.1; /* warp */
21083 mt->tuningParam[1] = 0.05; /* upweight and downweight probability */
21084 mt->tuningParam[2] = 0.03; /* typical branch length */
21085 mt->tuningParam[3] = 2.0 * log (1.05); /* multiplier tuning parameter lambda */
21086 mt->tuningParam[4] = 10.0; /* distance to move picked branch */
21087 mt->minimum[0] = 0.0;
21088 mt->maximum[0] = 1.0;
21089 mt->minimum[1] = 0.0;
21090 mt->maximum[1] = 0.3;
21091 mt->minimum[2] = 0.0001;
21092 mt->maximum[2] = 0.5;
21093 mt->minimum[3] = 2.0 * log (0.001);
21094 mt->maximum[3] = 2.0 * log (1000.);
21095 mt->minimum[4] = 2.0;
21096 mt->maximum[4] = 1000.0;
21097 mt->parsimonyBased = YES;
21098 mt->level = DEVELOPER;
21099 mt->isApplicable = &IsApplicable_FourTaxaOrMore;
21101 /* Move_ParsSPRClock */
21102 mt = &moveTypes[i++];
21103 mt->name = "Parsimony-biased SPR for clock trees";
21104 mt->shortName = "ParsSPRClock";
21105 mt->subParams = YES;
21106 mt->tuningName[0] = "parsimony warp factor";
21107 mt->shortTuningName[0] = "warp";
21108 mt->tuningName[1] = "reweighting probability";
21109 mt->shortTuningName[1] = "r";
21110 mt->tuningName[2] = "typical branch length";
21111 mt->shortTuningName[2] = "v_t";
21112 mt->applicableTo[0] = TOPOLOGY_CL_UNIFORM;
21113 mt->applicableTo[1] = TOPOLOGY_CCL_UNIFORM;
21114 mt->applicableTo[2] = TOPOLOGY_CL_CONSTRAINED;
21115 mt->applicableTo[3] = TOPOLOGY_CCL_CONSTRAINED;
21116 mt->applicableTo[4] = TOPOLOGY_RCL_UNIFORM;
21117 mt->applicableTo[5] = TOPOLOGY_RCL_CONSTRAINED;
21118 mt->applicableTo[6] = TOPOLOGY_RCCL_UNIFORM;
21119 mt->applicableTo[7] = TOPOLOGY_RCCL_CONSTRAINED;
21120 mt->nApplicable = 8;
21121 mt->moveFxn = &Move_ParsSPRClock;
21122 mt->relProposalProb = 8.0;
21123 mt->numTuningParams = 3;
21124 mt->tuningParam[0] = 0.1; /* warp */
21125 mt->tuningParam[1] = 0.05; /* upweight and downweight probability */
21126 mt->tuningParam[2] = 0.03; /* typical branch length */
21127 mt->minimum[0] = 0.0;
21128 mt->maximum[0] = 1.0;
21129 mt->minimum[1] = 0.0;
21130 mt->maximum[1] = 0.3;
21131 mt->minimum[2] = 0.0001;
21132 mt->maximum[2] = 0.5;
21133 mt->parsimonyBased = YES;
21134 mt->level = STANDARD_USER;
21135 mt->isApplicable = &IsApplicable_ThreeTaxaOrMore;
21137 /* Move_ParsTBR1 e^{-S} */
21138 mt = &moveTypes[i++];
21139 mt->name = "Parsimony-biased TBR variant 1";
21140 mt->shortName = "ParsTBR1";
21141 mt->subParams = YES;
21142 mt->tuningName[0] = "parsimony warp factor";
21143 mt->shortTuningName[0] = "warp";
21144 mt->tuningName[1] = "reweighting probability";
21145 mt->shortTuningName[1] = "r";
21146 mt->tuningName[2] = "typical branch length";
21147 mt->shortTuningName[2] = "v_t";
21148 mt->tuningName[3] = "multiplier tuning parameter";
21149 mt->shortTuningName[3] = "lambda";
21150 mt->tuningName[4] = "moving distance";
21151 mt->shortTuningName[4] = "d";
21152 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
21153 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
21154 mt->nApplicable = 2;
21155 mt->moveFxn = &Move_ParsTBR1;
21156 mt->relProposalProb = 0.0;
21157 mt->numTuningParams = 5;
21158 mt->tuningParam[0] = 0.5; /* warp */
21159 mt->tuningParam[1] = 0.05; /* upweight and downweight probability */
21160 mt->tuningParam[2] = 0.05; /* typical branch length */
21161 mt->tuningParam[3] = 2.0 * log (1.05); /* multiplier tuning parameter lambda */
21162 mt->tuningParam[4] = 5.0; /* distance to move picked branch */
21163 mt->minimum[0] = 0.0;
21164 mt->maximum[0] = 5.0;
21165 mt->minimum[1] = 0.0;
21166 mt->maximum[1] = 0.3;
21167 mt->minimum[2] = 0.0001;
21168 mt->maximum[2] = 0.5;
21169 mt->minimum[3] = 2.0 * log (0.001);
21170 mt->maximum[3] = 2.0 * log (1000.);
21171 mt->minimum[4] = 2.0;
21172 mt->maximum[4] = 1000.0;
21173 mt->parsimonyBased = YES;
21174 mt->level = DEVELOPER;
21175 mt->isApplicable = &IsApplicable_FiveTaxaOrMore;
21177 /* Move_ParsTBR2 S/N */
21178 mt = &moveTypes[i++];
21179 mt->name = "Parsimony-biased TBR variant 2";
21180 mt->shortName = "ParsTBR2";
21181 mt->subParams = YES;
21182 mt->tuningName[0] = "parsimony warp factor";
21183 mt->shortTuningName[0] = "warp";
21184 mt->tuningName[1] = "reweighting probability";
21185 mt->shortTuningName[1] = "r";
21186 mt->tuningName[2] = "typical branch length";
21187 mt->shortTuningName[2] = "v_t";
21188 mt->tuningName[3] = "multiplier tuning parameter";
21189 mt->shortTuningName[3] = "lambda";
21190 mt->tuningName[4] = "moving distance";
21191 mt->shortTuningName[4] = "d";
21192 mt->applicableTo[0] = TOPOLOGY_NCL_UNIFORM_HOMO;
21193 mt->applicableTo[1] = TOPOLOGY_NCL_CONSTRAINED_HOMO;
21194 mt->nApplicable = 2;
21195 mt->moveFxn = &Move_ParsTBR2;
21196 mt->relProposalProb = 0.0;
21197 mt->numTuningParams = 5;
21198 mt->tuningParam[0] = 0.1; /* warp */
21199 mt->tuningParam[1] = 0.05; /* upweight and downweight probability */
21200 mt->tuningParam[2] = 0.05; /* typical branch length */
21201 mt->tuningParam[3] = 2.0 * log (1.05); /* multiplier tuning parameter lambda */
21202 mt->tuningParam[4] = 5.0; /* distance to move picked branch */
21203 mt->minimum[0] = 0.0;
21204 mt->maximum[0] = 1.0;
21205 mt->minimum[1] = 0.0;
21206 mt->maximum[1] = 0.3;
21207 mt->minimum[2] = 0.0001;
21208 mt->maximum[2] = 0.5;
21209 mt->minimum[3] = 2.0 * log (0.001);
21210 mt->maximum[3] = 2.0 * log (1000.);
21211 mt->minimum[4] = 2.0;
21212 mt->maximum[4] = 1000.0;
21213 mt->parsimonyBased = YES;
21214 mt->level = DEVELOPER;
21215 mt->isApplicable = &IsApplicable_FiveTaxaOrMore;
21218 mt = &moveTypes[i++];
21219 mt->name = "Sliding window";
21220 mt->shortName = "Slider";
21221 mt->tuningName[0] = "Sliding window size";
21222 mt->shortTuningName[0] = "delta";
21223 mt->applicableTo[0] = PINVAR_UNI;
21224 mt->nApplicable = 1;
21225 mt->moveFxn = &Move_Pinvar;
21226 mt->relProposalProb = 1.0;
21227 mt->numTuningParams = 1;
21228 mt->tuningParam[0] = 0.1; /* window size */
21229 mt->minimum[0] = 0.001;
21230 mt->maximum[0] = 0.999;
21231 mt->parsimonyBased = NO;
21232 mt->level = STANDARD_USER;
21233 mt->Autotune = &AutotuneSlider;
21234 mt->targetRate = 0.25;
21236 /* Move_Popsize_M */
21237 mt = &moveTypes[i++];
21238 mt->name = "Multiplier";
21239 mt->shortName = "Multiplier";
21240 mt->tuningName[0] = "Multiplier tuning parameter";
21241 mt->shortTuningName[0] = "lambda";
21242 mt->applicableTo[0] = POPSIZE_UNI;
21243 mt->applicableTo[1] = POPSIZE_LOGNORMAL;
21244 mt->applicableTo[2] = POPSIZE_NORMAL;
21245 mt->applicableTo[3] = POPSIZE_GAMMA;
21246 mt->nApplicable = 4;
21247 mt->moveFxn = &Move_PopSize_M;
21248 mt->relProposalProb = 1.0;
21249 mt->numTuningParams = 1;
21250 mt->tuningParam[0] = 2.0 * log(1.5); /* lambda */
21251 mt->minimum[0] = 0.00001;
21252 mt->maximum[0] = 100.0;
21253 mt->parsimonyBased = NO;
21254 mt->level = STANDARD_USER;
21255 mt->Autotune = &AutotuneSlider;
21256 mt->targetRate = 0.25;
21258 /* Move_RateMult_Dir */
21259 mt = &moveTypes[i++];
21260 mt->name = "Dirichlet proposal";
21261 mt->shortName = "Dirichlet";
21262 mt->tuningName[0] = "Dirichlet parameter";
21263 mt->shortTuningName[0] = "alpha";
21264 mt->applicableTo[0] = RATEMULT_DIR;
21265 mt->nApplicable = 1;
21266 mt->moveFxn = &Move_RateMult_Dir;
21267 mt->relProposalProb = 0.75;
21268 mt->numTuningParams = 1;
21269 mt->tuningParam[0] = 50.0; /* alphaPi per site */
21270 mt->minimum[0] = 0.001;
21271 mt->maximum[0] = 10000.0;
21272 mt->parsimonyBased = NO;
21273 mt->level = STANDARD_USER;
21274 mt->Autotune = &AutotuneDirichlet;
21275 mt->targetRate = 0.25;
21277 /* Move_RateMult_Slider */
21278 mt = &moveTypes[i++];
21279 mt->name = "Sliding window";
21280 mt->shortName = "Slider";
21281 mt->tuningName[0] = "Sliding window size";
21282 mt->shortTuningName[0] = "delta";
21283 mt->applicableTo[0] = RATEMULT_DIR;
21284 mt->nApplicable = 1;
21285 mt->moveFxn = &Move_RateMult_Slider;
21286 mt->relProposalProb = 0.75;
21287 mt->numTuningParams = 1;
21288 mt->tuningParam[0] = 0.05; /* window size */
21289 mt->minimum[0] = 0.00001;
21290 mt->maximum[0] = 1.0;
21291 mt->parsimonyBased = NO;
21292 mt->level = STANDARD_USER;
21293 mt->Autotune = &AutotuneSlider;
21294 mt->targetRate = 0.25;
21296 /* Move_Revmat_Dir */
21297 mt = &moveTypes[i++];
21298 mt->name = "Dirichlet proposal";
21299 mt->shortName = "Dirichlet";
21300 mt->tuningName[0] = "Dirichlet parameter";
21301 mt->shortTuningName[0] = "alpha";
21302 mt->applicableTo[0] = REVMAT_DIR;
21303 mt->nApplicable = 1;
21304 mt->moveFxn = &Move_Revmat_Dir;
21305 mt->relProposalProb = 0.5;
21306 mt->numTuningParams = 1;
21307 mt->tuningParam[0] = 100.0; /* alphaPi per rate */
21308 mt->minimum[0] = 0.001;
21309 mt->maximum[0] = 10000.0;
21310 mt->parsimonyBased = NO;
21311 mt->level = STANDARD_USER;
21312 mt->Autotune = &AutotuneDirichlet;
21313 mt->targetRate = 0.25;
21315 /* Move_Revmat_Slider */
21316 mt = &moveTypes[i++];
21317 mt->name = "Sliding window";
21318 mt->shortName = "Slider";
21319 mt->tuningName[0] = "Sliding window size";
21320 mt->shortTuningName[0] = "delta";
21321 mt->applicableTo[0] = REVMAT_DIR;
21322 mt->nApplicable = 1;
21323 mt->moveFxn = &Move_Revmat_Slider;
21324 mt->relProposalProb = 0.5;
21325 mt->numTuningParams = 1;
21326 mt->tuningParam[0] = 0.15; /* window size */
21327 mt->minimum[0] = 0.00001;
21328 mt->maximum[0] = 1.0;
21329 mt->parsimonyBased = NO;
21330 mt->level = STANDARD_USER;
21331 mt->Autotune = &AutotuneSlider;
21332 mt->targetRate = 0.25;
21334 /* Move_Revmat_DirMix */
21335 mt = &moveTypes[i++];
21336 mt->name = "Dirichlet proposal";
21337 mt->shortName = "Dirichlet";
21338 mt->tuningName[0] = "Dirichlet parameter";
21339 mt->shortTuningName[0] = "alpha";
21340 mt->applicableTo[0] = REVMAT_MIX;
21341 mt->nApplicable = 1;
21342 mt->moveFxn = &Move_Revmat_DirMix;
21343 mt->relProposalProb = 1.0;
21344 mt->numTuningParams = 1;
21345 mt->tuningParam[0] = 100.0; /* alphaPi per rate */
21346 mt->minimum[0] = 0.01;
21347 mt->maximum[0] = 10000.0;
21348 mt->parsimonyBased = NO;
21349 mt->level = STANDARD_USER;
21350 mt->Autotune = &AutotuneDirichlet;
21351 mt->targetRate = 0.25;
21353 /* Move_Revmat_SplitMerge1 */
21354 mt = &moveTypes[i++];
21355 mt->name = "Split-merge move 1";
21356 mt->shortName = "Splitmerge1";
21357 mt->tuningName[0] = "Dirichlet parameter";
21358 mt->shortTuningName[0] = "alpha";
21359 mt->applicableTo[0] = REVMAT_MIX;
21360 mt->nApplicable = 1;
21361 mt->moveFxn = &Move_Revmat_SplitMerge1;
21362 mt->relProposalProb = 1.0;
21363 mt->numTuningParams = 1;
21364 mt->tuningParam[0] = 10.0; /* alphaPi per rate */
21365 mt->minimum[0] = 0.5;
21366 mt->maximum[0] = 100.0;
21367 mt->parsimonyBased = NO;
21368 mt->level = STANDARD_USER;
21369 mt->Autotune = &AutotuneDirichlet;
21370 mt->targetRate = 0.25;
21372 /* Move_Revmat_SplitMerge2 */
21373 mt = &moveTypes[i++];
21374 mt->name = "Split-merge move 2";
21375 mt->shortName = "Splitmerge2";
21376 mt->tuningName[0] = "Dirichlet parameter";
21377 mt->shortTuningName[0] = "alpha";
21378 mt->applicableTo[0] = REVMAT_MIX;
21379 mt->nApplicable = 1;
21380 mt->moveFxn = &Move_Revmat_SplitMerge2;
21381 mt->relProposalProb = 1.0;
21382 mt->numTuningParams = 1;
21383 mt->tuningParam[0] = 10.0; /* alphaPi per rate */
21384 mt->minimum[0] = 0.5;
21385 mt->maximum[0] = 100.0;
21386 mt->parsimonyBased = NO;
21387 mt->level = STANDARD_USER;
21388 mt->Autotune = &AutotuneDirichlet;
21389 mt->targetRate = 0.25;
21391 /* Move_Speciation */
21392 mt = &moveTypes[i++];
21393 mt->name = "Sliding window";
21394 mt->shortName = "Slider";
21395 mt->tuningName[0] = "Sliding window size";
21396 mt->shortTuningName[0] = "delta";
21397 mt->applicableTo[0] = SPECRATE_UNI;
21398 mt->applicableTo[1] = SPECRATE_EXP;
21399 mt->nApplicable = 2;
21400 mt->moveFxn = &Move_Speciation;
21401 mt->relProposalProb = 0.0;
21402 mt->numTuningParams = 1;
21403 mt->tuningParam[0] = 1.0; /* window size */
21404 mt->minimum[0] = 0.00001;
21405 mt->maximum[0] = 100.0;
21406 mt->parsimonyBased = NO;
21407 mt->level = STANDARD_USER;
21408 mt->Autotune = &AutotuneSlider;
21409 mt->targetRate = 0.25;
21411 /* Move_Speciation_M */
21412 mt = &moveTypes[i++];
21413 mt->name = "Multiplier";
21414 mt->shortName = "Multiplier";
21415 mt->tuningName[0] = "Multiplier tuning parameter";
21416 mt->shortTuningName[0] = "lambda";
21417 mt->applicableTo[0] = SPECRATE_UNI;
21418 mt->applicableTo[1] = SPECRATE_EXP;
21419 mt->nApplicable = 2;
21420 mt->moveFxn = &Move_Speciation_M;
21421 mt->relProposalProb = 3.0;
21422 mt->numTuningParams = 1;
21423 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21424 mt->minimum[0] = 0.00001;
21425 mt->maximum[0] = 20.0; /* smaller */
21426 mt->parsimonyBased = NO;
21427 mt->level = STANDARD_USER;
21428 mt->Autotune = &AutotuneMultiplier;
21429 mt->targetRate = 0.25;
21431 /* Move_SpeciesTree */
21432 mt = &moveTypes[i++];
21433 mt->name = "Species tree move";
21434 mt->shortName = "Distmatrixmove";
21435 mt->tuningName[0] = "Divider of rate of truncated exponential";
21436 mt->shortTuningName[0] = "lambdadiv";
21437 mt->applicableTo[0] = SPECIESTREE_UNIFORM;
21438 mt->nApplicable = 1;
21439 mt->moveFxn = &Move_SpeciesTree;
21440 mt->relProposalProb = 10.0;
21441 mt->numTuningParams = 1;
21442 mt->tuningParam[0] = 1.2; /* Default tuning parameter value */
21443 mt->minimum[0] = 0.00001; /* Minimum value of tuning param */
21444 mt->maximum[0] = 1000.0; /* Maximum value of tuning param */
21445 mt->parsimonyBased = NO; /* It does not use parsimony scores */
21446 mt->level = STANDARD_USER;
21447 mt->Autotune = &AutotuneMultiplier; /* Autotune this move as a mutliplier move (larger is more bold) */
21448 mt->targetRate = 0.25; /* Target acceptance rate */
21450 /* Move_Statefreqs */
21451 mt = &moveTypes[i++];
21452 mt->name = "Dirichlet proposal";
21453 mt->shortName = "Dirichlet";
21454 mt->tuningName[0] = "Dirichlet parameter";
21455 mt->shortTuningName[0] = "alpha";
21456 mt->applicableTo[0] = PI_DIR;
21457 mt->nApplicable = 1;
21458 mt->moveFxn = &Move_Statefreqs;
21459 mt->relProposalProb = 0.5;
21460 mt->numTuningParams = 1;
21461 mt->tuningParam[0] = 100.0; /* alphaPi per state */
21462 mt->minimum[0] = 0.001;
21463 mt->maximum[0] = 10000.0;
21464 mt->parsimonyBased = NO;
21465 mt->level = STANDARD_USER;
21466 mt->Autotune = &AutotuneDirichlet;
21467 mt->targetRate = 0.25;
21469 /* Move_Statefreqs_Slider */
21470 mt = &moveTypes[i++];
21471 mt->name = "Sliding window";
21472 mt->shortName = "Slider";
21473 mt->tuningName[0] = "Sliding window size";
21474 mt->shortTuningName[0] = "delta";
21475 mt->applicableTo[0] = PI_DIR;
21476 mt->nApplicable = 1;
21477 mt->moveFxn = &Move_Statefreqs_Slider;
21478 mt->relProposalProb = 0.5;
21479 mt->numTuningParams = 1;
21480 mt->tuningParam[0] = 0.20; /* window size (change in proportions) */
21481 mt->minimum[0] = 0.00001;
21482 mt->maximum[0] = 1.0;
21483 mt->parsimonyBased = NO;
21484 mt->level = STANDARD_USER;
21485 mt->Autotune = &AutotuneSlider;
21486 mt->targetRate = 0.25;
21488 /* Move_StatefreqsSymDirMultistate */
21489 mt = &moveTypes[i++];
21490 mt->name = "Dirichlet proposal";
21491 mt->shortName = "Dirichlet";
21492 mt->paramName = "Pi_symdir";
21493 mt->tuningName[0] = "Dirichlet parameter";
21494 mt->shortTuningName[0] = "alpha";
21495 mt->applicableTo[0] = SYMPI_FIX_MS;
21496 mt->applicableTo[1] = SYMPI_UNI_MS;
21497 mt->applicableTo[2] = SYMPI_EXP_MS;
21498 mt->nApplicable = 3;
21499 mt->moveFxn = &Move_StatefreqsSymDirMultistate;
21500 mt->relProposalProb = 5.0;
21501 mt->numTuningParams = 1;
21502 mt->tuningParam[0] = 50.0; /* alphaPi */
21503 mt->minimum[0] = 0.001;
21504 mt->maximum[0] = 10000.0;
21505 mt->parsimonyBased = NO;
21506 mt->level = STANDARD_USER;
21507 mt->Autotune = &AutotuneDirichlet;
21508 mt->targetRate = 0.25;
21510 /* Move_SwitchRate */
21511 mt = &moveTypes[i++];
21512 mt->name = "Sliding window";
21513 mt->shortName = "Slider";
21514 mt->tuningName[0] = "Sliding window size";
21515 mt->shortTuningName[0] = "delta";
21516 mt->applicableTo[0] = SWITCH_UNI;
21517 mt->applicableTo[1] = SWITCH_EXP;
21518 mt->nApplicable = 2;
21519 mt->moveFxn = &Move_SwitchRate;
21520 mt->relProposalProb = 1.0;
21521 mt->numTuningParams = 1;
21522 mt->tuningParam[0] = 1.0; /* window size */
21523 mt->minimum[0] = 0.00001;
21524 mt->maximum[0] = 100.0;
21525 mt->parsimonyBased = NO;
21526 mt->level = STANDARD_USER;
21527 mt->Autotune = &AutotuneSlider;
21528 mt->targetRate = 0.25;
21530 /* Move_SwitchRate_M */
21531 mt = &moveTypes[i++];
21532 mt->name = "Multiplier";
21533 mt->shortName = "Multiplier";
21534 mt->tuningName[0] = "Multiplier tuning parameter";
21535 mt->shortTuningName[0] = "lambda";
21536 mt->applicableTo[0] = SWITCH_UNI;
21537 mt->applicableTo[1] = SWITCH_EXP;
21538 mt->nApplicable = 2;
21539 mt->moveFxn = &Move_SwitchRate_M;
21540 mt->relProposalProb = 0.0;
21541 mt->numTuningParams = 1;
21542 mt->tuningParam[0] = 2.0 * log (1.5); /* lambda */
21543 mt->minimum[0] = 0.0001;
21544 mt->maximum[0] = 20.0; /* smaller */
21545 mt->parsimonyBased = NO;
21546 mt->level = STANDARD_USER;
21547 mt->Autotune = &AutotuneMultiplier;
21548 mt->targetRate = 0.25;
21550 /* Move_Tratio_Dir */
21551 mt = &moveTypes[i++];
21552 mt->name = "Dirichlet proposal";
21553 mt->shortName = "Dirichlet";
21554 mt->tuningName[0] = "Dirichlet parameter";
21555 mt->shortTuningName[0] = "alpha";
21556 mt->applicableTo[0] = TRATIO_DIR;
21557 mt->nApplicable = 1;
21558 mt->moveFxn = &Move_Tratio_Dir;
21559 mt->relProposalProb = 1.0;
21560 mt->numTuningParams = 1;
21561 mt->tuningParam[0] = 50.0; /* alphaPi */
21562 mt->minimum[0] = 0.001;
21563 mt->maximum[0] = 10000.0;
21564 mt->parsimonyBased = NO;
21565 mt->level = STANDARD_USER;
21566 mt->Autotune = &AutotuneDirichlet;
21567 mt->targetRate = 0.25;
21569 /* Move_TreeStretch */
21570 mt = &moveTypes[i++];
21571 mt->name = "Tree stretch";
21572 mt->shortName = "TreeStretch";
21573 mt->tuningName[0] = "Multiplier tuning parameter";
21574 mt->shortTuningName[0] = "lambda";
21575 mt->applicableTo[0] = BRLENS_CLOCK_UNI;
21576 mt->applicableTo[1] = BRLENS_CLOCK_BD;
21577 mt->applicableTo[2] = BRLENS_CLOCK_COAL;
21578 mt->applicableTo[3] = BRLENS_CLOCK_FOSSIL;
21579 mt->nApplicable = 4;
21580 mt->moveFxn = &Move_TreeStretch;
21581 mt->relProposalProb = 3.0;
21582 mt->numTuningParams = 1;
21583 mt->tuningParam[0] = 2.0 * log(1.01); /* lambda */
21584 mt->minimum[0] = 0.0001;
21585 mt->maximum[0] = 2.0 * log(2.0);
21586 mt->parsimonyBased = NO;
21587 mt->level = STANDARD_USER;
21588 mt->Autotune = &AutotuneMultiplier;
21589 mt->targetRate = 0.25;
21591 /* Move_TreeLen, by Jeremy Brown */
21592 mt = &moveTypes[i++];
21593 mt->name = "Whole treelength hit with multiplier";
21594 mt->shortName = "TLMultiplier";
21595 mt->tuningName[0] = "Multiplier tuning parameter";
21596 mt->shortTuningName[0] = "lambda";
21597 mt->applicableTo[0] = BRLENS_UNI;
21598 mt->applicableTo[1] = BRLENS_EXP;
21599 mt->applicableTo[2] = BRLENS_GamDir;
21600 mt->applicableTo[3] = BRLENS_iGmDir;
21601 mt->applicableTo[4] = BRLENS_twoExp;
21602 mt->nApplicable = 5; // was 2
21603 mt->moveFxn = &Move_TreeLen;
21604 mt->relProposalProb = 3.0;
21605 mt->numTuningParams = 1;
21606 mt->tuningParam[0] = 2.0 * log (2.0); /* lambda */
21607 mt->minimum[0] = 0.0001;
21608 mt->maximum[0] = 100.0; /* smaller */
21609 mt->parsimonyBased = NO;
21610 mt->level = STANDARD_USER;
21611 mt->Autotune = &AutotuneMultiplier;
21612 mt->targetRate = 0.25;
21614 /* Move_AddDeleteCPPEvent */
21615 mt = &moveTypes[i++];
21616 mt->name = "Random addition/deletion of CPP event";
21617 mt->shortName = "Add_delete";
21618 mt->applicableTo[0] = CPPEVENTS;
21619 mt->nApplicable = 1;
21620 mt->moveFxn = &Move_AddDeleteCPPEvent;
21621 mt->relProposalProb = 1.0;
21622 mt->numTuningParams = 0;
21623 mt->parsimonyBased = NO;
21624 mt->level = STANDARD_USER;
21626 /* Move_CPPEventPosition */
21627 mt = &moveTypes[i++];
21628 mt->name = "Random draw of CPP event position from prior";
21629 mt->shortName = "Prior_draw_pos";
21630 mt->applicableTo[0] = CPPEVENTS;
21631 mt->nApplicable = 1;
21632 mt->moveFxn = &Move_CPPEventPosition;
21633 mt->relProposalProb = 2.0;
21634 mt->numTuningParams = 0;
21635 mt->parsimonyBased = NO;
21636 mt->level = STANDARD_USER;
21639 mt = &moveTypes[i++];
21640 mt->name = "Multiplier";
21641 mt->shortName = "Multiplier";
21642 mt->tuningName[0] = "Multiplier tuning parameter";
21643 mt->shortTuningName[0] = "lambda";
21644 mt->applicableTo[0] = CPPRATE_EXP;
21645 mt->nApplicable = 1;
21646 mt->moveFxn = &Move_CPPRate;
21647 mt->relProposalProb = 2.0;
21648 mt->numTuningParams = 1;
21649 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21650 mt->minimum[0] = 0.0001;
21651 mt->maximum[0] = 20.0; /* smaller */
21652 mt->parsimonyBased = NO;
21653 mt->level = STANDARD_USER;
21654 mt->Autotune = &AutotuneMultiplier;
21655 mt->targetRate = 0.25;
21657 /* Move_CPPRateMultiplier_M */
21658 mt = &moveTypes[i++];
21659 mt->name = "Random CPP rate multiplier hit with multiplier";
21660 mt->shortName = "Multiplier";
21661 mt->tuningName[0] = "Multiplier tuning parameter";
21662 mt->shortTuningName[0] = "lambda";
21663 mt->applicableTo[0] = CPPEVENTS;
21664 mt->nApplicable = 1;
21665 mt->moveFxn = &Move_CPPRateMultiplier_M;
21666 mt->relProposalProb = 0.0;
21667 mt->numTuningParams = 1;
21668 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21669 mt->minimum[0] = 0.0001;
21670 mt->maximum[0] = 20.0; /* smaller */
21671 mt->parsimonyBased = NO;
21672 mt->level = STANDARD_USER;
21673 mt->Autotune = &AutotuneMultiplier;
21674 mt->targetRate = 0.25;
21676 /* Move_CPPRateMultiplierRnd */
21677 mt = &moveTypes[i++];
21678 mt->name = "Random draw of CPP rate multiplier from prior";
21679 mt->shortName = "Prior_draw_mult";
21680 mt->applicableTo[0] = CPPEVENTS;
21681 mt->nApplicable = 1;
21682 mt->moveFxn = &Move_CPPRateMultiplierRnd;
21683 mt->relProposalProb = 2.0;
21684 mt->numTuningParams = 0;
21685 mt->parsimonyBased = NO;
21686 mt->level = STANDARD_USER;
21689 mt = &moveTypes[i++];
21690 mt->name = "Multiplier";
21691 mt->shortName = "Multiplier";
21692 mt->tuningName[0] = "Multiplier tuning parameter";
21693 mt->shortTuningName[0] = "lambda";
21694 mt->applicableTo[0] = TK02VAR_EXP;
21695 mt->applicableTo[1] = TK02VAR_UNI;
21696 mt->nApplicable = 2;
21697 mt->moveFxn = &Move_Nu;
21698 mt->relProposalProb = 2.0;
21699 mt->numTuningParams = 1;
21700 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21701 mt->minimum[0] = 0.0001;
21702 mt->maximum[0] = 20.0; /* smaller */
21703 mt->parsimonyBased = NO;
21704 mt->level = STANDARD_USER;
21705 mt->Autotune = &AutotuneMultiplier;
21706 mt->targetRate = 0.25;
21708 /* Move_TK02BranchRate */
21709 mt = &moveTypes[i++];
21710 mt->name = "Multiplier";
21711 mt->shortName = "Multiplier";
21712 mt->tuningName[0] = "Multiplier tuning parameter";
21713 mt->shortTuningName[0] = "lambda";
21714 mt->applicableTo[0] = TK02BRANCHRATES;
21715 mt->nApplicable = 1;
21716 mt->moveFxn = &Move_TK02BranchRate;
21717 mt->relProposalProb = 10.0;
21718 mt->numTuningParams = 1;
21719 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21720 mt->minimum[0] = 0.0001;
21721 mt->maximum[0] = 20.0;
21722 mt->parsimonyBased = NO;
21723 mt->level = STANDARD_USER;
21724 mt->Autotune = &AutotuneMultiplier;
21725 mt->targetRate = 0.25;
21728 mt = &moveTypes[i++];
21729 mt->name = "Multiplier";
21730 mt->shortName = "Multiplier";
21731 mt->tuningName[0] = "Multiplier tuning parameter";
21732 mt->shortTuningName[0] = "lambda";
21733 mt->applicableTo[0] = IGRVAR_EXP;
21734 mt->applicableTo[1] = IGRVAR_UNI;
21735 mt->nApplicable = 2;
21736 mt->moveFxn = &Move_IgrVar;
21737 mt->relProposalProb = 2.0;
21738 mt->numTuningParams = 1;
21739 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21740 mt->minimum[0] = 0.0001;
21741 mt->maximum[0] = 20.0; /* smaller */
21742 mt->parsimonyBased = NO;
21743 mt->level = STANDARD_USER;
21744 mt->Autotune = &AutotuneMultiplier;
21745 mt->targetRate = 0.25;
21747 /* Move_IgrBranchRate */
21748 mt = &moveTypes[i++];
21749 mt->name = "Multiplier";
21750 mt->shortName = "Multiplier";
21751 mt->tuningName[0] = "Multiplier tuning parameter";
21752 mt->shortTuningName[0] = "lambda";
21753 mt->applicableTo[0] = IGRBRANCHRATES;
21754 mt->nApplicable = 1;
21755 mt->moveFxn = &Move_IgrBranchRate;
21756 mt->relProposalProb = 10.0;
21757 mt->numTuningParams = 1;
21758 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21759 mt->minimum[0] = 0.0001;
21760 mt->maximum[0] = 20.0;
21761 mt->parsimonyBased = NO;
21762 mt->level = STANDARD_USER;
21763 mt->Autotune = &AutotuneMultiplier;
21764 mt->targetRate = 0.25;
21766 /* Move_MixedVar */
21767 mt = &moveTypes[i++];
21768 mt->name = "Multiplier";
21769 mt->shortName = "Multiplier";
21770 mt->tuningName[0] = "Multiplier tuning parameter";
21771 mt->shortTuningName[0] = "lambda";
21772 mt->applicableTo[0] = MIXEDVAR_EXP;
21773 mt->applicableTo[1] = MIXEDVAR_UNI;
21774 mt->nApplicable = 2;
21775 mt->moveFxn = &Move_MixedVar;
21776 mt->relProposalProb = 2.0;
21777 mt->numTuningParams = 1;
21778 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21779 mt->minimum[0] = 0.0001;
21780 mt->maximum[0] = 20.0; /* smaller */
21781 mt->parsimonyBased = NO;
21782 mt->level = STANDARD_USER;
21783 mt->Autotune = &AutotuneMultiplier;
21784 mt->targetRate = 0.25;
21786 /* Move_MixedBranchRate */
21787 mt = &moveTypes[i++];
21788 mt->name = "Multiplier";
21789 mt->shortName = "Multiplier";
21790 mt->tuningName[0] = "Multiplier tuning parameter";
21791 mt->shortTuningName[0] = "lambda";
21792 mt->applicableTo[0] = MIXEDBRCHRATES;
21793 mt->nApplicable = 1;
21794 mt->moveFxn = &Move_MixedBranchRate;
21795 mt->relProposalProb = 10.0;
21796 mt->numTuningParams = 1;
21797 mt->tuningParam[0] = 2.0 * log (1.1); /* lambda */
21798 mt->minimum[0] = 0.0001;
21799 mt->maximum[0] = 20.0;
21800 mt->parsimonyBased = NO;
21801 mt->level = STANDARD_USER;
21802 mt->Autotune = &AutotuneMultiplier;
21803 mt->targetRate = 0.25;
21805 /* Move_RelaxedClockModel */
21806 mt = &moveTypes[i++];
21807 mt->name = "rjMCMC among Relaxed Clock Models";
21808 mt->shortName = "rjMCMC_RCL";
21809 mt->tuningName[0] = "sigma_TK over sigma_IGR";
21810 mt->shortTuningName[0] = "ratio";
21811 mt->tuningName[1] = "Sliding window size";
21812 mt->shortTuningName[1] = "delta";
21813 mt->applicableTo[0] = MIXEDBRCHRATES;
21814 mt->nApplicable = 1;
21815 mt->moveFxn = &Move_RelaxedClockModel;
21816 mt->relProposalProb = 5.0;
21817 mt->numTuningParams = 2;
21818 mt->tuningParam[0] = 100.0; /* TK/IGR var ratio */
21819 mt->tuningParam[1] = 10.0; /* window size */
21820 mt->minimum[0] = 0.0001;
21821 mt->maximum[0] = 10000.0;
21822 mt->minimum[1] = 0.0001;
21823 mt->maximum[1] = 1000.0;
21824 mt->parsimonyBased = NO;
21825 mt->level = STANDARD_USER;
21831 /* ShowModel: Display model on screen */
21832 int ShowModel (void)
21836 MrBayesPrint ("%s Model settings:\n\n", spacer);
21837 for (i=0; i<numCurrentDivisions; i++)
21841 if (numCurrentDivisions > 1)
21842 MrBayesPrint ("%s Settings for partition %d --\n", spacer, i+1);
21844 MrBayesPrint ("%s Data not partitioned --\n", spacer);
21846 if (modelParams[i].dataType == DNA)
21848 MrBayesPrint ("%s Datatype = DNA\n", spacer);
21851 else if (modelParams[i].dataType == RNA)
21853 MrBayesPrint ("%s Datatype = RNA\n", spacer);
21856 else if (modelParams[i].dataType == PROTEIN)
21858 MrBayesPrint ("%s Datatype = Protein\n", spacer);
21861 else if (modelParams[i].dataType == RESTRICTION)
21863 MrBayesPrint ("%s Datatype = Restriction\n", spacer);
21866 else if (modelParams[i].dataType == STANDARD)
21868 MrBayesPrint ("%s Datatype = Standard\n", spacer);
21871 else if (modelParams[i].dataType == CONTINUOUS)
21873 MrBayesPrint ("%s Datatype = Continuous\n", spacer);
21876 if (modelSettings[i].dataType == CONTINUOUS)
21878 /* begin description of continuous models */
21879 if (!strcmp(modelParams[i].brownCorPr, "Fixed") && AreDoublesEqual(modelParams[i].brownCorrFix, 0.0, ETA)==YES)
21880 MrBayesPrint ("%s Model = Independent Brownian motion\n", spacer);
21882 MrBayesPrint ("%s Model = Correlated Brownian motion\n", spacer);
21883 /* end description of continuous models */
21887 /* begin description of discrete models */
21888 if (!strcmp(modelParams[i].parsModel, "Yes"))
21890 MrBayesPrint ("%s Parsmodel = %s\n", spacer, modelParams[i].parsModel);
21894 /* dna characters in this partition */
21895 if (modelSettings[i].dataType == DNA || modelSettings[i].dataType == RNA)
21897 /* general form of the rate matrix */
21898 MrBayesPrint ("%s Nucmodel = %s\n", spacer, modelParams[i].nucModel);
21900 /* constraints on rates of substitution */
21901 MrBayesPrint ("%s Nst = %s\n", spacer, modelParams[i].nst);
21902 if (!strcmp(modelParams[i].nst, "2"))
21904 if (!strcmp(modelParams[i].tRatioPr,"Beta"))
21906 MrBayesPrint ("%s Transition and transversion rates, expressed\n", spacer);
21907 MrBayesPrint ("%s as proportions of the rate sum, have a\n", spacer);
21908 MrBayesPrint ("%s Beta(%1.2lf,%1.2lf) prior\n", spacer, modelParams[i].tRatioDir[0], modelParams[i].tRatioDir[1]);
21912 MrBayesPrint ("%s Transition/transversion rate ratio is fixed to %1.2lf.\n", spacer, modelParams[i].tRatioFix);
21915 else if (!strcmp(modelParams[i].nst, "6"))
21917 if (!strcmp(modelParams[i].revMatPr,"Dirichlet"))
21919 MrBayesPrint ("%s Substitution rates, expressed as proportions\n", spacer);
21920 MrBayesPrint ("%s of the rate sum, have a Dirichlet prior\n", spacer);
21921 MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer,
21922 modelParams[i].revMatDir[0], modelParams[i].revMatDir[1], modelParams[i].revMatDir[2],
21923 modelParams[i].revMatDir[3], modelParams[i].revMatDir[4], modelParams[i].revMatDir[5]);
21927 MrBayesPrint ("%s Substitution rates are fixed to be \n", spacer);
21928 MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf).\n", spacer,
21929 modelParams[i].revMatFix[0], modelParams[i].revMatFix[1], modelParams[i].revMatFix[2],
21930 modelParams[i].revMatFix[3], modelParams[i].revMatFix[4], modelParams[i].revMatFix[5]);
21933 else if (!strcmp(modelParams[i].nst, "Mixed"))
21935 if (!strcmp(modelParams[i].revMatPr,"Dirichlet"))
21937 MrBayesPrint ("%s Substitution rates, expressed as proportions\n", spacer);
21938 MrBayesPrint ("%s of the rate sum, have a Dirichlet prior\n", spacer);
21939 MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer,
21940 modelParams[i].revMatDir[0], modelParams[i].revMatDir[1], modelParams[i].revMatDir[2],
21941 modelParams[i].revMatDir[3], modelParams[i].revMatDir[4], modelParams[i].revMatDir[5]);
21945 MrBayesPrint ("%s Substitution rates are fixed to be \n", spacer);
21946 MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf).\n", spacer,
21947 modelParams[i].revMatFix[0], modelParams[i].revMatFix[1], modelParams[i].revMatFix[2],
21948 modelParams[i].revMatFix[3], modelParams[i].revMatFix[4], modelParams[i].revMatFix[5]);
21952 if (!strcmp(modelParams[i].nucModel,"Codon"))
21954 /* what is the distribution on the nonsyn./syn. rate ratio */
21955 if (!strcmp(modelParams[i].omegaVar, "Equal"))
21957 if (!strcmp(modelParams[i].omegaPr,"Dirichlet"))
21959 MrBayesPrint ("%s Nonsynonymous and synonymous rates, expressed\n", spacer);
21960 MrBayesPrint ("%s as proportions of the rate sum, have a\n", spacer);
21961 MrBayesPrint ("%s Dirichlet(%1.2lf,%1.2lf) prior\n", spacer, modelParams[i].omegaDir[0], modelParams[i].omegaDir[1]);
21965 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio is fixed to %1.2lf.\n", spacer, modelParams[i].omegaFix);
21968 else if (!strcmp(modelParams[i].omegaVar, "Ny98"))
21970 if (!strcmp(modelParams[i].ny98omega1pr, "Beta"))
21972 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for purifying selection\n", spacer);
21973 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]);
21977 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for purifying selection\n", spacer);
21978 MrBayesPrint ("%s (class 1) is fixed to %1.2lf.\n", spacer, modelParams[i].ny98omega1Fixed);
21980 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for neutral selection\n", spacer);
21981 MrBayesPrint ("%s (class 2) is fixed to 1.0.\n", spacer);
21982 if (!strcmp(modelParams[i].ny98omega3pr, "Uniform"))
21984 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for positive selection\n", spacer);
21985 MrBayesPrint ("%s is uniformly distributed on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].ny98omega3Uni[0], modelParams[i].ny98omega3Uni[1]);
21987 else if (!strcmp(modelParams[i].ny98omega3pr, "Exponential"))
21989 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for positive selection\n", spacer);
21990 MrBayesPrint ("%s is exponentially distributed with parameter (%1.2lf).\n", spacer, modelParams[i].ny98omega3Exp);
21994 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for positive \n", spacer);
21995 MrBayesPrint ("%s selection is fixed to %1.2lf.\n", spacer, modelParams[i].ny98omega3Fixed);
21998 else if (!strcmp(modelParams[i].omegaVar, "M3"))
22000 if (!strcmp(modelParams[i].m3omegapr, "Exponential"))
22002 MrBayesPrint ("%s Nonsynonymous and synonymous rates for the tree classes of\n", spacer);
22003 MrBayesPrint ("%s omega are exponentially distributed random variables.\n", spacer);
22005 else if (!strcmp(modelParams[i].m3omegapr, "Fixed"))
22007 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for the three omega\n", spacer);
22008 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]);
22011 else if (!strcmp(modelParams[i].omegaVar, "M10"))
22013 MrBayesPrint ("%s Nonsynonymous/synonymous rate ratio for purifying \n", spacer);
22014 MrBayesPrint ("%s selection (class 1) has a Beta(alpha1,beta1) on the \n", spacer);
22015 MrBayesPrint ("%s interval (0,1). Nonsynonymous/synonymous rate ratio \n", spacer);
22016 MrBayesPrint ("%s for positive selection (class 2) has an offset \n", spacer);
22017 MrBayesPrint ("%s Gamma(alpha2,beta2) on the interval (1,Infinity).\n", spacer);
22020 /* genetic code that is used (if nucmodel=codon) */
22021 MrBayesPrint ("%s Code = %s\n", spacer, modelParams[i].geneticCode);
22024 /* amino acid characters in this partition */
22025 else if (modelSettings[i].dataType == PROTEIN)
22027 if (modelParams[i].dataType == DNA || modelParams[i].dataType == RNA)
22028 MrBayesPrint ("%s Nucmodel = %s\n", spacer, modelParams[i].nucModel);
22029 /* constraints on rates of substitution in 20 X 20 matrix */
22030 if (!strcmp(modelParams[i].aaModelPr, "Mixed"))
22031 MrBayesPrint ("%s Aamodel = Mixture of models with fixed rate matrices\n", spacer);
22033 MrBayesPrint ("%s Aamodel = %s\n", spacer, modelParams[i].aaModel);
22035 if (!strcmp(modelParams[i].aaModelPr, "Mixed"))
22036 MrBayesPrint ("%s Substitution rates come from the mixture of models\n", spacer);
22037 else if (!strcmp(modelParams[i].aaModelPr, "Fixed") && (!strcmp(modelParams[i].aaModel, "Poisson") ||
22038 !strcmp(modelParams[i].aaModel, "Equalin")))
22039 MrBayesPrint ("%s Substitution rates are fixed to be equal\n", spacer);
22040 else if (!strcmp(modelParams[i].aaModelPr, "Fixed") && strcmp(modelParams[i].aaModel, "Gtr")!=0)
22041 MrBayesPrint ("%s Substitution rates are fixed to the %s rates\n", spacer, modelParams[i].aaModel);
22042 else if (!strcmp(modelParams[i].aaModelPr, "Fixed") && !strcmp(modelParams[i].aaModel, "Gtr"))
22044 if (!strcmp(modelParams[i].aaRevMatPr,"Dirichlet"))
22046 for (j=0; j<190; j++)
22047 if (AreDoublesEqual(modelParams[i].aaRevMatDir[0], modelParams[i].aaRevMatDir[j], 0.00001) == NO)
22051 MrBayesPrint ("%s Substitution rates have a Dirichlet(%1.2lf,%1.2lf,...) prior\n",
22052 spacer, modelParams[i].aaRevMatDir[0], modelParams[i].aaRevMatDir[0]);
22056 MrBayesPrint ("%s Substitution rates have a Dirichlet(\n", spacer);
22057 for (j=0; j<190; j++)
22060 MrBayesPrint ("%s ", spacer);
22061 MrBayesPrint ("%1.2lf", modelParams[i].aaRevMatDir[j]);
22063 MrBayesPrint (") prior\n");
22064 else if ((j+1) % 10 == 0)
22065 MrBayesPrint (",\n");
22067 MrBayesPrint (",");
22071 else /* if (!strcmp(modelParams[i].aaRevMatPr,"Fixed")) */
22073 for (j=0; j<190; j++)
22074 if (AreDoublesEqual(modelParams[i].aaRevMatFix[0], modelParams[i].aaRevMatFix[j], 0.00001) == NO)
22078 MrBayesPrint ("%s Substitution rates are fixed to (%1.1lf,%1.1lf,...)\n",
22079 spacer, modelParams[i].aaRevMatFix[0], modelParams[i].aaRevMatFix[0]);
22083 MrBayesPrint ("%s Substitution rates are fixed to (\n", spacer);
22084 for (j=0; j<190; j++)
22087 MrBayesPrint ("%s ", spacer);
22088 MrBayesPrint ("%1.1lf", modelParams[i].aaRevMatFix[j]);
22090 MrBayesPrint (") prior\n");
22091 else if ((j+1) % 10 == 0)
22092 MrBayesPrint (",\n");
22094 MrBayesPrint (",");
22100 /* restriction site or morphological characters in this partition */
22101 else if (modelSettings[i].dataType == RESTRICTION || modelSettings[i].dataType == STANDARD)
22103 /* what type of characters are sampled? */
22104 MrBayesPrint ("%s Coding = %s\n", spacer, modelParams[i].codingString);
22107 /* is there rate variation in a single site across the tree? */
22108 if (((modelSettings[i].dataType == DNA || modelSettings[i].dataType == RNA) && !strcmp(modelParams[i].nucModel, "4by4")) || modelSettings[i].dataType == PROTEIN)
22110 /* do rates change on tree accoding to covarion model? */
22111 MrBayesPrint ("%s Covarion = %s\n", spacer, modelParams[i].covarionModel);
22112 if (!strcmp(modelParams[i].covarionModel, "Yes"))
22114 /* distribution on switching parameters, if appropriate */
22115 if (!strcmp(modelParams[i].covSwitchPr,"Uniform"))
22117 MrBayesPrint ("%s Switching rates have independent uniform dist-\n", spacer);
22118 MrBayesPrint ("%s ributions on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].covswitchUni[0], modelParams[i].covswitchUni[1]);
22120 else if (!strcmp(modelParams[i].covSwitchPr,"Exponential"))
22122 MrBayesPrint ("%s Switching rates have independent exponential\n", spacer);
22123 MrBayesPrint ("%s distributions with parameters (%1.2lf).\n", spacer, modelParams[i].covswitchExp);
22127 MrBayesPrint ("%s Switching rates are fixed to %1.2lf and %1.2lf.\n", spacer, modelParams[i].covswitchFix[0], modelParams[i].covswitchFix[0]);
22133 /* now, let's deal with variation in omega */
22134 if ((modelParams[i].dataType == DNA || modelParams[i].dataType == RNA) && !strcmp(modelParams[i].nucModel,"Codon"))
22136 MrBayesPrint ("%s Omegavar = %s\n", spacer, modelParams[i].omegaVar);
22137 if (!strcmp(modelParams[i].geneticCode, "Universal"))
22139 else if (!strcmp(modelParams[i].geneticCode, "Vertmt"))
22141 else if (!strcmp(modelParams[i].geneticCode, "Invermt"))
22143 else if (!strcmp(modelParams[i].geneticCode, "Mycoplasma"))
22145 else if (!strcmp(modelParams[i].geneticCode, "Yeast"))
22147 else if (!strcmp(modelParams[i].geneticCode, "Ciliate"))
22149 else if (!strcmp(modelParams[i].geneticCode, "Echinoderm"))
22151 else if (!strcmp(modelParams[i].geneticCode, "Euplotid"))
22153 else if (!strcmp(modelParams[i].geneticCode, "Metmt"))
22157 /* what assumptions are made about the state frequencies? */
22158 if (modelParams[i].dataType != CONTINUOUS)
22160 if (modelParams[i].dataType == STANDARD)
22161 MrBayesPrint ("%s # States = Variable, up to 10\n", spacer);
22162 else if (modelSettings[i].numStates != modelSettings[i].numModelStates)
22163 MrBayesPrint ("%s # States = %d (in the model)\n", spacer, modelSettings[i].numModelStates);
22165 MrBayesPrint ("%s # States = %d\n", spacer, ns);
22166 if (modelSettings[i].dataType == STANDARD)
22168 if (!strcmp(modelParams[i].symPiPr,"Fixed"))
22170 if (AreDoublesEqual(modelParams[i].symBetaFix, -1.0, ETA)==YES)
22171 MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer);
22173 MrBayesPrint ("%s Symmetric Dirichlet alpha is fixed to %1.2lf\n", spacer, modelParams[i].symBetaFix);
22175 else if (!strcmp(modelParams[i].symPiPr,"Uniform"))
22177 MrBayesPrint ("%s Symmetric Dirichlet alpha has a Uniform(%1.2lf,%1.2lf) prior\n", spacer, modelParams[i].symBetaUni[0], modelParams[i].symBetaUni[1]);
22181 MrBayesPrint ("%s Symmetric Dirichlet alpha has a Exponential(%1.2lf) prior\n", spacer, modelParams[i].symBetaExp);
22184 else if (modelSettings[i].dataType == RESTRICTION)
22186 /* distribution on state frequencies for restriction site model */
22187 if (!strcmp(modelParams[i].stateFreqPr,"Dirichlet"))
22189 MrBayesPrint ("%s State frequencies have a Dirichlet (%1.2lf,%1.2lf) prior\n", spacer,
22190 modelParams[i].stateFreqsDir[0], modelParams[i].stateFreqsDir[1]);
22192 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Equal"))
22194 MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer);
22196 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"User"))
22198 MrBayesPrint ("%s State frequencies have been fixed by the user\n", spacer);
22200 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Empirical"))
22202 MrBayesPrint ("%s State frequencies have been fixed to the empirical frequencies in the data\n", spacer);
22205 else if (modelSettings[i].dataType == PROTEIN)
22207 /* distribution on state frequencies for aminoacid model */
22208 if (!strcmp(modelParams[i].aaModelPr, "Fixed") && (strcmp(modelParams[i].aaModel, "Equalin")==0 ||
22209 strcmp(modelParams[i].aaModel, "Gtr")==0))
22211 if (!strcmp(modelParams[i].stateFreqPr,"Dirichlet"))
22213 MrBayesPrint ("%s State frequencies have a Dirichlet prior\n", spacer);
22214 MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,", spacer,
22215 modelParams[i].stateFreqsDir[0], modelParams[i].stateFreqsDir[1], modelParams[i].stateFreqsDir[2],
22216 modelParams[i].stateFreqsDir[3], modelParams[i].stateFreqsDir[4]);
22217 MrBayesPrint ("%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,\n",
22218 modelParams[i].stateFreqsDir[5], modelParams[i].stateFreqsDir[6], modelParams[i].stateFreqsDir[7],
22219 modelParams[i].stateFreqsDir[8], modelParams[i].stateFreqsDir[9]);
22220 MrBayesPrint ("%s %1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,", spacer,
22221 modelParams[i].stateFreqsDir[10], modelParams[i].stateFreqsDir[11], modelParams[i].stateFreqsDir[12],
22222 modelParams[i].stateFreqsDir[13], modelParams[i].stateFreqsDir[14]);
22223 MrBayesPrint ("%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n",
22224 modelParams[i].stateFreqsDir[15], modelParams[i].stateFreqsDir[16], modelParams[i].stateFreqsDir[17],
22225 modelParams[i].stateFreqsDir[18], modelParams[i].stateFreqsDir[19]);
22227 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Equal"))
22229 MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer);
22231 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"User"))
22233 MrBayesPrint ("%s State frequencies have been fixed by the user\n", spacer);
22235 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Empirical"))
22237 MrBayesPrint ("%s State frequencies have been fixed to the empirical frequencies in the data\n", spacer);
22240 else if (!strcmp(modelParams[i].aaModelPr, "Fixed") && !strcmp(modelParams[i].aaModel, "Poisson"))
22242 MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer);
22244 else if (!strcmp(modelParams[i].aaModelPr, "Fixed") && strcmp(modelParams[i].aaModel, "Equalin") && strcmp(modelParams[i].aaModel, "Poisson"))
22246 MrBayesPrint ("%s State frequencies are fixed to the %s frequencies\n", spacer, modelParams[i].aaModel);
22250 MrBayesPrint ("%s State frequencies come from the mixture of models\n", spacer);
22255 /* distribution on state frequencies for all other models */
22256 if (!strcmp(modelParams[i].stateFreqPr,"Dirichlet"))
22258 MrBayesPrint ("%s State frequencies have a Dirichlet prior\n", spacer);
22259 if (!strcmp(modelParams[i].nucModel, "Doublet"))
22261 MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf,\n", spacer,
22262 modelParams[i].stateFreqsDir[0], modelParams[i].stateFreqsDir[1], modelParams[i].stateFreqsDir[2],
22263 modelParams[i].stateFreqsDir[3]);
22264 MrBayesPrint ("%s %1.2lf,%1.2lf,%1.2lf,%1.2lf,\n", spacer,
22265 modelParams[i].stateFreqsDir[4], modelParams[i].stateFreqsDir[5], modelParams[i].stateFreqsDir[6],
22266 modelParams[i].stateFreqsDir[7]);
22267 MrBayesPrint ("%s %1.2lf,%1.2lf,%1.2lf,%1.2lf,\n", spacer,
22268 modelParams[i].stateFreqsDir[8], modelParams[i].stateFreqsDir[9], modelParams[i].stateFreqsDir[10],
22269 modelParams[i].stateFreqsDir[11]);
22270 MrBayesPrint ("%s %1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer,
22271 modelParams[i].stateFreqsDir[12], modelParams[i].stateFreqsDir[13], modelParams[i].stateFreqsDir[14],
22272 modelParams[i].stateFreqsDir[15]);
22274 else if (!strcmp(modelParams[i].nucModel, "4by4"))
22276 MrBayesPrint ("%s (%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer,
22277 modelParams[i].stateFreqsDir[0], modelParams[i].stateFreqsDir[1], modelParams[i].stateFreqsDir[2],
22278 modelParams[i].stateFreqsDir[3]);
22281 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Equal"))
22283 MrBayesPrint ("%s State frequencies are fixed to be equal\n", spacer);
22285 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"User"))
22287 MrBayesPrint ("%s State frequencies have been fixed by the user\n", spacer);
22289 else if (!strcmp(modelParams[i].stateFreqPr,"Fixed") && !strcmp(modelParams[i].stateFreqsFixType,"Empirical"))
22291 MrBayesPrint ("%s State frequencies have been fixed to the empirical frequencies in the data\n", spacer);
22296 MrBayesPrint ("%s # States = Infinity\n", spacer);
22298 /* now, let's deal with rate variation across sites */
22299 if (modelSettings[i].dataType != CONTINUOUS)
22301 if (((modelSettings[i].dataType == DNA || modelSettings[i].dataType == RNA) && strcmp(modelParams[i].nucModel,"Codon")) ||
22302 modelSettings[i].dataType == PROTEIN || modelSettings[i].dataType == RESTRICTION || modelSettings[i].dataType == STANDARD)
22304 if (!strcmp(modelParams[i].covarionModel, "No"))
22305 MrBayesPrint ("%s Rates = %s\n", spacer, modelParams[i].ratesModel);
22308 if (!strcmp(modelParams[i].ratesModel, "Propinv"))
22309 MrBayesPrint ("%s Rates = Equal ", spacer);
22310 else if (!strcmp(modelParams[i].ratesModel, "Invgamma"))
22311 MrBayesPrint ("%s Rates = Gamma ", spacer);
22313 MrBayesPrint ("%s Rates = %s ", spacer, modelParams[i].ratesModel);
22314 MrBayesPrint ("(+ Propinv induced by covarion model)\n");
22317 if ((modelParams[i].dataType == RESTRICTION || modelParams[i].dataType == STANDARD) && !strcmp(modelParams[i].ratesModel, "Adgamma"))
22323 if (!strcmp(modelParams[i].ratesModel, "Gamma") || !strcmp(modelParams[i].ratesModel, "Invgamma") ||
22324 !strcmp(modelParams[i].ratesModel, "LNorm") || !strcmp(modelParams[i].ratesModel, "Adgamma"))
22326 /* how many categories is the continuous gamma approximated by? */
22327 MrBayesPrint ("%s The distribution is approximated using %d categories.\n", spacer, modelParams[i].numGammaCats);
22328 if (!strcmp(modelParams[i].useGibbs,"Yes"))
22329 MrBayesPrint ("%s Rate categories sampled using Gibbs sampling.\n", spacer, modelParams[i].numGammaCats);
22331 MrBayesPrint ("%s Likelihood summarized over all rate categories in each generation.\n", spacer, modelParams[i].numGammaCats);
22332 /* distribution on shape parameter, if appropriate */
22333 if (!strcmp(modelParams[i].shapePr,"Uniform"))
22335 MrBayesPrint ("%s Shape parameter is uniformly distributed\n", spacer);
22336 MrBayesPrint ("%s on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].shapeUni[0], modelParams[i].shapeUni[1]);
22338 else if (!strcmp(modelParams[i].shapePr,"Exponential"))
22340 MrBayesPrint ("%s Shape parameter is exponentially\n", spacer);
22341 MrBayesPrint ("%s distributed with parameter (%1.2lf).\n", spacer, modelParams[i].shapeExp);
22345 MrBayesPrint ("%s Shape parameter is fixed to %1.2lf.\n", spacer, modelParams[i].shapeFix);
22348 if ((!strcmp(modelParams[i].ratesModel, "Propinv") || !strcmp(modelParams[i].ratesModel, "Invgamma")) && !strcmp(modelParams[i].covarionModel, "No"))
22350 /* distribution on pInvar parameter, if appropriate */
22351 if (!strcmp(modelParams[i].pInvarPr,"Uniform"))
22353 MrBayesPrint ("%s Proportion of invariable sites is uniformly dist-\n", spacer);
22354 MrBayesPrint ("%s ributed on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].pInvarUni[0], modelParams[i].pInvarUni[1]);
22358 MrBayesPrint ("%s Proportion of invariable sites is fixed to %1.2lf.\n", spacer, modelParams[i].pInvarFix);
22361 if (!strcmp(modelParams[i].ratesModel, "Adgamma"))
22363 /* distribution on correlation parameter, if appropriate */
22364 if (!strcmp(modelParams[i].adGammaCorPr,"Uniform"))
22366 MrBayesPrint ("%s Rate correlation parameter is uniformly dist-\n", spacer);
22367 MrBayesPrint ("%s ributed on the interval (%1.2lf,%1.2lf).\n", spacer, modelParams[i].corrUni[0], modelParams[i].corrUni[1]);
22371 MrBayesPrint ("%s Rate correlation parameter is fixed to %1.2lf.\n", spacer, modelParams[i].corrFix);
22378 /* end description of discrete models */
22381 if (i != numCurrentDivisions - 1)
22382 MrBayesPrint ("\n");
22386 MrBayesPrint ("\n");
22387 ShowParameters (NO, NO, NO);
22393 /*------------------------------------------------------------------------------
22395 | ShowMoves: Show applicable moves
22397 ------------------------------------------------------------------------------*/
22398 int ShowMoves (int used)
22400 int i, k, run, chain, chainIndex, areRunsSame, areChainsSame, numPrintedMoves;
22404 numPrintedMoves = 0;
22405 for (i=0; i<numApplicableMoves; i++)
22409 for (k=0; k<numGlobalChains; k++)
22411 if (mv->relProposalProb[k] > 0.000001)
22415 if (k == numGlobalChains && used == YES)
22418 if (k < numGlobalChains && used == NO)
22423 /* print move number and name */
22424 MrBayesPrint ("%s %4d -- Move = %s\n", spacer, numPrintedMoves, mv->name);
22426 /* print move type */
22427 MrBayesPrint ("%s Type = %s\n", spacer, mv->moveType->name);
22429 /* print parameter */
22430 if (mv->parm->nSubParams > 0)
22431 MrBayesPrint ("%s Parameters = %s [param. %d] (%s)\n", spacer, mv->parm->name,
22432 mv->parm->index+1, mv->parm->paramTypeName);
22434 MrBayesPrint ("%s Parameter = %s [param. %d] (%s)\n", spacer, mv->parm->name,
22435 mv->parm->index+1, mv->parm->paramTypeName);
22436 for (k=0; k<mv->parm->nSubParams; k++)
22437 MrBayesPrint ("%s %s [param. %d] (%s)\n", spacer, mv->parm->subParams[k]->name,
22438 mv->parm->subParams[k]->index+1, mv->parm->subParams[k]->paramTypeName);
22440 /* print tuning parameters */
22441 for (k=0; k<mv->moveType->numTuningParams; k++)
22444 MrBayesPrint ("%s Tuningparam = %s (%s)\n", spacer, mv->moveType->shortTuningName[k], mv->moveType->tuningName[k]);
22446 MrBayesPrint ("%s %s (%s)\n", spacer, mv->moveType->shortTuningName[k], mv->moveType->tuningName[k]);
22449 /* loop over tuning parameters */
22450 for (k=0; k<mv->moveType->numTuningParams; k++)
22452 /* find if tuning parameters are different for different runs */
22454 for (run=1; run<chainParams.numRuns; run++)
22456 for (chain=0; chain<chainParams.numChains; chain++)
22458 chainIndex = run*chainParams.numChains + chain;
22459 if (AreDoublesEqual (mv->tuningParam[chainIndex][k], mv->tuningParam[chain][k], 0.000001) == NO)
22465 if (areRunsSame == NO)
22469 /* now print values */
22470 for (run=0; run<chainParams.numRuns; run++)
22472 if (areRunsSame == YES && run >= 1)
22475 /* find out if chains are different within this run */
22476 areChainsSame = YES;
22477 for (chain=1; chain<chainParams.numChains; chain++)
22479 chainIndex = run*chainParams.numChains + chain;
22480 if (AreDoublesEqual (mv->tuningParam[chainIndex][k], mv->tuningParam[chainIndex-chain][k],0.000001) == NO)
22482 areChainsSame = NO;
22486 /* now we can print the values */
22487 for (chain=0; chain<chainParams.numChains; chain++)
22489 chainIndex = run*chainParams.numChains + chain;
22490 if (areChainsSame == YES && chain >= 1)
22493 if (run == 0 && chain == 0)
22494 MrBayesPrint ("%s%22s = %1.3lf", spacer, mv->moveType->shortTuningName[k], mv->tuningParam[chainIndex][k]);
22496 MrBayesPrint ("%s %1.3lf", spacer, mv->tuningParam[chainIndex][k]);
22498 if (areChainsSame == NO && areRunsSame == YES)
22499 MrBayesPrint (" [chain %d]\n", chain+1);
22500 else if (areChainsSame == YES && areRunsSame == NO)
22501 MrBayesPrint (" [run %d]\n", run+1);
22502 else if (areChainsSame == NO && areRunsSame == NO)
22503 MrBayesPrint (" [run %d, chain %d]\n", run+1, chain+1);
22505 MrBayesPrint ("\n");
22508 } /* next tuning parameter */
22510 /* print target acceptance rate for autotuning */
22511 if (mv->moveType->targetRate > 0.0 && mv->moveType->targetRate < 1.0)
22514 /* first find out if the targets are different in different runs */
22516 for (run=1; run<chainParams.numRuns; run++)
22518 for (chain=0; chain<chainParams.numChains; chain++)
22520 chainIndex = run*chainParams.numChains + chain;
22521 if (AreDoublesEqual (mv->targetRate[chainIndex], mv->targetRate[chain], 0.000001) == NO)
22527 if (areRunsSame == NO)
22531 /* now print values */
22532 for (run=0; run<chainParams.numRuns; run++)
22534 if (areRunsSame == YES && run >= 1)
22537 /* find out if chains are different within this run */
22538 areChainsSame = YES;
22539 for (chain=1; chain<chainParams.numChains; chain++)
22541 chainIndex = run*chainParams.numChains + chain;
22542 if (AreDoublesEqual (mv->targetRate[chainIndex], mv->targetRate[chainIndex-chain], 0.000001) == NO)
22544 areChainsSame = NO;
22548 /* now we can print the values */
22549 for (chain=0; chain<chainParams.numChains; chain++)
22551 chainIndex = run*chainParams.numChains + chain;
22552 if (areChainsSame == YES && chain >= 1)
22555 if (run == 0 && chain == 0)
22556 MrBayesPrint ("%s Targetrate = %1.3lf", spacer, mv->targetRate[chainIndex]);
22558 MrBayesPrint ("%s %1.3lf", spacer, mv->targetRate[chainIndex]);
22560 if (areChainsSame == NO && areRunsSame == YES)
22561 MrBayesPrint (" [chain %d]\n", chain+1);
22562 else if (areChainsSame == YES && areRunsSame == NO)
22563 MrBayesPrint (" [run %d]\n", run+1);
22564 else if (areChainsSame == NO && areRunsSame == NO)
22565 MrBayesPrint (" [run %d, chain %d]\n", run+1, chain+1);
22567 MrBayesPrint ("\n");
22573 /* finally print the relative proposal probability */
22575 /* first find out if the probabilities are different in different runs */
22577 for (run=1; run<chainParams.numRuns; run++)
22579 for (chain=0; chain<chainParams.numChains; chain++)
22581 chainIndex = run*chainParams.numChains + chain;
22582 if (AreDoublesEqual (mv->relProposalProb[chainIndex], mv->relProposalProb[chain], 0.000001) == NO)
22588 if (areRunsSame == NO)
22592 /* now print values */
22593 for (run=0; run<chainParams.numRuns; run++)
22595 if (areRunsSame == YES && run >= 1)
22598 /* find out if chains are different within this run */
22599 areChainsSame = YES;
22600 for (chain=1; chain<chainParams.numChains; chain++)
22602 chainIndex = run*chainParams.numChains + chain;
22603 if (AreDoublesEqual (mv->relProposalProb[chainIndex], mv->relProposalProb[chainIndex-chain], 0.000001) == NO)
22605 areChainsSame = NO;
22609 /* now we can print the values */
22610 for (chain=0; chain<chainParams.numChains; chain++)
22612 chainIndex = run*chainParams.numChains + chain;
22613 if (areChainsSame == YES && chain >= 1)
22616 if (run == 0 && chain == 0)
22617 MrBayesPrint ("%s Rel. prob. = %1.1lf", spacer, mv->relProposalProb[chainIndex]);
22619 MrBayesPrint ("%s %1.1lf", spacer, mv->relProposalProb[chainIndex]);
22621 if (areChainsSame == NO && areRunsSame == YES)
22622 MrBayesPrint (" [chain %d]\n", chain+1);
22623 else if (areChainsSame == YES && areRunsSame == NO)
22624 MrBayesPrint (" [run %d]\n", run+1);
22625 else if (areChainsSame == NO && areRunsSame == NO)
22626 MrBayesPrint (" [run %d, chain %d]\n", run+1, chain+1);
22628 MrBayesPrint ("\n");
22631 MrBayesPrint ("\n");
22634 if (numPrintedMoves == 0)
22638 MrBayesPrint ("%s No moves currently used for this analysis. All parameters\n", spacer);
22639 MrBayesPrint ("%s will be fixed to their starting values.\n\n", spacer);
22643 MrBayesPrint ("%s No additional moves available for this model.\n\n", spacer);
22651 /*------------------------------------------------------------------------------
22653 | ShowParameters: Show parameter table and parameter info
22655 ------------------------------------------------------------------------------*/
22656 int ShowParameters (int showStartVals, int showMoves, int showAllAvailable)
22658 int a, b, d, i, j, k, m, n, run, chain, shouldPrint, isSame, areRunsSame, areChainsSame, nValues,
22659 chainIndex, refIndex, numPrinted, numMovedChains, printedCol, screenWidth=100;
22663 MrBFlt *value, *refValue, *subValue;
22666 MrBayesPrint ("%s Active parameters: \n\n", spacer);
22667 if (numCurrentDivisions > 1)
22669 MrBayesPrint ("%s Partition(s)\n", spacer);
22670 MrBayesPrint ("%s Parameters ", spacer);
22671 for (i=0; i<numCurrentDivisions; i++)
22672 MrBayesPrint (" %2d", i+1);
22673 MrBayesPrint ("\n");
22674 MrBayesPrint ("%s ------------------", spacer);
22675 for (i=0; i<numCurrentDivisions; i++)
22676 MrBayesPrint ("---");
22677 MrBayesPrint ("\n");
22681 MrBayesPrint ("%s Parameters\n", spacer);
22682 MrBayesPrint ("%s ---------------------\n", spacer);
22684 for (j=0; j<NUM_LINKED; j++)
22687 for (i=0; i<numCurrentDivisions; i++)
22689 if (activeParams[j][i] == -1)
22694 if (shouldPrint == NO)
22699 MrBayesPrint ("%s Tratio ", spacer);
22701 else if (j == P_REVMAT)
22703 MrBayesPrint ("%s Revmat ", spacer);
22705 else if (j == P_OMEGA)
22707 MrBayesPrint ("%s Omega ", spacer);
22709 else if (j == P_PI)
22711 MrBayesPrint ("%s Statefreq ", spacer);
22713 else if (j == P_SHAPE)
22715 MrBayesPrint ("%s Shape ", spacer);
22717 else if (j == P_PINVAR)
22719 MrBayesPrint ("%s Pinvar ", spacer);
22721 else if (j == P_CORREL)
22723 MrBayesPrint ("%s Correlation ", spacer);
22725 else if (j == P_SWITCH)
22727 MrBayesPrint ("%s Switchrates ", spacer);
22729 else if (j == P_RATEMULT)
22731 MrBayesPrint ("%s Ratemultiplier ", spacer);
22733 else if (j == P_GENETREERATE)
22735 MrBayesPrint ("%s Generatemult ", spacer);
22737 else if (j == P_TOPOLOGY)
22739 MrBayesPrint ("%s Topology ", spacer);
22741 else if (j == P_BRLENS)
22743 MrBayesPrint ("%s Brlens ", spacer);
22745 else if (j == P_SPECRATE)
22747 MrBayesPrint ("%s Speciationrate ", spacer);
22749 else if (j == P_EXTRATE)
22751 MrBayesPrint ("%s Extinctionrate ", spacer);
22753 else if (j == P_FOSLRATE)
22755 MrBayesPrint ("%s Fossilizationrate ", spacer);
22757 else if (j == P_POPSIZE)
22759 MrBayesPrint ("%s Popsize ", spacer);
22761 else if (j == P_GROWTH)
22763 MrBayesPrint ("%s Growthrate ", spacer);
22765 else if (j == P_AAMODEL)
22767 MrBayesPrint ("%s Aamodel ", spacer);
22769 else if (j == P_BRCORR)
22771 MrBayesPrint ("%s Brownian corr. ", spacer);
22773 else if (j == P_BRSIGMA)
22775 MrBayesPrint ("%s Brownian sigma ", spacer);
22777 else if (j == P_CPPRATE)
22779 MrBayesPrint ("%s Cpprate ", spacer);
22781 else if (j == P_CPPMULTDEV)
22783 MrBayesPrint ("%s Cppmultdev ", spacer);
22785 else if (j == P_CPPEVENTS)
22787 MrBayesPrint ("%s Cppevents ", spacer);
22789 else if (j == P_TK02VAR)
22791 MrBayesPrint ("%s TK02var ", spacer);
22793 else if (j == P_TK02BRANCHRATES)
22795 MrBayesPrint ("%s TK02branchrates ", spacer);
22797 else if (j == P_IGRVAR)
22799 MrBayesPrint ("%s Igrvar ", spacer);
22801 else if (j == P_IGRBRANCHRATES)
22803 MrBayesPrint ("%s Igrbranchrates ", spacer);
22805 else if (j == P_MIXEDVAR)
22807 MrBayesPrint ("%s Mixedvar ", spacer);
22809 else if (j == P_MIXEDBRCHRATES)
22811 MrBayesPrint ("%s Mixedbranchrates ", spacer);
22813 else if (j == P_CLOCKRATE)
22815 MrBayesPrint ("%s Clockrate ", spacer);
22817 else if (j == P_SPECIESTREE)
22819 MrBayesPrint ("%s Speciestree ", spacer);
22823 MrBayesPrint ("%s ERROR: Someone forgot to name parameter type %d", spacer, j);
22827 for (i=0; i<numCurrentDivisions; i++)
22829 if (activeParams[j][i] == -1)
22830 MrBayesPrint (" .");
22832 MrBayesPrint (" %2d", activeParams[j][i]);
22834 MrBayesPrint ("\n");
22836 if (numCurrentDivisions > 1)
22838 MrBayesPrint ("%s ------------------", spacer);
22839 for (i=0; i<numCurrentDivisions; i++)
22840 MrBayesPrint ("---");
22841 MrBayesPrint ("\n");
22845 MrBayesPrint ("%s ---------------------\n", spacer);
22848 MrBayesPrint ("\n");
22850 if (numCurrentDivisions > 1)
22851 MrBayesPrint ("%s Parameters can be linked or unlinked across partitions using 'link' and 'unlink'\n\n", spacer);
22853 for (i=0; i<numParams; i++)
22858 mp = &modelParams[p->relParts[0]];
22859 ms = &modelSettings[p->relParts[0]];
22861 /* print parameter number and name */
22862 MrBayesPrint ("%s %4d -- Parameter = %s\n", spacer, i+1, p->name);
22863 MrBayesPrint ("%s Type = %s\n", spacer, p->paramTypeName);
22867 if (!strcmp(mp->tRatioPr,"Beta"))
22868 MrBayesPrint ("%s Prior = Beta(%1.2lf,%1.2lf)\n", spacer, mp->tRatioDir[0], modelParams[i].tRatioDir[1]);
22870 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->tRatioFix);
22872 else if (j == P_REVMAT)
22874 if (ms->numModelStates != 20)
22876 if (!strcmp(mp->nst,"Mixed"))
22878 MrBayesPrint ("%s Prior = All GTR submodels have equal probability\n", spacer);
22879 MrBayesPrint ("%s All revmat rates have a Symmetric Dirichlet(%1.2lf) prior\n", spacer, mp->revMatSymDir);
22881 else if (!strcmp(mp->revMatPr,"Dirichlet"))
22883 MrBayesPrint ("%s Prior = Dirichlet(%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer,
22884 mp->revMatDir[0], mp->revMatDir[1], mp->revMatDir[2],
22885 mp->revMatDir[3], mp->revMatDir[4], mp->revMatDir[5]);
22888 MrBayesPrint ("%s Prior = Fixed(%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf,%1.2lf)\n", spacer,
22889 mp->revMatFix[0], mp->revMatFix[1], mp->revMatFix[2],
22890 mp->revMatFix[3], mp->revMatFix[4], mp->revMatFix[5]);
22892 else if (ms->numModelStates == 20)
22894 if (!strcmp(mp->aaRevMatPr,"Dirichlet"))
22895 MrBayesPrint ("%s Prior = Dirichlet\n", spacer);
22897 MrBayesPrint ("%s Prior = Fixed(user-specified)\n", spacer);
22900 else if (j == P_OMEGA)
22902 if (!strcmp(mp->omegaVar,"Equal"))
22904 if (!strcmp(mp->omegaPr,"Dirichlet"))
22905 MrBayesPrint ("%s Prior = Dirichlet(%1.2lf,%1.2lf)\n", spacer, mp->omegaDir[0], mp->omegaDir[1]);
22907 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->omegaFix);
22909 else if (!strcmp(mp->omegaVar,"Ny98"))
22911 if (!strcmp(mp->ny98omega1pr,"Beta"))
22912 MrBayesPrint ("%s Prior = Beta(%1.2lf,%1.2lf) on omega(1)\n", spacer, mp->ny98omega1Beta[0], mp->ny98omega1Beta[1]);
22914 MrBayesPrint ("%s Prior = Fixed(%1.2lf) on omega(1)\n", spacer, mp->ny98omega1Fixed);
22915 MrBayesPrint ("%s Fixed(1.00) on omega(2)\n", spacer);
22916 if (!strcmp(mp->ny98omega3pr,"Uniform"))
22917 MrBayesPrint ("%s Uniform(%1.2lf,%1.2lf) on omega(3)\n", spacer, mp->ny98omega3Uni[0], mp->ny98omega3Uni[1]);
22918 else if (!strcmp(mp->ny98omega3pr,"Exponential"))
22919 MrBayesPrint ("%s Exponential(%1.2lf) on omega(3)\n", spacer, mp->ny98omega3Exp);
22921 MrBayesPrint ("%s Fixed(%1.2lf) on omega(3)\n", spacer, mp->ny98omega3Fixed);
22922 if (!strcmp(mp->codonCatFreqPr,"Dirichlet"))
22923 MrBayesPrint ("%s Dirichlet(%1.2lf,%1.2lf,%1.2lf) on pi(-), pi(N), and pi(+)\n", spacer, mp->codonCatDir[0], mp->codonCatDir[1], mp->codonCatDir[2]);
22925 MrBayesPrint ("%s Fixed(%1.2lf,%1.2lf,%1.2lf) on pi(-), pi(N), and pi(+)\n", spacer, mp->codonCatFreqFix[0], mp->codonCatFreqFix[1], mp->codonCatFreqFix[2]);
22927 else if (!strcmp(mp->omegaVar,"M3"))
22929 if (!strcmp(mp->m3omegapr,"Exponential"))
22930 MrBayesPrint ("%s dN1, dN2, dN3, and dS are all exponential random variables\n", spacer);
22932 MrBayesPrint ("%s Fixed(%1.2lf,%1.2lf,%1.2lf) for the three selection categories\n", spacer, mp->m3omegaFixed[0], mp->m3omegaFixed[1], mp->m3omegaFixed[2]);
22933 if (!strcmp(mp->codonCatFreqPr,"Dirichlet"))
22934 MrBayesPrint ("%s Dirichlet(%1.2lf,%1.2lf,%1.2lf) on pi(1), pi(2), and pi(3)\n", spacer, mp->codonCatDir[0], mp->codonCatDir[1], mp->codonCatDir[2]);
22936 MrBayesPrint ("%s Fixed(%1.2lf,%1.2lf,%1.2lf) on pi(1), pi(2), and pi(3)\n", spacer, mp->codonCatFreqFix[0], mp->codonCatFreqFix[1], mp->codonCatFreqFix[2]);
22938 else if (!strcmp(mp->omegaVar,"M10"))
22940 MrBayesPrint ("%s With probability pi(1), omega is drawn from a Beta(alpha1,beta1) \n", spacer);
22941 MrBayesPrint ("%s distribution and with probability pi(2), omega is drawn from\n", spacer);
22942 MrBayesPrint ("%s a Gamma(alpha2,beta2) distribution.\n", spacer);
22943 if (!strcmp(mp->m10betapr,"Uniform"))
22945 MrBayesPrint ("%s The parameters of the beta distribution each follow \n", spacer);
22946 MrBayesPrint ("%s independent Uniform(%1.2lf,%1.2lf) priors\n", spacer, mp->m10betaUni[0], mp->m10betaUni[1]);
22948 else if (!strcmp(mp->m10betapr,"Exponential"))
22950 MrBayesPrint ("%s The parameters of the beta distribution each follow \n", spacer);
22951 MrBayesPrint ("%s independent Exponential(%1.2lf) priors\n", spacer, mp->m10betaExp);
22955 MrBayesPrint ("%s The parameters of the beta distribution are fixed to \n", spacer);
22956 MrBayesPrint ("%s %1.2lf and %1.2lf\n", spacer, mp->m10betaFix[0], mp->m10betaFix[0]);
22959 if (!strcmp(mp->m10gammapr,"Uniform"))
22961 MrBayesPrint ("%s The parameters of the gamma distribution each follow \n", spacer);
22962 MrBayesPrint ("%s independent Uniform(%1.2lf,%1.2lf) priors\n", spacer, mp->m10gammaUni[0], mp->m10gammaUni[1]);
22964 else if (!strcmp(mp->m10gammapr,"Exponential"))
22966 MrBayesPrint ("%s The parameters of the gamma distribution each follow \n", spacer);
22967 MrBayesPrint ("%s independent Exponential(%1.2lf) priors\n", spacer, mp->m10gammaExp);
22971 MrBayesPrint ("%s The parameters of the gamma distribution are fixed to \n", spacer);
22972 MrBayesPrint ("%s %1.2lf and %1.2lf\n", spacer, mp->m10gammaFix[0], mp->m10gammaFix[0]);
22975 if (!strcmp(mp->codonCatFreqPr,"Dirichlet"))
22976 MrBayesPrint ("%s Dirichlet(%1.2lf,%1.2lf) on pi(1) and pi(2)\n", spacer, mp->codonCatDir[0], mp->codonCatDir[1]);
22978 MrBayesPrint ("%s Fixed(%1.2lf,%1.2lf) on pi(1) and pi(2)\n", spacer, mp->codonCatFreqFix[0], mp->codonCatFreqFix[1]);
22981 else if (j == P_PI)
22983 if (ms->dataType == STANDARD)
22985 if (!strcmp(mp->symPiPr, "Uniform"))
22986 MrBayesPrint ("%s Prior = Symmetric dirichlet with uniform(%1.2lf,%1.2lf) variance parameter\n", spacer, mp->symBetaUni[0], mp->symBetaUni[1]);
22987 else if (!strcmp(mp->symPiPr, "Exponential"))
22988 MrBayesPrint ("%s Prior = Symmetric dirichlet with exponential(%1.2lf) variance parameter\n", spacer, mp->symBetaExp);
22990 { /* mp->symBetaFix == -1 */
22991 if (AreDoublesEqual(mp->symBetaFix, -1.0, ETA)==YES)
22992 MrBayesPrint ("%s Prior = Symmetric dirichlet with all parameters equal to infinity\n", spacer);
22994 MrBayesPrint ("%s Prior = Symmetric dirichlet with all parameters equal to %1.2lf\n", spacer, mp->symBetaFix);
22997 else if (ms->dataType == PROTEIN)
22999 if (!strcmp(mp->aaModelPr, "Fixed") && (!strcmp(mp->aaModel, "Equalin") || !strcmp(mp->aaModel, "Gtr")))
23001 if (!strcmp(mp->stateFreqPr,"Dirichlet"))
23003 MrBayesPrint ("%s Prior = Dirichlet\n", spacer);
23005 else if (!strcmp(mp->stateFreqPr,"Fixed") && !strcmp(mp->stateFreqsFixType,"Equal"))
23007 MrBayesPrint ("%s Prior = Fixed (equal frequencies)\n", spacer);
23009 else if (!strcmp(mp->stateFreqPr,"Fixed") && !strcmp(mp->stateFreqsFixType,"User"))
23011 MrBayesPrint ("%s Prior = Fixed (user-specified)\n", spacer);
23013 else if (!strcmp(mp->stateFreqPr,"Fixed") && !strcmp(mp->stateFreqsFixType,"Empirical"))
23015 MrBayesPrint ("%s Prior = Fixed (empirical frequencies)\n", spacer);
23018 else if (!strcmp(mp->aaModelPr, "Fixed") && !strcmp(mp->aaModel, "Poisson"))
23020 MrBayesPrint ("%s Prior = Fixed (equal frequencies)\n", spacer);
23022 else if (!strcmp(mp->aaModelPr, "Fixed") && strcmp(mp->aaModel, "Equalin") && strcmp(mp->aaModel, "Poisson"))
23024 MrBayesPrint ("%s Prior = Fixed (%s frequencies)\n", spacer, mp->aaModel);
23028 MrBayesPrint ("%s Prior = Fixed (from mixture of models)\n", spacer);
23033 if (!strcmp(mp->stateFreqPr,"Dirichlet"))
23034 MrBayesPrint ("%s Prior = Dirichlet\n", spacer);
23036 MrBayesPrint ("%s Prior = Fixed\n", spacer);
23039 else if (j == P_SHAPE)
23041 if (!strcmp(mp->shapePr,"Uniform"))
23042 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->shapeUni[0], mp->shapeUni[1]);
23043 else if (!strcmp(mp->shapePr,"Exponential"))
23044 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->shapeExp);
23046 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->shapeFix);
23048 else if (j == P_PINVAR)
23050 if (!strcmp(mp->pInvarPr,"Uniform"))
23051 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->pInvarUni[0], mp->pInvarUni[1]);
23053 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->pInvarFix);
23055 else if (j == P_CORREL)
23057 if (!strcmp(mp->adGammaCorPr,"Uniform"))
23058 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->corrUni[0], mp->corrUni[1]);
23060 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->corrFix);
23062 else if (j == P_SWITCH)
23064 if (!strcmp(mp->covSwitchPr,"Uniform"))
23065 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->covswitchUni[0], mp->covswitchUni[1]);
23066 else if (!strcmp(mp->covSwitchPr,"Exponential"))
23067 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->covswitchExp);
23069 MrBayesPrint ("%s Prior = Fixed(%1.2lf,%1.2lf)\n", spacer, mp->covswitchFix[0], mp->covswitchFix[1]);
23071 else if (j == P_RATEMULT)
23073 if (!strcmp(mp->ratePr,"Fixed"))
23074 MrBayesPrint ("%s Prior = Fixed(1.0)\n", spacer);
23077 MrBayesPrint ("%s Prior = Dirichlet(", spacer);
23078 for (d=n=0; d<numCurrentDivisions; d++)
23080 if (activeParams[j][d] == i+1)
23083 for (d=m=0; d<numCurrentDivisions; d++)
23085 if (activeParams[j][d] == i+1)
23089 MrBayesPrint ("%1.2lf,", modelParams[d].ratePrDir);
23091 MrBayesPrint ("%1.2lf)\n", modelParams[d].ratePrDir);
23096 else if (j == P_GENETREERATE)
23098 if (!strcmp(mp->generatePr,"Fixed"))
23099 MrBayesPrint ("%s Prior = Fixed(1.0)\n", spacer);
23102 MrBayesPrint ("%s Prior = Dirichlet(", spacer);
23103 printedCol = (int)(strlen(spacer)) + 25 + 10;
23104 for (n=0; n<numTrees-1; n++)
23106 if (printedCol + 5 > screenWidth)
23108 MrBayesPrint("\n%s ", spacer);
23109 printedCol = (int)(strlen(spacer)) + 25 + 10;
23111 if (n == numTrees-2)
23112 MrBayesPrint ("1.00)\n");
23114 MrBayesPrint ("1.00,");
23119 else if (j == P_TOPOLOGY)
23121 if (!strcmp(mp->topologyPr,"Uniform"))
23122 MrBayesPrint ("%s Prior = All topologies equally probable a priori\n", spacer);
23123 else if (!strcmp(mp->topologyPr,"Speciestree"))
23124 MrBayesPrint ("%s Prior = Topology constrained to fold within species tree\n", spacer);
23125 else if (!strcmp(mp->topologyPr,"Constraints"))
23126 MrBayesPrint ("%s Prior = Prior on topologies obeys constraints\n", spacer);
23128 MrBayesPrint ("%s Prior = Prior is fixed to the topology of user tree '%s'\n", spacer,
23129 userTree[mp->topologyFix]->name);
23131 else if (j == P_BRLENS)
23133 if (!strcmp(mp->parsModel, "Yes"))
23134 MrBayesPrint ("%s Prior = Reconstructed using parsimony\n", spacer);
23137 if (!strcmp(mp->brlensPr,"Unconstrained"))
23139 MrBayesPrint ("%s Prior = Unconstrained:%s", spacer, mp->unconstrainedPr);
23140 if (!strcmp(mp->unconstrainedPr, "Uniform"))
23141 MrBayesPrint ("(%1.1lf,%1.1lf)\n", mp->brlensUni[0], mp->brlensUni[1]);
23142 else if (!strcmp(mp->unconstrainedPr, "Exponential"))
23143 MrBayesPrint ("(%1.1lf)\n", mp->brlensExp);
23144 else if (!strcmp(mp->unconstrainedPr, "twoExp"))
23145 MrBayesPrint ("(%1.1lf,%1.1lf)\n", mp->brlens2Exp[0], mp->brlens2Exp[1]);
23147 MrBayesPrint ("(%1.1lf,%1.4lf,%1.1lf,%1.1lf)\n", mp->brlensDir[0], mp->brlensDir[1], mp->brlensDir[2], mp->brlensDir[3]);
23149 else if (!strcmp(mp->brlensPr, "Clock"))
23151 MrBayesPrint ("%s Prior = Clock:%s\n", spacer, mp->clockPr);
23152 if ((!strcmp(mp->clockPr,"Uniform") || !strcmp(mp->clockPr,"Fossilization")) && !strcmp(mp->nodeAgePr,"Unconstrained"))
23154 MrBayesPrint ("%s Tree age has a %s distribution\n", spacer, mp->treeAgePr.name);
23156 else if (!strcmp(mp->clockPr, "Birthdeath") && !strcmp(mp->nodeAgePr,"Unconstrained"))
23158 MrBayesPrint ("%s Tree age has a Uniform(0,infinity) distribution\n", spacer);
23160 if (!strcmp(mp->nodeAgePr,"Calibrated"))
23163 for (a=0; a<numTaxa; a++)
23165 if (taxaInfo[a].isDeleted == NO && tipCalibration[a].prior != unconstrained)
23168 for (a=0; a<numDefinedConstraints; a++)
23170 if (mp->activeConstraints[a] == YES && nodeCalibration[a].prior != unconstrained)
23174 MrBayesPrint ("%s Node depths are constrained by the following age constraints:\n", spacer);
23176 MrBayesPrint ("%s Node depths are calibrated by the following age constraint:\n", spacer);
23177 for (a=0; a<numTaxa; a++)
23179 if (taxaInfo[a].isDeleted == NO && tipCalibration[a].prior != unconstrained)
23181 MrBayesPrint ("%s -- The age of terminal \"%s\" is %s\n", spacer, taxaNames[a],
23182 tipCalibration[a].name);
23185 for (a=b=0; a<numDefinedConstraints; a++)
23187 if (mp->activeConstraints[a] == YES && nodeCalibration[a].prior != unconstrained)
23189 MrBayesPrint ("%s -- The age of node '%s' is %s\n", spacer,
23190 constraintNames[a], nodeCalibration[a].name);
23191 for (k=0; k<numTaxa; k++)
23192 if (taxaInfo[k].isDeleted == NO && IsBitSet(k,definedConstraint[a]) == NO)
23195 b = 1; /* root is calibrated */
23198 if (b == 0) /* we need to use default calibration for root for uniform and birthdeath */
23200 if (!strcmp(mp->clockPr,"Uniform") || !strcmp(mp->clockPr,"Fossilization"))
23202 MrBayesPrint ("%s -- Tree age has a %s distribution\n", spacer, mp->treeAgePr.name);
23204 else if (!strcmp(mp->clockPr,"Birthdeath"))
23206 MrBayesPrint ("%s -- Tree age has a Uniform(0,infinity) distribution\n", spacer);
23211 MrBayesPrint ("%s Node ages are not constrained\n", spacer);
23215 assert (!strcmp(mp->brlensPr, "Fixed"));
23216 MrBayesPrint ("%s Prior = Fixed, branch lengths are fixed to the ones of the user tree '%s'\n", spacer,
23217 userTree[mp->topologyFix]->name);
23221 else if (j == P_SPECRATE)
23223 if (!strcmp(mp->speciationPr,"Uniform"))
23224 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->speciationUni[0], mp->speciationUni[1]);
23225 else if (!strcmp(mp->speciationPr,"Exponential"))
23226 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->speciationExp);
23228 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->speciationFix);
23230 else if (j == P_EXTRATE)
23232 if (!strcmp(mp->extinctionPr,"Beta"))
23233 MrBayesPrint ("%s Prior = Beta(%1.2lf,%1.2lf)\n", spacer, mp->extinctionBeta[0], mp->extinctionBeta[1]);
23235 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->extinctionFix);
23237 else if (j == P_FOSLRATE)
23239 if (!strcmp(mp->fossilizationPr,"Beta"))
23240 MrBayesPrint ("%s Prior = Beta(%1.2lf,%1.2lf)\n", spacer, mp->fossilizationBeta[0], mp->fossilizationBeta[1]);
23242 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->fossilizationFix);
23244 else if (j == P_POPSIZE)
23246 if (!strcmp(mp->popSizePr,"Uniform"))
23247 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->popSizeUni[0], mp->popSizeUni[1]);
23248 else if (!strcmp(mp->popSizePr,"Lognormal"))
23249 MrBayesPrint ("%s Prior = Lognormal(%1.2lf,%1.2lf)\n", spacer, mp->popSizeLognormal[0], mp->popSizeLognormal[1]);
23250 else if (!strcmp(mp->popSizePr,"Normal"))
23251 MrBayesPrint ("%s Prior = Truncated Normal(%1.2lf,%1.2lf)\n", spacer, mp->popSizeNormal[0], mp->popSizeNormal[1]);
23252 else if (!strcmp(mp->popSizePr,"Gamma"))
23253 MrBayesPrint ("%s Prior = Gamma(%1.2lf,%1.2lf)\n", spacer, mp->popSizeGamma[0], mp->popSizeGamma[1]);
23255 MrBayesPrint ("%s Prior = Fixed(%1.5lf)\n", spacer, mp->popSizeFix);
23256 if (!strcmp(mp->topologyPr,"Speciestree"))
23258 if (!strcmp(mp->popVarPr,"Equal") || !strcmp(mp->popSizePr,"Fixed"))
23259 MrBayesPrint ("%s Population size the same across species tree\n", spacer);
23261 MrBayesPrint ("%s Population size varies across branches in species tree\n", spacer);
23264 else if (j == P_GROWTH)
23266 if (!strcmp(mp->growthPr,"Uniform"))
23267 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->growthUni[0], mp->growthUni[1]);
23268 else if (!strcmp(mp->growthPr,"Exponential"))
23269 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->growthExp);
23270 else if (!strcmp(mp->growthPr,"Normal"))
23271 MrBayesPrint ("%s Prior = Normal(%1.2lf,%1.2lf)\n", spacer, mp->growthNorm[0], mp->growthNorm[1]);
23273 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->growthFix);
23275 else if (j == P_AAMODEL)
23277 if (!strcmp(mp->aaModelPr,"Mixed"))
23279 /* check to see if you have a uniform prior */
23281 for (a=0; a<9; a++)
23282 for (b=a+1; b<10; b++)
23283 /* mp->aaModelPrProbs[a] != mp->aaModelPrProbs[b] */
23284 if (AreDoublesEqual(mp->aaModelPrProbs[a], mp->aaModelPrProbs[b], ETA)==FALSE)
23286 MrBayesPrint ("%s Prior = Poisson, Jones, Dayhoff, Mtrev, Mtmam, Wag, Rtrev,\n", spacer);
23288 MrBayesPrint ("%s Cprev, Vt, and Blosum models have equal prior probability\n", spacer);
23290 MrBayesPrint ("%s Cprev, Vt, and Blosum models have unequal prior probability\n", spacer);
23293 MrBayesPrint ("%s Prior = Fixed(%s)\n", spacer, mp->aaModel);
23295 else if (j == P_BRCORR)
23297 if (!strcmp(mp->brownCorPr,"Uniform"))
23298 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->brownCorrUni[0], mp->brownCorrUni[1]);
23300 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->brownCorrFix);
23302 else if (j == P_BRSIGMA)
23304 if (!strcmp(mp->brownScalesPr,"Uniform"))
23305 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->brownScalesUni[0], mp->brownScalesUni[1]);
23306 else if (!strcmp(mp->brownScalesPr,"Gammamean"))
23307 MrBayesPrint ("%s Prior = Gamma Mean=<char. ave.> Var=%1.2lf\n", spacer, mp->brownScalesGammaMean);
23308 else if (!strcmp(mp->brownScalesPr,"Gamma"))
23309 MrBayesPrint ("%s Prior = Gamma Mean=%lf Var=%1.2lf\n", spacer, mp->brownScalesGamma[0], mp->brownScalesGamma[1]);
23311 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->brownScalesFix);
23313 else if (j == P_CPPRATE)
23315 if (!strcmp(mp->cppRatePr,"Exponential"))
23316 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->cppRateExp);
23318 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->cppRateFix);
23320 else if (j == P_CPPMULTDEV)
23322 if (!strcmp(mp->cppMultDevPr,"Fixed"))
23323 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->cppMultDevFix);
23325 else if (j == P_CPPEVENTS)
23327 MrBayesPrint ("%s Prior = Poisson (%s) [Events]\n", spacer, modelSettings[p->relParts[0]].cppRate->name);
23328 MrBayesPrint ("%s Lognormal (0.00,%1.2lf) [Rate multipliers]\n", spacer, mp->cppMultDevFix);
23330 else if (j == P_TK02VAR)
23332 if (!strcmp(mp->tk02varPr,"Uniform"))
23333 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->tk02varUni[0], mp->tk02varUni[1]);
23334 else if (!strcmp(mp->tk02varPr,"Exponential"))
23335 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->tk02varExp);
23337 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->tk02varFix);
23339 else if (j == P_TK02BRANCHRATES)
23341 MrBayesPrint ("%s Prior = LogNormal (expectation = r_0, variance = %s * v) \n", spacer, modelSettings[p->relParts[0]].tk02var->name);
23342 MrBayesPrint ("%s [r_0 is beginning rate of branch, v is branch length]\n", spacer);
23344 else if (j == P_IGRVAR)
23346 if (!strcmp(mp->igrvarPr,"Uniform"))
23347 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->igrvarUni[0], mp->igrvarUni[1]);
23348 else if (!strcmp(mp->igrvarPr,"Exponential"))
23349 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->igrvarExp);
23351 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->igrvarFix);
23353 else if (j == P_IGRBRANCHRATES)
23355 MrBayesPrint ("%s Prior = Gamma (expectation = v, variance = %s * v) \n", spacer, modelSettings[p->relParts[0]].igrvar->name);
23356 MrBayesPrint ("%s [where v is branch length]\n", spacer);
23358 else if (j == P_MIXEDVAR)
23360 if (!strcmp(mp->mixedvarPr,"Uniform"))
23361 MrBayesPrint ("%s Prior = Uniform(%1.2lf,%1.2lf)\n", spacer, mp->mixedvarUni[0], mp->mixedvarUni[1]);
23362 else if (!strcmp(mp->mixedvarPr,"Exponential"))
23363 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->mixedvarExp);
23365 MrBayesPrint ("%s Prior = Fixed(%1.2lf)\n", spacer, mp->mixedvarFix);
23367 else if (j == P_MIXEDBRCHRATES)
23369 MrBayesPrint ("%s Prior = Mixed TK02 and IGR (variance = %s * v)\n", spacer, modelSettings[p->relParts[0]].mixedvar->name);
23370 MrBayesPrint ("%s [where v is branch length]\n", spacer);
23371 MrBayesPrint ("%s Uniform prior on relaxed clock models [Pr(TK02)=Pr(IGR)=1/2]\n", spacer);
23373 else if (j == P_CLOCKRATE)
23375 if (!strcmp(mp->clockRatePr,"Normal"))
23376 MrBayesPrint ("%s Prior = Normal(%1.6lf,%1.6lf)\n", spacer, mp->clockRateNormal[0], mp->clockRateNormal[1]);
23377 else if (!strcmp(mp->clockRatePr,"Lognormal"))
23378 MrBayesPrint ("%s Prior = Lognormal(%1.2lf,%1.2lf)\n", spacer, mp->clockRateLognormal[0], mp->clockRateLognormal[1]);
23379 else if (!strcmp(mp->clockRatePr,"Gamma"))
23380 MrBayesPrint ("%s Prior = Gamma(%1.2lf,%1.2lf)\n", spacer, mp->clockRateGamma[0], mp->clockRateGamma[1]);
23381 else if (!strcmp(mp->clockRatePr,"Exponential"))
23382 MrBayesPrint ("%s Prior = Exponential(%1.2lf)\n", spacer, mp->clockRateExp);
23384 MrBayesPrint ("%s Prior = Fixed(%1.6lf)\n", spacer, mp->clockRateFix);
23385 if (!strcmp(mp->clockVarPr,"Strict"))
23386 MrBayesPrint ("%s The clock rate is constant (strict clock)\n", spacer);
23387 else if (!strcmp(mp->clockVarPr,"Cpp"))
23388 MrBayesPrint ("%s The clock rate varies according to a CPP model\n", spacer);
23389 else if (!strcmp(mp->clockVarPr,"TK02"))
23390 MrBayesPrint ("%s The clock rate varies according to a Brownian motion model\n", spacer);
23391 else if (!strcmp(mp->clockVarPr,"Igr"))
23392 MrBayesPrint ("%s The clock rate varies according to an independent gamma (white noise) model\n", spacer);
23393 else /* if (!strcmp(mp->clockVarPr,"Mixed")) */
23394 MrBayesPrint ("%s The clock rate varies according to mixed TK02 and IGR models\n", spacer);
23396 else if (j == P_SPECIESTREE)
23398 MrBayesPrint ("%s Prior = Uniform on topologies and branch lengths\n", spacer);
23401 /* print partitions */
23402 if (numCurrentDivisions > 1)
23404 if (p->nRelParts == 1)
23405 MrBayesPrint ("%s Partition = %d\n", spacer, p->relParts[0]+1);
23406 else if (p->nRelParts == 2)
23408 MrBayesPrint ("%s Partitions = %d and %d\n", spacer, p->relParts[0]+1, p->relParts[1]+1);
23410 else if (p->nRelParts == numCurrentDivisions)
23412 MrBayesPrint ("%s Partitions = All\n", spacer);
23414 else /* if (p->nRelParts > 2) */
23416 MrBayesPrint ("%s Partitions = ", spacer);
23417 for (j=0; j<p->nRelParts; j++)
23419 if (j == p->nRelParts - 2)
23420 MrBayesPrint ("%d, and ", p->relParts[j]+1);
23421 else if (j == p->nRelParts - 1)
23422 MrBayesPrint ("%d\n", p->relParts[j]+1);
23424 MrBayesPrint ("%d, ", p->relParts[j]+1);
23429 /* show subparams */
23430 if (p->nSubParams > 0)
23432 if (p->nSubParams == 1)
23433 MrBayesPrint ("%s Subparam. = %s\n", spacer, p->subParams[0]->name);
23437 for (k=0; k<p->nSubParams; k++)
23441 MrBayesPrint ("%s Subparams = %s", spacer, p->subParams[k]->name);
23442 printedCol = (int)(strlen(spacer)) + 25 + (int)(strlen(p->subParams[k]->name));
23444 else if (k == p->nSubParams - 1)
23446 if (printedCol + 5 > screenWidth)
23447 MrBayesPrint ("\n%s and ", spacer);
23448 else if (printedCol + (int)(strlen(p->subParams[k]->name)) + 5 > screenWidth)
23449 MrBayesPrint (" and \n%s ", spacer);
23451 MrBayesPrint (" and ");
23452 MrBayesPrint ("%s\n", p->subParams[k]->name);
23456 if (printedCol + (int)(strlen(p->subParams[k]->name)) + 2 > screenWidth)
23458 MrBayesPrint (", \n%s ", spacer);
23459 printedCol = (int)(strlen(spacer)) + 25;
23463 MrBayesPrint(", ");
23466 MrBayesPrint ("%s", p->subParams[k]->name);
23467 printedCol += (int)strlen(p->subParams[k]->name);
23473 /* show used moves */
23474 if (showMoves == YES && (p->printParam == YES || p->paramType == P_TOPOLOGY || p->paramType == P_BRLENS))
23476 /* check if runs are same */
23478 for (run=1; run<chainParams.numRuns; run++)
23480 for (chain=0; chain<chainParams.numChains; chain++)
23482 for (k=0; k<numApplicableMoves; k++)
23487 chainIndex = run*chainParams.numChains + chain;
23489 if (AreDoublesEqual (mv->relProposalProb[chainIndex], mv->relProposalProb[refIndex], 0.000001) == NO)
23495 for (run=0; run<chainParams.numRuns; run++)
23497 if (run > 0 && areRunsSame == YES)
23500 /* check if chains are same */
23501 areChainsSame = YES;
23502 for (chain=1; chain<chainParams.numChains; chain++)
23504 for (k=0; k<numApplicableMoves; k++)
23509 chainIndex = run*chainParams.numChains + chain;
23510 refIndex = run*chainParams.numChains;
23511 if (AreDoublesEqual (mv->relProposalProb[chainIndex], mv->relProposalProb[refIndex], 0.000001) == NO)
23512 areChainsSame = NO;
23516 /* now print moves */
23517 for (chain=0; chain<chainParams.numChains; chain++)
23519 if (chain > 0 && areChainsSame == YES)
23521 if (run==0 && chain==0)
23522 MrBayesPrint ("%s Moves = ", spacer);
23524 MrBayesPrint ("%s ", spacer);
23526 printedCol = (int)(strlen(spacer)) + 25;
23527 for (k=0; k<numApplicableMoves; k++)
23532 chainIndex = run*chainParams.numChains + chain;
23533 if (mv->relProposalProb[chainIndex] <= 0.000001)
23535 if (numPrinted == 0)
23537 MrBayesPrint ("%s <prob %.1f>", mv->name, mv->relProposalProb[chainIndex]);
23538 printedCol += 9 + (int)strlen(mv->name) + (int)(log10(mv->relProposalProb[chainIndex])) + 3;
23542 if (printedCol + 11 + (int)(strlen(mv->name)) + (int)(log10(mv->relProposalProb[chainIndex])) + 3 > screenWidth)
23544 MrBayesPrint(", \n%s ", spacer);
23545 printedCol = 25 + (int)(strlen(spacer));
23549 MrBayesPrint(", ");
23552 MrBayesPrint ("%s <prob %.1f>", mv->name, mv->relProposalProb[chainIndex]);
23553 printedCol += (9 + (int)(strlen(mv->name)) + (int)(log10(mv->relProposalProb[chainIndex])) + 3);
23558 if (numPrinted == 0 && p->paramType == P_BRLENS)
23560 for (k=0; k<numParams; k++)
23561 if (params[k].tree == p->tree)
23563 MrBayesPrint ("For moves, see param. '%s'", params[k].name);
23565 else if (numPrinted == 0)
23566 MrBayesPrint ("WARNING! No moves -- param. fixed to startvals");
23568 if (areRunsSame == YES && areChainsSame == YES)
23569 MrBayesPrint ("\n");
23570 else if (areRunsSame == YES && areChainsSame == NO)
23571 MrBayesPrint (" [chain %d]\n", chain+1);
23572 else if (areRunsSame == NO && areChainsSame == YES)
23573 MrBayesPrint (" [run %d]\n", run+1);
23574 else /* if (areRunsSame == NO && areChainsSame == NO) */
23575 MrBayesPrint (" [run %d, chain %d]\n", run+1, chain+1);
23580 /* show available moves */
23581 if (showAllAvailable == YES && (p->printParam == YES || p->paramType == P_TOPOLOGY || p->paramType == P_BRLENS))
23583 /* loop over moves */
23586 for (k=0; k<numApplicableMoves; k++)
23591 numMovedChains = 0;
23592 for (run=0; run<chainParams.numRuns; run++)
23594 for (chain=0; chain<chainParams.numChains; chain++)
23596 chainIndex = run*chainParams.numChains + chain;
23597 if (mv->relProposalProb[chainIndex] > 0.000001)
23601 if (numMovedChains == 0)
23603 if (numPrinted == 0)
23605 MrBayesPrint ("%s Not used = ", spacer);
23606 printedCol = (int)(strlen(spacer)) + 25;
23608 else if (printedCol + 2 + (int)(strlen(mv->moveType->shortName)) > screenWidth)
23610 MrBayesPrint (", \n%s ", spacer);
23611 printedCol = (int)(strlen(spacer)) + 25;
23615 MrBayesPrint (", ");
23618 MrBayesPrint("%s", mv->moveType->shortName);
23619 printedCol += (int)strlen(mv->moveType->shortName);
23623 if (numPrinted > 0)
23624 MrBayesPrint ("\n");
23627 /* show startvals */
23628 if (showStartVals == YES && (p->printParam == YES || p->paramType == P_TOPOLOGY || p->paramType == P_BRLENS || p->paramType == P_SPECIESTREE || p->paramType == P_POPSIZE))
23630 if (p->paramType == P_TOPOLOGY || p->paramType == P_BRLENS || p->paramType == P_SPECIESTREE)
23632 /* check if they are the same */
23634 if (p->paramType == P_TOPOLOGY)
23636 for (run=1; run<chainParams.numRuns; run++)
23638 for (chain=0; chain<chainParams.numChains; chain++)
23640 if (AreTopologiesSame (GetTree (p, run*chainParams.numChains + chain, 0), GetTree (p, chain, 0)) == NO)
23648 else if (p->paramType == P_BRLENS)
23650 for (run=1; run<chainParams.numRuns; run++)
23652 for (chain=0; chain<chainParams.numChains; chain++)
23654 if (AreTreesSame (GetTree (p, run*chainParams.numChains + chain, 0), GetTree (p, chain, 0)) == NO)
23662 else if (p->paramType == P_SPECIESTREE)
23664 for (run=1; run<chainParams.numRuns; run++)
23666 for (chain=0; chain<chainParams.numChains; chain++)
23668 if (AreTreesSame (GetTree (p, run*chainParams.numChains + chain, 0), GetTree (p, chain, 0)) == NO)
23678 for (run=0; run<chainParams.numRuns; run++)
23680 if (run > 0 && areRunsSame == YES)
23682 for (chain=0; chain<chainParams.numChains; chain++)
23684 if (run == 0 && chain == 0)
23685 MrBayesPrint ("%s Startvals = tree '%s'", spacer, GetTree (p, run*chainParams.numChains+chain, 0)->name);
23687 MrBayesPrint ("%s tree '%s'", spacer, GetTree (p, run*chainParams.numChains+chain, 0)->name);
23688 if (chainParams.numChains > 1 && areRunsSame == YES)
23689 MrBayesPrint (" [chain %d]", chain+1);
23690 else if (chainParams.numChains == 1 && areRunsSame == NO)
23691 MrBayesPrint (" [run %d]", run+1);
23692 else if (areRunsSame == NO)
23693 MrBayesPrint (" [run %d, chain %d]", run+1, chain+1);
23694 MrBayesPrint ("\n");
23697 } /* end topology and brlens parameters */
23699 else if (p->paramType == P_OMEGA && p->paramId != OMEGA_DIR && p->paramId != OMEGA_FIX &&
23700 p->paramId != OMEGA_FFF && p->paramId != OMEGA_FF && p->paramId != OMEGA_10FFF)
23702 /* we need to print values and subvalues for the category frequencies in a NY98-like model. */
23704 for (run=1; run<chainParams.numRuns; run++)
23706 for (chain=0; chain<chainParams.numChains; chain++)
23708 value = GetParamVals (p, run*chainParams.numRuns+chain, 0);
23709 refValue = GetParamVals (p, chain, 0);
23710 nValues = p->nValues;
23711 for (k=0; k<nValues; k++)
23713 if (AreDoublesEqual (value[k], refValue[k], 0.000001) == NO)
23719 value = GetParamSubVals (p, run*chainParams.numRuns+chain, 0);
23720 refValue = GetParamSubVals (p, chain, 0);
23721 if (!strcmp(modelParams[p->relParts[0]].omegaVar, "M10"))
23723 value += (mp->numM10BetaCats + mp->numM10GammaCats);
23724 refValue += (mp->numM10BetaCats + mp->numM10GammaCats);
23725 for (k=0; k<4; k++)
23727 if (AreDoublesEqual (value[k + 4], refValue[k + 4], 0.000001) == NO)
23733 for (k=0; k<2; k++)
23735 if (AreDoublesEqual (value[k], refValue[k], 0.000001) == NO)
23744 for (k=0; k<3; k++)
23746 if (AreDoublesEqual (value[k], refValue[k], 0.000001) == NO)
23753 if (areRunsSame == NO)
23756 if (areRunsSame == NO)
23760 /* now print values */
23761 for (run=0; run<chainParams.numRuns; run++)
23763 for (chain=0; chain<chainParams.numChains; chain++)
23765 value = GetParamVals (p, run*chainParams.numRuns+chain, 0);
23766 subValue = GetParamSubVals (p, run*chainParams.numRuns+chain, 0);
23767 nValues = p->nValues;
23768 if (run == 0 && chain == 0)
23769 MrBayesPrint ("%s Startvals = (%1.3lf", spacer, value[0]);
23771 MrBayesPrint ("%s (%1.3lf", spacer, value[0]);
23772 for (k=1; k<nValues; k++)
23774 MrBayesPrint (",%1.3lf", value[k]);
23777 if (!strcmp(modelParams[p->relParts[0]].omegaVar, "M10"))
23779 for (k=0; k<4; k++)
23781 MrBayesPrint (",%1.3lf", subValue[k + mp->numM10BetaCats+mp->numM10GammaCats+4]);
23783 for (k=0; k<2; k++)
23785 MrBayesPrint (",%1.3lf", subValue[k + mp->numM10BetaCats+mp->numM10GammaCats]);
23790 for (k=0; k<3; k++)
23792 MrBayesPrint (",%1.3lf", subValue[k]);
23795 MrBayesPrint (")");
23796 if (chainParams.numChains > 1 && areRunsSame == YES)
23797 MrBayesPrint (" [chain %d]\n", chain+1);
23798 else if (chainParams.numChains == 1 && areRunsSame == NO)
23799 MrBayesPrint (" [run %d]\n", run+1);
23800 else if (areRunsSame == NO)
23801 MrBayesPrint (" [run %d, chain %d]\n", run+1, chain+1);
23807 /* run of the mill parameter */
23808 if (p->paramType == P_CLOCKRATE)
23810 for (j=0; j<numGlobalChains; j++)
23812 if (UpdateClockRate(-1.0, j) == ERROR)
23814 MrBayesPrint ("%s Warning: There is no appropriate clock rate that would satisfy all calibrated trees for run:%d chain%d. Some of calibration, trees or clockprior needs to be changed. ", spacer, j/chainParams.numChains, j%chainParams.numChains);
23819 for (run=1; run<chainParams.numRuns; run++)
23821 for (chain=0; chain<chainParams.numChains; chain++)
23823 if ((p->paramType == P_PI && modelParams[p->relParts[0]].dataType != STANDARD))
23825 nValues = p->nSubValues;
23826 value = GetParamSubVals (p, run*chainParams.numChains+chain, 0);
23827 refValue = GetParamSubVals (p, chain, 0);
23831 nValues = p->nValues;
23832 value = GetParamVals (p, run*chainParams.numChains+chain, 0);
23833 refValue = GetParamVals (p, chain, 0);
23835 for (k=0; k<nValues; k++)
23837 if (AreDoublesEqual(value[k], refValue[k], 0.000001) == NO)
23843 if (areRunsSame == NO)
23846 if (areRunsSame == NO)
23851 for (run=0; run<chainParams.numRuns; run++)
23853 if (run > 0 && areRunsSame == YES)
23855 areChainsSame = YES;
23856 for (chain=1; chain<chainParams.numChains; chain++)
23858 if ((p->paramType == P_PI && modelParams[p->relParts[0]].dataType != STANDARD))
23860 nValues = p->nSubValues;
23861 value = GetParamSubVals (p, run*chainParams.numChains+chain, 0);
23862 refValue = GetParamSubVals (p, run*chainParams.numChains, 0);
23866 nValues = p->nValues;
23867 value = GetParamVals (p, run*chainParams.numChains+chain, 0);
23868 refValue = GetParamVals (p, run*chainParams.numChains, 0);
23870 for (k=0; k<nValues; k++)
23872 if (AreDoublesEqual(value[k], refValue[k], 0.000001) == NO)
23874 areChainsSame = NO;
23879 for (chain=0; chain<chainParams.numChains; chain++)
23881 if (areChainsSame == YES && chain > 0)
23884 if ((p->paramType == P_PI && modelParams[p->relParts[0]].dataType != STANDARD))
23886 nValues = p->nSubValues;
23887 value = GetParamSubVals (p, run*chainParams.numChains+chain, 0);
23891 nValues = p->nValues;
23892 value = GetParamVals (p, run*chainParams.numChains+chain, 0);
23895 if (run == 0 && chain == 0)
23896 MrBayesPrint ("%s Startvals = (%1.3lf", spacer, value[0]);
23898 MrBayesPrint ("%s (%1.3lf", spacer, value[0]);
23900 for (k=1; k<nValues; k++)
23903 MrBayesPrint (",\n%s %1.3lf", spacer, value[k]);
23905 MrBayesPrint (",%1.3lf", value[k]);
23907 MrBayesPrint (")");
23909 if (areChainsSame == YES && areRunsSame == NO)
23910 MrBayesPrint (" [run %d]", run+1);
23911 else if (areChainsSame == NO && areRunsSame == YES)
23912 MrBayesPrint (" [chain %d]", chain+1);
23913 else if (areChainsSame == NO && areRunsSame == NO)
23914 MrBayesPrint (" [run %d, chain %d]", run+1, chain+1);
23915 MrBayesPrint ("\n");
23919 } /* end print start values */
23921 MrBayesPrint ("\n");
23922 } /* next parameter */
23934 /*-------------------------------------------------
23936 | UpdateClockRate: Update clockRate of the given chain. Above all it will enforce fixed clockrate prior if it is set.
23937 | Error will be returned if fixed clockrate prior may not be respected.
23938 | @param clockRate is the new clockRate to setup. Clock rate value could be set as positive, 0.0 or negative value.
23939 | The function does the fallowing depending on one of this three values:
23940 | positive - check that this 'positive' value is suitable rate. At the end re-enforce (update) the 'positive' value as clock rate on all trees.
23941 | 0.0 - check if current rate is suitable, if not update it with minimal suitable value. At the end re-enforce (update) the resulting clock rate on all trees.
23942 | negative - check if current rate is suitable, if not update it with minimal suitable value. At the end re-enforce (update) the resulting clock rate ONLY if clock rate was changed
23943 | @return ERROR if clockRate can not be set up, NO_ERROR otherwise.
23945 --------------------------------------------------*/
23946 int UpdateClockRate (MrBFlt clockRate, int chain)
23948 int i, updateTrees;
23949 MrBFlt *clockRatep;
23950 Tree *t, *t_calibrated=NULL;
23951 MrBFlt mintmp,maxtmp,minClockRate,maxClockRate;
23954 minClockRate = 0.0;
23955 maxClockRate = MRBFLT_MAX;
23957 for (i=0; i<numTrees; i++)
23959 t = GetTreeFromIndex(i, chain, 0);
23960 if (t->isCalibrated == NO)
23963 if (clockRatep == NULL)
23965 clockRatep = GetParamVals(modelSettings[t->relParts[0]].clockRate, chain, 0);
23967 assert (clockRatep);
23970 findAllowedClockrate (t, &mintmp, &maxtmp);
23972 if (minClockRate < mintmp)
23973 minClockRate = mintmp;
23975 if (maxClockRate > maxtmp)
23976 maxClockRate = maxtmp;
23979 /* clock rate is the same for all trees of a given chain */
23980 if (clockRatep != NULL)
23982 if (minClockRate > maxClockRate)
23984 MrBayesPrint ("%s ERROR: Calibrated trees require compatible clockrates but they are incompatible for run %d, chain %d.\n",
23985 spacer, chain/chainParams.numChains + 1, chain%chainParams.numChains + 1);
23990 if (!strcmp(modelParams[t_calibrated->relParts[0]].clockRatePr, "Fixed"))
23992 if (clockRate < 0.0 && AreDoublesEqual (*clockRatep, modelParams[t_calibrated->relParts[0]].clockRateFix, 0.0001) == YES)
24000 *clockRatep = modelParams[t_calibrated->relParts[0]].clockRateFix;
24001 if ((*clockRatep < minClockRate && AreDoublesEqual (*clockRatep, minClockRate, 0.0001) == NO) ||
24002 (*clockRatep > maxClockRate && AreDoublesEqual (*clockRatep, maxClockRate, 0.0001) == NO))
24004 MrBayesPrint ("%s ERROR: Calibrated trees require clockrate in range from %f to %f, while clockrate prior is fixed to %f for run %d chain %d.\n",
24005 spacer, minClockRate, maxClockRate, *clockRatep, chain/chainParams.numChains + 1, chain%chainParams.numChains + 1);
24009 if (clockRate > 0.0)
24011 if (AreDoublesEqual (*clockRatep, clockRate, 0.0001) == NO)
24013 MrBayesPrint ("%s ERROR: Requested clockrate:%f does not match fixed clockrate prior:%f.\n", spacer, clockRate, *clockRatep);
24020 /* clock prior is not fixed */
24022 if (clockRate > 0.0)
24024 *clockRatep = clockRate;
24025 if ((*clockRatep < minClockRate && AreDoublesEqual (*clockRatep, minClockRate, 0.0001) == NO) ||
24026 (*clockRatep > maxClockRate && AreDoublesEqual (*clockRatep, maxClockRate, 0.0001) == NO))
24028 MrBayesPrint ("%s ERROR: Calibrated trees require clockrate in range from %f to %f, while requested clockrate is %f for run %d chain %d.\n",
24029 spacer, minClockRate, maxClockRate, clockRate, chain/chainParams.numChains + 1, chain%chainParams.numChains + 1);
24034 else if (clockRate == 0.0)
24036 if ((*clockRatep < minClockRate && AreDoublesEqual (*clockRatep, minClockRate, 0.0001) == NO) ||
24037 (*clockRatep > maxClockRate && AreDoublesEqual (*clockRatep, maxClockRate, 0.0001) == NO))
24039 *clockRatep = minClockRate;
24042 else // if (clockRate < 0.0)
24044 if ((*clockRatep < minClockRate && AreDoublesEqual (*clockRatep, minClockRate, 0.0001) == NO) ||
24045 (*clockRatep > maxClockRate && AreDoublesEqual (*clockRatep, maxClockRate, 0.0001) == NO))
24047 *clockRatep = minClockRate;
24057 if (updateTrees == YES)
24059 for (i=0; i<numTrees; i++)
24061 t = GetTreeFromIndex(i, chain, 0);
24062 if (t->isCalibrated == NO)
24064 UpdateTreeWithClockrate (t,*clockRatep);
24073 /*----------------------------------------------
24075 | UpdateCppEvolLength: Recursive function to
24076 | update evolLength of one node for Cpp
24077 | relaxed clock model
24079 -----------------------------------------------*/
24080 int UpdateCppEvolLength (int *nEvents, MrBFlt **pos, MrBFlt **rateMult, MrBFlt *evolLength, TreeNode *p, MrBFlt baseRate)
24088 if (baseRate < POS_MIN || baseRate > POS_INFINITY)
24090 printf ("baseRate out of bounds (%.15e for node %d\n", baseRate, p->index);
24096 if (nEvents[p->index] == 0)
24098 evolLength[p->index] = p->length * baseRate;
24102 /* note that event positions are from the top of the branch (more recent)
24103 to the bottom of the branch (older) */
24104 /* The algorithm below successively multiplies in the more basal rate multipliers,
24105 starting from the top of the branch. The length of the branch is first assumed
24106 to be 1.0; at the end we multiply the result with the true length of the branch. */
24107 evolLength[p->index] = pos[p->index][0] * rateMult[p->index][0];
24108 for (i=1; i<nEvents[p->index]; i++)
24110 evolLength[p->index] += (pos[p->index][i] - pos[p->index][i-1]);
24111 evolLength[p->index] *= rateMult[p->index][i];
24113 evolLength[p->index] += (1.0 - pos[p->index][nEvents[p->index]-1]);
24114 evolLength[p->index] *= baseRate;
24115 evolLength[p->index] *= p->length;
24118 /* calculate end rate; we can do this in any order */
24119 endRate = baseRate;
24120 for (i=0; i<nEvents[p->index]; i++)
24121 endRate *= rateMult[p->index][i];
24124 if (endRate < POS_MIN || endRate > POS_INFINITY)
24126 printf ("endRate out of bounds (%.15e for node %d)\n", endRate, p->index);
24129 if (p->anc != NULL && p->anc->anc != NULL && (evolLength[p->index] < POS_MIN || evolLength[p->index] > POS_INFINITY))
24131 printf ("Effective branch length out of bounds (%.15e for node %d)\n", evolLength[p->index], p->index);
24135 /* call left and right descendants */
24136 if (UpdateCppEvolLength (nEvents, pos, rateMult, evolLength, p->left, endRate)==ERROR)
24138 if (UpdateCppEvolLength (nEvents, pos, rateMult, evolLength, p->right, endRate)==ERROR)
24146 /*-------------------------------------------------
24148 | UpdateCppEvolLengths: Recalculate effective
24149 | evolutionary lengths and set update flags
24150 | for Cpp relaxed clock model
24152 --------------------------------------------------*/
24153 int UpdateCppEvolLengths (Param *param, TreeNode *p, int chain)
24157 MrBFlt baseRate = 1.0, **pos, **rateMult, *evolLength;
24159 i = 2*chain + state[chain];
24160 nEvents = param->nEvents[i];
24161 pos = param->position[i];
24162 rateMult = param->rateMult[i];
24163 evolLength = GetParamSubVals (param, chain, state[chain]);
24166 while (q->anc != NULL)
24168 for (i=0; i<nEvents[q->index]; i++)
24169 baseRate *= rateMult[q->index][i];
24173 if (UpdateCppEvolLength (nEvents, pos, rateMult, evolLength, p, baseRate)==ERROR)
24180 /* UpdateTK02EvolLengths: update branch lengths for tk02 model */
24181 int UpdateTK02EvolLengths (Param *param, Tree *t, int chain)
24184 MrBFlt *tk02Rate, *brlens;
24187 tk02Rate = GetParamVals (param, chain, state[chain]);
24188 brlens = GetParamSubVals (param, chain, state[chain]);
24189 for (i=0; i<t->nNodes-2; i++)
24191 p = t->allDownPass[i];
24192 brlens[p->index] = p->length * (tk02Rate[p->index] + tk02Rate[p->anc->index]) / 2.0;
24199 /* UpdateIgrBranchLengths: update branch lengths for igr model */
24200 int UpdateIgrBrachLengths (Param *param, Tree *t, int chain)
24203 MrBFlt *igrRate, *brlens;
24206 igrRate = GetParamVals (param, chain, state[chain]);
24207 brlens = GetParamSubVals (param, chain, state[chain]);
24208 for (i=0; i<t->nNodes-2; i++)
24210 p = t->allDownPass[i];
24211 brlens[p->index] = p->length * igrRate[p->index];