40 #ifndef _MARKOVMODULATEDSUBSTITUTIONMODEL_H_ 41 #define _MARKOVMODULATEDSUBSTITUTIONMODEL_H_ 45 #include <Bpp/Numeric/AbstractParameterAliasable.h> 46 #include <Bpp/Numeric/Matrix/MatrixTools.h> 77 public AbstractParameterAliasable
162 AbstractParameterAliasable(prefix),
172 addParameters_(
model_->getIndependentParameters());
180 #ifndef NO_VIRTUAL_COV 211 const Matrix<double>&
getPij_t(
double t)
const;
212 const Matrix<double>&
getdPij_dt(
double t)
const;
228 double Pij_t (
size_t i,
size_t j,
double t)
const {
return getPij_t(t)(i, j); }
232 double getInitValue(
size_t i,
int state)
const throw (IndexOutOfBoundsException, BadIntException);
261 std::vector<double> v;
263 return -VectorTools::scalar<double, double>(v,
freq_);
282 AbstractParameterAliasable::fireParameterChanged(parameters);
283 model_->matchParametersValues(parameters);
306 #endif //_MARKOVMODULATEDSUBSTITUTIONMODEL_H_ void setRate(double rate)
Set the rate of the model (must be positive).
virtual void updateMatrices()
Vdouble freq_
The vector of equilibrium frequencies.
bool isDiagonalizable() const
virtual const std::vector< int > & getAlphabetStates() const
void enableEigenDecomposition(bool yn)
Set if eigenValues and Vectors must be computed.
size_t getRate(size_t i) const
Get the rate category corresponding to a particular state in the compound model.
const Matrix< double > & getd2Pij_dt2(double t) const
MarkovModulatedStateMap stateMap_
std::string getAlphabetStateAsChar(size_t index) const
bool enableEigenDecomposition()
Tell if eigenValues and Vectors must be computed.
Vdouble iEigenValues_
The vector of imaginary parts of the eigen values (zero in case of reversible pmodel).
const Vdouble & getFrequencies() const
virtual const Alphabet * getAlphabet() const =0
virtual std::vector< size_t > getModelStates(int code) const
std::vector< size_t > getModelStates(const std::string &code) const
Get the state in the model corresponding to a particular state in the alphabet.
bool isNonSingular() const
const Vdouble & getIEigenValues() const
RowMatrix< double > ratesGenerator_
const Matrix< double > & getColumnRightEigenVectors() const
virtual void setScale(double scale)=0
Multiplies the current generator by the given scale.
virtual void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)=0
Set equilibrium frequencies equal to the frequencies estimated from the data.
void setNamespace(const std::string &prefix)
MarkovModulatedSubstitutionModel * clone() const =0
virtual void setRate(double rate)=0
Set the rate of the model (must be positive).
virtual void updateRatesModel()=0
Update the rates vector, generator and equilibrium frequencies.
double dPij_dt(size_t i, size_t j, double t) const
virtual ~MarkovModulatedSubstitutionModel()
const Vdouble & getEigenValues() const
double freq(size_t i) const
MarkovModulatedSubstitutionModel & operator=(const MarkovModulatedSubstitutionModel &model)
double Qij(size_t i, size_t j) const
RowMatrix< double > generator_
The generator matrix of the model.
double getScale() const
Get the scalar product of diagonal elements of the generator and the frequencies vector. If the generator is normalized, then scale=1. Otherwise each element must be multiplied by 1/scale.
Interface for reversible substitution models.
Vdouble eigenValues_
The vector of real parts of eigen values.
RowMatrix< double > pijt_
These ones are for bookkeeping:
RowMatrix< double > rates_
double Sij(size_t i, size_t j) const
RowMatrix< double > leftEigenVectors_
The matrix made of left eigen vectors (by row).
double getInitValue(size_t i, int state) const
RowMatrix< double > dpijt_
const Matrix< double > & getdPij_dt(double t) const
const std::vector< int > & getAlphabetStates() const
bool eigenDecompose_
Tell if the eigen decomposition should be performed.
void setScale(double scale)
Multiplies the current generator by the given scale.
std::string nestedPrefix_
const ReversibleSubstitutionModel * getNestedModel() const
double Pij_t(size_t i, size_t j, double t) const
const Matrix< double > & getGenerator() const
Partial implementation of the Markov-modulated class of substitution models.
virtual std::string getAlphabetStateAsChar(size_t index) const
double getRate() const
Get the rate.
std::vector< size_t > getModelStates(int code) const
Get the state in the model corresponding to a particular state in the alphabet.
virtual double getRate() const =0
Get the rate.
ReversibleSubstitutionModel * model_
MarkovModulatedSubstitutionModel(ReversibleSubstitutionModel *model, unsigned int nbRates, bool normalizeRateChanges, const std::string &prefix)
Build a new MarkovModulatedSubstitutionModel object.
size_t getNumberOfStates() const
Get the number of states.
virtual void fireParameterChanged(const ParameterList ¶meters)
Tells the model that a parameter value has changed.
RowMatrix< double > d2pijt_
const Alphabet * getAlphabet() const
const Matrix< double > & getRowLeftEigenVectors() const
RowMatrix< double > ratesExchangeability_
virtual int getAlphabetStateAsInt(size_t index) const
bool normalizeRateChanges_
This class implements a state map for Markov modulated models.
int getAlphabetStateAsInt(size_t index) const
Map the states of a given alphabet which have a model state.
const Matrix< double > & getExchangeabilityMatrix() const
RowMatrix< double > rightEigenVectors_
The matrix made of right eigen vectors (by column).
void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)
Set equilibrium frequencies equal to the frequencies estimated from the data.
const Matrix< double > & getPij_t(double t) const
RowMatrix< double > exchangeability_
The exchangeability matrix of the model.
double d2Pij_dt2(size_t i, size_t j, double t) const
const StateMap & getStateMap() const