bpp-phyl3  3.0.0
bpp::TransitionFromTransitionModel Class Reference

From a transition model, compute the transition function probabilities. More...

#include <Bpp/Phyl/Model/TransitionFromTransitionModel.h>

+ Inheritance diagram for bpp::TransitionFromTransitionModel:
+ Collaboration diagram for bpp::TransitionFromTransitionModel:

Public Member Functions

 TransitionFromTransitionModel (std::shared_ptr< TransitionModelInterface > originalModel)
 
 TransitionFromTransitionModel (const TransitionFromTransitionModel &fmsm)
 
TransitionFromTransitionModeloperator= (const TransitionFromTransitionModel &fmsm)
 
virtual ~TransitionFromTransitionModel ()
 
TransitionFromTransitionModelclone () const override
 
void fireParameterChanged (const ParameterList &parameters) override
 
const BranchModelInterfacemodel () const override
 
const TransitionModelInterfacetransitionModel () const
 
const Eigen::VectorXd & Lik_t (const Eigen::VectorXd &from, double t) const override
 
const Eigen::VectorXd & dLik_dt (const Eigen::VectorXd &from, double t) const override
 
const Eigen::VectorXd & d2Lik_dt2 (const Eigen::VectorXd &from, double t) const override
 
void setFreqFromData (const SequenceDataInterface &data, double pseudoCount)
 
virtual void setFreq (std::map< int, double > &m)
 
double getRate () const override
 Get the rate. More...
 
void setRate (double rate) override
 Set the rate of the model (must be positive). More...
 
double getInitValue (size_t i, int state) const override
 
std::string getName () const override
 Get the name of the model. More...
 
void addRateParameter () override
 
void setNamespace (const std::string &prefix)
 
bool hasIndependentParameter (const std::string &name) const
 
const ParameterListgetIndependentParameters () const
 
size_t getNumberOfIndependentParameters () const
 
void aliasParameters (const std::string &p1, const std::string &p2)
 
void aliasParameters (std::map< std::string, std::string > &unparsedParams, bool verbose)
 
void unaliasParameters (const std::string &p1, const std::string &p2)
 
ParameterList getAliasedParameters (const ParameterList &pl) const
 
ParameterList getFromParameters (const ParameterList &pl) const
 
virtual std::vector< std::string > getAlias (const std::string &name) const
 
virtual std::map< std::string, std::string > getAliases () const
 
std::string getFrom (const std::string &name) const
 
bool hasParameter (const std::string &name) const override
 
const ParameterListgetParameters () const override
 
const Parameterparameter (const std::string &name) const override
 
const std::shared_ptr< Parameter > & getParameter (const std::string &name) const
 
double getParameterValue (const std::string &name) const override
 
void setAllParametersValues (const ParameterList &parameters) override
 
void setParameterValue (const std::string &name, double value) override
 
void setParametersValues (const ParameterList &parameters) override
 
bool matchParametersValues (const ParameterList &parameters) override
 
void removeConstraint (const std::string &name) override
 
void setConstraint (const std::string &name, std::shared_ptr< ConstraintInterface > constraint) override
 
size_t getNumberOfParameters () const override
 
std::string getNamespace () const override
 
std::string getParameterNameWithoutNamespace (const std::string &name) const override
 
const std::vector< int > & getAlphabetStates () const override
 
const StateMapInterfacestateMap () const override
 
std::shared_ptr< const StateMapInterfacegetStateMap () const override
 
int getAlphabetStateAsInt (size_t i) const override
 
std::string getAlphabetStateAsChar (size_t i) const override
 
std::vector< size_t > getModelStates (int code) const override
 Get the state in the model corresponding to a particular state in the alphabet. More...
 
std::vector< size_t > getModelStates (const std::string &code) const override
 Get the state in the model corresponding to a particular state in the alphabet. More...
 
const Alphabetalphabet () const override
 
std::shared_ptr< const AlphabetgetAlphabet () const override
 
size_t getNumberOfStates () const override
 Get the number of states. More...
 
const FrequencySetInterfacefrequencySet () const override
 

Protected Member Functions

BranchModelInterfacemodel_ ()
 
TransitionModelInterfacetransitionModel_ ()
 
const std::shared_ptr< Parameter > & getParameter (size_t i) const
 
std::shared_ptr< Parameter > & getParameter (size_t i)
 
void addParameter_ (Parameter *parameter)
 
