Exceptional brain and ecological diversity in the earliest snakes.
The 10 matches
- [1] § Methods › Phylodynamic relaxed-clock Bayesian macroevolutionary analyses ↔ src/command.c, lines 2257–2316 · score 0.72 · independent gamma rate, white noise, independent lognormal, MrBayes, clock model, autocorrelated
- [2] § Methods › Phylodynamic relaxed-clock Bayesian macroevolutionary analyses ↔ src/bayes.c, lines 819–858 · score 0.70 · standard deviation, log scale, clock tree, clock rate, lognormal, age
- [3] § Methods › Phylodynamic relaxed-clock Bayesian macroevolutionary analyses ↔ src/bayes.h, lines 1100–1181 · score 0.66 · relative extinction, fossil sampling rates, turnover, speciation, diversification, uniform
- [4] § Methods › Phylodynamic relaxed-clock Bayesian macroevolutionary analyses ↔ src/command.c, lines 1357–1416 · score 0.59 · offset exponential distribution, maximum age, minimum age, root
- [5] § Methods › Phylodynamic relaxed-clock Bayesian macroevolutionary analyses ↔ src/bayes.h, lines 1100–1181 · score 0.59 · independent lognormal, WN, Bayes, TK02, ILN, IGR
- [6] § Methods › Bayesian phylogenetic inference ↔ src/sumpt.c, lines 3316–3357 · score 0.58 · majority rule, consensus tree, split
- [7] § Methods › Bayesian phylogenetic inference ↔ src/bayes.c, lines 668–711 · score 0.57 · ascertainment bias, GTR, component, substitution, gamma, model
- [8] § Methods › Phylodynamic relaxed-clock Bayesian macroevolutionary analyses ↔ src/bayes.c, lines 819–858 · score 0.56 · fossil sampling rates, turnover, extinction, speciation, exponential, diversification
- [9] § Methods › Phylodynamic relaxed-clock Bayesian macroevolutionary analyses ↔ src/mcmc.c, lines 120–179 · score 0.51 · birth death, rho, diversity, distance, fossilized, tips
- [10] § Methods › Morphological and molecular phylogenetic data ↔ src/command.c, lines 2017–2076 · score 0.51 · amino acids, phylogenetic inference, nucleotide, protein, Molecular, evolution
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
C · 4,121 lines · 195 KB · GPL-3.0 · 3 matches
- /*
- * MrBayes 3
- *
- * (c) 2002-2023
- *
- * John P. Huelsenbeck
- * Dept. Integrative Biology
- * University of California, Berkeley
- * Berkeley, CA 94720-3140
- * [email hidden]
- *
- * Fredrik Ronquist
- * Swedish Museum of Natural History
- * Box 50007
- * SE-10405 Stockholm, SWEDEN
- * [email hidden]
- *
- * With important contributions by
- *
- * Paul van der Mark ([email hidden])
- * Maxim Teslenko ([email hidden])
- * Chi Zhang ([email hidden])
- *
- * and by many users (run 'acknowledgments' to see more info)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details (www.gnu.org).
- *
- */
- #include "bayes.h"
- #include "command.h"
- #include "mbbeagle.h"
- #include "model.h"
- #include "mcmc.h"
- #include "sumpt.h"
- #include "utils.h"
- #if defined(__MWERKS__)
- #include "SIOUX.h"
- #endif
- #define NUMCOMMANDS 62 /* The total number of commands in the program */
- #define NUMPARAMS 283 /* The total number of parameters */
- #define PARAM(i, s, f, l) p->string = s; \
- p->fp = f; \
- p->valueList = l; \
- p++;
- #define HIDE 0
- #define SHOW 1
- /* Debugging options */
- #undef SHOW_TOKENS
- #undef ECHO_PROCESSED_COMMANDS
- /* Local function prototypes */
- int AddNameSet(NameSet **nameSetList, int numNameSets, char **nameSet, int numNames);
- int AddToSet (int i, int j, int k, int id);
- int AllocCharacters (void);
- int AllocMatrix (void);
- int AllocTaxa (void);
- char ChangeCase (char c);
- int CharacterCode (char ch, int *charCode, int chType);
- int CharacterNumber (int charCode, int chType);
- int CheckInitialPartitions (void);
- int Dex (TreeNode *p);
- int DoAbout (void);
- int DoAcknowledgments (void);
- int DoBeginParm (char *parmName, char *tkn);
- int DoBreaks (void);
- int DoBreaksParm (char *parmName, char *tkn);
- int DoCalibrate (void);
- int DoCalibrateParm (char *parmName, char *tkn);
- int DoCharset (void);
- int DoCharsetParm (char *parmName, char *tkn);
- int DoCharStat (void);
- int DoCitations (void);
- int DoConstraint (void);
- int DoConstraintParm (char *parmName, char *tkn);
- int DoCtype (void);
- int DoCtypeParm (char *parmName, char *tkn);
- int DoDelete (void);
- int DoDeleteParm (char *parmName, char *tkn);
- int DoDimensions (void);
- int DoDimensionsParm (char *parmName, char *tkn);
- int DoDisclaimer (void);
- int DoEndBlock (void);
- int DoExecuteParm (char *parmName, char *tkn);
- int DoExclude (void);
- int DoExcludeParm (char *parmName, char *tkn);
- int DoFormat (void);
- int DoFormatParm (char *parmName, char *tkn);
- int DoHelp (void);
- int DoHelpParm (char *parmName, char *tkn);
- int DoInclude (void);
- int DoIncludeParm (char *parmName, char *tkn);
- int DoLog (void);
- int DoLogParm (char *parmName, char *tkn);
- int DoManual (void);
- int DoManualParm (char *parmName, char *tkn);
- int DoMatrix (void);
- int DoMatrixParm (char *parmName, char *tkn);
- int DoNexusParm (char *parmName, char *tkn);
- int DoOutgroup (void);
- int DoOutgroupParm (char *parmName, char *tkn);
- int DoPairs (void);
- int DoPairsParm (char *parmName, char *tkn);
- int DoPartition (void);
- int DoPartitionParm (char *parmName, char *tkn);
- int DoRestore (void);
- int DoRestoreParm (char *parmName, char *tkn);
- int DoSet (void);
- int DoSetParm (char *parmName, char *tkn);
- int DoShowBeagle (void);
- int DoShowMatrix (void);
- int DoShowUserTrees (void);
- int DoSpeciespartition (void);
- int DoSpeciespartitionParm (char *parmName, char *tkn);
- int DoTaxaset (void);
- int DoTaxasetParm (char *parmName, char *tkn);
- int DoTaxaStat (void);
- int DoTaxlabels (void);
- int DoTaxlabelsParm (char *parmName, char *tkn);
- int DoTranslate (void);
- int DoTranslateParm (char *parmName, char *tkn);
- int DoTree (void);
- int DoTreeParm (char *parmName, char *tkn);
- int DoUserTree (void);
- int DoUserTreeParm (char *parmName, char *tkn);
- int DoVersion (void);
- int FindValidParam (char *tk, int *numMatches);
- int FreeCharacters (void);
- int FreeMatrix (void);
- int FreeTaxa (void);
- int GetNumPartDivisions (int n);
- int GetUserHelp (char *helpTkn);
- int IsAmbig (int charCode, int dType);
- int IsMissing (int charCode, int dType);
- int MBResID (char nuc);
- int NucID (char nuc);
- void PrintSettings (char *command);
- void PrintYesNo (int yn, char s[4]);
- int ProtID (char aa);
- int SetPartition (int part);
- int SetSpeciespartition (int part);
- int SetTaxaFromTranslateTable (void);
- int StandID (char nuc);
- void WhatVariableExp (BitsLong exp, char *st);
- /* globals */
- int autoClose; /* autoclose */
- int autoOverwrite; /* Overwrite or append outputfiles when nowarnings=yes */
- Calibration *calibrationPtr; /* ptr to calibration being set */
- CharInformation *charInfo; /* holds critical information about characters */
- BitsLong **charSet; /* holds information about defined charsets */
- char **charSetNames; /* holds names of character sets */
- Comptree comptreeParams; /* holds parameters for comparetree command */
- char **constraintNames; /* holds names of constraints */
- int dataType; /* type of data */
- Calibration defaultCalibration; /* default calibration */
- BitsLong **definedConstraint; /* bitfields representing taxa sets of defined constraints */
- BitsLong **definedConstraintTwo; /* bitfields representing second taxa sets of defined constraints (used for PARTIAL constraints) */
- BitsLong **definedConstraintPruned; /* bitfields representing taxa sets of defined constraints after deleted taxa are removed */
- BitsLong **definedConstraintTwoPruned; /* bitfields representing second taxa sets of defined constraints for PARTIAL constraints after deleted*/
- /* taxa are removed and for NEGATIVE constraint it contains complements of definedConstraintPruned */
- int echoMB; /* flag used by Manual to prevent echoing */
- BitsLong expecting; /* variable denoting expected token type */
- int foundNewLine; /* whether a new line has been found */
- int inComment; /* flag for whether input stream is commented */
- int inComparetreeCommand; /* flag set whenever you enter comparetree cmd */
- int inferAncStates; /* should ancestral states be inferred (y/n) */
- int inferSiteOmegas; /* should site omegas be inferred (y/n) */
- int inferSiteRates; /* should site rates be inferred (y/n) */
- int inMrbayesBlock; /* flag for whether we are in a mrbayes block */
- int inSumtCommand; /* flag set whenever you enter sumt cmd */
- int inTreesBlock; /* flag for whether we are in a trees block */
- int inValidCommand; /* a useful flag set whenever you enter a cmd */
- int isInAmbig, isInPoly; /* flags whether we are within () or {} */
- int isTaxsetDef; /* is a taxon set defined */
- int isTranslateDef; /* is a translation block defined */
- int isTranslateDiff; /* is translate different from current taxaset? */
- char logFileName[100]; /* name of the log file */
- int logToFile; /* should screen output be logged to a file */
- FILE *logFileFp; /* file pointer to log file */
- int longIntegerSize; /* size of an unsigned integer */
- char manFileName[100]; /* name of the file for the command help info */
- int *matrix; /* matrix containing original data */
- int matrixHasPoly; /* flag for whether matrix has polymorphisms */
- int memAllocs[NUM_ALLOCS]; /* allocated memory flags */
- int mode; /* mode of program (interactive/noninteractive) */
- Calibration *nodeCalibration; /* holds information about node calibrations */
- int noWarn; /* no warnings on overwriting files */
- int numChar; /* number of characters in character matrix */
- int numCharSets; /* number of character sets */
- int numComments; /* counts how deeply nested a comment is */
- int numDefinedConstraints; /* number of constraints defined */
- int numDefinedPartitions; /* number of partitions defined */
- int numDefinedSpeciespartitions; /* number of speciespartitions defined */
- int numNamedTaxa; /* number of named taxa during parsing of cmd */
- int numOpenExeFiles; /* number of execute files open */
- int numSpecies; /* number of species in current speciespartition */
- int numTaxa; /* number of taxa in character matrix */
- int numTaxaSets; /* number of taxa sets */
- int numTranslates; /* number of taxa in active translate block */
- int outGroupNum; /* number of outgroup taxon */
- ParmInfo paramTable[NUMPARAMS]; /* information on parameters */
- char **partitionNames; /* hold names of partitions (first is "default") */
- int **partitionId; /* holds information about defined partitions */
- int partitionNum; /* index of current partition */
- Plot plotParams; /* holds parameters for plot command */
- int precision; /* precision of samples and summary stats */
- int quitOnError; /* quit on error? */
- int replaceLogFile; /* should logfile be replace/appended to */
- int scientific; /* use scientific format for samples ? */
- char spacer[10]; /* holds blanks for printing indentations */
- NameSet *speciesNameSets; /* hold species name sets, one for each speciespartition */
- int **speciespartitionId; /* holds info about defined speciespartitions */
- char **speciespartitionNames; /* hold names of speciespartitions (first is "default") */
- int speciespartitionNum; /* index of current speciespartition */
- Sump sumpParams; /* holds parameters for sump command */
- Sumt sumtParams; /* holds parameters for sumt command */
- Sumss sumssParams; /* holds parameters for sumss command */
- TaxaInformation *taxaInfo; /* holds critical information about taxa */
- char **taxaNames; /* holds name of taxa */
- BitsLong **taxaSet; /* holds information about defined taxasets */
- char **taxaSetNames; /* holds names of taxa sets */
- int *tempActiveConstraints;/* temporarily holds active constraints size allocated */
- enum ConstraintType *definedConstraintsType; /* Store type of constraint */
- int *tempSet; /* temporarily holds defined set */
- int *tempSetNeg; /* holds bitset of negative set of taxa for partial constraint*/
- int theAmbigChar; /* int containing ambiguous character */
- Calibration *tipCalibration; /* holds information about node calibrations */
- char **transFrom; /* translation block information */
- char **transTo; /* translation block information */
- int userBrlensDef; /* are the branch lengths on user tree defined */
- #if defined (BEAGLE_ENABLED)
- int tryToUseBEAGLE; /* try to use the BEAGLE library */
- int beagleScalingScheme; /* BEAGLE dynamic scaling */
- int beagleScalingFrequency;/* BEAGLE dynamic scaling frequency */
- long beagleFlags; /* BEAGLE required resource flags */
- int beagleResourceNumber; /* BEAGLE resource number */
- int *beagleResource; /* BEAGLE resource choice list */
- int beagleResourceCount; /* BEAGLE resource choice list length */
- int beagleInstanceCount; /* total number of BEAGLE instances */
- #if defined (BEAGLE_V3_ENABLED)
- int beagleThreadCount; /* max number of BEAGLE CPU threads */
- int beagleAllFloatTips; /* use floating-point representation for all tips */
- #endif
- #endif
- /* local (to this file) */
- char *tokenP, token[CMD_STRING_LENGTH], *cmdStr=NULL;
- Calibration defaultCalibration = {
- "Unconstrained", /* name */
- unconstrained, /* prior */
- { -1.0, -1.0, -1.0 }, /* priorParams */
- NULL, /* LnPriorProb */
- NULL, /* LnPriorRatio */
- -1.0, /* min */
- -1.0 /* max */
- };
- CmdType commands[] =
- {
- /* Information on commands initialization:
- 1 = Command number (cmdNumber)
- 2 = Command name (string)
- 3 = Special command (YES/NO) (specialCmd)
- 4 = Pointer to finishing function (fp)
- 5 = Number of valid parameters (numParms)
- 6 = List of valid parameters (parmList)
- 7 = Expecting (2^TokenType) (expect) (PARAMETER = 4; SEMICOLON = 32; ALPHA = 16384;
- ALPHA | QUESTIONMARK | DASH | NUMBER | ASTERISK | EXCLAMATIONMARK | PERCENT | WEIRD | SEMICOLON = 11715360;
- ALPHA | QUESTIONMARK | DASH | NUMBER | ASTERISK | EXCLAMATIONMARK | PERCENT | WEIRD | VERTICALBAR | SEMICOLON | LEFTPAR | RIGHTPAR | LEFTCURL | RIGHTCURL = 649252640;
- PARAMETER | SEMICOLON = 36; NUMBER | ALPHA = 49152; ALPHA | SEMICOLON = 16416; EQUALSIGN = 8; NUMBER = 32768)
- 8 = Description of the command (cmdDescription)
- 9 = Where should the command be used (cmdUse) (IN_CMD = used from command line or mrbayes block; IN_FILE = used in data block or in tree block)
- 10 = Should the command be shown when "help" is typed (hiding).
- #1 #2 #3 #4 #5 #6 #7 #8 #9 #10
- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
- { 0, "#", NO, NULL, 1, {0}, 4, "", IN_FILE, HIDE },
- { 1, "About", NO, DoAbout, 0, {-1}, 32, "Describes the program", IN_CMD, SHOW },
- { 2, "Acknowledgments", NO, DoAcknowledgments, 0, {-1}, 32, "Shows program acknowledgments", IN_CMD, SHOW },
- { 3, "Begin", NO, NULL, 6, {1,2,3,201,226,227}, 4, "Denotes beginning of block in file", IN_FILE, SHOW },
- { 4, "Calibrate", NO, DoCalibrate, 1, {119}, 4, "Assigns dates to terminals or interior nodes", IN_CMD, SHOW },
- { 5, "Charset", NO, DoCharset, 1, {15}, 4, "Assigns a group of sites to a set", IN_CMD, SHOW },
- { 6, "Charstat", NO, DoCharStat, 0, {-1}, 32, "Shows status of characters", IN_CMD, SHOW },
- { 7, "Citations", NO, DoCitations, 0, {-1}, 32, "Citation of program, models, and methods", IN_CMD, SHOW },
- { 8, "Comparetree", NO, DoCompareTree, 7, {127,128,129,130,221,222,223}, 36, "Compares the trees from two tree files", IN_CMD, SHOW },
- { 9, "Constraint", NO, DoConstraint, 1, {66}, 4, "Defines a constraint on tree topology", IN_CMD, SHOW },
- { 10, "Ctype", NO, DoCtype, 1, {65}, 4, "Assigns ordering for the characters", IN_CMD, SHOW },
- { 11, "Databreaks", YES, DoBreaks, 1, {93}, 32768, "Defines data breaks for autodiscrete gamma model", IN_CMD, SHOW },
- { 12, "Delete", YES, DoDelete, 1, {47}, 49152, "Deletes taxa from the analysis", IN_CMD, SHOW },
- { 13, "Dimensions", NO, DoDimensions, 2, {4,5}, 4, "Defines size of character matrix", IN_FILE, SHOW },
- { 14, "Disclaimer", NO, DoDisclaimer, 0, {-1}, 32, "Describes program disclaimer", IN_CMD, SHOW },
- { 15, "End", NO, DoEndBlock, 0, {-1}, 32, "Denotes end of a block in file", IN_FILE, SHOW },
- { 16, "Endblock", NO, DoEndBlock, 0, {-1}, 32, "Alternative way of denoting end of a block", IN_FILE, SHOW },
- { 17, "Exclude", YES, DoExclude, 1, {45}, 49152, "Excludes sites from the analysis", IN_CMD, SHOW },
- { 18, "Execute", YES, DoExecute, 1, {12}, 16384, "Executes a file", IN_CMD, SHOW },
- { 19, "Format", NO, DoFormat, 7, {6,7,8,9,10,219,220}, 4, "Defines character format in data block", IN_FILE, SHOW },
- { 20, "Help", YES, DoHelp, 1, {50}, 16416, "Provides detailed description of commands", IN_CMD, SHOW },
- { 21, "Include", YES, DoInclude, 1, {46}, 49152, "Includes sites", IN_CMD, SHOW },
- { 22, "Link", NO, DoLink, 30, {55,56,57,58,59,60,61,62,63,72,73,74,75,76,105,118,193,194,195,196,197,242,243,252,253,255,256,
- 270,273,274}, 4, "Links parameters across character partitions", IN_CMD, SHOW },
- { 23, "Log", NO, DoLog, 5, {85,86,87,88,89}, 4, "Logs screen output to a file", IN_CMD, SHOW },
- { 24, "Lset", NO, DoLset, 20, {28,29,30,31,32,33,34,40,51,52,53,90,91,131,188,189,276,277,280,282},4, "Sets the parameters of the likelihood model", IN_CMD, SHOW },
- { 25, "Manual", NO, DoManual, 1, {126}, 36, "Prints a command reference to a text file", IN_CMD, SHOW },
- { 26, "Matrix", YES, DoMatrix, 1, {11},649252640, "Defines matrix of characters in data block", IN_FILE, SHOW },
- { 27, "Mcmc", NO, DoMcmc, 46, {17,18,19,20,21,22,23,24,25,26,27,84,98,112,113,114,115,116,132,142,143,144,148,149,150,151,152,
- 153,154,155,156,157,158,159,160,166,169,190,191,198,199,200,202,213,214,215}, 36, "Starts Markov chain Monte Carlo analysis", IN_CMD, SHOW },
- { 28, "Mcmcp", NO, DoMcmcp, 46, {17,18,19,20,21,22,23,24,25,26,27,84,98,112,113,114,115,116,132,142,143,144,148,149,150,151,152,
- 153,154,155,156,157,158,159,160,166,169,190,191,198,199,200,202,213,214,215}, 4, "Sets parameters of a chain (without starting analysis)", IN_CMD, SHOW },
- { 29, "Outgroup", YES, DoOutgroup, 1, {78}, 49152, "Changes outgroup taxon", IN_CMD, SHOW },
- { 30, "Pairs", YES, DoPairs, 1, {92}, 32768, "Defines nucleotide pairs (doublets) for stem models", IN_CMD, SHOW },
- { 31, "Partition", NO, DoPartition, 1, {16}, 4, "Assigns a character partition", IN_CMD, SHOW },
- { 32, "Plot", NO, DoPlot, 6, {106,107,108,109,224,225}, 36, "Plots parameters from MCMC analysis", IN_CMD, SHOW },
- { 33, "Prset", NO, DoPrset, 44, {35,36,37,38,39,41,42,43,44,54,64,67,68,69,70,71,77,100,101,102,103,104,110,111,117,120,121,133,
- 168,172,173,174,183,184,185,218,241,246,247,251,254,269,271,272}, 4, "Sets the priors for the parameters", IN_CMD, SHOW },
- { 34, "Propset", NO, DoPropset, 1, {186}, 4, "Sets proposal probabilities and tuning parameters", IN_CMD, SHOW },
- { 35, "Quit", NO, DoQuit, 0, {-1}, 32, "Quits the program", IN_CMD, SHOW },
- { 36, "Report", NO, DoReport, 9, {122,123,124,125,134,135,136,192,217}, 4, "Controls how model parameters are reported", IN_CMD, SHOW },
- { 37, "Restore", YES, DoRestore, 1, {48}, 49152, "Restores taxa", IN_CMD, SHOW },
- { 38, "Set", NO, DoSet, 23, {13,14,94,145,170,171,179,181,182,216,229,233,234,235,236,238,239,240,245,268,275,278,279}, 4, "Sets run conditions and defines active data partition", IN_CMD, SHOW },
- { 39, "Showbeagle", NO, DoShowBeagle, 0, {-1}, 32, "Show available BEAGLE resources", IN_CMD, SHOW },
- { 40, "Showmatrix", NO, DoShowMatrix, 0, {-1}, 32, "Shows current character matrix", IN_CMD, SHOW },
- { 41, "Showmcmctrees", NO, DoShowMcmcTrees, 0, {-1}, 32, "Shows trees used in MCMC analysis", IN_CMD, SHOW },
- { 42, "Showmodel", NO, DoShowModel, 0, {-1}, 32, "Shows model settings", IN_CMD, SHOW },
- { 43, "Showmoves", NO, DoShowMoves, 1, {180}, 36, "Shows moves for current model", IN_CMD, SHOW },
- { 44, "Showparams", NO, DoShowParams, 0, {-1}, 32, "Shows parameters in current model", IN_CMD, SHOW },
- { 45, "Showusertrees", NO, DoShowUserTrees, 0, {-1}, 32, "Shows user-defined trees", IN_CMD, SHOW },
- { 46,"Speciespartition", NO,DoSpeciespartition, 1, {244}, 4, "Defines a partition of tips into species", IN_CMD, SHOW },
- { 47, "Ss", NO, DoSs, 50, {17,18,19,20,21,22,23,24,25,26,27,84,98,112,113,114,115,116,132,142,143,144,148,149,150,151,152,
- 153,154,155,156,157,158,159,160,166,169,190,191,198,199,200,202,213,214,215,248,249,250,257}, 36, "Starts stepping-stone sampling", IN_CMD, SHOW },
- { 48, "Ssp", NO, DoSsp, 50, {17,18,19,20,21,22,23,24,25,26,27,84,98,112,113,114,115,116,132,142,143,144,148,149,150,151,152,
- 153,154,155,156,157,158,159,160,166,169,190,191,198,199,200,202,213,214,215,248,249,250,257}, 36,"Sets parameters of stepping-stone analysis (without starting)",IN_CMD, SHOW },
- { 49, "Startvals", NO, DoStartvals, 1, {187}, 4, "Sets starting values of parameters", IN_CMD, SHOW },
- { 50, "Sump", NO, DoSump, 14, {96,97,137,138,139,140,141,161,162,176,178,211,212,231}, 36, "Summarizes parameters from MCMC analysis", IN_CMD, SHOW },
- { 51, "Sumss", NO, DoSumSs, 10, {258,259,260,261,262,263,264,265,266,267}, 36, "Summarizes parameters from stepping-stone analysis", IN_CMD, SHOW },
- { 52, "Sumt", NO, DoSumt, 21, {80,81,82,95,146,147,163,164,165,167,175,177,204,205,206,207,208,209,210,230,232}, 36, "Summarizes trees from MCMC analysis", IN_CMD, SHOW },
- { 53, "Taxastat", NO, DoTaxaStat, 0, {-1}, 32, "Shows status of taxa", IN_CMD, SHOW },
- { 54, "Taxset", NO, DoTaxaset, 1, {49}, 4, "Assigns a group of taxa to a set", IN_CMD, SHOW },
- { 55, "Taxlabels", YES, DoTaxlabels, 1, {228}, 49152, "Defines taxon labels", IN_FILE, SHOW },
- { 56, "Translate", YES, DoTranslate, 1, {83}, 49152, "Defines alternative names for taxa", IN_FILE, SHOW },
- { 57, "Tree", NO, DoTree, 1, {79}, 4, "Defines a tree", IN_FILE, SHOW },
- { 58, "Unlink", NO, DoUnlink, 30, {55,56,57,58,59,60,61,62,63,72,73,74,75,76,105,118,193,194,195,196,197,242,243,252,253,255,256,
- 270,273,274}, 4, "Unlinks parameters across character partitions", IN_CMD, SHOW },
- { 59, "Usertree", YES, DoUserTree, 1, {203}, 8, "Defines a single user tree", IN_CMD, HIDE },
- { 60, "Version", NO, DoVersion, 0, {-1}, 32, "Shows program version", IN_CMD, SHOW },
- { 61, "Compareref", NO, DoCompRefTree, 7, {127,128,129,130,221,222,223}, 36, "Compares the tree to the reference trees", IN_CMD, HIDE },
- /* NOTE: If you add a command here, make certain to change NUMCOMMANDS (above, in this file) appropriately! */
- { 999, NULL, NO, NULL, 0, {-1}, 32, "", IN_CMD, HIDE }
- };
- int inDataBlock, inForeignBlock, isInterleaved, isFirstMatrixRead, isFirstInterleavedBlock,
- taxonCount, fromI, toJ, everyK, foundDash, foundSlash, foundFirst, isMixed, whichPartition,
- isNegative, numDivisions, charOrdering, foundExp, foundColon, isFirstNode, nextAvailableNode,
- pairId, firstPair, inTaxaBlock, inCharactersBlock, foundEqual;
- char gapId, missingId, matchId, tempSetName[100], **tempNames;
- CmdType *commandPtr; /* Points to the commands array entry which corresponds to currently processed command */
- ParmInfoPtr paramPtr; /* Points to paramTable table array entry which corresponds to currently processed parameter of current command */
- TreeNode *pPtr, *qPtr;
- enum ConstraintType constraintType; /* Used only in processing of constraint command to indicate the type of constraint */
- int AddToGivenSet (int i, int j, int k, int id, int *Set)
- {
- int m, n;
- if (id <= 0)
- {
- MrBayesPrint ("%s The id for a temporary set should be greater than 0\n", spacer);
- return (ERROR);
- }
- if (i < 0 && j < 0)
- return (ERROR);
- else if (i < 0 && j >= 0)
- return (ERROR);
- else if (i >= 0 && j < 0)
- {
- if (k >= 0)
- return (ERROR);
- else
- {
- if (Set[i] != 0)
- {
- MrBayesPrint ("%s Character %d defined more than once\n", spacer, i+1);
- return (ERROR);
- }
- Set[i] = id;
- }
- }
- else if (i >= 0 && j >= 0)
- {
- if (k < 0)
- {
- for (m=i; m<=j; m++)
- {
- if (Set[m] != 0)
- {
- MrBayesPrint ("%s Character %d defined more than once\n", spacer, m+1);
- return (ERROR);
- }
- Set[m] = id;
- }
- }
- else
- {
- n = k;
- for (m=i; m<=j; m++)
- {
- if (n % k == 0)
- {
- if (Set[m] != 0)
- {
- MrBayesPrint ("%s Character %d defined more than once\n", spacer, m+1);
- return (ERROR);
- }
- Set[m] = id;
- }
- n++;
- }
- }
- }
- return (NO_ERROR);
- }
- int AddToSet (int i, int j, int k, int id)
- {
- return AddToGivenSet (i, j, k,id, tempSet);
- }
- /* AddNameSet: Push a name set onto the end of a list of name sets, with reallocation
- of list to hold the extra element. The calling function needs to keep track of
- the counter holding the length of the list. */
- int AddNameSet (NameSet **nameSetList, int numNameSets, char **nameSet, int numNames)
- {
- int i;
- (*nameSetList) = (NameSet*) SafeRealloc ((void*)(*nameSetList), ((size_t)numNameSets+1)*sizeof(NameSet));
- (*nameSetList)[numNameSets].names = NULL;
- (*nameSetList)[numNameSets].numNames = numNames;
- for (i=0; i<numNames; i++)
- AddString(&((*nameSetList)[numNameSets].names), i, nameSet[i]);
- return NO_ERROR;
- }
- /* AddString: Push a string onto the end of a list, with reallocation of list
- to hold the extra element. The calling function needs to keep track of
- the counter holding the length of the list. */
- int AddString (char ***list, int len, char *token)
- {
- (*list) = (char **) SafeRealloc ((void *)(*list), ((size_t)len+1)*sizeof(char*));
- if (!(*list))
- return ERROR;
- (*list)[len] = (char *) SafeCalloc ((strlen(token)+1), sizeof(char));
- if (!(*list)[len])
- return ERROR;
- strcpy ((*list)[len], token);
- return NO_ERROR;
- }
- int AllocCharacters (void)
- {
- int i, tempSetSize;
- if (memAllocs[ALLOC_MATRIX] == YES)
- goto errorExit;
- matrix = (int *) SafeMalloc((size_t)numTaxa * (size_t)numChar * sizeof(int));
- if (!matrix)
- {
- MrBayesPrint ("%s Problem allocating matrix (%d)\n", spacer, numTaxa * numChar * sizeof(int));
- goto errorExit;
- }
- for (i=0; i<numTaxa * numChar; i++)
- matrix[i] = 0;
- memAllocs[ALLOC_MATRIX] = YES;
- if (memAllocs[ALLOC_CHARINFO] == YES)
- goto errorExit;
- charInfo = (CharInformation *) SafeMalloc ((size_t)numChar * sizeof(CharInformation));
- if (!charInfo)
- {
- MrBayesPrint ("%s Problem allocating charInfo (%d)\n", spacer, numChar * sizeof(CharInformation));
- goto errorExit;
- }
- for (i=0; i<numChar; i++)
- {
- charInfo[i].isExcluded = NO;
- charInfo[i].numStates = 0;
- charInfo[i].charType = 0;
- charInfo[i].isMissAmbig = NO;
- charInfo[i].ctype = UNORD;
- charInfo[i].charId = 0;
- charInfo[i].pairsId = 0;
- charInfo[i].bigBreakAfter = NO;
- }
- memAllocs[ALLOC_CHARINFO] = YES;
- if (memAllocs[ALLOC_CHARSETS] == YES)
- goto errorExit;
- charSetNames = NULL;
- charSet = NULL;
- numCharSets = 0;
- memAllocs[ALLOC_CHARSETS] = YES; /* safe to do free */
- if (memAllocs[ALLOC_PARTITIONS] == YES)
- goto errorExit;
- partitionNames = NULL;
- partitionId = (int**) SafeMalloc ((size_t)numChar * sizeof(int*));
- for (i=0; i<numChar; i++)
- partitionId[i] = (int *) SafeMalloc (sizeof(int));
- numDefinedPartitions = 0; /* number of defined partitions */
- memAllocs[ALLOC_PARTITIONS] = YES; /* safe to do free */
- if (memAllocs[ALLOC_PARTITIONVARS] == YES)
- goto errorExit;
- numVars = NULL;
- activeParts = NULL;
- tempLinkUnlinkVec = NULL;
- tempNum = NULL;
- for (i=0; i<NUM_LINKED; i++)
- {
- linkTable[i] = NULL;
- tempLinkUnlink[i] = NULL;
- activeParams[i] = NULL;
- }
- memAllocs[ALLOC_PARTITIONVARS] = YES;
- if (memAllocs[ALLOC_TMPSET] == NO)
- goto errorExit;
- if (numChar > numTaxa)
- tempSetSize = numChar;
- else
- tempSetSize = numTaxa;
- tempSet = (int *) SafeRealloc ((void *)tempSet, (size_t)tempSetSize * sizeof(int));
- tempSetNeg = (int *) SafeRealloc ((void *)tempSetNeg, (size_t)tempSetSize * sizeof(int));
- if (!tempSet || !tempSetNeg)
- {
- MrBayesPrint ("%s Problem reallocating tempSet (%d)\n", spacer, tempSetSize * sizeof(int));
- goto errorExit;
- }
- MrBayesPrint ("%s Allocated matrix\n", spacer);
- return (NO_ERROR);
- errorExit:
- MrBayesPrint ("%s Problem allocating matrix\n", spacer);
- FreeMatrix();
- return (ERROR);
- }
- int AllocMatrix (void)
- {
- if (memAllocs[ALLOC_TAXA] == NO && AllocTaxa() == ERROR)
- return ERROR;
- else
- return (AllocCharacters());
- }
- int AllocTaxa (void)
- {
- int i;
- if (defTaxa == NO)
- {
- MrBayesPrint ("%s Number of taxa not defined\n", spacer);
- return (ERROR);
- }
- if (numTaxa == 0)
- {
- MrBayesPrint ("%s Number of taxa is 0\n", spacer);
- return (ERROR);
- }
- /* allocate space for taxa */
- if (memAllocs[ALLOC_TAXA] == YES)
- goto errorExit;
- taxaNames = NULL; /* This variable is allocated in AddString */
- taxaInfo =
- (TaxaInformation *) SafeMalloc ((size_t) numTaxa *
- sizeof (TaxaInformation));
- if (!taxaInfo)
- goto errorExit;
- tipCalibration =
- (Calibration *) SafeMalloc ((size_t) numTaxa * sizeof (Calibration));
- if (!tipCalibration)
- {
- free (taxaInfo);
- taxaInfo = NULL;
- goto errorExit;
- }
- for (i = 0; i < numTaxa; i++)
- {
- taxaInfo[i].isDeleted = NO;
- taxaInfo[i].charCount = 0;
- }
- memAllocs[ALLOC_TAXA] = YES;
- /* taxa sets */
- if (memAllocs[ALLOC_TAXASETS] == YES)
- goto errorExit;
- taxaSetNames = NULL;
- taxaSet = NULL;
- numTaxaSets = 0;
- memAllocs[ALLOC_TAXASETS] = YES; /* safe to free */
- /* species partitions; allocate space and set default species partition */
- if (memAllocs[ALLOC_SPECIESPARTITIONS] == YES)
- goto errorExit;
- speciespartitionNames = NULL;
- speciesNameSets = NULL;
- speciespartitionId =
- (int **) SafeMalloc ((size_t) numTaxa * sizeof (int *));
- for (i = 0; i < numTaxa; i++)
- {
- speciespartitionId[i] = (int *) SafeMalloc (sizeof (int));
- speciespartitionId[i][0] = i + 1; /* 1-based taxon index, do not ask me why */
- }
- numDefinedSpeciespartitions = 0; /* number of defined species partitions */
- memAllocs[ALLOC_SPECIESPARTITIONS] = YES; /* safe to do free */
- /* constraints */
- if (memAllocs[ALLOC_CONSTRAINTS] == YES)
- goto errorExit;
- constraintNames = NULL;
- definedConstraintsType = NULL;
- definedConstraint = NULL;
- definedConstraintTwo = NULL;
- definedConstraintPruned = NULL;
- definedConstraintTwoPruned = NULL;
- numDefinedConstraints = 0;
- tempActiveConstraints = NULL;
- memAllocs[ALLOC_CONSTRAINTS] = YES; /* safe to free */
- /* translate table */
- transFrom = NULL;
- transTo = NULL;
- numTranslates = 0;
- /* tempSet */
- if (memAllocs[ALLOC_TMPSET] == YES)
- goto errorExit;
- tempSet = (int *) SafeMalloc ((size_t) numTaxa * sizeof (int));
- tempSetNeg = (int *) SafeMalloc ((size_t) numTaxa * sizeof (int));
- if (!tempSet || !tempSetNeg)
- goto errorExit;
- memAllocs[ALLOC_TMPSET] = YES;
- /* make sure previous user trees are freed */
- if (numUserTrees > 0)
- {
- MrBayesPrint ("%s Previous user trees not freed\n", spacer);
- goto errorExit;
- }
- MrBayesPrint ("%s Allocated taxon set\n", spacer);
- return NO_ERROR;
- errorExit:
- MrBayesPrint ("%s Problem allocating taxon set\n", spacer);
- FreeTaxa();
- return ERROR;
- }
- char ChangeCase (char c)
- {
- int x;
- x = tolower(c);
- return (x);
- }
- int CharacterCode (char ch, int *charCode, int chType)
- {
- if (chType == DNA || chType == RNA)
- {
- if ((*charCode = NucID (ch)) == -1)
- {
- MrBayesPrint ("%s Unrecognized DNA/RNA character '%c'\n", spacer, ch);
- return (ERROR);
- }
- }
- else if (chType == PROTEIN)
- {
- if ((*charCode = ProtID (ch)) == -1)
- {
- MrBayesPrint ("%s Unrecognized Protein character '%c'\n", spacer, ch);
- return (ERROR);
- }
- }
- else if (chType == RESTRICTION)
- {
- if ((*charCode = MBResID (ch)) == -1)
- {
- MrBayesPrint ("%s Unrecognized Restriction character '%c'\n", spacer, ch);
- return (ERROR);
- }
- }
- else if (chType == STANDARD)
- {
- if ((*charCode = StandID (ch)) == -1)
- {
- MrBayesPrint ("%s Unrecognized Standard character '%c'\n", spacer, ch);
- return (ERROR);
- }
- }
- else if (chType == CONTINUOUS)
- {
- MrBayesPrint ("%s CharacterCode function cannot check continuous characters\n", spacer);
- }
- else
- {
- MrBayesPrint ("%s Unrecognized character type (%d)\n", spacer, chType);
- return (ERROR);
- }
- return (NO_ERROR);
- }
- int CharacterNumber (int charCode, int chType)
- {
- int i, x = charCode;
- if (chType == CONTINUOUS)
- return 0;
- for (i=0; x!=0; i++)
- x >>= 1;
- return (i);
- }
- int CheckInitialPartitions (void)
- {
- int i;
- for (i=0; i<numChar; i++)
- {
- if (partitionId[i][0] <= 0 || partitionId[i][0] > numDivisions)
- {
- MrBayesPrint ("%s The partition for site %d is incorrect\n", spacer, i+1);
- return (ERROR);
- }
- }
- return (NO_ERROR);
- }
- int CheckStringValidity (char *s)
- {
- int i, numUnknownChars, tempNumComments, tempInComment;
- char temp[100];
- i = 0;
- numUnknownChars = 0;
- tempNumComments = numComments;
- tempInComment = inComment;
- while (s[i] != '\0')
- {
- if (tempInComment == NO)
- {
- if (!IsIn(s[i],"=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789.;:,#()[]?-*/'\\'!%\"&~+^$@|{}`>< "))
- {
- if (IsWhite(s[i]) == 1 || IsWhite(s[i]) == 2)
- {
- }
- else
- {
- if (commandPtr == NULL)
- return (ERROR);
- MrBayesPrint ("%s Unknown character \"%c\" (ASCII code %d)\n", spacer, s[i], s[i]);
- if (!strcmp(commandPtr->string,"Matrix"))
- {
- if (foundNewLine == NO)
- {
- MrBayesPrint ("%s The error is in character %d for taxon %s\n", spacer, taxaInfo[taxonCount-1].charCount+i+1, "???"); /* bug? */
- }
- else
- {
- if (taxonCount == 0)
- MrBayesPrint ("%s The error is in the first taxon name\n", spacer);
- else
- {
- strcpy(temp, taxaNames[taxonCount]);
- if (isInterleaved == NO)
- MrBayesPrint ("%s The error is in the name of the taxon following taxon %s\n", spacer, temp);
- else
- {
- MrBayesPrint ("%s The error is in the name of the taxon following taxon %s\n", spacer, temp);
- MrBayesPrint ("%s in one of the interleaved data blocks\n", spacer);
- }
- }
- }
- }
- else if (!strcmp(commandPtr->string,"Execute"))
- {
- MrBayesPrint ("%s Assuming irrelevant characters at beginning of file; processing continues\n", spacer);
- return (NO_ERROR);
- }
- return (ERROR);
- }
- }
- if (s[i]=='[')
- {
- tempInComment = YES;
- tempNumComments++;
- }
- }
- else if (tempInComment == YES)
- {
- if (s[i]==']')
- {
- tempNumComments--;
- if (tempNumComments == 0)
- tempInComment = NO;
- }
- }
- i++;
- }
- if (numUnknownChars > 0)
- return (ERROR);
- else
- return (NO_ERROR);
- }
- /* CheckString: This function simply checks a vector of strings for a match against token.
- Upon return, matchIndex contains the index of the matched string. An
- ERROR is returned if there are no matches. */
- int CheckString (char **list, int len, char *token, int *matchIndex)
- {
- int i;
- *matchIndex = -1;
- for (i=0; i<len; i++)
- {
- if (StrCmpCaseInsensitive(token,list[i]) == 0)
- {
- *matchIndex = i;
- return (NO_ERROR);
- }
- }
- return (ERROR);
- }
- int Dex (TreeNode *p)
- {
- return (p == NULL) ? -1 : p->index;
- }
- int DoAbout (void)
- {
- MrBayesPrint (" --------------------------------------------------------------------------- \n");
- MrBayesPrint (" About the program \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" MrBayes is a program for the Bayesian estimation of phylogeny. Bayesian \n");
- MrBayesPrint (" inference of phylogeny is based upon the posterior probability distribution \n");
- MrBayesPrint (" of trees. Trees are labelled T1, T2, ..., Tn, where n is the number of \n");
- MrBayesPrint (" possible trees. The posterior probability of the i-th tree is calculated \n");
- MrBayesPrint (" using Bayes\'s formula as \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Pr[Ti | X] = Pr[X | Ti] X Pr[Ti] / Pr[X] \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" where X is a character matrix. Here, \"Pr[Ti | X]\" is the posterior \n");
- MrBayesPrint (" probability of the i-th tree, \"Pr[X | Ti]\" is the likelihood of the \n");
- MrBayesPrint (" i-th tree, and \"Pr[Ti]\" is the prior probability of the i-th tree. The \n");
- MrBayesPrint (" denominator of Bayes\'s formula (\"Pr[X]\") is a normalizing constant that \n");
- MrBayesPrint (" involves a summation over all possible trees. The likelihood, as described \n");
- MrBayesPrint (" above, cannot be calculated with knowledge of only the tree\'s topology. You \n");
- MrBayesPrint (" also need to have information on the lengths of the branches and on the \n");
- MrBayesPrint (" mechanism of character change. Hence, the likelihood (\"Pr[X | Ti]\") \n");
- MrBayesPrint (" involves a multidimensional integral over all possible combinations of \n");
- MrBayesPrint (" branch lengths and substitution model parameters. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" In practice, it is impossible to calculate the posterior probability dist- \n");
- MrBayesPrint (" ribution of trees analytically. Instead, the posterior probability \n");
- MrBayesPrint (" of trees must be approximated. MrBayes uses a method called Markov chain \n");
- MrBayesPrint (" Monte Carlo (MCMC) to approximate the posterior probability of trees. \n");
- MrBayesPrint (" The object of MCMC is to construct a Markov chain that has as its state \n");
- MrBayesPrint (" space the parameters of the phylogenetic model and a stationary distribution \n");
- MrBayesPrint (" that is the posterior probability distribution of trees. MCMC takes valid, \n");
- MrBayesPrint (" albeit dependent, samples from the posterior probability distribution of \n");
- MrBayesPrint (" trees. The fraction of the time any tree appears in this sample is a \n");
- MrBayesPrint (" valid approximation of the posterior probability of the tree. MrBayes keeps \n");
- MrBayesPrint (" track of all the parameters of the phylogenetic model. The trees (with branch \n");
- MrBayesPrint (" lengths) that were sampled by the MCMC procedure are saved in one file \n");
- MrBayesPrint (" (a file with a \".t\" extension) whereas the parameters of the model of \n");
- MrBayesPrint (" character change are saved in another file (a file with a \".p\" ext- \n");
- MrBayesPrint (" ension). You can summarize the results in the \".t\" and \".p\" files \n");
- MrBayesPrint (" using the \"sumt\" and \"sump\" commands, respectively. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" MrBayes was originally written by John Huelsenbeck in August of 2000 and was \n");
- MrBayesPrint (" intended to be distributed to a small number of people. In March of 2001, \n");
- MrBayesPrint (" Fredrik Ronquist started making contributions to the program. The contribu- \n");
- MrBayesPrint (" tions were of such a significant nature that he was made a coauthor of the \n");
- MrBayesPrint (" program. Version 3 of MrBayes was a fully joint effort, started in the summer \n");
- MrBayesPrint (" of 2002 when JPH visited Sweden on a grant from the Wenner-Gren Foundations. \n");
- MrBayesPrint (" Several others have contributed to the MrBayes code since then, most notably \n");
- MrBayesPrint (" Paul van der Mark, Maxim Teslenko and Chi Zhang, all postdocs/programmers in \n");
- MrBayesPrint (" Fredrik's lab. A large number of users and students, too many to list here, \n");
- MrBayesPrint (" have also contributed importantly to the project (type 'Acknowledgments' for \n");
- MrBayesPrint (" a list of some of them). \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" From 2003, MrBayes was distributed from SourceForge; the repository was moved \n");
- MrBayesPrint (" to GitHub in 2018, when the project entered maintenance phase and the res- \n");
- MrBayesPrint (" ponsibility was transferred to National Bioinformatics Infrastructure Sweden \n");
- MrBayesPrint (" (https://nbis.se), where Andreas Kahari and Johan Nylander jointly take care \n");
- MrBayesPrint (" of bug fixes, documentation updates, and other maintenance tasks. \n");
- MrBayesPrint (" --------------------------------------------------------------------------- \n");
- return (NO_ERROR);
- }
- int DoAcknowledgments (void)
- {
- MrBayesPrint (" --------------------------------------------------------------------------- \n");
- MrBayesPrint (" Acknowledgments \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" JPH and FR would like to thank Gautam Altekar, Andrea Betancourt, Jon \n");
- MrBayesPrint (" Bollback, Barry Hall, Jimmy McGuire, Rasmus Nielsen, David Swofford, \n");
- MrBayesPrint (" Johan Nylander, Mikael Thollesson, and Derrick Zwickl for help during the \n");
- MrBayesPrint (" initial development of this program. Gautam Altekar, especially, was instru- \n");
- MrBayesPrint (" mental in getting the parallel version of the program working. Important bug- \n");
- MrBayesPrint (" fixes and additional functionality was contributed by Clemens Lakner, Sebas- \n");
- MrBayesPrint (" tian Hoehna, Paul Lewis, Mark Holder, Julian Catchen and Bret Larget. Marc \n");
- MrBayesPrint (" Suchard, Daniel Ayres and Aaron Darling got MrBayes working with beagle and \n");
- MrBayesPrint (" contributed a lot of related functionality and bug fixes. Aaron Darling was \n");
- MrBayesPrint (" instrumental in getting the Windows installer set up. Liu Liang and Dennis \n");
- MrBayesPrint (" Pearl helped integrate MrBayes with BEST. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Bug fixes and user support was provided by Paul van der Mark (2005-2007), \n");
- MrBayesPrint (" Maxim Teslenko (2010-2012) and Chi Zhang (2012-2015). From 2015, Andreas \n");
- MrBayesPrint (" Kahari and Johan Nylander at the National Bioinformatics Infrastructure \n");
- MrBayesPrint (" Sweden (NBIS; https://nbis.se) have been responsible for bug fixes and \n");
- MrBayesPrint (" maintenance of the code base. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Our wives -- Edna Huelsenbeck and Eva Ronquist -- showed extraordinary \n");
- MrBayesPrint (" patience with us while we spent many late nights programming. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" JPH was supported by NSF grants DEB-007540 and MCB-0075404 and a Wenner- \n");
- MrBayesPrint (" Gren scholarship while writing this program. FR was supported by grants \n");
- MrBayesPrint (" from the Swedish Natural Science Research Council and the Swedish Research \n");
- MrBayesPrint (" Council, which also supports NBIS work on MrBayes. \n");
- MrBayesPrint (" --------------------------------------------------------------------------- \n");
- return (NO_ERROR);
- }
- int DoBeginParm (char *parmName, char *tkn)
- {
- if (expecting == Expecting(PARAMETER))
- {
- /* set Data (inDataBlock) *************************************************************/
- if (!strcmp(parmName, "Data"))
- {
- if (FreeModel () == ERROR)
- return (ERROR);
- if (FreeMatrix () == ERROR)
- return (ERROR);
- MrBayesPrint (" Reading data block\n");
- inDataBlock = YES;
- expecting = Expecting(SEMICOLON);
- strcpy (spacer, " ");
- }
- /* set Characters (inCharactersBlock) *************************************************************/
- else if (!strcmp(parmName, "Characters"))
- {
- if (FreeModel () == ERROR)
- return (ERROR);
- if (FreeCharacters () == ERROR)
- return (ERROR);
- MrBayesPrint (" Reading characters block\n");
- inCharactersBlock = YES;
- expecting = Expecting(SEMICOLON);
- strcpy (spacer, " ");
- }
- /* set Taxa (inTaxaBlock) *************************************************************/
- else if (!strcmp(parmName, "Taxa"))
- {
- if (FreeModel () == ERROR)
- return (ERROR);
- if (FreeMatrix () == ERROR)
- return (ERROR);
- MrBayesPrint (" Reading taxa block\n");
- inTaxaBlock = YES;
- expecting = Expecting(SEMICOLON);
- strcpy (spacer, " ");
- }
- /* set Mrbayes (inMrbayesBlock) *******************************************************/
- else if (!strcmp(parmName, "Mrbayes"))
- {
- MrBayesPrint (" Reading mrbayes block\n");
- inMrbayesBlock = YES;
- expecting = Expecting(SEMICOLON);
- strcpy (spacer, " ");
- }
- /* set Trees (inTreesBlock) *******************************************************/
- else if (!strcmp(parmName, "Trees"))
- {
- MrBayesPrint (" Reading trees block\n");
- inTreesBlock = YES;
- expecting = Expecting(SEMICOLON);
- strcpy (spacer, " ");
- }
- /* set Foreign (inForeignBlock) *******************************************************/
- else
- {
- MrBayesPrint (" Skipping \"%s\" block\n", tkn);
- inForeignBlock = YES;
- expecting = Expecting(SEMICOLON);
- strcpy (spacer, "");
- }
- }
- else
- return (ERROR);
- return (NO_ERROR);
- }
- int DoBreaks (void)
- {
- int i, numBreaks;
- numBreaks = 0;
- for (i=0; i<numChar; i++)
- {
- if (charInfo[i].bigBreakAfter == YES)
- {
- numBreaks++;
- }
- }
- if (numBreaks > 0)
- {
- if (numBreaks == 1)
- MrBayesPrint ("%s One data break found after character ", spacer, numBreaks);
- else
- MrBayesPrint ("%s %d data breaks found after characters: ", spacer, numBreaks);
- for (i=0; i<numChar; i++)
- {
- if (charInfo[i].bigBreakAfter == YES)
- {
- MrBayesPrint ("%d ", i+1);
- }
- }
- MrBayesPrint ("\n");
- if (numBreaks == 1)
- MrBayesPrint ("%s Successfully defined one break in data\n", spacer);
- else
- MrBayesPrint ("%s Successfully defined %d breaks in data\n", spacer, numBreaks);
- }
- else
- {
- MrBayesPrint ("%s No breaks in data found\n", spacer);
- }
- return (NO_ERROR);
- }
- int DoBreaksParm (char *parmName, char *tkn)
- {
- int i, tempInt;
- if (defMatrix == NO)
- {
- MrBayesPrint ("%s A matrix must be specified before you can define breaks in the data\n", spacer);
- return (ERROR);
- }
- if (expecting == Expecting(NUMBER))
- {
- sscanf (tkn, "%d", &tempInt);
- if (tempInt <= 0 || tempInt > numChar)
- {
- MrBayesPrint ("%s Character number %d is out of range (should be between %d and %d)\n", spacer, tempInt, 1, numChar);
- for (i=0; i<numChar; i++)
- charInfo[i].bigBreakAfter = NO;
- return (ERROR);
- }
- if (tempInt == numChar)
- {
- MrBayesPrint ("%s Character number %d is the last character. MrBayes will define the\n", spacer, tempInt);
- MrBayesPrint ("%s break, even though it doesn't make too much sense.\n", spacer);
- }
- tempInt--;
- charInfo[tempInt].bigBreakAfter = YES;
- expecting = (Expecting(NUMBER) | Expecting(SEMICOLON));
- }
- else
- {
- for (i=0; i<numChar; i++)
- charInfo[i].bigBreakAfter = NO;
- return (ERROR);
- }
- return (NO_ERROR);
- }
- int DoCalibrate (void)
- {
- int i;
- /* show calibration times (for debugging) */
- # if 0
- MrBayesPrint ("Taxon ages\n");
- for (i=0; i<numTaxa; i++)
- MrBayesPrint ("%4d -- %s\n", i+1, tipCalibration[i].name);
- MrBayesPrint ("Constraint ages\n");
- for (i=0; i<numDefinedConstraints; i++)
- {
- if (definedConstraintsType[i] != HARD)
- continue;
- MrBayesPrint ("%4d -- %s\n", i+1, nodeCalibration[i].name);
- }
- # endif
- /* Update model if calibrations enforced */
- for (i=0; i<numCurrentDivisions; i++)
- {
- if (!strcmp(modelParams[i].nodeAgePr,"Calibrated"))
- {
- if (SetUpAnalysis (&globalSeed) == ERROR)
- return (ERROR);
- break;
- }
- }
- return (NO_ERROR);
- }
- int DoCalibrateParm (char *parmName, char *tkn)
- {
- static int isTaxon, paramIndex;
- static char nodeName[100], calName[100];
- static MrBFlt priorParams[3];
- static enum CALPRIOR calPrior;
- int howMany, index;
- char s[20], tempStr[100];
- MrBFlt tempD;
- if (defMatrix == NO)
- {
- MrBayesPrint ("%s A matrix must be specified before you can calibrate nodes\n", spacer);
- return (ERROR);
- }
- if (expecting == Expecting(PARAMETER))
- {
- if (strcmp(parmName, "Xxxxxxxxxx") != 0)
- {
- MrBayesPrint ("%s Unexpected error - Wrong parmName in DoCalibrateParm\n", spacer);
- return (ERROR);
- }
- /* find taxon with this name */
- calibrationPtr = NULL;
- howMany = 0;
- /* first look in constraint names */
- if (CheckString (constraintNames, numDefinedConstraints, tkn, &index) != ERROR && definedConstraintsType[index] == HARD)
- {
- calibrationPtr = &nodeCalibration[index];
- howMany++;
- isTaxon = NO;
- strcpy (nodeName, tkn);
- }
- /* then look in terminal taxon names */
- if (CheckString (taxaNames, numTaxa, tkn, &index) != ERROR)
- {
- calibrationPtr = &tipCalibration[index];
- howMany++;
- isTaxon = YES;
- strcpy (nodeName, tkn);
- }
- /* return error if not found or ambiguous */
- if (howMany == 0)
- {
- MrBayesPrint ("%s No taxon or hard constraint named ""%s"" found. Note that only hard constraint can be calibrated.\n", spacer, tkn);
- return (ERROR);
- }
- else if (howMany > 1)
- {
- MrBayesPrint ("%s Both a taxon and a constraint named ""%s"" encountered -- please rename one\n", spacer, tkn);
- return (ERROR);
- }
- /* get ready to find the equal sign */
- expecting = Expecting(EQUALSIGN);
- }
- else if (expecting == Expecting(EQUALSIGN))
- {
- /* get ready to find the calibration prior */
- expecting = Expecting(ALPHA);
- }
- else if (expecting == Expecting(ALPHA))
- {
- /* set the calibration prior type */
- if (IsArgValid(tkn,tempStr) == NO_ERROR)
- {
- if (!strcmp (tempStr, "Unconstrained"))
- calPrior = unconstrained;
- else if (!strcmp (tempStr, "Fixed"))
- calPrior = fixed;
- else if (!strcmp (tempStr, "Uniform"))
- calPrior = uniform;
- else if (!strcmp (tempStr, "Offsetexponential"))
- calPrior = offsetExponential;
- else if (!strcmp (tempStr, "Truncatednormal"))
- calPrior = truncatedNormal;
- else if (!strcmp (tempStr, "Lognormal"))
- calPrior = logNormal;
- else if (!strcmp (tempStr, "Offsetlognormal"))
- calPrior = offsetLogNormal;
- else if (!strcmp (tempStr, "Gamma"))
- calPrior = standardGamma;
- else if (!strcmp (tempStr, "Offsetgamma"))
- calPrior = offsetGamma;
- if (calPrior == unconstrained)
- {
- /* reset the values of the calibration */
- MrBayesPrint ("%s Resetting previous calibration for ""%s""\n", spacer, nodeName);
- calibrationPtr->prior = defaultCalibration.prior;
- calibrationPtr->priorParams[0] = defaultCalibration.priorParams[0];
- calibrationPtr->priorParams[1] = defaultCalibration.priorParams[1];
- calibrationPtr->priorParams[2] = defaultCalibration.priorParams[2];
- calibrationPtr->LnPriorProb = defaultCalibration.LnPriorProb;
- calibrationPtr->LnPriorRatio = defaultCalibration.LnPriorRatio;
- calibrationPtr->min = defaultCalibration.min;
- calibrationPtr->max = defaultCalibration.max;
- strcpy(calibrationPtr->name, defaultCalibration.name);
- expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
- }
- else
- {
- strcpy (calName, tempStr);
- paramIndex = 0;
- priorParams[0] = priorParams[1] = priorParams[2] = -1.0;
- expecting = Expecting(LEFTPAR);
- }
- }
- else
- {
- MrBayesPrint ("%s Invalid calibration prior argument \n", spacer);
- return (ERROR);
- }
- }
- else if (expecting == Expecting(LEFTPAR))
- {
- strcat (calName, "(");
- expecting = Expecting(NUMBER);
- }
- else if (expecting == Expecting(NUMBER))
- {
- sscanf (tkn, "%lf", &tempD);
- if (paramIndex == 0)
- {
- if (calPrior == logNormal)
- {
- if (tempD < 0.0)
- {
- MrBayesPrint ("%s Mean age must be nonnegative\n", spacer);
- MrBayesPrint ("%s Parameters of the lognormal distribution used for dating are mean age\n", spacer);
- MrBayesPrint ("%s and standard deviation, both specified on the linear scale, not as log values.\n", spacer);
- return (ERROR);
- }
- }
- else if (calPrior == standardGamma)
- {
- if (tempD <= 0.0)
- {
- MrBayesPrint ("%s Mean parameter must be positive\n", spacer);
- MrBayesPrint ("%s Parameters of the gamma distribution used for dating are mean age and\n", spacer);
- MrBayesPrint ("%s standard deviation. In terms of the common shape (alpha) and rate (beta)\n", spacer);
- MrBayesPrint ("%s parameterization, the expected mean is alpha/beta and the standard\n", spacer);
- MrBayesPrint ("%s deviation is the square root of (alpha / beta^2).\n", spacer);
- return (ERROR);
- }
- }
- else if (tempD < 0.0)
- {
- if (calPrior == fixed)
- MrBayesPrint ("%s Fixed age must be nonnegative\n", spacer);
- else if (calPrior == uniform)
- {
- MrBayesPrint ("%s Minimum age must be nonnegative\n", spacer);
- MrBayesPrint ("%s Parameters of the uniform are minimum age and maximum age.\n", spacer);
- }
- else if (calPrior == truncatedNormal)
- {
- MrBayesPrint ("%s Offset (minimum or truncation) age must be nonnegative.\n", spacer);
- MrBayesPrint ("%s Parameters of the truncated normal distribution are offset (minimum\n", spacer);
- MrBayesPrint ("%s or truncation) age, mean age and standard deviation.\n", spacer);
- }
- else if (calPrior == offsetGamma)
- {
- MrBayesPrint ("%s Offset age must be nonnegative\n", spacer);
- MrBayesPrint ("%s Parameters of the offset gamma distribution used for dating are offset age,\n", spacer);
- MrBayesPrint ("%s mean age, and standard deviation. In terms of the common shape (alpha) and\n", spacer);
- MrBayesPrint ("%s rate (beta) parameterization, the expected mean is alpha/beta and the standard\n", spacer);
- MrBayesPrint ("%s deviation is the square root of (alpha / beta^2).\n", spacer);
- }
- else if (calPrior == offsetExponential)
- {
- MrBayesPrint ("%s Offset age must be nonnegative\n", spacer);
- MrBayesPrint ("%s Parameters of the offset exponential are offset age and mean age.\n", spacer);
- }
- else if (calPrior == offsetLogNormal)
- {
- MrBayesPrint ("%s Offset age must be nonnegative\n", spacer);
- MrBayesPrint ("%s Parameters of the offset lognormal distribution are offset age, mean age,\n", spacer);
- MrBayesPrint ("%s and standard deviation. All values are specified on the linear scale, not\n", spacer);
- MrBayesPrint ("%s as log values.\n", spacer);
- }
- return (ERROR);
- }
- priorParams[0] = tempD;
- if (calPrior == fixed)
- expecting = Expecting(RIGHTPAR);
- else
- expecting = Expecting(COMMA);
- }
- else if (paramIndex == 1)
- {
- if (calPrior == uniform)
- {
- if (tempD <= priorParams[0])
- {
- MrBayesPrint ("%s Maximum age of uniform distribution must be larger than minimum age\n", spacer);
- return (ERROR);
- }
- }
- else if (calPrior == offsetExponential)
- {
- if (tempD <= priorParams[0])
- {
- MrBayesPrint ("%s Mean age must be larger than offset age.\n", spacer);
- MrBayesPrint ("%s MrBayes now uses offset and mean rather than offset and rate\n", spacer);
- MrBayesPrint ("%s as the parameters for the offset exponential distribution.\n", spacer);
- return (ERROR);
- }
- }
- else if (calPrior == truncatedNormal)
- {
- if (tempD <= priorParams[0])
- {
- MrBayesPrint ("%s Mean age must be larger than offset (truncation) age.\n", spacer);
- MrBayesPrint ("%s Parameters of the truncated normal distribution are offset (minimum\n", spacer);
- MrBayesPrint ("%s or truncation) age, mean age and standard deviation\n", spacer);
- return (ERROR);
- }
- }
- else if (calPrior == logNormal)
- {
- if (tempD <= 0.0)
- {
- MrBayesPrint ("%s Standard deviation must be positive.\n", spacer);
- MrBayesPrint ("%s Parameters of the lognormal distribution used for dating are mean age\n", spacer);
- MrBayesPrint ("%s and standard deviation, both specified on the linear scale, not as log values.\n", spacer);
- return (ERROR);
- }
- }
- else if (calPrior == offsetLogNormal)
- {
- if (tempD <= priorParams[0])
- {
- MrBayesPrint ("%s Mean age must be larger than offset age.\n", spacer);
- MrBayesPrint ("%s Parameters of the offset lognormal distribution are offset age, mean age,\n", spacer);
- MrBayesPrint ("%s and standard deviation. All values are specified on the linear scale, not\n", spacer);
- MrBayesPrint ("%s as log values.\n", spacer);
- return (ERROR);
- }
- }
- else if (calPrior == standardGamma)
- {
- if (tempD <= 0.0)
- {
- MrBayesPrint ("%s Standard deviation must be positive.\n", spacer);
- MrBayesPrint ("%s Parameters of the gamma distribution used for dating are mean age and\n", spacer);
- MrBayesPrint ("%s standard deviation. In terms of the common shape (alpha) and rate (beta)\n", spacer);
- MrBayesPrint ("%s parameterization, the expected mean is alpha/beta and the standard\n", spacer);
- MrBayesPrint ("%s deviation is the square root of (alpha / beta^2).\n", spacer);
- return (ERROR);
- }
- }
- else if (calPrior == offsetGamma)
- {
- if (tempD <= 0.0)
- {
- MrBayesPrint ("%s Mean age must be positive.\n", spacer);
- MrBayesPrint ("%s Parameters of the offset gamma distribution used for dating are offset age,\n", spacer);
- MrBayesPrint ("%s mean age, and standard deviation. In terms of the common shape (alpha) and\n", spacer);
- MrBayesPrint ("%s rate (beta) parameterization, the expected mean is alpha/beta and the standard\n", spacer);
- MrBayesPrint ("%s deviation is the square root of (alpha / beta^2).\n", spacer);
- return (ERROR);
- }
- }
- priorParams[1] = tempD;
- if (calPrior == uniform || calPrior == standardGamma || calPrior == logNormal || calPrior == offsetExponential)
- expecting = Expecting(RIGHTPAR);
- else
- expecting = Expecting(COMMA);
- }
- else /* if (paramIndex == 2) */
- {
- if (calPrior == offsetGamma)
- {
- if (tempD <= 0.0)
- {
- MrBayesPrint ("%s Standard deviation must be positive.\n", spacer);
- MrBayesPrint ("%s Parameters of the offset gamma distribution used for dating are offset age,\n", spacer);
- MrBayesPrint ("%s mean age, and standard deviation. In terms of the common shape (alpha) and\n", spacer);
- MrBayesPrint ("%s rate (beta) parameterization, the expected mean is alpha/beta and the standard\n", spacer);
- MrBayesPrint ("%s deviation is the square root of (alpha / beta^2).\n", spacer);
- return (ERROR);
- }
- }
- else if (calPrior == offsetLogNormal)
- {
- if (tempD <= 0.0)
- {
- MrBayesPrint ("%s Standard deviation must be positive.\n", spacer);
- MrBayesPrint ("%s Parameters of the offset lognormal distribution are offset age, mean age,\n", spacer);
- MrBayesPrint ("%s and standard deviation. All values are specified on the linear scale, not\n", spacer);
- MrBayesPrint ("%s as log values.\n", spacer);
- return (ERROR);
- }
- }
- priorParams[2] = tempD;
- expecting = Expecting(RIGHTPAR);
- }
- sprintf (s, "%1.2lf", tempD);
- strcat (calName, s);
- }
- else if (expecting == Expecting(COMMA))
- {
- strcat (calName, ",");
- paramIndex++;
- expecting = Expecting(NUMBER);
- }
- else if (expecting == Expecting(RIGHTPAR))
- {
- strcat (calName, ")");
- if (isTaxon == YES)
- MrBayesPrint ("%s Setting age of taxon '%s' to %s\n", spacer, nodeName, calName);
- else
- MrBayesPrint ("%s Setting age of constraint node '%s' to %s\n", spacer, nodeName, calName);
- /* set calibration based on collected values and settings */
- strcpy(calibrationPtr->name, calName);
- calibrationPtr->priorParams[0] = priorParams[0];
- calibrationPtr->priorParams[1] = priorParams[1];
- calibrationPtr->priorParams[2] = priorParams[2];
- calibrationPtr->prior = calPrior;
- if (calPrior == fixed)
- {
- calibrationPtr->LnPriorProb = &LnPriorProbFix;
- calibrationPtr->LnPriorRatio = &LnProbRatioFix;
- calibrationPtr->min = priorParams[0];
- calibrationPtr->max = priorParams[0];
- }
- else if (calPrior == uniform)
- {
- calibrationPtr->LnPriorProb = &LnPriorProbUniform;
- calibrationPtr->LnPriorRatio = &LnProbRatioUniform;
- calibrationPtr->min = priorParams[0];
- calibrationPtr->max = priorParams[1];
- }
- else if (calPrior == offsetExponential)
- {
- calibrationPtr->LnPriorProb = &LnPriorProbOffsetExponential_Param_Offset_Mean;
- calibrationPtr->LnPriorRatio = &LnProbRatioOffsetExponential_Param_Offset_Mean;
- calibrationPtr->min = priorParams[0];
- calibrationPtr->max = POS_INFINITY;
- }
- else if (calPrior == truncatedNormal)
- {
- calibrationPtr->LnPriorProb = &LnPriorProbTruncatedNormal_Param_Trunc_Mean_Sd;
- calibrationPtr->LnPriorRatio = &LnProbRatioTruncatedNormal_Param_Trunc_Mean_Sd;
- calibrationPtr->min = priorParams[0];
- calibrationPtr->max = POS_INFINITY;
- }
- else if (calPrior == logNormal)
- {
- calibrationPtr->LnPriorProb = &LnPriorProbLognormal_Param_Mean_Sd;
- calibrationPtr->LnPriorRatio = &LnProbRatioLognormal_Param_Mean_Sd;
- calibrationPtr->min = BRLENS_MIN;
- calibrationPtr->max = POS_INFINITY;
- }
- else if (calPrior == offsetLogNormal)
- {
- calibrationPtr->LnPriorProb = &LnPriorProbOffsetLognormal_Param_Offset_Mean_Sd;
- calibrationPtr->LnPriorRatio = &LnProbRatioOffsetLognormal_Param_Offset_Mean_Sd;
- calibrationPtr->min = BRLENS_MIN + priorParams[0];
- calibrationPtr->max = POS_INFINITY;
- }
- else if (calPrior == standardGamma)
- {
- calibrationPtr->LnPriorProb = &LnPriorProbGamma_Param_Mean_Sd;
- calibrationPtr->LnPriorRatio = &LnProbRatioGamma_Param_Mean_Sd;
- calibrationPtr->min = BRLENS_MIN;
- calibrationPtr->max = POS_INFINITY;
- }
- else if (calPrior == offsetGamma)
- {
- calibrationPtr->LnPriorProb = &LnPriorProbOffsetGamma_Param_Offset_Mean_Sd;
- calibrationPtr->LnPriorRatio = &LnProbRatioOffsetGamma_Param_Offset_Mean_Sd;
- calibrationPtr->min = BRLENS_MIN + priorParams[0];
- calibrationPtr->max = POS_INFINITY;
- }
- /* get ready to find more calibrated nodes or taxa, if present */
- expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
- }
- else
- return (ERROR);
- return (NO_ERROR);
- }
- int DoCharset (void)
- {
- /* first add set to tempSet */
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- /* add name to charSetNames */
- if (AddString (&charSetNames, numCharSets, tempSetName) == ERROR)
- {
- MrBayesPrint ("%s Problem adding charset %s to list\n", spacer, tempSetName);
- return (ERROR);
- }
- /* store charset */
- AddBitfield (&charSet, numCharSets, tempSet, numChar);
- /* increment number of char sets */
- numCharSets++;
- return (NO_ERROR);
- }
- int DoCharsetParm (char *parmName, char *tkn)
- {
- int i, index, tempInt, allDigit;
- if (defMatrix == NO)
- {
- MrBayesPrint ("%s A matrix must be specified before charsets can be defined\n", spacer);
- return (ERROR);
- }
- if (expecting == Expecting(PARAMETER))
- {
- if (!strcmp(parmName, "Xxxxxxxxxx"))
- {
- /* check that the name of the charset is not a number */
- allDigit = YES;
- for (i=0; i<(int)strlen(tkn); i++)
- {
- if (tkn[i] == '0' || tkn[i] == '1' || tkn[i] == '2' || tkn[i] == '3' || tkn[i] == '4' ||
- tkn[i] == '5' || tkn[i] == '6' || tkn[i] == '7' || tkn[i] == '8' || tkn[i] == '9' || tkn[i] == '.')
- {}
- else
- allDigit = NO;
- }
- if (allDigit == YES)
- {
- MrBayesPrint ("%s Charset name may not be a number\n", spacer);
- return (ERROR);
- }
- /* check size of charset name */
- if (strlen(tkn) > 99)
- {
- MrBayesPrint ("%s Charset name is too long\n", spacer);
- return (ERROR);
- }
- /* check to see if the name has already been used as a charset */
- if (numCharSets > 1)
- {
- if (CheckString (charSetNames, numCharSets, tkn, &index) == ERROR)
- {
- /* if the charset name has not been used, then we should have an ERROR returned */
- /* we _want_ to be here */
- }
- else
- {
- MrBayesPrint ("%s Charset name has been used previously\n", spacer);
- return (ERROR);
- }
- }
- /* add the name to the character set */
- strcpy (tempSetName, tkn);
- /* clear tempSet */
- for (i=0; i<numChar; i++)
- tempSet[i] = 0;
- fromI = toJ = everyK = -1;
- foundDash = foundSlash = NO;
- MrBayesPrint ("%s Defining charset called '%s'\n", spacer, tkn);
- expecting = Expecting(EQUALSIGN);
- }
- else
- return (ERROR);
- }
- else if (expecting == Expecting(EQUALSIGN))
- {
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- }
- else if (expecting == Expecting(ALPHA))
- {
- /* We are defining a character set in terms of another (called tkn, here). We should be able
- to find tkn in the list of character set names. If we cannot, then we have a problem and
- return an error. */
- if (numCharSets < 1)
- {
- MrBayesPrint ("%s Could not find a character set called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- if (CheckString (charSetNames, numCharSets, tkn, &index) == ERROR)
- {
- MrBayesPrint ("%s Could not find a character set called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- /* add characters from charset "tkn" to new tempset */
- for (i=0; i<numChar; i++)
- {
- if (IsBitSet(i,charSet[index]) == YES)
- tempSet[i] = 1;
- }
- fromI = toJ = everyK = -1;
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(SEMICOLON);
- }
- else if (expecting == Expecting(NUMBER))
- {
- if (strlen(tkn) == 1 && tkn[0] == '.')
- tempInt = numChar;
- else
- sscanf (tkn, "%d", &tempInt);
- if (tempInt <= 0 || tempInt > numChar)
- {
- MrBayesPrint ("%s Character number %d is out of range (should be between %d and %d)\n", spacer, tempInt, 1, numChar);
- return (ERROR);
- }
- tempInt--;
- if (foundDash == YES)
- {
- if (fromI >= 0)
- toJ = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted charset\n", spacer);
- return (ERROR);
- }
- foundDash = NO;
- }
- else if (foundSlash == YES)
- {
- tempInt++;
- if (tempInt <= 1)
- {
- MrBayesPrint ("%s Improperly formatted charset\n", spacer);
- return (ERROR);
- }
- if (fromI >= 0 && toJ >= 0 && fromI < toJ)
- everyK = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted charset\n", spacer);
- return (ERROR);
- }
- foundSlash = NO;
- }
- else
- {
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- }
- else if (fromI < 0 && toJ < 0)
- {
- fromI = tempInt;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else
- {
- MrBayesPrint ("%s Improperly formatted charset\n", spacer);
- {
- return (ERROR);
- }
- }
- }
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(SEMICOLON);
- expecting |= Expecting(DASH);
- expecting |= Expecting(BACKSLASH);
- }
- else if (expecting == Expecting(DASH))
- {
- foundDash = YES;
- expecting = Expecting(NUMBER);
- }
- else if (expecting == Expecting(BACKSLASH))
- {
- foundSlash = YES;
- expecting = Expecting(NUMBER);
- }
- else
- return (ERROR);
- return (NO_ERROR);
- }
- int DoCharStat (void)
- {
- int i, j, numDivs;
- char tempName[100];
- if (defMatrix == NO)
- {
- MrBayesPrint ("%s A character matrix must be defined first\n", spacer);
- return (ERROR);
- }
- if (numDefinedPartitions == 1)
- MrBayesPrint ("%s 1 character partition defined:\n", spacer, numDefinedPartitions);
- else
- MrBayesPrint ("%s %d character partitions defined:\n", spacer, numDefinedPartitions);
- for (i=0; i<numDefinedPartitions; i++)
- {
- numDivs = GetNumPartDivisions (i);
- if (numDivs == 1)
- MrBayesPrint ("%s Partition %d (\"%s\") does not divide the characters\n", spacer, i+1, partitionNames[i]);
- else
- MrBayesPrint ("%s Partition %d (\"%s\") divides the characters into %d parts\n", spacer, i+1, partitionNames[i], numDivs);
- }
- MrBayesPrint ("%s Current partition is \"%s\"\n", spacer, partitionNames[partitionNum]);
- MrBayesPrint ("\n");
- /* print out list of characters with information about each */
- MrBayesPrint ("%s Showing character status:\n\n", spacer);
- MrBayesPrint ("%s Partition(s)\n", spacer);
- MrBayesPrint ("%s # Type In/Out Ambiguity Order ", spacer);
- for (i=0; i<numDefinedPartitions; i++)
- MrBayesPrint (" %2d", i+1);
- MrBayesPrint ("\n");
- MrBayesPrint ("%s -----------------------------------------------", spacer);
- for (i=0; i<numDefinedPartitions; i++)
- MrBayesPrint ("---");
- MrBayesPrint ("\n");
- for (i=0; i<numChar; i++)
- {
- MrBayesPrint ("%s %4d -- ", spacer, i+1);
- if (charInfo[i].charType == DNA)
- MrBayesPrint (" DNA");
- else if (charInfo[i].charType == RNA)
- MrBayesPrint (" RNA");
- else if (charInfo[i].charType == PROTEIN)
- MrBayesPrint (" Prot");
- else if (charInfo[i].charType == RESTRICTION)
- MrBayesPrint (" Rest");
- else if (charInfo[i].charType == STANDARD)
- MrBayesPrint (" Stand");
- else if (charInfo[i].charType == CONTINUOUS)
- MrBayesPrint (" Cont");
- if (charInfo[i].charType == DNA)
- MrBayesPrint (" 4");
- else if (charInfo[i].charType == RNA)
- MrBayesPrint (" 4");
- else if (charInfo[i].charType == PROTEIN)
- MrBayesPrint (" 20");
- else if (charInfo[i].charType == RESTRICTION)
- MrBayesPrint (" 2");
- else if (charInfo[i].charType == STANDARD)
- MrBayesPrint (" %2d", charInfo[i].numStates);
- else if (charInfo[i].charType == CONTINUOUS)
- MrBayesPrint (" Inf");
- if (charInfo[i].isExcluded == NO)
- MrBayesPrint (" Included");
- else
- MrBayesPrint (" Excluded");
- if (charInfo[i].isMissAmbig == YES)
- MrBayesPrint (" MissAmbig");
- else
- MrBayesPrint (" None");
- if (charInfo[i].ctype == UNORD)
- MrBayesPrint (" Unord");
- else if (charInfo[i].ctype == ORD)
- MrBayesPrint (" Ord");
- else if (charInfo[i].ctype == DOLLO)
- MrBayesPrint (" Dollo");
- else if (charInfo[i].ctype == IRREV)
- MrBayesPrint (" Irrev");
- MrBayesPrint (" ");
- for (j=0; j<numDefinedPartitions; j++)
- MrBayesPrint (" %2d", partitionId[i][j]);
- /* MrBayesPrint ("%4d ", charSet[i]);*/
- if (charInfo[i].pairsId > 0)
- {
- /* find paired character */
- for (j=0; j<numChar; j++)
- {
- if (i != j && charInfo[j].pairsId == charInfo[i].pairsId)
- {
- MrBayesPrint (" (coupled with %d)", j+1);
- break;
- }
- }
- }
- MrBayesPrint ("\n");
- if (charInfo[i].bigBreakAfter == YES)
- {
- MrBayesPrint ("%s ", spacer);
- MrBayesPrint (" - - - - - - - - - - - - - - - - - - - - \n");
- }
- /* we may want to pause */
- if (autoClose == NO)
- {
- if ((i+1) % 100 == 0)
- {
- MrBayesPrint ("%s Hit return key to continue ", spacer);
- fflush (stdin);
- if (fgets (tempName, 100, stdin) == NULL)
- {
- printf ("Error in function: %s at line: %d in file: %s", __func__, __LINE__, __FILE__);
- }
- }
- }
- }
- return (NO_ERROR);
- }
- int DoCitations (void)
- {
- MrBayesPrint (" --------------------------------------------------------------------------- \n");
- MrBayesPrint (" Citations \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" If you publish results obtained using MrBayes you may want to cite the \n");
- MrBayesPrint (" program using one of these papers: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Huelsenbeck, J. P. and F. Ronquist. 2001. MRBAYES: Bayesian \n");
- MrBayesPrint (" inference of phylogeny. Bioinformatics 17:754-755. \n");
- MrBayesPrint (" Ronquist, F. and J. P. Huelsenbeck. 2003. MRBAYES 3: Bayesian phylogenetic \n");
- MrBayesPrint (" inference under mixed models. Bioinformatics 19:1572-1574. \n");
- MrBayesPrint (" Ronquist, F. et al. 2012. MRBAYES 3.2: Efficient Bayesian phylogenetic \n");
- MrBayesPrint (" inference and model selection across a large model space. \n");
- MrBayesPrint (" Syst. Biol. 61:539-542. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" If you use the parallel abilities of the program, you may also want to cite \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Altekar, G., S. Dwarkadas, J. P. Huelsenbeck, and F. Ronquist. 2004. \n");
- MrBayesPrint (" Parallel Metropolis-coupled Markov chain Monte Carlo for Bayesian \n");
- MrBayesPrint (" phylogenetic inference. Bioinformatics 20:407-415. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" If you use the BEAGLE library, the appropriate citation is \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Ayres, D. L., A. Darling, D. J. Zwickl, P. Beerli, M. T. Holder, P. O. \n");
- MrBayesPrint (" Lewis, J. P. Huelsenbeck, F. Ronquist, D. L. Swofford, M. P. \n");
- MrBayesPrint (" Cummings, A. Rambaut, and M. A. Suchard. 2012. BEAGLE: an application \n");
- MrBayesPrint (" programming interface for statistical phylogenetics. Syst. Biol. \n");
- MrBayesPrint (" 61:170-173. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" You should also cite other papers for different ideas that are implemented \n");
- MrBayesPrint (" in the program. For example, the program performs Bayesian inference of \n");
- MrBayesPrint (" phylogeny, an idea that was first proposed in the following papers: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Larget, B., and D. Simon. 1999. Markov chain Monte Carlo \n");
- MrBayesPrint (" algorithms for the Bayesian analysis of phylogenetic trees. \n");
- MrBayesPrint (" Mol. Biol. Evol. 16:750-759. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Li, S. 1996. Phylogenetic tree construction using Markov chain \n");
- MrBayesPrint (" Monte carlo. Ph. D. dissertation, Ohio State University, Columbus. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Mau, B. 1996. Bayesian phylogenetic inference via Markov chain \n");
- MrBayesPrint (" Monte carlo methods. Ph. D. dissertation, University of \n");
- MrBayesPrint (" Wisconsin, Madison. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Mau, B., and M. Newton. 1997. Phylogenetic inference for binary \n");
- MrBayesPrint (" data on dendrograms using Markov chain Monte Carlo. Journal of \n");
- MrBayesPrint (" Computational and Graphical Statistics 6:122-131. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Mau, B., M. Newton, and B. Larget. 1999. Bayesian phylogenetic \n");
- MrBayesPrint (" inference via Markov chain Monte carlo methods. Biometrics. 55:1-12. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Newton, M., B. Mau, and B. Larget. 1999. Markov chain Monte Carlo \n");
- MrBayesPrint (" for the Bayesian analysis of evolutionary trees from aligned \n");
- MrBayesPrint (" molecular sequences. In Statistics in molecular biology (F. Seillier- \n");
- MrBayesPrint (" Moseiwitch, T. P. Speed, and M. Waterman, eds.). Monograph Series \n");
- MrBayesPrint (" of the Institute of Mathematical Statistics. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Rannala, B., and Z. Yang. 1996. Probability distribution of \n");
- MrBayesPrint (" molecular evolutionary trees: a new method of phylogenetic \n");
- MrBayesPrint (" inference. J. Mol. Evol. 43:304-311. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Yang, Z., and B. Rannala. 1997. Bayesian phylogenetic inference \n");
- MrBayesPrint (" using DNA sequences: a Markov chain Monte Carlo method. Molecular \n");
- MrBayesPrint (" Biology and Evolution. 14:717-724. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" MrBayes uses Markov chain Monte Carlo (MCMC) to approximate the posterior \n");
- MrBayesPrint (" probability of trees. MCMC was developed in the following papers: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Metropolis, N., A. W. Rosenbluth, M. N. Rosenbluth, A. H. Teller, \n");
- MrBayesPrint (" and E. Teller. 1953. Equations of state calculations by fast \n");
- MrBayesPrint (" computing machines. J. Chem. Phys. 21:1087-1091. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Hastings, W. K. 1970. Monte Carlo sampling methods using Markov \n");
- MrBayesPrint (" chains and their applications. Biometrika 57:97-109. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" In particular, MrBayes implements a variant of MCMC that was described by \n");
- MrBayesPrint (" Charles Geyer: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Geyer, C. J. 1991. Markov chain Monte Carlo maximum likelihood. \n");
- MrBayesPrint (" Pages 156-163 in Computing Science and Statistics: Proceed- \n");
- MrBayesPrint (" ings of the 23rd Symposium on the Interface. (E. M. Keramidas, \n");
- MrBayesPrint (" ed.). Fairfax Station: Interface Foundation. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" MrBayes implements a large number of DNA substitution models. These models \n");
- MrBayesPrint (" are of three different structures. The \"4by4\" models are the usual flavor \n");
- MrBayesPrint (" of phylogenetic models. The \"Doublet\" model was first proposed by \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Schoniger, M., and A. von Haeseler. 1994. A stochastic model and the \n");
- MrBayesPrint (" evolution of autocorrelated DNA sequences. Molecular Phylogenetics \n");
- MrBayesPrint (" and Evolution 3:240-247. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The program also implements codon models. Two papers, published back-to-back \n");
- MrBayesPrint (" were the first to implement a codon model of DNA substitution in which the \n");
- MrBayesPrint (" substitution process is modelled on the codon, not on a site-by-site basis: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Goldman, N., and Z. Yang. 1994. A codon-based model of nucleotide \n");
- MrBayesPrint (" substitution for protein coding DNA sequences. Molecular Biology \n");
- MrBayesPrint (" and Evolution. 11:725-736. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Muse, S., and B. Gaut. 1994. A likelihood approach for comparing \n");
- MrBayesPrint (" synonymous and non-synonymous substitution rates, with application \n");
- MrBayesPrint (" to the chloroplast genome. Molecular Biology and Evolution. \n");
- MrBayesPrint (" 11:715-724. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The program can be used to detect positively selected amino-acid sites using \n");
- MrBayesPrint (" a full hierarchical Bayes analysis. The method is based on the excellent \n");
- MrBayesPrint (" paper by Nielsen and Yang: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Nielsen, R., and Z. Yang. 1998. Likelihood models for detecting \n");
- MrBayesPrint (" positively selected amino acid sites and applications to the HIV-1 \n");
- MrBayesPrint (" envelope gene. Genetics. 148:929-936. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The previous four papers describe three different structures for the \n");
- MrBayesPrint (" nucleotide models implemented in MrBayes--the four-by-four models, the \n");
- MrBayesPrint (" 16-by-16 (doublet) models and the 64-by-64 (codon) models. The program \n");
- MrBayesPrint (" implements three different substitution models within each model structure. \n");
- MrBayesPrint (" These include the nst=1 models: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Jukes, T., and C. Cantor. 1969. Evolution of protein molecules. \n");
- MrBayesPrint (" Pages 21-132 in Mammalian Protein Metabolism. (H. Munro, ed.). \n");
- MrBayesPrint (" Academic Press, New York. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Felsenstein, J. 1981. Evolutionary trees from DNA sequences: A \n");
- MrBayesPrint (" maximum likelihood approach. Journal of Molecular Evolution \n");
- MrBayesPrint (" 17:368-376. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" the nst=2 models: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Kimura, M. 1980. A simple method for estimating evolutionary rates \n");
- MrBayesPrint (" of base substitutions through comparative studies of nucleotide \n");
- MrBayesPrint (" sequences. Journal of Molecular Evolution. 16:111-120. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Hasegawa, M., T. Yano, and H. Kishino. 1984. A new molecular clock \n");
- MrBayesPrint (" of mitochondrial DNA and the evolution of Hominoids. Proc. \n");
- MrBayesPrint (" Japan Acad. Ser. B 60:95-98. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Hasegawa, M., H. Kishino, and T. Yano. 1985. Dating the human-ape \n");
- MrBayesPrint (" split by a molecular clock of mitochondrial DNA. Journal of \n");
- MrBayesPrint (" Molecular Evolution 22:160-174. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" and the the nst=6 models: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Tavare, S. 1986. Some probabilistic and statistical problems on the \n");
- MrBayesPrint (" analysis of DNA sequences. Lect. Math. Life Sci. 17:57-86. \n");
- MrBayesPrint (" 17:368-376. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" MrBayes implements a large number of amino-acid models. These include: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Poisson -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Bishop, M.J., and A.E. Friday. 1987. Tetrapod relationships: the \n");
- MrBayesPrint (" molecular evidence. Pp. 123-139 in Molecules and morphology in \n");
- MrBayesPrint (" evolution: conflict or compromise? (C. Patterson, ed.). Cambridge \n");
- MrBayesPrint (" University Press, Cambridge, England. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Jones -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Jones, D.T., W. R. Taylor, and J. M. Thornton. 1992. The rapid generation \n");
- MrBayesPrint (" of mutation data matrices from protein sequences. Comput. Appl. \n");
- MrBayesPrint (" Biosci. 8:275-282. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Dayhoff -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Dayhoff, M.O., R.M. Schwartz, and B.C. Orcutt. 1978. A model of evol- \n");
- MrBayesPrint (" utionary change in proteins. Pp. 345-352 in Atlas of protein sequence \n");
- MrBayesPrint (" and structure. Vol. 5, Suppl. 3. National Biomedical Research \n");
- MrBayesPrint (" Foundation, Washington, D.C. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Mtrev -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Adachi, J. and M. Hasegawa. 1996. MOLPHY version 2.3: programs for \n");
- MrBayesPrint (" molecular phylogenetics based on maximum likelihood. Computer Science \n");
- MrBayesPrint (" Monographs of Institute of Statistical Mathematics 28:1-150. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Mtmam -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Cao, Y., A. Janke, P.J. Waddell, M. Westerman, O. Takenaka, S. Murata, \n");
- MrBayesPrint (" N. Okada, S. Paabo, and M. Hasegawa. 1998. Conflict amongst individual \n");
- MrBayesPrint (" mitochondrial proteins in resolving the phylogeny of eutherian orders. \n");
- MrBayesPrint (" Journal of Molecular Evolution \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Yang, Z., R. Nielsen, and M. Hasegawa. 1998. Models of amino acid \n");
- MrBayesPrint (" substitution and applications to mitochondrial protein evolution \n");
- MrBayesPrint (" Molecular Biology and Evolution 15:1600-1611. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" WAG -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Whelan, S. and Goldman, N. 2001. A general empirical model of protein \n");
- MrBayesPrint (" evolution derived from multiple protein families using a maximum- \n");
- MrBayesPrint (" likelihood approach. Molecular Biology and Evolution 18:691-699. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Rtrev -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Dimmic M.W., J.S. Rest, D.P. Mindell, and D. Goldstein. 2002. RArtREV: \n");
- MrBayesPrint (" An amino acid substitution matrix for inference of retrovirus and \n");
- MrBayesPrint (" reverse transcriptase phylogeny. Journal of Molecular Evolution \n");
- MrBayesPrint (" 55: 65-73. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Cprev -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Adachi, J., P. Waddell, W. Martin, and M. Hasegawa. 2000. Plastid \n");
- MrBayesPrint (" genome phylogeny and a model of amino acid substitution for proteins \n");
- MrBayesPrint (" encoded by chloroplast DNA. Journal of Molecular Evolution \n");
- MrBayesPrint (" 50:348-358. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Blosum -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Henikoff, S., and J. G. Henikoff. 1992. Amino acid substitution \n");
- MrBayesPrint (" matrices from protein blocks. Proc. Natl. Acad. Sci., U.S.A. \n");
- MrBayesPrint (" 89:10915-10919. The matrix implemented in MrBayes is Blosum62. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Vt -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Muller, T., and M. Vingron. 2000. Modeling amino acid replacement. \n");
- MrBayesPrint (" Journal of Computational Biology 7:761-776. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" LG -- \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Le, Si Q. & Gascuel, O. 2008 An improved general amino- acid replacement \n");
- MrBayesPrint (" matrix. Mol. Biol. Evol. 25, 1307-1320. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" MrBayes implements a simple Jukes-Cantor-like model for restriction sites \n");
- MrBayesPrint (" and other binary data. A problem with some of these data is that there is a \n");
- MrBayesPrint (" coding bias, such that certain characters are missing from any observable data\n");
- MrBayesPrint (" matrix. It is impossible, for instance, to observe restriction sites that are\n");
- MrBayesPrint (" absent in all the studied taxa. However, MrBayes corrects for this coding \n");
- MrBayesPrint (" bias according to an idea described in \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Felsenstein, J. 1992. Phylogenies from restriction sites: A maximum- \n");
- MrBayesPrint (" likelihood approach. Evolution 46:159-173. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The model used by MrBayes for 'standard' or morphological data is based on \n");
- MrBayesPrint (" the ideas originally presented by \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Lewis, P. O. 2001. A likelihood approach to estimating phylogeny from \n");
- MrBayesPrint (" discrete morphological character data. Systematic Biology 50:913-925. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" For both DNA sequence and amino-acid data, the program allows rates to change \n");
- MrBayesPrint (" under a covarion-like model, first described by Tuffley and Steel \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Tuffley, C., and M. Steel. 1998. Modeling the covarion hypothesis \n");
- MrBayesPrint (" of nucleotide substitution. Mathematical Biosciences 147:63-91. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" and implemented by Huelsenbeck (2002) \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Huelsenbeck, J. P. 2002. Testing a covariotide model of DNA sub- \n");
- MrBayesPrint (" stitution. Molecular Biology and Evolution 19(5):698-707. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Galtier (2001) implements a different variant of the covarion model in a \n");
- MrBayesPrint (" paper that is worth reading: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Galtier, N. 2001. Maximum-likelihood phylogenetic analysis under a \n");
- MrBayesPrint (" covarion-like model. Mol. Biol. Evol. 18:866-873. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" A number of models are available that allow rates to vary across the \n");
- MrBayesPrint (" characters. The program implements the proportion of invariable sites model \n");
- MrBayesPrint (" and two variants of gamma distributed rate variation. Yang\'s (1993) paper \n");
- MrBayesPrint (" is a good one to cite for implementing a gamma-distributed rates model. \n");
- MrBayesPrint (" In the 1994 paper he provides a way to approximate the continuous gamma \n");
- MrBayesPrint (" distribution: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Yang, Z. 1993. Maximum likelihood estimation of phylogeny from DNA \n");
- MrBayesPrint (" sequences when substitution rates differ over sites. Molecular \n");
- MrBayesPrint (" Biology and Evolution 10:1396-1401. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Yang, Z. 1994. Maximum likelihood phylogenetic estimation from DNA \n");
- MrBayesPrint (" sequences with variable rates over sites: Approximate methods. \n");
- MrBayesPrint (" Journal of Molecular Evolution 39:306-314. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The program also implements Yang\'s autocorrelated gamma model. In this \n");
- MrBayesPrint (" model, the rate at one site depends to some extent on the rate at an adjacent \n");
- MrBayesPrint (" site. The appropriate citation for this model is: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Yang, Z. 1995. A space-time process model for the evolution of \n");
- MrBayesPrint (" DNA sequences. Genetics 139:993-1005. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The following two papers show how ancestral states on a tree can be \n");
- MrBayesPrint (" reconstructed. The Yang et al. paper implements an empirical Bayes approach \n");
- MrBayesPrint (" while Huelsenbeck and Bollback use a pure, hierarchical Bayes approach. The \n");
- MrBayesPrint (" method used in MrBayes is the latter, since it integrates over uncertainty in \n");
- MrBayesPrint (" model parameters. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Yang, Z., S. Kumar, and M. Nei. 1995. A new method of inference of \n");
- MrBayesPrint (" ancestral nucleotide and amino acid sequences. Genetics 141:1641 \n");
- MrBayesPrint (" 1650. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Huelsenbeck, J. P., and J. P. Bollback. 2001. Empirical and hier- \n");
- MrBayesPrint (" archical Bayesian estimation of ancestral states. Systematic \n");
- MrBayesPrint (" Biology 50:351-366. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" You may also want to consult a more recent review of Bayesian reconstruction \n");
- MrBayesPrint (" of ancestral states and character evolution: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Ronquist, F. 2004. Bayesian inference of character evolution. Trends in \n");
- MrBayesPrint (" Ecology and Evolution 19: 475-481. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" MrBayes allows you to analyze gene tree - species tree problems using the \n");
- MrBayesPrint (" multi-species coalescent approach originally proposed by Edwards et al: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Edwards, S., L. Liu, and D. Pearl. 2007. High-resolution species trees \n");
- MrBayesPrint (" without concatenation. Proc. Natl. Acad. Sci. USA 104: 5936-5941. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The program implements an incredibly parameter rich model, first described by \n");
- MrBayesPrint (" Tuffley and Steel (1997), that orders trees in the same way as the so-called \n");
- MrBayesPrint (" parsimony method of phylogenetic inference. The appropriate citation is: \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Tuffley, C., and M. Steel. 1997. Links between maximum likelihood \n");
- MrBayesPrint (" and maximum parsimony under a simple model of site substitution. \n");
- MrBayesPrint (" Bull. Math. Bio. 59:581-607. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" MrBayes implements five relaxed clock models: the Compound Poisson Process \n");
- MrBayesPrint (" (CPP), the Autocorrelated Lognormal (TK02), the White Noise (WN), the \n");
- MrBayesPrint (" Independent Gamma Rates (IGR), and the Independent Lognormal (ILN) models. \n");
- MrBayesPrint (" The CPP model was first described by Huelsenbeck et al. (2000). It is an \n");
- MrBayesPrint (" autocorrelated discrete model of rate variation over time. Instead of \n");
- MrBayesPrint (" the modified gamma distribution originally proposed for the rate multipliers, \n");
- MrBayesPrint (" MrBayes uses a lognormal distribution. The extensions necessary to sample \n");
- MrBayesPrint (" over tree space under this model are original to MrBayes; the original paper \n");
- MrBayesPrint (" only considered fixed trees. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The TK02 model was first described by Thorne and Kishino (2002), and is a \n");
- MrBayesPrint (" variant of a model presented by them earlier (Thorne et al., 1998). It is an \n");
- MrBayesPrint (" autocorrelated continuous model, in which rates vary according to a lognormal \n");
- MrBayesPrint (" distribution. Specifically, the rate of a descendant node is assumed to \n");
- MrBayesPrint (" be drawn from a lognormal distribution with the mean being the rate of the \n");
- MrBayesPrint (" ancestral node (and not the log of the rate of the ancestral node), and the \n");
- MrBayesPrint (" variance (on the log scale) being proportional to the length of the branch \n");
- MrBayesPrint (" separating the nodes (measured in terms of expected substitutions per site at \n");
- MrBayesPrint (" the base rate of the clock). Note that in MrBayes versions up until 3.2.7, \n");
- MrBayesPrint (" the variance was measured on the linear scale and not on the log scale, which \n");
- MrBayesPrint (" a slight difference from the original formulation of the model. Note also that\n");
- MrBayesPrint (" we factor out the base rate of the clock in MrBayes, so the model applies to \n");
- MrBayesPrint (" the deviations from this rate. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" In the WN model, the branch rates are modeled as being drawn independently \n");
- MrBayesPrint (" from gamma distributions. The distributions are not identical as the variance \n");
- MrBayesPrint (" is proportional to the branch length. See Lepage et al. (2007) for details. \n");
- MrBayesPrint (" Note that the WN model was named 'IGR' in previous versions of MrBayes (up to \n");
- MrBayesPrint (" version 3.2.7), but now 'IGR' refers to a slightly different model, in which \n");
- MrBayesPrint (" the branch rates are drawn from independent and identically distributed \n");
- MrBayesPrint (" (i.i.d.) gamma distributions. This naming change better reflects common usage \n");
- MrBayesPrint (" of the term 'independent' in the relaxed clock model literature. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The ILN model is analogous to IGR but differs in that the branch rates follow \n");
- MrBayesPrint (" i.i.d. lognormal (instead of gamma) distributions (Drummond et al. 2006). \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Huelsenbeck, J. P., B. Larget, and D. Swofford. 2000. A compound Poisson \n");
- MrBayesPrint (" process for relaxing the molecular clock. Genetics 154: 1879-1892. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Thorne, J. L., H. Kishino, and I. S. Painter. 1998. Estimating the rate \n");
- MrBayesPrint (" of evolution of the rate of molecular evolution. Mol. Biol. Evol. \n");
- MrBayesPrint (" 15: 1647-1657. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Thorne, J. L., and H. Kishino. 2002. Divergence time and evolutionary \n");
- MrBayesPrint (" rate estimation with multilocus data. Syst. Biol. 51: 689-702. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Drummond, A. J., S. Y. W. Ho, M. J. Phillips, and A. Rambaut. 2006. \n");
- MrBayesPrint (" Relaxed phylogenetics and dating with confidence. PLoS Biology \n");
- MrBayesPrint (" 4: 699-710. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Lepage, T., D. Bryant, H. Philippe, and N. Lartillot. 2007. A general \n");
- MrBayesPrint (" comparison of relaxed molecular clock models. Mol. Biol. Evol. \n");
- MrBayesPrint (" 24: 2669-2680. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The standard tree proposals used by MrBayes are described by Lakner et al. \n");
- MrBayesPrint (" (2008). The parsimony-biased tree proposals are still undescribed, although \n");
- MrBayesPrint (" a rough outline of the idea is presented in the same paper. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Lakner, C., P. van der Mark, J. P. Huelsenbeck, B. Larget, and F. Ronquist.\n");
- MrBayesPrint (" 2008. Efficiency of Markov chain Monte Carlo tree proposals in Bayesian \n");
- MrBayesPrint (" phylogenetics. Syst. Biol. 57: 86-103. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The topology convergence diagnostic used by MrBayes, the average standard \n");
- MrBayesPrint (" deviation of split frequencies, is described by Lakner et al. (2008). \n");
- MrBayesPrint (" The potential scale reduction factor, the diagnostic used by MrBayes for \n");
- MrBayesPrint (" continous parameters, was first proposed by Gelman and Rubin (1992). The \n");
- MrBayesPrint (" auto-tuning mechanism used in MrBayes is based on a paper by Roberts and \n");
- MrBayesPrint (" Rosenthal (2009). \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Gelman, A., and D. B. Rubin. 1992. Inference from iterative simulation \n");
- MrBayesPrint (" using multiple sequences. Statistical Science 7: 457-472. \n");
- MrBayesPrint (" Bull. Math. Bio. 59:581-607. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Lakner, C., P. van der Mark, J. P. Huelsenbeck, B. Larget, and F. Ronquist.\n");
- MrBayesPrint (" 2008. Efficiency of Markov chain Monte Carlo tree proposals in Bayesian \n");
- MrBayesPrint (" phylogenetics. Syst. Biol. 57: 86-103. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Roberts, G. O., and J. S. Rosenthal. 2009. Examples of adaptive \n");
- MrBayesPrint (" MCMC. Journal of Compuational and Graphical Statistics 18: 349-367. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" The harmonic mean estimator of model likelihoods, used for Bayes factor \n");
- MrBayesPrint (" testing, was discussed by Newton and Raftery (1996). The more accurate \n");
- MrBayesPrint (" stepping-stone algorithm was first proposed by Xie et al. (2011). The paper \n");
- MrBayesPrint (" by Lartillot and Philippe (2006) presents an interesting discussion of the \n");
- MrBayesPrint (" shortcomings of the harmonic mean estimator and describes thermodynamic \n");
- MrBayesPrint (" integration, a technique that is similar to the stepping-stone algorithm. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Newton, M. A., and A. E. Raftery. 1994. Approximate Bayesian inference \n");
- MrBayesPrint (" with the weighted likelihood bootstrap. J. R. Stat. Soc. B. 56. 3-48. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Lartillot, N., and H. Philippe. 2006. Computing Bayes factors using \n");
- MrBayesPrint (" thermodynamic integration. Syst. Biol. 55: 195-207. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Xie, W., P. O. Lewis, Y. Fan, L. Kuo, and M.-H. Chen. 2011. Improving \n");
- MrBayesPrint (" marginal likelihood estimation for Bayesian phylogenetic model \n");
- MrBayesPrint (" selection. Syst. Biol. 60: 150-160. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" For unconstrained branch lengths, MrBayes implements the compound Dirichlet \n");
- MrBayesPrint (" priors for branch lengths described by Rannala et al. (2012) and Zhang et al. \n");
- MrBayesPrint (" (2012). Compared with the i.i.d. exponential and uniform priors for branch \n");
- MrBayesPrint (" lengths in the previous versions of MrBayes, the Dirichlet priors appear more \n");
- MrBayesPrint (" reasonable and may avoid the problem of extremely long trees, as discussed \n");
- MrBayesPrint (" by Brown et al. (2010) and Marshall (2010). The two-exponential prior on \n");
- MrBayesPrint (" internal and external branch lengths described by Yang & Rannala (2005) and \n");
- MrBayesPrint (" Yang (2007) is also implemented in this version. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Brown, J. M., S. M. Hedtke, A. R. Lemmon, and E. M. Lemmon. 2010. When \n");
- MrBayesPrint (" trees grow too long: investigating the causes of highly inaccurate \n");
- MrBayesPrint (" Bayesian branch-length estimates. Syst. Biol. 59:145-161. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Marshall, D. C. 2010. Cryptic failure of partitioned Bayesian phylogenetic \n");
- MrBayesPrint (" analyses: lost in the land of long trees. Syst. Biol. 59:108-117. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Rannala, B., T. Zhu, and Z. Yang. 2012. Tail paradox, partial \n");
- MrBayesPrint (" identifiability and influential priors in Bayesian branch length \n");
- MrBayesPrint (" inference. Mol. Biol. Evol. 29:325-335. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Zhang, C., B. Rannala, and Z. Yang. 2012. Robustness of compound Dirichlet \n");
- MrBayesPrint (" priors for Bayesian inference of branch lengths. Syst. Biol. 61:779-784.\n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Yang, Z. 2007. Fair-balance paradox, star-tree paradox and Bayesian \n");
- MrBayesPrint (" phylogenetics. Mol. Biol. Evol. 24:1639-1655. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Yang, Z., and B. Rannala. 2005. Branch-length prior influences Bayesian \n");
- MrBayesPrint (" posterior probability of phylogeny. Syst. Biol. 54:455-470. \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" --------------------------------------------------------------------------- \n");
- return (NO_ERROR);
- }
- int DoConstraint (void)
- {
- int i, howMany;
- int *tset;
- if (constraintType == PARTIAL)
- tset=tempSetNeg;
- else
- tset=tempSet;
- /* add set to tempSet */
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToGivenSet (fromI, toJ, everyK, 1, tset) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToGivenSet (fromI, toJ, everyK, 1, tset) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToGivenSet (fromI, toJ, everyK, 1, tset) == ERROR)
- return (ERROR);
- }
- /* check that this is not a stupid constraint */
- howMany = 0;
- for (i=0; i<numTaxa; i++)
- if (tempSet[i] != 0)
- howMany++;
- if (howMany == 0)
- {
- MrBayesPrint ("%s This constraint does not include any taxa and will not be defined\n", spacer);
- return (ERROR);
- }
- if (constraintType == HARD)
- {
- if (howMany == numTaxa)
- {
- /* We allow this so we can report states from and calibrate root */
- }
- } /*end constraintType == HARD */
- else if (constraintType == PARTIAL)
- {
- if (howMany == 1)
- {
- MrBayesPrint ("%s This partial constraint includes only one taxon. It is always satisfied and will not be defined.\n", spacer);
- return (ERROR);
- }
- howMany = 0;
- for (i=0; i<numTaxa; i++)
- {
- if (tempSetNeg[i] != 0)
- {
- howMany++;
- if (tempSetNeg[i] == tempSet[i])
- {
- MrBayesPrint ("%s Two sets of taxa in partial constraint are not allowed to intersect. Constraint will not be defined\n", spacer);
- return (ERROR);
- }
- }
- }
- if (howMany == 0)
- {
- MrBayesPrint ("%s This partial constraint does not include any taxa in the second set and will not be defined\n", spacer);
- return (ERROR);
- }
- }
- else if (constraintType == NEGATIVE)
- {
- if (howMany == 1)
- {
- MrBayesPrint ("%s Negative constraint should include more than one taxon. Constraint will not be defined\n", spacer);
- return (ERROR);
- }
- }
- /* add name to constraintNames */
- if (AddString (&constraintNames, numDefinedConstraints, tempSetName) == ERROR)
- {
- MrBayesPrint ("%s Problem adding constraint %s to list\n", spacer, tempSetName);
- return (ERROR);
- }
- /* store tempSet */
- AddBitfield (&definedConstraint, numDefinedConstraints, tempSet, numTaxa);
- if (constraintType == PARTIAL)
- {
- AddBitfield (&definedConstraintTwo, numDefinedConstraints, tempSetNeg, numTaxa);
- }
- else
- {
- definedConstraintTwo = (BitsLong **) SafeRealloc ((void *)(definedConstraintTwo), ((size_t)numDefinedConstraints+1)*sizeof(BitsLong *));
- if (definedConstraintTwo==NULL)
- return ERROR;
- definedConstraintTwo[numDefinedConstraints]=NULL;
- }
- /* add a default node calibration */
- nodeCalibration = (Calibration *) SafeRealloc ((void *)nodeCalibration, ((size_t)numDefinedConstraints+1)*sizeof(Calibration));
- nodeCalibration[numDefinedConstraints].prior = defaultCalibration.prior;
- nodeCalibration[numDefinedConstraints].priorParams[0] = defaultCalibration.priorParams[0];
- nodeCalibration[numDefinedConstraints].priorParams[1] = defaultCalibration.priorParams[1];
- nodeCalibration[numDefinedConstraints].priorParams[2] = defaultCalibration.priorParams[2];
- nodeCalibration[numDefinedConstraints].min = defaultCalibration.min;
- nodeCalibration[numDefinedConstraints].max = defaultCalibration.max;
- nodeCalibration[numDefinedConstraints].LnPriorProb = defaultCalibration.LnPriorProb;
- nodeCalibration[numDefinedConstraints].LnPriorRatio = defaultCalibration.LnPriorRatio;
- strcpy(nodeCalibration[numDefinedConstraints].name, defaultCalibration.name);
- /* increment number of defined constraints */
- numDefinedConstraints++;
- /* reallocate and initialize space for activeConstraints */
- for (i=0; i<numCurrentDivisions; i++)
- {
- modelParams[i].activeConstraints = (int *) SafeRealloc((void *)(modelParams[i].activeConstraints), (size_t)numDefinedConstraints*sizeof(int));
- modelParams[i].activeConstraints[numDefinedConstraints-1] = NO;
- }
- /* reallocate and initialize space for tempActiveConstraints */
- tempActiveConstraints = (int *) SafeRealloc((void *)(tempActiveConstraints), (size_t)numDefinedConstraints*sizeof(int));
- tempActiveConstraints[numDefinedConstraints-1] = NO;
- definedConstraintsType = (enum ConstraintType *) SafeRealloc((void *)(definedConstraintsType), (size_t)numDefinedConstraints*sizeof(enum ConstraintType));
- if (definedConstraintsType==NULL)
- return ERROR;
- definedConstraintsType[numDefinedConstraints-1] = constraintType;
- definedConstraintPruned = (BitsLong **) SafeRealloc ((void *)(definedConstraintPruned), (size_t)numDefinedConstraints*sizeof(BitsLong *));
- if (definedConstraintPruned==NULL)
- return ERROR;
- definedConstraintPruned[numDefinedConstraints-1]=NULL;
- definedConstraintTwoPruned = (BitsLong **) SafeRealloc ((void *)(definedConstraintTwoPruned), (size_t)numDefinedConstraints*sizeof(BitsLong *));
- if (definedConstraintTwoPruned==NULL)
- return ERROR;
- definedConstraintTwoPruned[numDefinedConstraints-1]=NULL;
- /* show taxset (for debugging) */
- // for (i=0; i<numTaxa; i++)
- // MrBayesPrint ("%4d %4d\n", i+1, taxaInfo[i].constraints[numDefinedConstraints-1]);
- return (NO_ERROR);
- }
- int DoConstraintParm (char *parmName, char *tkn)
- {
- int i, index, tempInt;
- MrBFlt tempD;
- static int *tempSetCurrent;
- if (defMatrix == NO)
- {
- MrBayesPrint ("%s A matrix must be specified before constraints can be defined\n", spacer);
- return (ERROR);
- }
- if (expecting == Expecting(PARAMETER))
- {
- if (!strcmp(parmName, "Xxxxxxxxxx"))
- {
- /* check size of constraint name */
- if (strlen(tkn) > 99)
- {
- MrBayesPrint ("%s Constraint name is too long\n", spacer);
- return (ERROR);
- }
- /* check to see if the name has already been used as a constraint */
- if (numDefinedConstraints > 0)
- {
- if (CheckString (constraintNames, numDefinedConstraints, tkn, &index) == ERROR)
- {
- /* an ERROR returned if the constraint name has not been used. we _want_ to be here */
- }
- else
- {
- MrBayesPrint ("%s Constraint name '%s' has been used previously\n", spacer, tkn);
- return (ERROR);
- }
- }
- /* copy the name to the temporary constraint names string */
- strcpy (tempSetName, tkn);
- /* clear tempSet */
- for (i=0; i<numTaxa; i++)
- tempSet[i] = 0;
- constraintType = HARD; /* set default constrain type */
- tempSetCurrent=tempSet;
- fromI = toJ = everyK = -1;
- foundDash = foundSlash = NO;
- MrBayesPrint ("%s Defining constraint called '%s'\n", spacer, tkn);
- foundExp = NO;
- foundFirst = YES;
- foundEqual = NO;
- isNegative = NO;
- foundColon = NO;
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(DASH);
- expecting |= Expecting(EQUALSIGN);
- }
- else
- return (ERROR);
- }
- else if (expecting == Expecting(EQUALSIGN))
- {
- foundEqual = YES;
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- }
- else if (expecting == Expecting(LEFTPAR))
- {
- isNegative = NO;
- expecting = Expecting(NUMBER);
- expecting |= Expecting(DASH);
- }
- else if (expecting == Expecting(RIGHTPAR))
- {
- isNegative = NO;
- foundExp = NO;
- expecting = Expecting(EQUALSIGN);
- }
- else if (expecting == Expecting(DASH))
- {
- if (foundExp == YES)
- isNegative = YES;
- else
- foundDash = YES;
- expecting = Expecting(NUMBER);
- }
- else if (expecting == Expecting(ALPHA))
- {
- if (foundFirst == YES && foundEqual == NO)
- {
- /* We are filling in the probability for the constraint. Specifically, we expect exp(number). */
- if (IsSame ("Partial", tkn) == SAME)
- {
- for (i=0; i<numTaxa; i++)
- tempSetNeg[i] = 0;
- constraintType = PARTIAL;
- expecting = Expecting(EQUALSIGN);
- expecting |= Expecting(ALPHA);
- }
- else if (IsSame ("Hard", tkn) == SAME)
- {
- constraintType = HARD;
- expecting = Expecting(EQUALSIGN);
- expecting |= Expecting(ALPHA);
- }
- else if (IsSame ("Negative", tkn) == SAME)
- {
- constraintType = NEGATIVE;
- expecting = Expecting(EQUALSIGN);
- expecting |= Expecting(ALPHA);
- }
- else if (IsSame ("Exp", tkn) == SAME || IsSame ("Exp", tkn) == CONSISTENT_WITH)
- {
- foundExp = YES;
- foundDash = NO;
- isNegative = NO;
- expecting = Expecting(LEFTPAR);
- }
- else
- {
- MrBayesPrint ("%s Do not understand %s\n", spacer, tkn);
- return (ERROR);
- }
- }
- else
- {
- /* We are defining a constraint in terms of a taxon set (called tkn, here) or we are referring to
- the taxon name. We should be able to find tkn in the list of taxon set names or in the list
- of taxon names. If we cannot, then we have a problem and return an error. */
- if (CheckString (taxaNames, numTaxa, tkn, &index) == ERROR)
- {
- if (numTaxaSets < 1)
- {
- MrBayesPrint ("%s Could not find a taxset called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- if (CheckString (taxaSetNames, numTaxaSets, tkn, &index) == ERROR)
- {
- MrBayesPrint ("%s Could not find a taxset called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- /* add taxa from taxset tkn to new tempSet */
- for (i=0; i<numTaxa; i++)
- {
- if (IsBitSet(i, taxaSet[index]) == YES)
- {
- tempSetCurrent[i] = 1;
- }
- }
- }
- else
- {
- tempSetCurrent[index] = 1;
- }
- fromI = toJ = everyK = -1;
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- if (constraintType != PARTIAL || foundColon == YES)
- expecting |= Expecting(SEMICOLON);
- else
- expecting |= Expecting(COLON);
- }
- }
- else if (expecting == Expecting(NUMBER))
- {
- if (foundFirst == YES && foundEqual == NO)
- {
- /* We are filling in the probability for the constraint. Specifically, we expect number. */
- sscanf (tkn, "%lf", &tempD);
- if (foundExp == NO && tempD < 0.0)
- {
- MrBayesPrint ("%s The probability of a clade cannot be less than zero\n", spacer, tkn);
- return (ERROR);
- }
- if (isNegative == YES || foundDash == YES)
- tempD *= -1.0;
- if (foundExp == YES)
- {
- expecting = Expecting(RIGHTPAR);
- }
- else
- {
- expecting = Expecting(EQUALSIGN);
- }
- foundFirst = NO;
- foundDash = NO;
- }
- else
- {
- if (strlen(tkn) == 1 && !strcmp(tkn, "."))
- {
- tempInt = numTaxa;
- }
- else
- {
- sscanf (tkn, "%d", &tempInt);
- if (tempInt <= 0 || tempInt > numTaxa)
- {
- MrBayesPrint ("%s Taxon number %d is out of range (should be between %d and %d)\n", spacer, tempInt, 1, numTaxa);
- return (ERROR);
- }
- }
- tempInt--;
- if (foundDash == YES)
- {
- if (fromI >= 0)
- toJ = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted constraint\n", spacer);
- return (ERROR);
- }
- foundDash = NO;
- }
- else if (foundSlash == YES)
- {
- tempInt++;
- if (tempInt <= 1)
- {
- MrBayesPrint ("%s Improperly formatted constraint\n", spacer);
- return (ERROR);
- }
- if (fromI >= 0 && toJ >= 0 && fromI < toJ)
- everyK = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted constraint\n", spacer);
- return (ERROR);
- }
- foundSlash = NO;
- }
- else
- {
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToGivenSet (fromI, toJ, everyK, 1, tempSetCurrent) == ERROR)
- return (ERROR);
- fromI = tempInt;
- }
- else if (fromI < 0 && toJ < 0)
- {
- fromI = tempInt;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToGivenSet (fromI, toJ, everyK, 1, tempSetCurrent) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToGivenSet (fromI, toJ, everyK, 1, tempSetCurrent) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else
- {
- MrBayesPrint ("%s Improperly formatted constraint\n", spacer);
- {
- return (ERROR);
- }
- }
- }
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(DASH);
- expecting |= Expecting(BACKSLASH);
- if (constraintType != PARTIAL || foundColon == YES)
- expecting |= Expecting(SEMICOLON);
- else
- expecting |= Expecting(COLON);
- }
- }
- else if (expecting == Expecting(BACKSLASH))
- {
- foundSlash = YES;
- expecting = Expecting(NUMBER);
- }
- else if (expecting == Expecting(COLON))
- {
- if (foundColon == YES)
- {
- MrBayesPrint ("%s Improperly formatted constraint: two colon characters in constraint command.\n", spacer);
- return (ERROR);
- }
- /* add set to tempSet */
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- fromI = toJ = everyK = -1;
- foundDash = foundSlash = NO;
- foundColon = YES;
- tempSetCurrent = tempSetNeg;
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- }
- else
- return (ERROR);
- return (NO_ERROR);
- }
- int DoCtype (void)
- {
- int i, foundIllegal, marks[5], numAppliedTo;
- /* add set to tempSet */
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- /* merge tempSet with ctype */
- numAppliedTo = 0;
- for (i=0; i<5; i++)
- marks[i] = NO;
- for (i=0; i<numChar; i++)
- {
- if (tempSet[i] != 0)
- {
- foundIllegal = NO;
- if (charOrdering != UNORD)
- {
- if (charInfo[i].charType == DNA)
- {
- foundIllegal = YES;
- if (marks[0] == NO)
- MrBayesPrint ("%s Ctype not applied to DNA states which must be unordered\n", spacer);
- marks[0] = YES;
- }
- else if (charInfo[i].charType == RNA)
- {
- foundIllegal = YES;
- if (marks[1] == NO)
- MrBayesPrint ("%s Ctype not applied to RNA states which must be unordered\n", spacer);
- marks[1] = YES;
- }
- else if (charInfo[i].charType == PROTEIN)
- {
- foundIllegal = YES;
- if (marks[2] == NO)
- MrBayesPrint ("%s Ctype not applied to amino acid states which must be unordered\n", spacer);
- marks[2] = YES;
- }
- else if (charInfo[i].charType == RESTRICTION)
- {
- foundIllegal = YES;
- if (marks[3] == NO)
- MrBayesPrint ("%s Ctype not applied to restriction site states which must be unordered\n", spacer);
- marks[3] = YES;
- }
- else if (charInfo[i].charType == CONTINUOUS)
- {
- foundIllegal = YES;
- if (marks[4] == NO)
- MrBayesPrint ("%s Ctype not applied to continuous characters\n", spacer);
- marks[4] = YES;
- }
- }
- if (foundIllegal == NO)
- {
- charInfo[i].ctype = charOrdering;
- numAppliedTo++;
- }
- }
- }
- if (numAppliedTo > 0)
- {
- MrBayesPrint ("%s Ctype was applied to %d standard characters\n", spacer, numAppliedTo);
- }
- else
- {
- MrBayesPrint ("%s No standard characters found to apply ctype to\n", spacer);
- }
- # if 0
- for (i=0; i<numChar; i++)
- MrBayesPrint ("%4d -- %d\n", i, ctype[i]);
- # endif
- return (NO_ERROR);
- }
- int DoCtypeParm (char *parmName, char *tkn)
- {
- int i, index, tempInt;
- if (defMatrix == NO)
- {
- MrBayesPrint ("%s A matrix must be specified before typesets can be defined\n", spacer);
- return (ERROR);
- }
- if (expecting == Expecting(PARAMETER))
- {
- if (!strcmp(parmName, "Xxxxxxxxxx"))
- {
- if (IsSame ("Ordered", tkn) == SAME || IsSame ("Ordered", tkn) == CONSISTENT_WITH)
- charOrdering = ORD;
- else if (IsSame ("Unordered", tkn) == SAME || IsSame ("Unordered", tkn) == CONSISTENT_WITH)
- charOrdering = UNORD;
- else if (IsSame ("Dollo", tkn) == SAME || IsSame ("Dollo", tkn) == CONSISTENT_WITH)
- charOrdering = DOLLO;
- else if (IsSame ("Irreversible", tkn) == SAME || IsSame ("Irreversible", tkn) == CONSISTENT_WITH)
- charOrdering = IRREV;
- else
- {
- MrBayesPrint ("%s Do not understand delimiter \"%s\"\n", spacer, tkn);
- return (ERROR);
- }
- /* clear tempSet */
- for (i=0; i<numChar; i++)
- tempSet[i] = 0;
- fromI = toJ = everyK = -1;
- foundDash = foundSlash = NO;
- MrBayesPrint ("%s Setting characters to %s\n", spacer, tkn);
- expecting = Expecting(COLON);
- }
- else
- return (ERROR);
- }
- else if (expecting == Expecting(COLON))
- {
- expecting = Expecting(ALPHA) | Expecting(NUMBER);
- }
- else if (expecting == Expecting(ALPHA))
- {
- /* first, check that we are not trying to put in another character ordering */
- if (IsSame ("Ordered", tkn) == SAME || IsSame ("Ordered", tkn) == CONSISTENT_WITH)
- {
- MrBayesPrint ("%s You cannot specify more than one ordering with a single use of ctype\n", spacer, tkn);
- return (ERROR);
- }
- else if (IsSame ("Unordered", tkn) == SAME || IsSame ("Unordered", tkn) == CONSISTENT_WITH)
- {
- MrBayesPrint ("%s You cannot specify more than one ordering with a single use of ctype\n", spacer, tkn);
- return (ERROR);
- }
- else if (IsSame ("Dollo", tkn) == SAME || IsSame ("Dollo", tkn) == CONSISTENT_WITH)
- {
- MrBayesPrint ("%s You cannot specify more than one ordering with a single use of ctype\n", spacer, tkn);
- return (ERROR);
- }
- else if (IsSame ("Irreversible", tkn) == SAME || IsSame ("Irreversible", tkn) == CONSISTENT_WITH)
- {
- MrBayesPrint ("%s You cannot specify more than one ordering with a single use of ctype\n", spacer, tkn);
- return (ERROR);
- }
- /* We are defining a type set in terms of another (called tkn, here). We should be able
- to find tkn in the list of character set names. If we cannot, then we have a problem and
- return an error. */
- if (IsSame ("All", tkn) == SAME)
- {
- for (i=0; i<numChar; i++)
- tempSet[i] = 1;
- fromI = toJ = everyK = -1;
- expecting = Expecting(SEMICOLON);
- }
- else
- {
- if (numCharSets < 1)
- {
- MrBayesPrint ("%s Could not find a character set called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- if (CheckString (charSetNames, numCharSets, tkn, &index) == ERROR)
- {
- MrBayesPrint ("%s Could not find a character set called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- /* add characters from charset tkn to new tempset */
- for (i=0; i<numChar; i++)
- {
- if (IsBitSet(i, charSet[index]) == YES)
- tempSet[i] = 1;
- }
- fromI = toJ = everyK = -1;
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(SEMICOLON);
- }
- }
- else if (expecting == Expecting(NUMBER))
- {
- if (strlen(tkn) == 1 && tkn[0] == '.')
- tempInt = numChar;
- else
- sscanf (tkn, "%d", &tempInt);
- if (tempInt <= 0 || tempInt > numChar)
- {
- MrBayesPrint ("%s Character number %d is out of range (should be between %d and %d)\n", spacer, tempInt, 1, numChar);
- return (ERROR);
- }
- tempInt--;
- if (foundDash == YES)
- {
- if (fromI >= 0)
- toJ = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted ctype\n", spacer);
- return (ERROR);
- }
- foundDash = NO;
- }
- else if (foundSlash == YES)
- {
- tempInt++;
- if (tempInt <= 1)
- {
- MrBayesPrint ("%s Improperly formatted ctype\n", spacer);
- return (ERROR);
- }
- if (fromI >= 0 && toJ >= 0 && fromI < toJ)
- everyK = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted ctype\n", spacer);
- return (ERROR);
- }
- foundSlash = NO;
- }
- else
- {
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- }
- else if (fromI < 0 && toJ < 0)
- {
- fromI = tempInt;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else
- {
- MrBayesPrint ("%s Improperly formatted ctype\n", spacer);
- {
- return (ERROR);
- }
- }
- }
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(SEMICOLON);
- expecting |= Expecting(DASH);
- expecting |= Expecting(BACKSLASH);
- }
- else if (expecting == Expecting(DASH))
- {
- foundDash = YES;
- expecting = Expecting(NUMBER);
- }
- else if (expecting == Expecting(BACKSLASH))
- {
- foundSlash = YES;
- expecting = Expecting(NUMBER);
- }
- else
- return (ERROR);
- return (NO_ERROR);
- }
- int DoDelete (void)
- {
- int i, alreadyDone;
- MrBayesPrint ("%s Excluding taxa\n", spacer);
- /* add set to tempSet */
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- /* merge tempSet with taxaset */
- alreadyDone = NO;
- for (i=0; i<numTaxa; i++)
- {
- if (tempSet[i] == 1)
- {
- if (taxaInfo[i].isDeleted == YES && alreadyDone == NO)
- {
- MrBayesPrint ("%s Some taxa already excluded\n", spacer);
- alreadyDone = YES;
- }
- taxaInfo[i].isDeleted = YES;
- }
- }
- SetLocalTaxa ();
- if (SetUpAnalysis(&globalSeed) == ERROR)
- return ERROR;
- /* show tempSet (for debugging) */
- # if 0
- for (i=0; i<numTaxa; i++)
- MrBayesPrint ("%4d %4d\n", i+1, tempSet[i]);
- # endif
- return (NO_ERROR);
- }
- int DoDeleteParm (char *parmName, char *tkn)
- {
- int i, index, tempInt;
- if (defMatrix == NO)
- {
- MrBayesPrint ("%s A matrix must be specified before you can delete taxa\n", spacer);
- return (ERROR);
- }
- if (foundFirst == NO)
- {
- /* this is the first time in */
- fromI = toJ = everyK = -1;
- foundDash = NO;
- for (i=0; i<numTaxa; i++) /* clear tempSet */
- tempSet[i] = 0;
- foundFirst = YES;
- }
- if (expecting == Expecting(ALPHA))
- {
- if (IsSame ("All", tkn) == SAME || IsSame ("All", tkn) == CONSISTENT_WITH)
- {
- for (i=0; i<numTaxa; i++)
- tempSet[i] = 1;
- }
- else
- {
- if (CheckString (taxaNames, numTaxa, tkn, &index) == ERROR)
- {
- /* we are using a pre-defined taxa set */
- if (numTaxaSets < 1)
- {
- MrBayesPrint ("%s Could not find a taxset called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- if (CheckString (taxaSetNames, numTaxaSets, tkn, &index) == ERROR)
- {
- MrBayesPrint ("%s Could not find a taxset called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- /* add taxa from taxset tkn to new tempSet */
- for (i=0; i<numTaxa; i++)
- {
- if (IsBitSet (i, taxaSet[index]) == YES)
- tempSet[i] = 1;
- }
- }
- else
- {
- /* we found the taxon name */
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- tempSet[index] = 1;
- }
- }
- foundDash = NO;
- fromI = toJ = everyK = -1;
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(SEMICOLON);
- }
- else if (expecting == Expecting(NUMBER))
- {
- if (strlen(tkn) == 1 && !strcmp(tkn, "."))
- tempInt = numTaxa;
- else
- {
- sscanf (tkn, "%d", &tempInt);
- if (tempInt <= 0 || tempInt > numTaxa)
- {
- MrBayesPrint ("%s Taxon number %d is out of range (should be between %d and %d)\n", spacer, tempInt, 1, numTaxa);
- return (ERROR);
- }
- }
- tempInt--;
- if (foundDash == YES)
- {
- if (fromI >= 0)
- toJ = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted delete set\n", spacer);
- return (ERROR);
- }
- foundDash = NO;
- }
- else
- {
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- }
- else if (fromI < 0 && toJ < 0)
- {
- fromI = tempInt;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else
- {
- MrBayesPrint ("%s Improperly formatted delete set\n", spacer);
- {
- return (ERROR);
- }
- }
- }
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(SEMICOLON);
- expecting |= Expecting(DASH);
- }
- else if (expecting == Expecting(DASH))
- {
- foundDash = YES;
- expecting = Expecting(NUMBER);
- }
- else
- return (ERROR);
- return (NO_ERROR);
- }
- int DoDimensions (void)
- {
- if (inDataBlock == NO && inTaxaBlock == NO && inCharactersBlock == NO)
- {
- MrBayesPrint ("%s Dimensions can only be defined in a data, characters or taxa block\n", spacer);
- return (ERROR);
- }
- /* other problems are detected already when reading in DoDimensionsParm */
- if (inDataBlock == YES && (defTaxa == NO || defChars == NO))
- {
- MrBayesPrint ("%s Expecting both Ntax and Nchar to be defined in a data block\n", spacer);
- return (ERROR);
- }
- /* allocate matrix */
- if (inTaxaBlock == YES)
- {
- if (AllocTaxa () == ERROR)
- return ERROR;
- MrBayesPrint ("%s Defining new set of %d taxa\n", spacer, numTaxa);
- }
- if (inCharactersBlock == YES)
- {
- if (AllocMatrix() == ERROR)
- return (ERROR);
- MrBayesPrint ("%s Defining new character matrix with %d characters\n", spacer, numChar);
- }
- if (inDataBlock == YES)
- {
- if (AllocMatrix() == ERROR)
- return (ERROR);
- MrBayesPrint ("%s Defining new matrix with %d taxa and %d characters\n", spacer, numTaxa, numChar);
- }
- return (NO_ERROR);
- }
- int DoDimensionsParm (char *parmName, char *tkn)
- {
- if (expecting == Expecting(PARAMETER))
- {
- expecting = Expecting(EQUALSIGN);
- }
- else
- {
- /* set Ntax (numTaxa) *****************************************************************/
- if (!strcmp(parmName, "Ntax"))
- {
- if (inCharactersBlock == YES)
- {
- MrBayesPrint ("%s You cannot define ntax in a characters block\n");
- return (ERROR);
- }
- if (expecting == Expecting(EQUALSIGN))
- expecting = Expecting(NUMBER);
- else if (expecting == Expecting(NUMBER))
- {
- sscanf (tkn, "%d", &numTaxa);
- defTaxa = YES;
- expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
- }
- else
- return (ERROR);
- }
- /* set Nchar (numChar) ****************************************************************/
- else if (!strcmp(parmName, "Nchar"))
- {
- if (inTaxaBlock == YES)
- {
- MrBayesPrint ("%s You cannot define nchar in a taxa block\n");
- return (ERROR);
- }
- if (expecting == Expecting(EQUALSIGN))
- expecting = Expecting(NUMBER);
- else if (expecting == Expecting(NUMBER))
- {
- sscanf (tkn, "%d", &numChar);
- defChars = YES;
- expecting = Expecting(PARAMETER) | Expecting(SEMICOLON);
- }
- else
- return (ERROR);
- }
- else
- return (ERROR);
- }
- return (NO_ERROR);
- }
- int DoDisclaimer (void)
- {
- MrBayesPrint (" --------------------------------------------------------------------------- \n");
- MrBayesPrint (" Disclaimer \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" Copyright 2003 by John P. Huelsenbeck and Fredrik Ronquist \n");
- MrBayesPrint (" \n");
- MrBayesPrint (" This software package is provided \"as is\" and without a warranty of any \n");
- MrBayesPrint (" kind. In no event shall the authors be held responsible for any damage \n");
- MrBayesPrint (" resulting from the use of this software. The program--including source code, \n");
- MrBayesPrint (" example data sets, and executables--is distributed free of charge for \n");
- MrBayesPrint (" academic use only. \n");
- MrBayesPrint (" --------------------------------------------------------------------------- \n");
- return (NO_ERROR);
- }
- int DoEndBlock (void)
- {
- if (inMrbayesBlock == YES)
- {
- MrBayesPrint (" Exiting mrbayes block\n");
- inMrbayesBlock = NO;
- }
- else if (inDataBlock == YES)
- {
- MrBayesPrint (" Exiting data block\n");
- inDataBlock = NO;
- }
- else if (inCharactersBlock == YES)
- {
- MrBayesPrint (" Exiting characters block\n");
- inCharactersBlock = NO;
- }
- else if (inTaxaBlock == YES)
- {
- MrBayesPrint (" Exiting taxa block\n");
- if (numNamedTaxa < numTaxa)
- {
- MrBayesPrint ("%s Leaving taxa block without taxon labels being defined\n", spacer);
- FreeTaxa();
- }
- inTaxaBlock = NO;
- }
- else if (inTreesBlock == YES)
- {
- MrBayesPrint (" Exiting trees block\n");
- inTreesBlock = NO;
- ResetTranslateTable();
- }
- else if (inForeignBlock == YES)
- {
- MrBayesPrint (" Exiting foreign block\n");
- inForeignBlock = NO;
- }
- else
- {
- MrBayesPrint (" Unknown \"end\" statement\n");
- return (ERROR);
- }
- strcpy(spacer,""); /* reset indentation */
- return (NO_ERROR);
- }
- int DoExecute (void)
- {
- int rc, cmdLine, lineTerm, longestLineLength, nErrors;
- char *s;
- FILE *fp;
- CmdType *oldCommandPtr;
- char *oldTokenP, oldToken[CMD_STRING_LENGTH];
- # if defined (MPI_ENABLED)
- int sumErrors;
- # endif
- nErrors = 0;
- cmdLine = 0;
- numOpenExeFiles++;
- s = NULL;
- if (numOpenExeFiles > 1)
- MrBayesPrint ("\n%s Executing file \"%s\"...\n\n", spacer, inputFileName);
- else
- MrBayesPrint ("%s Executing file \"%s\"\n", spacer, inputFileName);
- /* Save old command ptr, token pointer and token */
- oldCommandPtr = commandPtr;
- oldTokenP = tokenP;
- strcpy(oldToken, token);
- /* open binary file */
- if ((fp = OpenBinaryFileR(inputFileName)) == NULL)
- nErrors++;
- /* set indentation to 0 */
- strcpy (spacer, "");
- # if defined (MPI_ENABLED)
- MPI_Allreduce (&nErrors, &sumErrors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- if (sumErrors > 0)
- {
- MrBayesPrint ("%s There was an error on at least one processor\n", spacer);
- goto errorExit;
- }
- # else
- if (nErrors > 0)
- goto errorExit;
- # endif
- /* find out what type of line termination is used */
- lineTerm = LineTermType (fp);
- if (lineTerm == LINETERM_MAC)
- MrBayesPrint ("%s Macintosh line termination\n", spacer);
- else if (lineTerm == LINETERM_DOS)
- MrBayesPrint ("%s DOS line termination\n", spacer);
- else if (lineTerm == LINETERM_UNIX)
- MrBayesPrint ("%s UNIX line termination\n", spacer);
- else
- {
- MrBayesPrint ("%s Unknown line termination\n", spacer);
- nErrors++;
- }
- # if defined (MPI_ENABLED)
- MPI_Allreduce (&nErrors, &sumErrors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- if (sumErrors > 0)
- {
- MrBayesPrint ("%s There was an error on at least one processor\n", spacer);
- goto errorExit;
- }
- # else
- if (nErrors > 0)
- goto errorExit;
- # endif
- /* find length of longest line */
- longestLineLength = LongestLine (fp);
- MrBayesPrint ("%s Longest line length = %d\n", spacer, longestLineLength);
- longestLineLength += 10;
- /* allocate a string long enough to hold a line */
- s = (char *)SafeMalloc((size_t)longestLineLength * sizeof(char));
- if (!s)
- {
- MrBayesPrint ("%s Problem allocating string for reading file\n", spacer);
- nErrors++;
- }
- # if defined (MPI_ENABLED)
- MPI_Allreduce (&nErrors, &sumErrors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- if (sumErrors > 0)
- {
- MrBayesPrint ("%s There was an error on at least one processor\n", spacer);
- goto errorExit;
- }
- # else
- if (nErrors > 0)
- goto errorExit;
- # endif
- /* close binary file */
- SafeFclose (&fp);
- /* open text file */
- if ((fp = OpenTextFileR(inputFileName)) == NULL)
- {
- nErrors++;
- }
- # if defined (MPI_ENABLED)
- MPI_Allreduce (&nErrors, &sumErrors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- if (sumErrors > 0)
- {
- MrBayesPrint ("%s There was an error on at least one processor\n", spacer);
- goto errorExit;
- }
- # else
- if (nErrors > 0)
- goto errorExit;
- # endif
- /* parse file, reading each line in turn */
- MrBayesPrint ("%s Parsing file\n", spacer);
- inMrbayesBlock = inDataBlock = inForeignBlock = inTreesBlock = NO;
- foundNewLine = NO;
- expecting = Expecting(COMMAND);
- cmdLine = 0;
- /* read lines into s until end of file */
- while ( fgets(s, longestLineLength, fp) != NULL)
- {
- foundNewLine = YES;
- cmdLine++;
- /* process string if not empty */
- if (strlen(s) > 1)
- {
- /* check that all characters in the string are valid */
- if (CheckStringValidity (s) == ERROR)
- {
- nErrors++;
- }
- # if defined (MPI_ENABLED)
- MPI_Allreduce (&nErrors, &sumErrors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- if (sumErrors > 0)
- {
- MrBayesPrint ("%s There was an error on at least one processor\n", spacer);
- goto errorExit;
- }
- # else
- if (nErrors > 0)
- goto errorExit;
- # endif
- /* interpret commands on line */
- rc = ParseCommand (s);
- if (rc == ERROR)
- nErrors++;
- # if defined (MPI_ENABLED)
- MPI_Allreduce (&nErrors, &sumErrors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- if (sumErrors > 0)
- {
- MrBayesPrint ("%s There was an error on at least one processor\n", spacer);
- goto errorExit;
- }
- # else
- if (nErrors > 0)
- goto errorExit;
- # endif
- if (rc == NO_ERROR_QUIT)
- nErrors++;
- # if defined (MPI_ENABLED)
- MPI_Allreduce (&nErrors, &sumErrors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- if (sumErrors > 0)
- goto quitExit;
- # else
- if (nErrors > 0)
- goto quitExit;
- # endif
- }
- }
- MrBayesPrint ("%s Reached end of file\n", spacer);
- if (inComment == YES)
- nErrors++;
- # if defined (MPI_ENABLED)
- MPI_Allreduce (&nErrors, &sumErrors, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- if (sumErrors > 0)
- {
- MrBayesPrint ("%s There was an error on at least one processor\n", spacer);
- goto errorExit;
- }
- # else
- if (nErrors > 0)
- goto errorExit;
- # endif
- if (s)
- free (s);
- SafeFclose (&fp);
- numOpenExeFiles--;
- if (numOpenExeFiles > 0)
- {
- inMrbayesBlock = YES;
- MrBayesPrint ("\n Returning execution to calling file ...\n\n");
- strcpy (spacer, " ");
- }
- else
- strcpy (spacer, "");
- commandPtr = oldCommandPtr;
- return (NO_ERROR);
- quitExit:
- if (s)
- free (s);
- SafeFclose (&fp);
- numOpenExeFiles--;
- if (numOpenExeFiles > 0)
- {
- inMrbayesBlock = YES;
- strcpy (spacer, " ");
- }
- else
- strcpy (spacer, "");
- commandPtr = oldCommandPtr;
- tokenP = oldTokenP;
- strcpy(token, oldToken);
- return (NO_ERROR_QUIT);
- errorExit:
- if (inComment == YES)
- {
- MrBayesPrint ("%s ERROR: Reached end of file while in comment.\n", spacer);
- inComment = NO;
- numComments = 0;
- }
- if (fp)
- {
- MrBayesPrint ("%s The error occurred when reading char. %d-%d on line %d\n", spacer,
- (size_t)(tokenP-s)-strlen(token)+1, (size_t)(tokenP-s), cmdLine);
- MrBayesPrint ("%s in the file '%s'\n", spacer, inputFileName);
- }
- if (s)
- free (s);
- SafeFclose (&fp);
- /* make sure we exit the block we were reading from correctly */
- if (inMrbayesBlock == YES)
- inMrbayesBlock = NO;
- else if (inDataBlock == YES)
- inDataBlock = NO;
- else if (inTreesBlock == YES)
- {
- inTreesBlock = NO;
- ResetTranslateTable();
- }
- else if (inForeignBlock == YES)
- inForeignBlock = NO;
- /* make sure correct return if we came from mrbayes block in another execute file */
- if (numOpenExeFiles > 1)
- {
- inMrbayesBlock = YES;
- MrBayesPrint ("\n Returning execution to calling file ...\n\n");
- strcpy (spacer, " ");
- }
- else
- {
- strcpy (spacer, "");
- MrBayesPrint ("\n Returning execution to command line ...\n\n");
- }
- numOpenExeFiles--; /* we increase the value above even if no file is successfully opened */
- /* restore state of globals */
- commandPtr = oldCommandPtr;
- tokenP = oldTokenP;
- strcpy(token, oldToken);
- return (ERROR);
- }
- int DoExecuteParm (char *parmName, char *tkn)
- {
- if (strlen(tkn)>99)
- {
- MrBayesPrint ("%s Maximum allowed length of file name is 99 characters. The given name:\n", spacer);
- MrBayesPrint ("%s '%s'\n", spacer,tkn);
- MrBayesPrint ("%s has %d characters.\n", spacer, strlen(tkn));
- return (ERROR);
- }
- strcpy (inputFileName, tkn);
- expecting = Expecting (SEMICOLON);
- return (NO_ERROR);
- }
- int DoExclude (void)
- {
- int i, alreadyDone;
- MrBayesPrint ("%s Excluding character(s)\n", spacer);
- /* add set to tempSet */
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- }
- /* merge tempSet with charset */
- alreadyDone = NO;
- for (i=0; i<numChar; i++)
- {
- if (tempSet[i] == 1)
- {
- if (charInfo[i].isExcluded == YES && alreadyDone == NO)
- {
- MrBayesPrint ("%s Some characters already excluded\n", spacer);
- alreadyDone = YES;
- }
- charInfo[i].isExcluded = YES;
- }
- }
- foundFirst = NO;
- /* reset analysis to recompress data */
- if (SetUpAnalysis(&globalSeed) == ERROR)
- return ERROR;
- return (NO_ERROR);
- }
- int DoExcludeParm (char *parmName, char *tkn)
- {
- int i, index, tempInt;
- if (defMatrix == NO)
- {
- MrBayesPrint ("%s A matrix must be specified before you can exclude characters\n", spacer);
- return (ERROR);
- }
- if (foundFirst == NO)
- {
- /* this is the first time in */
- fromI = toJ = everyK = -1;
- foundDash = foundSlash = NO;
- for (i=0; i<numChar; i++) /* clear tempSet */
- tempSet[i] = 0;
- foundFirst = YES;
- }
- if (expecting == Expecting(ALPHA))
- {
- if (IsSame ("All", tkn) == SAME || IsSame ("All", tkn) == CONSISTENT_WITH)
- {
- for (i=0; i<numChar; i++)
- tempSet[i] = 1;
- }
- else if (IsSame ("Missambig", tkn) == SAME || IsSame ("Missambig", tkn) == CONSISTENT_WITH)
- {
- for (i=0; i<numChar; i++)
- {
- if (charInfo[i].isMissAmbig == YES)
- tempSet[i] = 1;
- }
- }
- else
- {
- /* we are using a pre-defined character set */
- if (numCharSets < 1)
- {
- MrBayesPrint ("%s Could not find a character set called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- if (CheckString (charSetNames, numCharSets, tkn, &index) == ERROR)
- {
- MrBayesPrint ("%s Could not find a character set called '%s'\n", spacer, tkn);
- return (ERROR);
- }
- /* add characters from charset tkn to new tempSet */
- for (i=0; i<numChar; i++)
- {
- if (IsBitSet(i, charSet[index]) == YES)
- tempSet[i] = 1;
- }
- fromI = toJ = everyK = -1;
- }
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(SEMICOLON);
- }
- else if (expecting == Expecting(NUMBER))
- {
- if (strlen(tkn) == 1 && tkn[0] == '.')
- tempInt = numChar;
- else
- sscanf (tkn, "%d", &tempInt);
- if (tempInt <= 0 || tempInt > numChar)
- {
- MrBayesPrint ("%s Character number %d is out of range (should be between %d and %d)\n", spacer, tempInt, 1, numChar);
- return (ERROR);
- }
- tempInt--;
- if (foundDash == YES)
- {
- if (fromI >= 0)
- toJ = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted exclude set\n", spacer);
- return (ERROR);
- }
- foundDash = NO;
- }
- else if (foundSlash == YES)
- {
- tempInt++;
- if (tempInt <= 1)
- {
- MrBayesPrint ("%s Improperly formatted exclude set\n", spacer);
- return (ERROR);
- }
- if (fromI >= 0 && toJ >= 0 && fromI < toJ)
- everyK = tempInt;
- else
- {
- MrBayesPrint ("%s Improperly formatted exclude set\n", spacer);
- return (ERROR);
- }
- foundSlash = NO;
- }
- else
- {
- if (fromI >= 0 && toJ < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- }
- else if (fromI < 0 && toJ < 0)
- {
- fromI = tempInt;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK < 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else if (fromI >= 0 && toJ >= 0 && everyK >= 0)
- {
- if (AddToSet (fromI, toJ, everyK, 1) == ERROR)
- return (ERROR);
- fromI = tempInt;
- toJ = everyK = -1;
- }
- else
- {
- MrBayesPrint ("%s Improperly formatted exclude set\n", spacer);
- {
- return (ERROR);
- }
- }
- }
- expecting = Expecting(ALPHA);
- expecting |= Expecting(NUMBER);
- expecting |= Expecting(SEMICOLON);
- expecting |= Expecting(DASH);
- expecting |= Expecting(BACKSLASH);
- }
- else if (expecting == Expecting(DASH))
- {
- foundDash = YES;
- expecting = Expecting(NUMBER);
- }
- else if (expecting == Expecting(BACKSLASH))
- {
- foundSlash = YES;
- expecting = Expecting(NUMBER);
- }
- else
- return (ERROR);
- return (NO_ERROR);
- }
- int DoFormat (void)
- {
- if (inDataBlock == NO && inCharactersBlock == NO)
- {
- MrBayesPrint ("%s Formats can only be defined in a data or characters block\n", spacer);
- return (ERROR);
- }
- return CheckInitialPartitions();
- }
- int DoFormatParm (char *parmName, char *tkn)
- {
- int i, tempInt;
- char tempStr[100];
- if (inDataBlock == NO && inCharactersBlock == NO)
- {
- MrBayesPrint ("%s Formats can only be defined in a data or characters block\n", spacer);
- return (ERROR);
- }
- if (defTaxa == NO || defChars == NO)
- {
- MrBayesPrint ("%s The dimensions of the matrix must be defined before the format\n", spacer);
- return (ERROR);
- }
- if (expecting == Expecting(PARAMETER))
- {
- expecting = Expecting(EQUALSIGN);
- if (!strcmp(parmName, "Interleave"))
- {
- expecting = Expecting(EQUALSIGN) | Expecting(PARAMETER) | Expecting(SEMICOLON);
- isInterleaved = YES;
- }
- }
- else
- {
- /* set Datatype (dataType) ************************************************************/
- if (!strcmp(parmName, "Datatype"))
- {
- if (expecting == Expecting(EQUALSIGN))
- expecting = Expecting(ALPHA);
- else if (expecting == Expecting(ALPHA))
- {
- if (IsArgValid(tkn, tempStr) == NO_ERROR)
- {
- if (isMixed == NO)
- {
- if (!strcmp(tempStr, "Dna"))
- dataType = DNA;
- else if (!strcmp(tempStr, "Rna"))
- dataType = RNA;
- else if (!strcmp(tempStr, "Protein"))
- dataType = PROTEIN;
- else if (!strcmp(tempStr, "Restriction"))
- dataType = RESTRICTION;
- else if (!strcmp(tempStr, "Standard"))
- dataType = STANDARD;
- else if (!strcmp(tempStr, "Continuous"))
- dataType = CONTINUOUS;
- else if (!strcmp(tempStr, "Mixed"))
- {
command.c at commit 3c99f1d, under GPL-3.0 · at the source
Overview
- Department of Ecology and Evolutionary Biology, Princeton University,Princeton, NJ USA
- Department of Palaeontology, Staatliches Museum für Naturkunde Stuttgart,Stuttgart, Germany
- Institute of Biotechnology, Helsinki Institute of Life Science, University of Helsinki,Helsinki, Finland
- Division of Ecology and Evolution, Research School of Biology, Australian National University,Canberra, Australian Central Territory Australia
- Sciences Department, Museums Victoria,Melbourne, Victoria Australia
- Laboratório de Paleontologia de Ribeirão Preto, Departamento de Biologia, Faculdade de Filosofia Ciências e Letras de Ribeirão Preto, Universidade de São Paulo,Ribeirão Preto, Brazil
- Sección Paleontología de Vertebrados, Museo Argentino de Ciencias Naturales “Bernardino Rivadavia”,Buenos Aires, Argentina
- Museu de Paleontologia de Marília, Marília, Brazil
- Laboratório de Paleobiologia, Programa de Pós-Graduação em Ciências Biológicas, Universidade Federal do Pampa,São Gabriel, Brazil
- Dinosaur Institute, Natural History Museum of Los Angeles County,Los Angeles, CA USA
- Laboratório de Paleobiodiversidade Integrada, Departamento de Biologia, Faculdade de Filosofia Ciências e Letras de Ribeirão Preto, Universidade de São Paulo,Ribeirão Preto, Brazil
Abstract
The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.
Repository
Its files are read in the Code ↔ Paper reader above, with 10 matches between paragraphs and lines of code.
NBISweden/MrBayes
3c99f1df0a5eaf7ad1f54e08974fe4a68cca9a48, 18 September 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
23 files
- autotools/
tap-driver.sh , Shell, 655 lines - src/
bayes.c , C, 1,114 lines, 3 matches - src/
bayes.h , C/C++, 1,838 lines, 2 matches - src/
best.c , C, 1,816 lines - src/
best.h , C/C++, 29 lines - src/
command.c , C, 4,121 lines, 3 matches - src/
command.h , C/C++, 34 lines - src/
likelihood.c , C, 5,448 lines - src/
likelihood.h , C/C++, 171 lines - src/
mbbeagle.c , C, 3,022 lines - src/
mbbeagle.h , C/C++, 39 lines - src/
mcmc.c , C, 5,550 lines, 1 match - src/
mcmc.h , C/C++, 35 lines - src/
model.c , C, 4,982 lines - src/
model.h , C/C++, 60 lines - src/
proposal.c , C, 5,754 lines - src/
proposal.h , C/C++, 94 lines - src/
sumpt.c , C, 5,170 lines, 1 match - src/
sumpt.h , C/C++, 51 lines - src/
utils.c , C, 6,931 lines - src/
utils.h , C/C++, 288 lines - COPYING, License, 674 lines
- README, Text, 58 lines
Code availability statement
The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- no repository, dataset or request procedure was recognized in it
Read it in the paper: doi.org/10.1038/s41586-026-10809-9.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 21 scripts, each with its path and the digest of its content;
- 10 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
Datasets cited
- doi:10.7910/
dvn/ , at the source; found in “Data availability”c6wxmo
Data availability statement
The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to a dataset: DOI 10.7910/
dvn/ c6wxmo
Read it in the paper: doi.org/10.1038/s41586-026-10809-9.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 2, 28 September 2026
- Publisher: n/a → Nature Portfolio
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 11 authors, 3 keywords, 14 MeSH terms, 77 references, 2 RRIDs.
Cite
This paper
Simões, T. R., Sobral, G., Macrì, S., Ebel, R., Fachini, T. S., Martinelli, A. G., Nava, W. R., Paixão, G. M. X., Chiappe, L. M., Di-Poï, N., & Hsiou, A. S. (2026). Exceptional brain and ecological diversity in the earliest snakes. Nature, 657(8130), 170-178. https://
BibTeX
@article{simoes2026excep
author = {Simões, Tiago R. and Sobral, Gabriela and Macrì, Simone and Ebel, Roy and Fachini, Thiago S. and Martinelli, Agustín G. and Nava, William R. and Paixão, Giovanna M. X. and Chiappe, Luis M. and Di-Poï, Nicolas and Hsiou, Annie S.},
title = {{Exceptional brain and ecological diversity in the earliest snakes}},
journal = {Nature},
year = {2026},
month = jul,
volume = {657},
number = {8130},
pages = {170--178},
publisher = {Nature Portfolio},
issn = {0028-0836},
doi = {10.1038/
url = {https://
pmid = {42486987},
pmcid = {PMC13538052}
}
RIS
TY - JOUR
AU - Simões, Tiago R.
AU - Sobral, Gabriela
AU - Macrì, Simone
AU - Ebel, Roy
AU - Fachini, Thiago S.
AU - Martinelli, Agustín G.
AU - Nava, William R.
AU - Paixão, Giovanna M. X.
AU - Chiappe, Luis M.
AU - Di-Poï, Nicolas
AU - Hsiou, Annie S.
TI - Exceptional brain and ecological diversity in the earliest snakes
T2 - Nature
J2 - Nature
PY - 2026
DA - 2026/
VL - 657
IS - 8130
SP - 170
EP - 178
SN - 0028-0836
PB - Nature Portfolio
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Exceptional brain and ecological diversity in the earliest snakes",
"container-title": "Nature",
"author": [
{
"family": "Simões",
"given": "Tiago R."
},
{
"family": "Sobral",
"given": "Gabriela"
},
{
"family": "Macrì",
"given": "Simone"
},
{
"family": "Ebel",
"given": "Roy"
},
{
"family": "Fachini",
"given": "Thiago S."
},
{
"family": "Martinelli",
"given": "Agustín G."
},
{
"family": "Nava",
"given": "William R."
},
{
"family": "Paixão",
"given": "Giovanna M. X."
},
{
"family": "Chiappe",
"given": "Luis M."
},
{
"family": "Di-Poï",
"given": "Nicolas"
},
{
"family": "Hsiou",
"given": "Annie S."
}
],
"container-title-short":
"volume": "657",
"issue": "8130",
"page": "170-178",
"DOI": "10.1038/
"PMID": "42486987",
"PMCID": "PMC13538052",
"ISSN": "0028-0836",
"publisher": "Nature Portfolio",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
22
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s41598-026-53133-y [code]
- Evolutionary stasis in synapsid encephalization during the end-permian mass extinction.Journal: Scientific reportsIn common: 3 references
- [2] doi:10.1093/molbev/msag159 [code]
- Genomic signature of repeated transitions to diurnality in spiders.Journal: Molecular biology and evolutionIn common: 2 references
- [3] doi:10.1093/nar/gkag544 [code]
- Single-base resolution atlas reveals moderate conservation and regulatory diversity of m6A modifications across mammals.Journal: Nucleic acids researchIn common: 2 references
- [4] doi:10.1038/s41467-026-75225-z [code]
- A single-cell atlas of alternative wing development in two hemipteran species.Journal: Nature communicationsIn common: 2 references
- [5] doi:10.1111/jne.70203 [code]
- Nonapeptide molecular evolution during the adaptive radiation of Tanganyika cichlids.Journal: Journal of neuroendocrinologyIn common: 2 references
- [6] doi:10.1016/j.xpro.2026.104787 [code]
- Protocol for 3D digital dynamic histomorphometry of mouse bone via time-lapse registration of serial microCT scans.Journal: STAR protocolsIn common: 1 reference
- [7] doi:10.1093/pnasnexus/pgag055 [code]
- Comparative transcriptomics reveals differences in cortical cell type organization between metatherian and eutherian mammals.Journal: PNAS nexusIn common: 1 reference
- [8] doi:10.1016/j.isci.2026.116825 [code]
- Social hierarchy shapes behavioral and transcriptional responses to chronic stress and ketamine in male mice.Journal: iScienceIn common: 1 reference
- [9] doi:10.1186/s12879-026-13657-0
- Fatal European subtype tick-borne encephalitis in a fully vaccinated immunocompetent child: a case report with viral sequencing.Journal: BMC infectious diseasesIn common: 1 reference
- [10] doi:10.1002/mrm.70380 [code]
- The Impact and Reliability of Tissue Segmentation on In Vivo Magnetic Resonance Spectroscopy Metabolite Quantification.Journal: Magnetic resonance in medicineIn common: 1 reference
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 21 scripts, and 10 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:db6ea3994c0e5ecd…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
