41 #ifndef _SUBSTITUTIONMODELSET_H_ 42 #define _SUBSTITUTIONMODELSET_H_ 50 #include <Bpp/Exceptions.h> 51 #include <Bpp/Numeric/Random/RandomTools.h> 52 #include <Bpp/Numeric/VectorTools.h> 55 #include <Bpp/Seq/Alphabet/Alphabet.h> 56 #include <Bpp/Seq/Alphabet/NucleicAlphabet.h> 105 public AbstractParameterAliasable
151 AbstractParameterAliasable(
""),
171 AbstractParameterAliasable(
""),
208 #ifndef NO_VIRTUAL_COV 253 if (i >
modelSet_.size())
throw IndexOutOfBoundsException(
"SubstitutionModelSet::getNumberOfModels().", 0,
modelSet_.size() - 1, i);
259 if (i >
modelSet_.size())
throw IndexOutOfBoundsException(
"SubstitutionModelSet::getNumberOfModels().", 0,
modelSet_.size() - 1, i);
272 std::map<int, size_t>::iterator i =
nodeToModel_.find(nodeId);
274 throw Exception(
"SubstitutionModelSet::getModelIndexForNode(). No model associated to node with id " + TextTools::toString(nodeId));
287 std::map<int, size_t>::const_iterator i =
nodeToModel_.find(nodeId);
289 throw Exception(
"SubstitutionModelSet::getModelForNode(). No model associated to node with id " + TextTools::toString(nodeId));
294 std::map<int, size_t>::iterator i =
nodeToModel_.find(nodeId);
296 throw Exception(
"SubstitutionModelSet::getModelForNode(). No model associated to node with id " + TextTools::toString(nodeId));
309 if (i >=
modelSet_.size())
throw IndexOutOfBoundsException(
"SubstitutionModelSet::getNodesWithModel().", i, 0,
modelSet_.size());
319 std::vector<int>
getNodesWithParameter(
const std::string& name)
const throw (ParameterNotFoundException);
377 return ParameterList();
393 i < getNumberOfParameters(); i++)
395 pl.addParameter(getParameter_(i));
493 #endif // _SUBSTITUTIONMODELSET_H_ bool isFullySetUpFor(const Tree &tree, bool throwEx=true) const
Check if the model set is fully specified for a given tree.
std::map< size_t, std::vector< int > > modelToNodes_
Substitution models manager for non-homogeneous / non-reversible models of evolution.
Interface for all substitution models.
const SubstitutionModel * getModelForNode(int nodeId) const
Get the model associated to a particular node id.
virtual std::vector< size_t > getModelStates(int code) const =0
Get the state in the model corresponding to a particular state in the alphabet.
ParameterList getRootFrequenciesParameters() const
Get the parameters corresponding to the root frequencies.
virtual int getAlphabetStateAsInt(size_t index) const =0
const SubstitutionModel * getModel(size_t i) const
Get one model from the set knowing its index.
SubstitutionModelSet(const Alphabet *alpha, FrequenciesSet *rootFreqs)
Create a model set according to the specified alphabet and root frequencies. Stationarity is not assu...
virtual const StateMap & getStateMap() const =0
virtual const std::vector< int > & getAlphabetStates() const
virtual const std::vector< int > & getAlphabetStates() const =0
ParameterList getModelParameters(size_t modelIndex) const
Get the parameters attached to a Model.
void setRootFrequencies(FrequenciesSet *rootFreqs)
Sets a given FrequenciesSet for root frequencies.
size_t getModelIndexForNode(int nodeId) const
Get the index in the set of the model associated to a particular node id.
std::vector< double > getRootFrequencies() const
void listModelNames(std::ostream &out=std::cout) const
virtual std::string getAlphabetStateAsChar(size_t index) const
Interface for phylogenetic tree objects.
Parametrize a set of state frequencies.
virtual const StateMap & getStateMap() const
virtual std::vector< size_t > getModelStates(const std::string &code) const
SubstitutionModel * getModelForNode(int nodeId)
void addModel(SubstitutionModel *model, const std::vector< int > &nodesId)
Add a new model to the set, and set relationships with nodes and params.
std::map< int, size_t > nodeToModel_
Contains for each node in a tree the index of the corresponding model in modelSet_.
ParameterList getNodeParameters() const
Get the parameters corresponding attached to the nodes of the tree.
std::vector< ParameterList > modelParameters_
Parameters for each model in the set.
const Alphabet * getAlphabet() const
const FrequenciesSet * getRootFrequenciesSet() const
void clear()
Resets all the information contained in this object.
virtual ~SubstitutionModelSet()
void replaceModel(size_t modelIndex, SubstitutionModel *model)
Replace a model in the set, and all corresponding parameters. The replaced model deleted.
std::auto_ptr< FrequenciesSet > rootFrequencies_
Root frequencies.
virtual std::string getAlphabetStateAsChar(size_t index) const =0
virtual int getAlphabetStateAsInt(size_t index) const
std::vector< SubstitutionModel * > modelSet_
Contains all models used in this tree.
size_t getNumberOfStates() const
Get the number of states associated to this model set.
bool checkOrphanModels(bool throwEx) const
virtual void fireParameterChanged(const ParameterList ¶meters)
void updateRootFrequencies()
const std::vector< int > & getNodesWithModel(size_t i) const
Get a list of nodes id for which the given model is associated.
SubstitutionModel * getModel(size_t i)
size_t getNumberOfModels() const
SubstitutionModelSet & operator=(const SubstitutionModelSet &set)
SubstitutionModelSet(const Alphabet *alpha)
Create a model set according to the specified alphabet. Stationarity is assumed.
SubstitutionModelSet * clone() const
Map the states of a given alphabet which have a model state.
bool hasMixedSubstitutionModel() const
std::vector< int > getNodesWithParameter(const std::string &name) const
const Alphabet * alphabet_
A pointer toward the common alphabet to all models in the set.
bool checkOrphanNodes(const Tree &tree, bool throwEx) const
bool checkUnknownNodes(const Tree &tree, bool throwEx) const
virtual std::vector< size_t > getModelStates(int code) const