bool GeneralGamlConfig::ReadPossibleModelPartition(ConfigReader &cr){ string origSection = cr.GetCurrentSection(); bool foundAnyModels = false; for(int modelNum = 0; ;modelNum++){ char modName[10]; sprintf(modName, "model%d", modelNum); int found = cr.SetSection(modName); //models need to appear consecuatively, but can start at 0 (old) or 1 (new) if(modelNum == 0 && found < 0){ continue; } else if(found < 0){ cr.SetSection(origSection.c_str()); return foundAnyModels; } else{ foundAnyModels = true; ConfigModelSettings configModSet; cr.GetStringOption("ratehetmodel", configModSet.rateHetModel, true); cr.GetUnsignedOption("numratecats", configModSet.numRateCats, true); cr.GetStringOption("statefrequencies", configModSet.stateFrequencies, true); cr.GetStringOption("ratematrix", configModSet.rateMatrix, true); cr.GetStringOption("invariantsites", configModSet.proportionInvariant, true); cr.GetStringOption("datatype", configModSet.datatype, true); cr.GetStringOption("geneticcode", configModSet.geneticCode, true); configModelSets.push_back(configModSet); } } //we shouldn't be getting to here return false; }
int GeneralGamlConfig::Read(const char* fname, bool isMaster /*=false*/) { ConfigReader cr; if (cr.Load(fname) != 0) { printf("ERROR: GamlConfig::General::Read(%s) failed.\n", fname); return -1; } int errors = 0; errors += cr.SetSection("general"); if(errors < 0) throw ErrorException("Didn't find [general] section in config file\n (this section heading is required)"); errors += cr.GetUnsignedOption("logevery", logevery); errors += cr.GetUnsignedOption("saveevery", saveevery); int found=cr.GetPositiveNonZeroDoubleOption("megsclamemory", megsClaMemory, true); found += cr.GetPositiveNonZeroDoubleOption("availablememory", availableMemory, true); if(found == -2) throw ErrorException("Either \"megsclamemory\" or \"availablememory\" must be specified in conf!"); errors += cr.GetStringOption("datafname", datafname); errors += cr.GetStringOption("ofprefix", ofprefix); errors += cr.GetStringOption("streefname", streefname); cr.GetStringOption("constraintfile", constraintfile, true); errors += cr.GetIntNonZeroOption("randseed", randseed); errors += cr.GetBoolOption("refinestart", refineStart); cr.GetBoolOption("refineend", refineEnd, true); errors += cr.GetBoolOption("outputeachbettertopology", outputTreelog); errors += cr.GetBoolOption("enforcetermconditions", enforceTermConditions); errors += cr.GetUnsignedNonZeroOption("genthreshfortopoterm", lastTopoImproveThresh); errors += cr.GetPositiveNonZeroDoubleOption("scorethreshforterm", improveOverStoredIntervalsThresh); cr.GetPositiveNonZeroDoubleOption("significanttopochange", significantTopoChange, true); cr.GetUnsignedNonZeroOption("attachmentspertaxon", attachmentsPerTaxon, true); cr.GetUnsignedOption("outputsitelikelihoods", outputSitelikelihoods, true); cr.GetBoolOption("reportrunprogress", reportRunProgress, true); cr.GetBoolOption("outputmostlyuselessfiles", outputMostlyUselessFiles, true); cr.GetBoolOption("outputphyliptree", outputPhylipTree, true); cr.GetBoolOption("collapsebranches", collapseBranches, true); cr.GetIntOption("genthreshforswapterm", swapTermThreshold, true); cr.GetStringOption("arbitrarystring", arbitraryString, true); cr.GetUnsignedOption("windowlength", siteWindowLength, true); cr.GetUnsignedOption("windowstride", siteWindowStride, true); cr.GetBoolOption("usepatternmanager", usePatternManager, true); //changed the wording of this from besttree to besttopology, to match outputeachbettertopology //still allow besttree, since that is what I told Maddison, and I think has already been incorporated //into Mesquite int ret = cr.GetBoolOption("outputcurrentbesttopology", outputCurrentBestTopology, true); if(ret < 0) cr.GetBoolOption("outputcurrentbesttree", outputCurrentBestTopology, true); cr.GetBoolOption("restart", restart, true); cr.GetBoolOption("writecheckpoints", checkpoint, true); //after changes to Population, this is now allowed // if((restart || checkpoint) && collapseBranches) // throw ErrorException("Sorry, the collapsebranches option can not currently be used with checkpointing"); cr.GetUnsignedNonZeroOption("searchreps", searchReps, true); cr.GetUnsignedOption("runmode", runmode, true); cr.GetBoolOption("scoreonly", scoreOnly, true); //cr.GetBoolOption("useflexrates", useflexrates, true); //cr.GetBoolOption("dontinferproportioninvariant", dontInferProportionInvariant, true); cr.GetStringOption("ratehetmodel", rateHetModel, true); cr.GetUnsignedOption("numratecats", numRateCats, true); cr.GetStringOption("statefrequencies", stateFrequencies, true); cr.GetStringOption("ratematrix", rateMatrix, true); if(cr.GetStringOption("invariantsites", proportionInvariant, true) == -1) proportionInvariant = "unspecified"; cr.GetStringOption("datatype", datatype, true); cr.GetStringOption("geneticcode", geneticCode, true); cr.GetStringOption("outgroup", outgroupString, true); if(isMaster){ errors += cr.SetSection("master"); if(errors < 0) throw ErrorException("Didn't find [master] section in config file\n (this section heading is required)"); } else{ errors += cr.SetSection("remote"); if(errors < 0) throw ErrorException("Didn't find [remote] section in config file\n (this section heading is required)"); } errors += cr.GetUnsignedNonZeroOption("nindivs", nindivs); errors += cr.GetUnsignedOption("holdover", holdover); errors += cr.GetPositiveNonZeroDoubleOption("selectionintensity", selectionIntensity); errors += cr.GetDoubleOption("holdoverpenalty", holdoverPenalty); errors += cr.GetUnsignedNonZeroOption("stopgen", stopgen); errors += cr.GetUnsignedNonZeroOption("stoptime", stoptime); errors += cr.GetPositiveNonZeroDoubleOption("startoptprec", startOptPrec); errors += cr.GetPositiveNonZeroDoubleOption("minoptprec", minOptPrec); //changing this to specify either the number of reductions in the precision or the //multiplier as before. Prefer the number, since it should be easier to specify. // found=0; found=cr.GetIntOption("numberofprecreductions", numPrecReductions, true); found += cr.GetPositiveNonZeroDoubleOption("precreductionfactor", precReductionFactor, true); if(found == -2) throw ErrorException("Error: either \"numberofprecreductions\" (preferably) or \"precreductionfactor\" must be specified in conf!"); errors += cr.GetPositiveDoubleOption("topoweight", topoWeight); errors += cr.GetPositiveDoubleOption("modweight", modWeight); errors += cr.GetPositiveDoubleOption("brlenweight", brlenWeight); errors += cr.GetPositiveDoubleOption("randnniweight", randNNIweight); errors += cr.GetPositiveDoubleOption("randsprweight", randSPRweight); errors += cr.GetPositiveDoubleOption("limsprweight", limSPRweight); cr.GetPositiveNonZeroDoubleOption("uniqueswapbias", uniqueSwapBias, true); cr.GetPositiveNonZeroDoubleOption("distanceswapbias", distanceSwapBias, true); cr.GetDoubleOption("treerejectionthreshold", treeRejectionThreshold, true); cr.GetUnsignedOption("bootstrapreps", bootstrapReps, true); cr.GetPositiveNonZeroDoubleOption("resampleproportion", resampleProportion, true); #ifdef MPI_VERSION if(bootstrapReps != 0) throw ErrorException("Sorry, Bootstrap not yet implemented in parallel GARLI!"); #endif cr.GetBoolOption("inferinternalstateprobs", inferInternalStateProbs, true); #ifdef MPI_VERSION if(isMaster==false) errors += cr.GetDoubleOption("sendinterval", sendInterval); #endif #ifdef GANESH errors += cr.GetDoubleOption("randpecrweight", randPECRweight); #endif // errors += cr.GetUnsignedOption("gammashapebrlen", gammaShapeBrlen); // errors += cr.GetUnsignedOption("gammashapemodel", gammaShapeModel); errors += cr.GetPositiveNonZeroDoubleOption("gammashapebrlen", gammaShapeBrlen); errors += cr.GetPositiveNonZeroDoubleOption("gammashapemodel", gammaShapeModel); errors += cr.GetUnsignedNonZeroOption("limsprrange", limSPRrange); errors += cr.GetUnsignedNonZeroOption("intervallength", intervalLength); errors += cr.GetUnsignedNonZeroOption("intervalstostore", intervalsToStore); errors += cr.GetPositiveNonZeroDoubleOption("meanbrlenmuts", meanBrlenMuts); cr.GetPositiveNonZeroDoubleOption("minbrlen", minBrlen, true); cr.GetPositiveNonZeroDoubleOption("maxbrlen", maxBrlen, true); cr.GetPositiveNonZeroDoubleOption("startingbrlen", startingBrlen, true); #ifdef INCLUDE_PERTURBATION errors += cr.SetSection("perturbation"); errors += cr.GetIntOption("perttype", pertType); errors += cr.GetDoubleOption("pertthresh", pertThresh); errors += cr.GetIntOption("minpertinterval", minPertInterval); errors += cr.GetIntOption("maxpertsnoimprove", maxPertsNoImprove); errors += cr.GetBoolOption("restartafterabandon", restartAfterAbandon); errors += cr.GetIntOption("gensbeforerestart", gensBeforeRestart); errors += cr.GetDoubleOption("ratchetproportion", ratchetProportion); errors += cr.GetDoubleOption("ratchetoffthresh", ratchetOffThresh); errors += cr.GetIntOption("ratchetmaxgen", ratchetMaxGen); errors += cr.GetIntOption("nnitargetaccepts", nniTargetAccepts); errors += cr.GetIntOption("nnimaxattempts", nniMaxAttempts); errors += cr.GetIntOption("numsprcycles", numSprCycles); errors += cr.GetIntOption("sprpertrange", sprPertRange); #endif return errors; }
int GeneralGamlConfig::Read(const char* fname, bool isMaster /*=false*/) { ConfigReader cr; if (cr.Load(fname) != 0) { printf("ERROR: GamlConfig::General::Read(%s) failed.\n", fname); return -1; } int errors = 0; errors += cr.SetSection("general"); errors += cr.GetIntOption("logevery", logevery); errors += cr.GetIntOption("saveevery", saveevery); errors += cr.GetDoubleOption("megsclamemory", megsClaMemory); errors += cr.GetStringOption("datafname", datafname); // errors += cr.GetStringOption("method", method); errors += cr.GetStringOption("ofprefix", ofprefix); errors += cr.GetStringOption("streefname", streefname); errors += cr.GetIntOption("randseed", randseed); errors += cr.GetBoolOption("refinestart", refineStart); errors += cr.GetBoolOption("outputeachbettertopology", outputTreelog); errors += cr.GetBoolOption("enforcetermconditions", enforceTermConditions); errors += cr.GetIntOption("genthreshfortopoterm", lastTopoImproveThresh); errors += cr.GetDoubleOption("scorethreshforterm", improveOverStoredIntervalsThresh); if(isMaster) errors += cr.SetSection("master"); else errors += cr.SetSection("remote"); errors += cr.GetIntOption("nindivs", min_nindivs); max_nindivs=min_nindivs; errors += cr.GetIntOption("holdover", holdover); errors += cr.GetDoubleOption("selectionintensity", selectionIntensity); errors += cr.GetDoubleOption("holdoverpenalty", holdoverPenalty); errors += cr.GetIntOption("stopgen", stopgen); errors += cr.GetIntOption("stoptime", stoptime); errors += cr.GetDoubleOption("startoptprec", startOptPrec); errors += cr.GetDoubleOption("minoptprec", minOptPrec); errors += cr.GetDoubleOption("precreductionfactor", precReductionFactor); errors += cr.GetDoubleOption("topoweight", topoWeight); errors += cr.GetDoubleOption("modweight", modWeight); errors += cr.GetDoubleOption("brlenweight", brlenWeight); errors += cr.GetDoubleOption("randnniweight", randNNIweight); errors += cr.GetDoubleOption("randsprweight", randSPRweight); errors += cr.GetDoubleOption("limsprweight", limSPRweight); #ifdef MPI_VERSION if(isMaster==false) errors += cr.GetDoubleOption("sendinterval", sendInterval); #endif #ifdef GANESH errors += cr.GetDoubleOption("randpecrweight", randPECRweight); #endif errors += cr.GetIntOption("gammashapebrlen", gammaShapeBrlen); errors += cr.GetIntOption("gammashapemodel", gammaShapeModel); errors += cr.GetIntOption("limsprrange", limSPRrange); errors += cr.GetIntOption("intervallength", intervalLength); errors += cr.GetIntOption("intervalstostore", intervalsToStore); errors += cr.GetDoubleOption("meanbrlenmuts", minBrlenMuts); maxBrlenMuts=minBrlenMuts; #ifdef INCLUDE_PERTURBATION errors += cr.SetSection("perturbation"); errors += cr.GetIntOption("perttype", pertType); errors += cr.GetDoubleOption("pertthresh", pertThresh); errors += cr.GetIntOption("minpertinterval", minPertInterval); errors += cr.GetIntOption("maxpertsnoimprove", maxPertsNoImprove); errors += cr.GetBoolOption("restartafterabandon", restartAfterAbandon); errors += cr.GetIntOption("gensbeforerestart", gensBeforeRestart); errors += cr.GetDoubleOption("ratchetproportion", ratchetProportion); errors += cr.GetDoubleOption("ratchetoffthresh", ratchetOffThresh); errors += cr.GetIntOption("ratchetmaxgen", ratchetMaxGen); errors += cr.GetIntOption("nnitargetaccepts", nniTargetAccepts); errors += cr.GetIntOption("nnimaxattempts", nniMaxAttempts); errors += cr.GetIntOption("numsprcycles", numSprCycles); errors += cr.GetIntOption("sprpertrange", sprPertRange); #endif return errors; }
int GeneralGamlConfig::Read(const char* fname, bool isMaster /*=false*/) { ConfigReader cr; if (cr.Load(fname) != 0) { printf("ERROR: GamlConfig::General::Read(%s) failed.\n", fname); return -1; } cr.MakeAllSection(); int errors = 0; errors += cr.SetSection("general"); if(errors < 0) throw ErrorException("Didn't find [general] section in config file\n (this section heading is required)"); errors += cr.GetUnsignedOption("logevery", logevery); errors += cr.GetUnsignedOption("saveevery", saveevery); int found=cr.GetPositiveNonZeroDoubleOption("megsclamemory", megsClaMemory, true); found += cr.GetPositiveNonZeroDoubleOption("availablememory", availableMemory, true); if(found == -2) throw ErrorException("Either \"megsclamemory\" or \"availablememory\" must be specified in conf!"); errors += cr.GetStringOption("datafname", datafname); errors += cr.GetStringOption("ofprefix", ofprefix); errors += cr.GetStringOption("streefname", streefname); cr.GetStringOption("constraintfile", constraintfile, true); errors += cr.GetIntNonZeroOption("randseed", randseed); cr.GetIntNonZeroOption("bootstrapseed", bootstrapSeed, true); errors += cr.GetBoolOption("refinestart", refineStart); cr.GetBoolOption("refineend", refineEnd, true); errors += cr.GetBoolOption("outputeachbettertopology", outputTreelog); errors += cr.GetBoolOption("enforcetermconditions", enforceTermConditions); errors += cr.GetUnsignedNonZeroOption("genthreshfortopoterm", lastTopoImproveThresh); errors += cr.GetPositiveNonZeroDoubleOption("scorethreshforterm", improveOverStoredIntervalsThresh); cr.GetPositiveNonZeroDoubleOption("significanttopochange", significantTopoChange, true); cr.GetUnsignedNonZeroOption("attachmentspertaxon", attachmentsPerTaxon, true); cr.GetUnsignedOption("outputsitelikelihoods", outputSitelikelihoods, true); cr.GetBoolOption("reportrunprogress", reportRunProgress, true); cr.GetBoolOption("optimizeinputonly", optimizeInputOnly, true); cr.GetBoolOption("ignorestopcodons", ignoreStopCodons, true); cr.GetBoolOption("outputmostlyuselessfiles", outputMostlyUselessFiles, true); cr.GetBoolOption("outputphyliptree", outputPhylipTree, true); cr.GetBoolOption("collapsebranches", collapseBranches, true); cr.GetIntOption("genthreshforswapterm", swapTermThreshold, true); cr.GetStringOption("arbitrarystring", arbitraryString, true); cr.GetUnsignedOption("windowlength", siteWindowLength, true); cr.GetUnsignedOption("windowstride", siteWindowStride, true); cr.GetBoolOption("usepatternmanager", usePatternManager, true); cr.GetStringOption("parametervaluestring", parameterValueString, true); cr.GetBoolOption("combineadjacentidenticalgappatterns", combineAdjacentIdenticalGapPatterns, true); cr.GetBoolOption("rootatbranchmidpoint", rootAtBranchMidpoint, true); cr.GetBoolOption("useoptboundedforblen", useOptBoundedForBlen, true); //changed the wording of this from besttree to besttopology, to match outputeachbettertopology //still allow besttree, since that is what I told Maddison, and I think has already been incorporated //into Mesquite int ret = cr.GetBoolOption("outputcurrentbesttopology", outputCurrentBestTopology, true); if(ret < 0) cr.GetBoolOption("outputcurrentbesttree", outputCurrentBestTopology, true); cr.GetBoolOption("restart", restart, true); cr.GetBoolOption("writecheckpoints", checkpoint, true); cr.GetUnsignedNonZeroOption("searchreps", searchReps, true); cr.GetUnsignedOption("runmode", runmode, true); cr.GetBoolOption("scoreonly", scoreOnly, true); //These three used to be in the [master] section, for no apparent reason. Now allowed in [general] //as well. If in both, will be overridden by master cr.GetUnsignedOption("bootstrapreps", bootstrapReps, true); cr.GetPositiveNonZeroDoubleOption("resampleproportion", resampleProportion, true); cr.GetBoolOption("inferinternalstateprobs", inferInternalStateProbs, true); cr.GetBoolOption("workphasedivision", workPhaseDivision, true); bool multipleModelsFound = ReadPossibleModelPartition(cr); if(!multipleModelsFound){//if we didn't find multiple models in separate model sections, look for them in ConfigModelSettings configModSet; int settingsFound = 0; settingsFound += cr.GetStringOption("ratehetmodel", configModSet.rateHetModel, true); settingsFound += cr.GetUnsignedOption("numratecats", configModSet.numRateCats, true); settingsFound += cr.GetStringOption("statefrequencies", configModSet.stateFrequencies, true); settingsFound += cr.GetStringOption("ratematrix", configModSet.rateMatrix, true); settingsFound += cr.GetStringOption("invariantsites", configModSet.proportionInvariant, true); settingsFound += cr.GetStringOption("datatype", configModSet.datatype, true); settingsFound += cr.GetStringOption("geneticcode", configModSet.geneticCode, true); if(settingsFound == -7) throw ErrorException("No model descriptions found in config file. Proper setup is either:\n\t1. Model settings found somewhere under [general] heading,\n\t applying to all data subsets\n\t2. Separate model settings for each partition subset\n\t found under different headings [model1], [model2]. etc"); configModelSets.push_back(configModSet); } cr.GetBoolOption("linkmodels", linkModels, true); cr.GetBoolOption("subsetspecificrates", subsetSpecificRates, true); cr.GetStringOption("outgroup", outgroupString, true); if(isMaster){ errors += cr.SetSection("master"); if(errors < 0) throw ErrorException("Didn't find [master] section in config file\n (this section heading is required)"); } else{ errors += cr.SetSection("remote"); if(errors < 0) throw ErrorException("Didn't find [remote] section in config file\n (this section heading is required)"); } errors += cr.GetUnsignedNonZeroOption("nindivs", nindivs); errors += cr.GetUnsignedOption("holdover", holdover); errors += cr.GetPositiveNonZeroDoubleOption("selectionintensity", selectionIntensity); errors += cr.GetDoubleOption("holdoverpenalty", holdoverPenalty); errors += cr.GetUnsignedNonZeroOption("stopgen", stopgen); errors += cr.GetUnsignedNonZeroOption("stoptime", stoptime); errors += cr.GetPositiveNonZeroDoubleOption("startoptprec", startOptPrec); errors += cr.GetPositiveNonZeroDoubleOption("minoptprec", minOptPrec); //changing this to specify either the number of reductions in the precision or the //multiplier as before. Prefer the number, since it should be easier to specify. // found=0; found=cr.GetIntOption("numberofprecreductions", numPrecReductions, true); found += cr.GetPositiveNonZeroDoubleOption("precreductionfactor", precReductionFactor, true); if(found == -2) throw ErrorException("Error: either \"numberofprecreductions\" (preferably) or \"precreductionfactor\" must be specified in conf!"); errors += cr.GetPositiveDoubleOption("topoweight", topoWeight); errors += cr.GetPositiveDoubleOption("modweight", modWeight); errors += cr.GetPositiveDoubleOption("brlenweight", brlenWeight); errors += cr.GetPositiveDoubleOption("randnniweight", randNNIweight); errors += cr.GetPositiveDoubleOption("randsprweight", randSPRweight); errors += cr.GetPositiveDoubleOption("limsprweight", limSPRweight); cr.GetPositiveNonZeroDoubleOption("uniqueswapbias", uniqueSwapBias, true); cr.GetPositiveNonZeroDoubleOption("distanceswapbias", distanceSwapBias, true); cr.GetDoubleOption("treerejectionthreshold", treeRejectionThreshold, true); cr.GetUnsignedOption("bootstrapreps", bootstrapReps, true); cr.GetPositiveNonZeroDoubleOption("resampleproportion", resampleProportion, true); cr.GetBoolOption("inferinternalstateprobs", inferInternalStateProbs, true); #ifdef MPI_VERSION if(bootstrapReps != 0) throw ErrorException("Sorry, Bootstrap not yet implemented in parallel GARLI!"); #endif #ifdef MPI_VERSION if(isMaster==false) errors += cr.GetDoubleOption("sendinterval", sendInterval); #endif #ifdef GANESH errors += cr.GetDoubleOption("randpecrweight", randPECRweight); #endif // errors += cr.GetUnsignedOption("gammashapebrlen", gammaShapeBrlen); // errors += cr.GetUnsignedOption("gammashapemodel", gammaShapeModel); errors += cr.GetPositiveNonZeroDoubleOption("gammashapebrlen", gammaShapeBrlen); errors += cr.GetPositiveNonZeroDoubleOption("gammashapemodel", gammaShapeModel); errors += cr.GetUnsignedNonZeroOption("limsprrange", limSPRrange); errors += cr.GetUnsignedNonZeroOption("intervallength", intervalLength); errors += cr.GetUnsignedNonZeroOption("intervalstostore", intervalsToStore); errors += cr.GetPositiveNonZeroDoubleOption("meanbrlenmuts", meanBrlenMuts); cr.GetPositiveNonZeroDoubleOption("minbrlen", minBrlen, true); cr.GetPositiveNonZeroDoubleOption("maxbrlen", maxBrlen, true); cr.GetPositiveNonZeroDoubleOption("startingbrlen", startingBrlen, true); #ifdef INCLUDE_PERTURBATION errors += cr.SetSection("perturbation"); errors += cr.GetIntOption("perttype", pertType); errors += cr.GetDoubleOption("pertthresh", pertThresh); errors += cr.GetIntOption("minpertinterval", minPertInterval); errors += cr.GetIntOption("maxpertsnoimprove", maxPertsNoImprove); errors += cr.GetBoolOption("restartafterabandon", restartAfterAbandon); errors += cr.GetIntOption("gensbeforerestart", gensBeforeRestart); errors += cr.GetDoubleOption("ratchetproportion", ratchetProportion); errors += cr.GetDoubleOption("ratchetoffthresh", ratchetOffThresh); errors += cr.GetIntOption("ratchetmaxgen", ratchetMaxGen); errors += cr.GetIntOption("nnitargetaccepts", nniTargetAccepts); errors += cr.GetIntOption("nnimaxattempts", nniMaxAttempts); errors += cr.GetIntOption("numsprcycles", numSprCycles); errors += cr.GetIntOption("sprpertrange", sprPertRange); #endif return errors; }