void addParameters_ (const ParameterList &parameters)
 
void shareParameter_ (const std::shared_ptr< Parameter > &parameter)
 
void shareParameters_ (const ParameterList &parameters)
 
void includeParameters_ (const ParameterList &parameters)
 
void deleteParameter_ (size_t index)
 
void deleteParameter_ (std::string &name)
 
void deleteParameters_ (const std::vector< std::string > &names)
 
void resetParameters_ ()
 
ParametergetParameter_ (const std::string &name)
 
ParametergetParameter_ (size_t index)
 
const ParametergetParameter_ (size_t index) const
 
ParametergetParameterWithNamespace_ (const std::string &name)
 
const ParametergetParameterWithNamespace_ (const std::string &name) const
 
ParameterListgetParameters_ () override
 

Private Attributes

std::shared_ptr< TransitionModelInterfacesubModel_
 The related model. More...
 
size_t size_
 
double tref_
 Reference time to avoid recomuputation of transition matrix when time has not changed. If <0, it means that transition matrix should be recomputed (for ex if parameters have changed). More...
 
const Matrix< double > * Pij_t
 Transition Matrices owned by the submodel. More...
 
const Matrix< double > * dPij_dt
 
const Matrix< double > * d2Pij_dt2
 
Eigen::VectorXd Pi_
 Used return vectors. More...
 
Eigen::VectorXd dPi_
 
Eigen::VectorXd d2Pi_
 
ParameterList independentParameters_
 
std::map< std::string, std::shared_ptr< AliasParameterListener > > aliasListenersRegister_
 
ParameterList parameters_
 
std::string prefix_
 

Detailed Description

From a transition model, compute the transition function probabilities.

This class is (up to now) mostly for test purpose.

It has the same parameters as the SubModel.

Definition at line 21 of file TransitionFromTransitionModel.h.

Constructor & Destructor Documentation

◆ TransitionFromTransitionModel() [1/2]

bpp::TransitionFromTransitionModel::TransitionFromTransitionModel ( std::shared_ptr< TransitionModelInterface originalModel)
inline

◆ TransitionFromTransitionModel() [2/2]

bpp::TransitionFromTransitionModel::TransitionFromTransitionModel ( const TransitionFromTransitionModel fmsm)
inline

Definition at line 69 of file TransitionFromTransitionModel.h.

◆ ~TransitionFromTransitionModel()

virtual bpp::TransitionFromTransitionModel::~TransitionFromTransitionModel ( )
inlinevirtual

Definition at line 92 of file TransitionFromTransitionModel.h.

Member Function Documentation

◆ addRateParameter()

◆ alphabet()

const Alphabet& bpp::AbstractWrappedModel::alphabet ( ) const
inlineoverridevirtualinherited

◆ clone()

TransitionFromTransitionModel* bpp::TransitionFromTransitionModel::clone ( ) const
inlineoverridevirtual

◆ d2Lik_dt2()

const Eigen::VectorXd & TransitionFromTransitionModel::d2Lik_dt2 ( const Eigen::VectorXd &  from,
double  t 
) const
overridevirtual

Implements bpp::BranchModelInterface.

Definition at line 59 of file TransitionFromTransitionModel.cpp.

References to().

◆ dLik_dt()

const Eigen::VectorXd & TransitionFromTransitionModel::dLik_dt ( const Eigen::VectorXd &  from,
double  t 
) const
overridevirtual

Implements bpp::BranchModelInterface.

Definition at line 37 of file TransitionFromTransitionModel.cpp.

References to().

◆ fireParameterChanged()

void bpp::TransitionFromTransitionModel::fireParameterChanged ( const ParameterList parameters)
inlineoverridevirtual

◆ frequencySet()

const FrequencySetInterface& bpp::AbstractWrappedModel::frequencySet ( ) const
inlineoverridevirtualinherited
Returns
Get the FrequencySet of equilibrium of this model.
Exceptions
Exceptionif no FrequenceSet is associated to this model.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel, bpp::OneChangeTransitionModel, bpp::OneChangeRegisterTransitionModel, bpp::YN98, and bpp::AbstractWrappedTransitionModel.

Definition at line 59 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::frequencySet(), and bpp::WrappedModelInterface::model().

Referenced by bpp::YN98::frequencySet().

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::AbstractWrappedModel::getAlphabet ( ) const
inlineoverridevirtualinherited

