bpp-phyl
2.2.0
|
This class provides some common tools for applications. More...
#include <Bpp/Phyl/App/PhylogeneticsApplicationTools.h>
Public Member Functions | |
PhylogeneticsApplicationTools () | |
virtual | ~PhylogeneticsApplicationTools () |
Static Public Member Functions | |
static Tree * | getTree (std::map< std::string, std::string > ¶ms, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) throw (Exception) |
Build a Tree object according to options. More... | |
static std::vector< Tree * > | getTrees (std::map< std::string, std::string > ¶ms, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) throw (Exception) |
Build a list ofTree objects according to options. More... | |
static SubstitutionModel * | getSubstitutionModel (const Alphabet *alphabet, const GeneticCode *gCode, const SiteContainer *data, std::map< std::string, std::string > ¶ms, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) throw (Exception) |
Build a SubstitutionModel object according to options. More... | |
static void | setSubstitutionModelParametersInitialValuesWithAliases (SubstitutionModel &model, std::map< std::string, std::string > &unparsedParameterValues, size_t modelNumber, const SiteContainer *data, std::map< std::string, double > &existingParams, std::map< std::string, std::string > &sharedParams, bool verbose) throw (Exception) |
Set parameter initial values of a given model in a set according to options. More... | |
static FrequenciesSet * | getRootFrequenciesSet (const Alphabet *alphabet, const GeneticCode *gCode, const SiteContainer *data, std::map< std::string, std::string > ¶ms, const std::vector< double > &rateFreqs, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) throw (Exception) |
Get A FrequenciesSet object for root frequencies (NH models) according to options. More... | |
static FrequenciesSet * | getFrequenciesSet (const Alphabet *alphabet, const GeneticCode *gCode, const std::string &freqDescription, const SiteContainer *data, const std::vector< double > &rateFreqs, bool verbose=true, int warn=1) throw (Exception) |
Get A FrequenciesSet object according to options. More... | |
static SubstitutionModelSet * | getSubstitutionModelSet (const Alphabet *alphabet, const GeneticCode *gcode, const SiteContainer *data, 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, const Alphabet *alphabet, const GeneticCode *gcode, const SiteContainer *data, 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, const Alphabet *alphabet, const SiteContainer *data, 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 MultipleDiscreteDistribution * | getMultipleDistributionDefaultInstance (const std::string &distDescription, std::map< std::string, std::string > &unparsedParameterValues, bool verbose=true) |
Build a multi-dimension distribution as a MultipleDiscreteDistribution object with default parameter values according to a keyval description. More... | |
static DiscreteDistribution * | getRateDistribution (std::map< std::string, std::string > ¶ms, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true) throw (Exception) |
Build a DiscreteDistribution object according to options. More... | |
static TreeLikelihood * | optimizeParameters (TreeLikelihood *tl, const ParameterList ¶meters, std::map< std::string, std::string > ¶ms, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) throw (Exception) |
Optimize parameters according to options. More... | |
static void | optimizeParameters (DiscreteRatesAcrossSitesClockTreeLikelihood *tl, const ParameterList ¶meters, std::map< std::string, std::string > ¶ms, const std::string &suffix="", bool suffixIsOptional=true, bool verbose=true, int warn=1) throw (Exception) |
Optimize parameters according to options, with a molecular clock. More... | |
static void | checkEstimatedParameters (const ParameterList &pl) |
Check if parameter values are close to their definition boundary. More... | |
static SubstitutionCount * | getSubstitutionCount (const Alphabet *alphabet, const SubstitutionModel *model, map< string, string > ¶ms, string suffix="", bool verbose=true, int warn=1) |
Get a SubstitutionCount instance. More... | |
static void | writeTree (const TreeTemplate< Node > &tree, 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) throw (Exception) |
Write a tree according to options. More... | |
static void | writeTrees (const std::vector< Tree *> &trees, 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) throw (Exception) |
Write a tree according to options. More... | |
static void | printParameters (const SubstitutionModel *model, OutputStream &out, int warn=1) |
Output a SubstitutionModel description to a file. More... | |
static void | printParameters (const SubstitutionModelSet *modelSet, OutputStream &out, int warn=1) |
Output a SubstitutionModelSet description to a file. More... | |
static void | printParameters (const DiscreteDistribution *rDist, OutputStream &out) |
Output a DiscreteDistribution 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 85 of file PhylogeneticsApplicationTools.h.
bpp::PhylogeneticsApplicationTools::PhylogeneticsApplicationTools | ( | ) |
|
virtual |
|
static |
Check if parameter values are close to their definition boundary.
This allows the detection of potential optimization issues. A warning message will be output for each problematic parameter.
pl | A list of parameters. Parameters without constraint will be ignored. |
Definition at line 1333 of file PhylogeneticsApplicationTools.cpp.
|
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]. Additionnaly, 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 combination 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 alpabet to use in all models. |
data | A pointer toward the SiteContainer 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). |
Exception | if an error occured. |
Definition at line 521 of file PhylogeneticsApplicationTools.cpp.
References bpp::MixedSubstitutionModelSet::addEmptyHyperNode(), bpp::MixedSubstitutionModelSet::addToHyperNode(), bpp::MixedSubstitutionModelSet::complete(), bpp::MixedSubstitutionModelSet::computeHyperNodesProbabilities(), bpp::MixedSubstitutionModelSet::getHyperNode(), bpp::SubstitutionModelSet::getModel(), bpp::MixedSubstitutionModelSet::getNumberOfHyperNodes(), bpp::MixedSubstitutionModel::getSubmodelNumbers(), and bpp::MixedSubstitutionModelSet::hasExclusivePaths().
|
static |
Get A FrequenciesSet object according to options.
alphabet | The alpabet to use. |
gCode | The genetic code to use (only for codon alphabets, otherwise can be set to 0). If set to NULL and a codon frequencies set is requested, an Exception will be thrown. |
freqDescription | A string in the keyval syntaxe describing the frequency set to use.:if expand("%") == ""|browse confirm w|else|confirm w|endif |
data | A pointer toward the SiteContainer 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. |
rateFreqs | A vector of rate catégories frequencies in case of a Markov Modulated Markov Model. Ignored if a vector with size 0 is passed. |
verbose | Print some info to the 'message' output stream. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
Exception | if an error occured. |
Definition at line 313 of file PhylogeneticsApplicationTools.cpp.
References bpp::BppOFrequenciesSetFormat::ALL, bpp::BppOFrequenciesSetFormat::read(), and bpp::BppOFrequenciesSetFormat::setGeneticCode().
|
static |
Build a multi-dimension distribution as a MultipleDiscreteDistribution object with default parameter values according to a keyval description.
Check the Bio++ Program Suite documentation for a description of the syntax. It is mainly for internal usage, you're probably looking for the getRateDistribution function.
distDescription | A string describing the model in the keyval syntax. |
unparsedParameterValues | [out] a map that will contain all the distribution parameters names and their corresponding unparsed value, if they were found. |
verbose | Print some info to the 'message' output stream. |
Exception | if an error occured. |
Definition at line 615 of file PhylogeneticsApplicationTools.cpp.
|
static |
Build a DiscreteDistribution object according to options.
Creates a new rate distribution object according to distribution description syntax (see the Bio++ Progam Suite manual for a detailed description of this syntax). The function also parses the parameter values and set them accordingly.
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. |
Exception | if an error occured. |
Definition at line 661 of file PhylogeneticsApplicationTools.cpp.
References bpp::BppORateDistributionFormat::read().
|
static |
Get A FrequenciesSet object for root frequencies (NH models) according to options.
alphabet | The alpabet to use. |
gCode | The genetic code to use (only for codon alphabets, otherwise can be set to 0). If set to NULL and a codon frequencies set is requested, an Exception will be thrown. |
data | A pointer toward the SiteContainer 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. |
rateFreqs | A vector of rate catégories frequencies in case of a Markov Modulated Markov Model. Ignored if a vector with size 0 is passed. |
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). |
Exception | if an error occured. |
Definition at line 286 of file PhylogeneticsApplicationTools.cpp.
References bpp::FrequenciesSet::getName().
|
static |
Get a SubstitutionCount instance.
alphabet | The alphabet to use. |
model | The model to use. |
params | The attribute map where options may be found. |
suffix | Optional suffix for command name. |
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 1493 of file PhylogeneticsApplicationTools.cpp.
|
static |
Build a SubstitutionModel object according to options.
Creates a new substitution model object according to model description syntax (see the Bio++ Progam Suite manual for a detailed description of this syntax). The function also parses the parameter values and set them accordingly.
alphabet | The alphabet to use in the model. |
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 SiteContainer 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 case 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). |
Exception | if an error occured. |
Definition at line 165 of file PhylogeneticsApplicationTools.cpp.
References bpp::BppOSubstitutionModelFormat::ALL, bpp::BppOSubstitutionModelFormat::read(), and bpp::BppOSubstitutionModelFormat::setGeneticCode().
|
static |
Gets a SubstitutionModelSet object according to options.
See setSubstitutionModelSet and setMixedSubstitutionModelSet methods.
Definition at line 346 of file PhylogeneticsApplicationTools.cpp.
References bpp::SubstitutionModelSet::hasMixedSubstitutionModel().
|
static |
Build a Tree object according to options.
See the Bio++ Program Suite manual for a description of available options.
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. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
Exception | if an error occured. |
Definition at line 96 of file PhylogeneticsApplicationTools.cpp.
References bpp::ITree::read().
|
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. |
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). |
Exception | if an error occured. |
Definition at line 126 of file PhylogeneticsApplicationTools.cpp.
References bpp::IMultiTree::read().
|
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). |
Exception | Any exception that may happen during the optimization process. |
optimization options
Definition at line 692 of file PhylogeneticsApplicationTools.cpp.
References bpp::NNITopologySearch::BETTER, bpp::NNITopologySearch::FAST, bpp::NonHomogeneousTreeLikelihood::getRootFrequenciesParameters(), bpp::OptimizationTools::OPTIMIZATION_BFGS, bpp::OptimizationTools::OPTIMIZATION_BRENT, bpp::OptimizationTools::OPTIMIZATION_GRADIENT, bpp::OptimizationTools::OPTIMIZATION_NEWTON, bpp::OptimizationTools::optimizeNumericalParameters(), bpp::OptimizationTools::optimizeNumericalParameters2(), bpp::OptimizationTools::optimizeTreeNNI(), bpp::OptimizationTools::optimizeTreeNNI2(), bpp::OptimizationTools::optimizeTreeScale(), and bpp::NNITopologySearch::PHYML.
|
static |
Optimize parameters according to options, with a molecular clock.
tl | The ClockTreeLikelihood 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). |
Exception | Any exception that may happen during the optimization process. |
Definition at line 1110 of file PhylogeneticsApplicationTools.cpp.
References bpp::NonHomogeneousTreeLikelihood::getRootFrequenciesParameters(), bpp::OptimizationTools::OPTIMIZATION_GRADIENT, bpp::OptimizationTools::OPTIMIZATION_NEWTON, bpp::OptimizationTools::optimizeNumericalParametersWithGlobalClock(), and bpp::OptimizationTools::optimizeNumericalParametersWithGlobalClock2().
|
static |
Output a SubstitutionModel description to a file.
model | The model to serialize. |
out | The stream where to print. |
warn | Set the warning level (0: always display warnings, >0 display warnings on demand). |
Definition at line 1411 of file PhylogeneticsApplicationTools.cpp.
References bpp::BppOSubstitutionModelFormat::ALL, and bpp::BppOSubstitutionModelFormat::write().
|
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). |
Definition at line 1423 of file PhylogeneticsApplicationTools.cpp.
References bpp::BppOFrequenciesSetFormat::ALL, bpp::BppOSubstitutionModelFormat::ALL, bpp::SubstitutionModelSet::getModel(), bpp::SubstitutionModelSet::getNodesWithModel(), bpp::SubstitutionModelSet::getNumberOfModels(), bpp::SubstitutionModelSet::getRootFrequenciesSet(), bpp::BppOFrequenciesSetFormat::write(), and bpp::BppOSubstitutionModelFormat::write().
|
static |
Output a DiscreteDistribution description to a file.
rDist | The rate distribution to serialize. |
out | The stream where to print. |
Definition at line 1477 of file PhylogeneticsApplicationTools.cpp.
References bpp::BppORateDistributionFormat::write().
|
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 the SiteContainer 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 case use_observed_freq option will be unavailable. |
existingParams | (in/out) A map with already existing value that have been found in previous calls, and may be recalled here. New parameters found here will be added. |
sharedParams | (out) remote parameters will be recorded here. |
verbose | Print some info to the 'message' output stream. |
Exception | if an error occured. |
Definition at line 194 of file PhylogeneticsApplicationTools.cpp.
|
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 alpabet 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 SiteContainer 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). |
Exception | if an error occured. |
Definition at line 390 of file PhylogeneticsApplicationTools.cpp.
References bpp::SubstitutionModelSet::addModel(), bpp::BppOSubstitutionModelFormat::ALL, bpp::SubstitutionModelSet::clear(), bpp::BppOSubstitutionModelFormat::getUnparsedArguments(), bpp::BppOSubstitutionModelFormat::read(), bpp::BppOSubstitutionModelFormat::setGeneticCode(), bpp::SubstitutionModelSet::setRootFrequencies(), and bpp::BppOSubstitutionModelFormat::setVerbose().
|
static |
Write a tree according to options.
See the Bio++ Program Suite manual for a descriptio of all available options.
tree | The tree 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). |
Exception | if an error occured. |
Definition at line 1351 of file PhylogeneticsApplicationTools.cpp.
References bpp::OTree::write().
|
static |
Write a tree according to options.
See the Bio++ Program Suite manual for a descriptio 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). |
Exception | if an error occured. |
Definition at line 1381 of file PhylogeneticsApplicationTools.cpp.
References bpp::OMultiTree::write().