bpp-phyl3
3.0.0
|
This class provides some common tools for applications. More...
#include <Bpp/Phyl/Legacy/App/PhylogeneticsApplicationTools.h>
Public Member Functions | |
LegacyPhylogeneticsApplicationTools () | |
virtual | ~LegacyPhylogeneticsApplicationTools () |
Static Public Member Functions | |
static std::map< size_t, std::shared_ptr< Tree > > | getTrees (const std::map< std::string, std::string > ¶ms, const std::map< size_t, std::shared_ptr< AlignmentDataInterface >> &mSeq, std::map< std::string, std::string > &unparsedParams, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) |
Build a list ofTree objects according to options. More... | |
static void | setSubstitutionModelParametersInitialValuesWithAliases (BranchModelInterface &model, std::map< std::string, std::string > &unparsedParameterValues, size_t modelNumber, std::shared_ptr< const AlignmentDataInterface > data, std::map< std::string, std::string > &sharedParams, bool verbose) |
Set parameter initial values of a given model in a set according to options. More... | |
static std::unique_ptr< SubstitutionModelSet > | getSubstitutionModelSet (std::shared_ptr< const Alphabet > alphabet, std::shared_ptr< const GeneticCode > gcode, std::shared_ptr< const AlignmentDataInterface > data, const std::map< std::string, std::string > ¶ms, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) |
Gets a SubstitutionModelSet object according to options. More... | |
static void | setSubstitutionModelSet (SubstitutionModelSet &modelSet, std::shared_ptr< const Alphabet > alphabet, std::shared_ptr< const GeneticCode > gcode, std::shared_ptr< const AlignmentDataInterface > data, const std::map< std::string, std::string > ¶ms, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) |
Sets a SubstitutionModelSet object according to options. More... | |
static void | completeMixedSubstitutionModelSet (MixedSubstitutionModelSet &mixedModelSet, std::shared_ptr< const Alphabet > alphabet, std::shared_ptr< const AlignmentDataInterface > data, const std::map< std::string, std::string > ¶ms, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) |
Complete a MixedSubstitutionModelSet object according to options, given this model has already been filled through setSubstitutionModelSet method. More... | |
static std::shared_ptr< TreeLikelihoodInterface > | optimizeParameters (std::shared_ptr< TreeLikelihoodInterface > tl, const ParameterList ¶meters, const std::map< std::string, std::string > ¶ms, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) |
Optimize parameters according to options. More... | |
static void | writeTrees (const std::vector< const Tree * > &trees, const std::map< std::string, std::string > ¶ms, const std::string &prefix="output.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, bool checkOnly=false, int warn=1) |
Write a tree according to options. More... | |
static void | writeTrees (const std::vector< const TreeTemplate< Node > * > &trees, const std::map< std::string, std::string > ¶ms, const std::string &prefix="output.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, bool checkOnly=false, int warn=1) |
static void | printParameters (const SubstitutionModelSet &modelSet, OutputStream &out, int warn=1, bool withAlias=true) |
Output a SubstitutionModelSet description to a file. More... | |
This class provides some common tools for applications.
The functions parse some option file, create corresponding objects and send a pointer toward it.
The option files are supposed to follow this simple format:
with one parameter per line.
Definition at line 50 of file PhylogeneticsApplicationTools.h.
bpp::LegacyPhylogeneticsApplicationTools::LegacyPhylogeneticsApplicationTools | ( | ) |
|
virtual |
|
static |
Complete a MixedSubstitutionModelSet object according to options, given this model has already been filled through setSubstitutionModelSet method.
In addition, this method builds the allowed combinations of submodels of the different mixed models.
If none combination is given, then all possible submodels combinations will be considered.
The submodels dependencies are given a sets of combinations of the mixed variables of the mixed models. For instance, if we have:
In this case model1 is a mixture of 4 T92 submodels and model2 a mixture of 15 T92 submodels. These submodels are denoted with the parameter name and the class number. For example, the submodels of model1 are denoted model1[kappa_1], ..., model1[kappa_4], and the submodels of model2 are denoted model2[kappa_1,theta_1], ..., model2[kappa_5, theta_3]. Additionally, for instance, model2[kappa_2] denotes all the submodels whose description has kappa_2.
By default, when switching from model1 to model2, a site is allowed to switch between any submodel of model1 and any submodel of model2. If the only allowed combination is that a site follows submodels model1(kappa_1) and model2(kappa_3,theta_2), it is denoted:
With additional co()mbination saying that a site can follow submodels model1[kappa_2] and any submodel of model2[kappa_3] is denoted:
See MixedSubstitutionModelSet description for further information.
mixedModelSet | The modified MixedSubstitutionModelSet object according to options specified. |
alphabet | The alphabet to use in all models. |
data | A pointer toward the AlignedValuesContainer for which the substitution model is designed. The alphabet associated to the data must be of the same type as the one specified for the model. May be equal to NULL, but in this cas use_observed_freq option will be unavailable. |
params | The attribute map where options may be found. |
suffix | A suffix to be applied to each attribute name. |
suffixIsOptional | Tell if the suffix is absolutely required. |
verbose | Print some info to the 'message' output stream. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
Definition at line 616 of file PhylogeneticsApplicationTools.cpp.
References bpp::MixedSubstitutionModelSet::addEmptyHyperNode(), bpp::MixedSubstitutionModelSet::addToHyperNode(), bpp::MixedSubstitutionModelSet::complete(), bpp::MixedSubstitutionModelSet::computeHyperNodesProbabilities(), bpp::ApplicationTools::displayResult(), bpp::MixedSubstitutionModelSet::getHyperNode(), bpp::SubstitutionModelSet::getModel(), bpp::MixedSubstitutionModelSet::getNumberOfHyperNodes(), bpp::ApplicationTools::getStringParameter(), bpp::MixedSubstitutionModelSet::hasExclusivePaths(), bpp::StringTokenizer::hasMoreToken(), bpp::MixedSubstitutionModelSet::HyperNode::isComplete(), bpp::StringTokenizer::nextToken(), bpp::ApplicationTools::parameterExists(), bpp::TextTools::toInt(), and bpp::TextTools::toString().
|
static |
Gets a SubstitutionModelSet object according to options.
See setSubstitutionModelSet and setMixedSubstitutionModelSet methods.
Definition at line 432 of file PhylogeneticsApplicationTools.cpp.
References bpp::ApplicationTools::getStringParameter(), bpp::ApplicationTools::parameterExists(), and bpp::TextTools::toString().
|
static |
Build a list ofTree objects according to options.
See the Bio++ Program Suite manual for a description of available options.
params | The attribute map where options may be found. |
mSeq | A map of pointers of AlignedValuesContainers, necessary in case of random trees |
unparsedParams | A map of parameters (BrLen) that will be aliased after. |
prefix | A prefix to be applied to each attribute name. |
suffix | A suffix to be applied to each attribute name. |
suffixIsOptional | Tell if the suffix is absolutely required. |
verbose | Print some info to the 'message' output stream. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
Definition at line 66 of file PhylogeneticsApplicationTools.cpp.
References bpp::TreeTools::computeBranchLengthsGrafen(), bpp::TreeTools::constrainedMidPointRooting(), bpp::TreeTools::convertToClockTree(), bpp::ApplicationTools::displayMessage(), bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::displayWarning(), bpp::ApplicationTools::getAFilePath(), bpp::ApplicationTools::getDoubleParameter(), bpp::TreeTools::getHeight(), bpp::TreeTemplateTools::getRandomTree(), bpp::ApplicationTools::getStringParameter(), bpp::TextTools::isDecimalInteger(), bpp::ApplicationTools::matchingParameters(), bpp::KeyvalTools::parseProcedure(), bpp::TextTools::toDouble(), bpp::TextTools::toInt(), and bpp::TextTools::toString().
|
static |
Optimize parameters according to options.
tl | The TreeLikelihood function to optimize. |
parameters | The initial list of parameters to optimize. Use tl->getIndependentParameters() in order to estimate all parameters. |
params | The attribute map where options may be found. |
suffix | A suffix to be applied to each attribute name. |
suffixIsOptional | Tell if the suffix is absolutely required. |
verbose | Print some info to the 'message' output stream. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
Definition at line 709 of file PhylogeneticsApplicationTools.cpp.
References bpp::abs(), bpp::NNITopologySearch::BETTER, bpp::Parameter::constraint(), bpp::AutoParameter::CONSTRAINTS_AUTO, bpp::convert(), bpp::ParameterList::deleteParameter(), bpp::ParameterList::deleteParameters(), bpp::VectorTools::diff(), bpp::ApplicationTools::displayMessage(), bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::displayWarning(), bpp::NNITopologySearch::FAST, bpp::FileTools::fileExists(), bpp::ApplicationTools::getAFilePath(), bpp::ApplicationTools::getBooleanParameter(), bpp::Parameter::getConstraint(), bpp::ConstraintInterface::getDescription(), bpp::ApplicationTools::getDoubleParameter(), bpp::Parameter::getName(), bpp::ParameterList::getParameterNames(), bpp::ApplicationTools::getStringParameter(), bpp::Parameter::hasConstraint(), bpp::StringTokenizer::hasMoreToken(), bpp::ParameterList::hasParameter(), bpp::ConstraintInterface::isEmpty(), bpp::TextTools::isEmpty(), bpp::ApplicationTools::matchingParameters(), bpp::ParameterList::matchParametersValues(), bpp::ApplicationTools::message, bpp::StringTokenizer::nextToken(), bpp::StringTokenizer::numberOfRemainingTokens(), bpp::OptimizationTools::OPTIMIZATION_BFGS, bpp::OptimizationTools::OPTIMIZATION_BRENT, bpp::OptimizationTools::OPTIMIZATION_GRADIENT, bpp::OptimizationTools::OPTIMIZATION_NEWTON, bpp::LegacyOptimizationTools::optimizeNumericalParameters(), bpp::LegacyOptimizationTools::optimizeNumericalParameters2(), bpp::LegacyOptimizationTools::optimizeTreeNNI(), bpp::LegacyOptimizationTools::optimizeTreeNNI2(), bpp::LegacyOptimizationTools::optimizeTreeScale(), bpp::ParameterNotFoundException::parameter(), bpp::ParameterList::parameter(), bpp::KeyvalTools::parseProcedure(), bpp::NNITopologySearch::PHYML, bpp::FileTools::putStreamIntoVectorOfStrings(), bpp::ParameterList::reset(), bpp::Parameter::setConstraint(), bpp::ParameterList::setParameter(), bpp::TextTools::toDouble(), bpp::TextTools::toString(), and bpp::ParameterList::whichParameterHasName().
|
static |
Output a SubstitutionModelSet description to a file.
modelSet | The model set to serialize. |
out | The stream where to print. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
withAlias | outputs the alias names of the aliased Parameters instead of the values (default : true). |
Definition at line 1184 of file PhylogeneticsApplicationTools.cpp.
References bpp::BppOFrequencySetFormat::ALL, bpp::BppOSubstitutionModelFormat::ALL, bpp::OutputStream::endLine(), bpp::AbstractParameterAliasable::getFrom(), bpp::SubstitutionModelSet::getModel(), bpp::SubstitutionModelSet::getNodesWithModel(), bpp::SubstitutionModelSet::getNumberOfModels(), bpp::SubstitutionModelSet::isStationary(), bpp::SubstitutionModelSet::rootFrequencySet(), bpp::ParameterList::size(), bpp::TextTools::toString(), bpp::BppOSubstitutionModelFormat::write(), and bpp::BppOFrequencySetFormat::writeFrequencySet().
|
static |
Set parameter initial values of a given model in a set according to options.
Parameters actually depends on the model passed as argument. See getSubstitutionModelSet for more information.
This function is mainly for internal usage, you're probably looking for the getSubstitutionModel or getSubstitutionModelSet function.
model | The model to set. |
unparsedParameterValues | A map that contains all the model parameters names and their corresponding unparsed value, if they were found. |
modelNumber | The number of this model in the SubstitutionModelSet. |
data | A pointer toward an AlignedValuesContainer used for the initialization of substitution model when this data is needed (typically use_observed_freq option). The alphabet associated to the data must be of the same type as the one specified for the model. May be equal to NULL, but in this case will be unavailable. |
sharedParams | (out) remote parameters will be recorded here. |
verbose | Print some info to the 'message' output stream. |
Definition at line 345 of file PhylogeneticsApplicationTools.cpp.
References bpp::ApplicationTools::displayMessage(), bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::displayWarning(), bpp::ParameterAliasable::getIndependentParameters(), bpp::BranchModelInterface::getName(), bpp::ParameterAliasable::getNamespace(), bpp::ParameterAliasable::getParameterNameWithoutNamespace(), bpp::ApplicationTools::getStringParameter(), bpp::StringTokenizer::hasMoreToken(), bpp::ParameterAliasable::matchParametersValues(), bpp::StringTokenizer::nextToken(), bpp::AutoParameter::setMessageHandler(), bpp::ParameterList::setParameter(), bpp::ParameterList::size(), bpp::TextTools::toDouble(), bpp::TextTools::toString(), and bpp::ApplicationTools::warning.
|
static |
Sets a SubstitutionModelSet object according to options.
This model set is meant to be used with non-homogeneous substitution models of sequence evolution.
Recognized options are:
Then, for each of the models, the following information must be provided:
All models must be fully specified, and at the end of the description, all nodes must be attributed to a model, otherwise an exception is thrown.
Finally, this is also allowed for models to share one or several parameters. for instance:
In this case model1 and model2 with have their own and independent theta parameter, but only one kappa parameter will be used for both models. Note that
is equivalent to
but will require more memory and use more CPU, since some calculations will be performed twice.
modelSet | The modified SubstitutionModelSet object according to options specified. |
alphabet | The alphabet to use in all models. |
gcode | The genetic code to use (only for codon models, otherwise can be set to 0). If set to NULL and a codon model is requested, an Exception will be thrown. |
data | A pointer toward the AlignedValuesContainer for which the substitution model is designed. The alphabet associated to the data must be of the same type as the one specified for the model. May be equal to NULL, but in this cas use_observed_freq option will be unavailable. |
params | The attribute map where options may be found. |
suffix | A suffix to be applied to each attribute name. |
suffixIsOptional | Tell if the suffix is absolutely required. |
verbose | Print some info to the 'message' output stream. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
Definition at line 476 of file PhylogeneticsApplicationTools.cpp.
References bpp::SubstitutionModelSet::addModel(), bpp::AbstractParameterAliasable::aliasParameters(), bpp::BppOSubstitutionModelFormat::ALL, bpp::SubstitutionModelSet::clear(), bpp::ApplicationTools::displayBooleanResult(), bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::getBooleanParameter(), bpp::PhylogeneticsApplicationTools::getRootFrequencySet(), bpp::ApplicationTools::getStringParameter(), bpp::BppOSubstitutionModelFormat::getUnparsedArguments(), bpp::StringTokenizer::hasMoreToken(), bpp::AlphabetTools::isCodonAlphabet(), bpp::AlphabetTools::isWordAlphabet(), bpp::StringTokenizer::nextToken(), bpp::ApplicationTools::parameterExists(), bpp::BppOTransitionModelFormat::readTransitionModel(), bpp::BppOSubstitutionModelFormat::setGeneticCode(), bpp::SubstitutionModelSet::setRootFrequencies(), bpp::BppOSubstitutionModelFormat::setVerbose(), and bpp::TextTools::toString().
|
static |
Write a tree according to options.
See the Bio++ Program Suite manual for a description of all available options.
trees | The trees to write. |
params | The attribute map where options may be found. |
prefix | A prefix to be applied to each attribute name. |
suffix | A suffix to be applied to each attribute name. |
suffixIsOptional | Tell if the suffix is absolutely required. |
verbose | Print some info to the 'message' output stream. |
checkOnly | If this parameter is set to true, then all options are checked and error messages sent, but no file is written. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
Definition at line 1151 of file PhylogeneticsApplicationTools.cpp.
References bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::getAFilePath(), bpp::ApplicationTools::getStringParameter(), and bpp::OMultiTree::writeTrees().
|
static |