◆ getAlphabetStateAsChar()

std::string bpp::AbstractWrappedModel::getAlphabetStateAsChar ( size_t  index) const
inlineoverridevirtualinherited
Parameters
indexThe model state.
Returns
The corresponding alphabet state as character code.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 46 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getAlphabetStateAsChar(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getAlphabetStateAsChar().

◆ getAlphabetStateAsInt()

int bpp::AbstractWrappedModel::getAlphabetStateAsInt ( size_t  index) const
inlineoverridevirtualinherited
Parameters
indexThe model state.
Returns
The corresponding alphabet state as character code.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 44 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getAlphabetStateAsInt(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getAlphabetStateAsInt().

◆ getAlphabetStates()

const std::vector<int>& bpp::AbstractWrappedModel::getAlphabetStates ( ) const
inlineoverridevirtualinherited

@ brief Methods to supersede TransitionModel methods.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 38 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getAlphabetStates(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getAlphabetStates().

◆ getInitValue()

double bpp::TransitionFromTransitionModel::getInitValue ( size_t  i,
int  state 
) const
inlineoverridevirtual

This method is used to initialize likelihoods in recursions. It typically sends 1 if i = state, 0 otherwise, where i is one of the possible states of the alphabet allowed in the model and state is the observed state in the considered sequence/site.

Parameters
ithe index of the state in the model.
stateAn observed state in the sequence/site.
Returns
1 or 0 depending if the two states are compatible.
Exceptions
IndexOutOfBoundsExceptionif array position is out of range.
BadIntExceptionif states are not allowed in the associated alphabet.
See also
getStates();

Implements bpp::BranchModelInterface.

Definition at line 132 of file TransitionFromTransitionModel.h.

References bpp::BranchModelInterface::getInitValue(), and transitionModel().

◆ getModelStates() [1/2]

std::vector<size_t> bpp::AbstractWrappedModel::getModelStates ( const std::string &  code) const
inlineoverridevirtualinherited

Get the state in the model corresponding to a particular state in the alphabet.

Parameters
codeThe alphabet state to check.
Returns
A vector of indices of model states.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 50 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getModelStates(), and bpp::WrappedModelInterface::model().

◆ getModelStates() [2/2]

std::vector<size_t> bpp::AbstractWrappedModel::getModelStates ( int  code) const
inlineoverridevirtualinherited

Get the state in the model corresponding to a particular state in the alphabet.

Parameters
codeThe alphabet state to check.
Returns
A vector of indices of model states.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 48 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getModelStates(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getModelStates().

◆ getName()

std::string bpp::TransitionFromTransitionModel::getName ( ) const
inlineoverridevirtual

Get the name of the model.

Returns
The name of this model.

Reimplemented from bpp::AbstractWrappedModel.

Definition at line 137 of file TransitionFromTransitionModel.h.

◆ getNumberOfStates()

size_t bpp::AbstractWrappedModel::getNumberOfStates ( ) const
inlineoverridevirtualinherited

Get the number of states.

For most models, this equals the size of the alphabet.

See also
getAlphabetChars for the list of supported states.
Returns
The number of different states in the model.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 57 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getNumberOfStates(), and bpp::WrappedModelInterface::model().

◆ getRate()

double bpp::TransitionFromTransitionModel::getRate ( ) const
inlineoverridevirtual

Get the rate.

Implements bpp::BranchModelInterface.

Definition at line 128 of file TransitionFromTransitionModel.h.

References bpp::BranchModelInterface::getRate(), and transitionModel().

Referenced by addRateParameter().

◆ getStateMap()

std::shared_ptr<const StateMapInterface> bpp::AbstractWrappedModel::getStateMap ( ) const
inlineoverridevirtualinherited
Returns
A shared_ptr to the mapping of model states with alphabet states.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 42 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getStateMap(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getStateMap().

◆ Lik_t()

const Eigen::VectorXd & TransitionFromTransitionModel::Lik_t ( const Eigen::VectorXd &  values,
double  t 
) const
overridevirtual

This method is used to compute likelihoods in recursions. It computes the probability of a vector given a start state.

Parameters
valuesAn vector of states on the site.
ttime
Exceptions
IndexOutOfBoundsExceptionif array position is out of range.
BadIntExceptionif states are not allowed in the associated alphabet.

Implements bpp::BranchModelInterface.

Definition at line 14 of file TransitionFromTransitionModel.cpp.

References to().

◆ model()

const BranchModelInterface& bpp::TransitionFromTransitionModel::model ( ) const
inlineoverridevirtual

Implements bpp::WrappedModelInterface.

Definition at line 104 of file TransitionFromTransitionModel.h.

References subModel_.

Referenced by addRateParameter().

◆ model_()

BranchModelInterface& bpp::TransitionFromTransitionModel::model_ ( )
inlineprotected

Definition at line 149 of file TransitionFromTransitionModel.h.

References subModel_.

Referenced by addRateParameter(), and fireParameterChanged().

◆ operator=()

TransitionFromTransitionModel& bpp::TransitionFromTransitionModel::operator= ( const TransitionFromTransitionModel fmsm)
inline

◆ setFreq()

virtual void bpp::TransitionFromTransitionModel::setFreq ( std::map< int, double > &  m)
inlinevirtual

◆ setFreqFromData()

void bpp::TransitionFromTransitionModel::setFreqFromData ( const SequenceDataInterface data,
double  pseudoCount 
)
inline

◆ setRate()

void bpp::TransitionFromTransitionModel::setRate ( double  rate)
inlineoverridevirtual

Set the rate of the model (must be positive).

Parameters
ratemust be positive.

Implements bpp::BranchModelInterface.

Definition at line 130 of file TransitionFromTransitionModel.h.

References bpp::BranchModelInterface::setRate(), and transitionModel_().

◆ stateMap()

const StateMapInterface& bpp::AbstractWrappedModel::stateMap ( ) const
inlineoverridevirtualinherited
Returns
The mapping of model states with alphabet states.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 40 of file AbstractWrappedModel.h.

References bpp::WrappedModelInterface::model(), and bpp::BranchModelInterface::stateMap().

Referenced by bpp::RegisterRatesSubstitutionModel::stateMap().

◆ transitionModel()

const TransitionModelInterface& bpp::TransitionFromTransitionModel::transitionModel ( ) const
inline

Definition at line 109 of file TransitionFromTransitionModel.h.

References subModel_.

Referenced by getInitValue(), and getRate().

◆ transitionModel_()

TransitionModelInterface& bpp::TransitionFromTransitionModel::transitionModel_ ( )
inlineprotected

Definition at line 154 of file TransitionFromTransitionModel.h.

References subModel_.

Referenced by setFreq(), setFreqFromData(), and setRate().

Member Data Documentation

◆ d2Pi_

Eigen::VectorXd bpp::TransitionFromTransitionModel::d2Pi_
private

Definition at line 55 of file TransitionFromTransitionModel.h.

Referenced by operator=().

◆ d2Pij_dt2

const Matrix<double> * bpp::TransitionFromTransitionModel::d2Pij_dt2
private

Definition at line 50 of file TransitionFromTransitionModel.h.

◆ dPi_

Eigen::VectorXd bpp::TransitionFromTransitionModel::dPi_
private

Definition at line 55 of file TransitionFromTransitionModel.h.

Referenced by operator=().

◆ dPij_dt

const Matrix<double> * bpp::TransitionFromTransitionModel::dPij_dt
private

Definition at line 50 of file TransitionFromTransitionModel.h.

◆ Pi_

Eigen::VectorXd bpp::TransitionFromTransitionModel::Pi_
mutableprivate

Used return vectors.

Definition at line 55 of file TransitionFromTransitionModel.h.

Referenced by operator=().

◆ Pij_t

const Matrix<double>* bpp::TransitionFromTransitionModel::Pij_t
mutableprivate

Transition Matrices owned by the submodel.

These ones are for bookkeeping:

Definition at line 50 of file TransitionFromTransitionModel.h.

◆ size_

size_t bpp::TransitionFromTransitionModel::size_
private

The number of states

Definition at line 33 of file TransitionFromTransitionModel.h.

Referenced by operator=().

◆ subModel_

std::shared_ptr<TransitionModelInterface> bpp::TransitionFromTransitionModel::subModel_
private

◆ tref_

double bpp::TransitionFromTransitionModel::tref_
mutableprivate

Reference time to avoid recomuputation of transition matrix when time has not changed. If <0, it means that transition matrix should be recomputed (for ex if parameters have changed).

Definition at line 41 of file TransitionFromTransitionModel.h.

Referenced by fireParameterChanged(), and operator=().


The documentation for this class was generated from the following files: