7#include "../Model/MixedTransitionModel.h"
14std::vector<size_t> SubstitutionProcessCollectionMember::getModelNumbers()
const
19 vMN.push_back(it.first);
118 std::map<size_t, std::vector<unsigned int>>::const_iterator it;
147 throw NullPointerException(
"SubstitutionProcessCollectionMember::rootFrequencySet(). No root frequency parameters, this is a stationary model.");
155 throw NullPointerException(
"SubstitutionProcessCollectionMember::rootFrequencySet(). No root frequency parameters, this is a stationary model.");
165 return model->getFrequencies();
173 throw Exception(
"SubstitutionProcessCollectionMember::setModelScenario: Collection does not have ModelScenario number");
179 auto models = modelScenario->getModels();
183 for (
const auto&
model:models)
186 for (
auto num:modnum)
208 throw Exception(
"SubstitutionProcessCollectionMember::parametrizablePhyloTree(). No associated tree.");
221 throw Exception(
"SubstitutionProcessCollectionMember::parametrizablePhyloTree(). No associated tree.");
232 throw BadIntException((
int)nTree,
"SubstitutionProcessCollectionMember::setTreeNumber(). No associated tree.",
getAlphabet());
251 if (nmod.getAlphabet()->getAlphabetType() != modi.getAlphabet()->getAlphabetType())
252 throw Exception(
"SubstitutionProcessCollectionMember::addModel. A Substitution Model cannot be added to a Model Set if it does not have the same alphabet.");
253 if (nmod.getNumberOfStates() != modi.getNumberOfStates())
254 throw Exception(
"SubstitutionProcessCollectionMember::addModel. A Substitution Model cannot be added to a Model Set if it does not have the same number of states.");
259 if (freq.getAlphabet()->getAlphabetType() != nmod.getAlphabet()->getAlphabetType())
260 throw Exception(
"SubstitutionProcessCollectionMember::addModel. A Substitution Model cannot be added to a Model Set if it does not have the same alphabet as the root frequencies.");
261 if (freq.getFrequencies().size() != nmod.getNumberOfStates())
262 throw Exception(
"SubstitutionProcessCollectionMember::addModel. A Substitution Model cannot be added to a Model Set if it does not have the same number of states as the root frequencies.");
266 for (
size_t i = 0; i < nodesId.size(); i++)
283 if (freq.getAlphabet()->getAlphabetType() != modi.getAlphabet()->getAlphabetType())
284 throw Exception(
"SubstitutionProcessCollectionMember::setRootFrequencies. A Frequencies Set cannot be added to a Model Set if it does not have the same alphabet as the models.");
285 if (freq.getFrequencies().size() != modi.getNumberOfStates())
286 throw Exception(
"SubstitutionProcessCollectionMember::setRootFrequencies. A Frequencies Set cannot be added to a Model Set if it does not have the same number of states as the models.");
299 throw Exception(
"SubstitutionProcessCollectionMember::checkOrphanNodes(). No Tree");
306 for (
size_t i = 0; i < ids.size(); i++)
311 throw Exception(
"SubstitutionProcessCollectionMember::checkOrphanNodes(). Node '" +
TextTools::toString(ids[i]) +
"' in tree has no model associated.");
323 throw Exception(
"SubstitutionProcessCollectionMember::checkUnknownNodes(). No Tree");
334 for (
auto id : it.second)
339 throw Exception(
"SubstitutionProcessCollectionMember::checkUnknownNodes(). Node '" +
TextTools::toString(
id) +
"' is not found in tree or is the root node.");
351 if (dynamic_pointer_cast<const MixedTransitionModelInterface>(
collection().
getModel(it.first)))
void addParameters_(const ParameterList ¶meters)
void deleteParameters_(const std::vector< std::string > &names)
ParameterList getAliasedParameters(const ParameterList &pl) const
ParameterList getFromParameters(const ParameterList &pl) const
bool matchParametersValues(const ParameterList ¶meters) override
std::shared_ptr< const Alphabet > getAlphabet() const
Interface for all Branch models.
virtual std::string getName() const =0
Get the name of the model.
virtual double getCategory(size_t categoryIndex) const=0
virtual size_t getNumberOfCategories() const=0
virtual double getProbability(size_t categoryIndex) const=0
Parametrize a set of state frequencies.
virtual const Vdouble & getFrequencies() const =0
virtual void includeParameters(const ParameterList ¶ms)
PhyloTree with Parametrizable Phylo Branches. They SHARE their branch length parameters.
void updateParameters()
sets the parameters as the independent parameters on the objects
std::vector< size_t > getModelNumbers() const override
std::shared_ptr< const DiscreteDistributionInterface > getRateDistribution() const override
Get a pointer to the rate distribution (or null if there is no rate distribution).
const DiscreteDistributionInterface & rateDistribution() const override
Get the rate distribution.
const SubstitutionProcessCollection * getCollection() const
size_t nPath_
the number of the set of model path, if needed.
size_t nRoot_
The number of the root frequencies (0 if the process is stationary).
bool isFullySetUp(bool throwEx=true) const
Check if the model set is fully specified for a given tree.
const FrequencySetInterface & rootFrequencySet() const override
size_t nProc_
The number of the process in the collection.
bool hasMixedTransitionModel() const
std::map< size_t, std::vector< unsigned int > > modelToNodes_
ParameterList getBranchLengthParameters(bool independent) const override
Get the parameters of the tree.
void setTreeNumber(size_t nTree, bool check=true)
bool isStationary() const
double getRateForModel(size_t classIndex) const override
bool matchParametersValues(const ParameterList ¶meters) override
AbsractParametrizable interface.
const SubstitutionProcessCollection & collection() const
const BranchModelInterface & model(size_t n) const override
std::shared_ptr< const ModelScenario > getModelScenario() const override
Get the Model Scenario associated with this process, in case there are mixture models involved.
size_t nTree_
The number of the tree: 0 means no assigned tree.
void addModel(size_t numModel, const std::vector< unsigned int > &nodesId)
Add a new model to the set, and set relationships with nodes.
std::shared_ptr< const FrequencySetInterface > getRootFrequencySet() const override
std::shared_ptr< const BranchModelInterface > getModel(size_t n) const override
ParameterList getSubstitutionModelParameters(bool independent) const override
Get the parameters of the substitution models.
const std::vector< double > & getRootFrequencies() const override
ParameterList getRateDistributionParameters(bool independent) const override
Get the parameters of the rate distribution.
std::shared_ptr< const ParametrizablePhyloTree > getParametrizablePhyloTree() const override
void setModelScenario(size_t numPath)
Vdouble getClassProbabilities() const override
bool checkUnknownNodes(bool throwEx) const
size_t nDist_
The number of the rate distribution.
const ParametrizablePhyloTree & parametrizablePhyloTree() const override
bool checkOrphanNodes(bool throwEx) const
std::map< unsigned int, size_t > nodeToModel_
Contains for each node in a tree the index of the corresponding model in modelSet_.
void setRootFrequencies(size_t numFreq)
Set the root Frequencies Set.
ParameterList getNonDerivableParameters() const override
get all NonDerivable parameters.
ParameterList getRootFrequenciesParameters(bool independent) const override
Get the parameters of the root frequencies set.
double getProbabilityForModel(size_t classIndex) const override
ParameterList getRootFrequenciesParameters(size_t nFreq, bool independent) const
Get the parameters associated to the root frequencies(s).
FrequencySetInterface & frequencySet(size_t frequenciesIndex)
Get a FrequencySet from the collection.
std::shared_ptr< FrequencySetInterface > getFrequencySet(size_t frequenciesIndex)
bool hasTreeNumber(size_t n) const
ParameterList getRateDistributionParameters(size_t nRate, bool independent) const
Get the parameters associated to the rate distribution(s).
DiscreteDistributionInterface & rateDistribution(size_t distributionIndex)
std::shared_ptr< ParametrizablePhyloTree > getTree(size_t treeIndex)
std::shared_ptr< BranchModelInterface > getModel(size_t modelIndex)
BranchModelInterface & model(size_t modelIndex)
Get a BranchModel from the collection.
ParameterList getBranchLengthParameters(bool independent) const
Methods to retrieve parameters.
std::shared_ptr< const ModelScenario > getModelScenario(size_t numPath) const
Get a ModelScenario from the set.
std::shared_ptr< DiscreteDistributionInterface > getRateDistribution(size_t distributionIndex)
Get a DiscreteDistribution from the collection.
ParametrizablePhyloTree & tree(size_t treeIndex)
Get a tree from the set.
std::string toString(T t)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble