43 #include <Bpp/Seq/Container/SequenceContainerTools.h> 55 AbstractParameterAliasable(
"JC69."),
57 exp_(), p_(size_, size_), freqSet_(0)
64 AbstractParameterAliasable(
"JC69+F."),
66 exp_(), p_(size_, size_), freqSet_(freqSet)
71 addParameters_(
freqSet_->getParameters());
81 for (
unsigned int i = 0; i < 20; i++)
freq_[i] = 1. / 20.;
84 for (
unsigned int i = 0; i < 20; i++)
86 for (
unsigned int j = 0; j < 20; j++)
95 for (
unsigned int i = 1; i < 20; i++)
eigenValues_[i] = -20. / 19.;
99 for (
unsigned int i = 1; i < 20; i++)
100 for (
unsigned int j = 0; j < 20; j++)
106 for (
unsigned int i = 0; i < 19; i++)
107 for (
unsigned int j = 1; j < 20; j++)
117 if(i == j)
return 1./20. + 19./20. * exp(-
rate_ * 20./19. * d);
118 else return 1./20. - 1./20. * exp(-
rate_ * 20./19. * d);
125 if(i == j)
return -
rate_ * exp(-
rate_ * 20./19. * d);
126 else return rate_ * 1./19. * exp(-
rate_ * 20./19. * d);
133 if(i == j)
return rate_ *
rate_ * 20./19. * exp(-
rate_ * 20./19. * d);
142 for(
unsigned int i = 0; i <
size_; i++)
144 for(
unsigned int j = 0; j <
size_; j++)
146 p_(i,j) = (i==j) ? 1./20. + 19./20. *
exp_ : 1./20. - 1./20. *
exp_;
155 for(
unsigned int i = 0; i <
size_; i++)
157 for(
unsigned int j = 0; j <
size_; j++)
168 for(
unsigned int i = 0; i <
size_; i++)
170 for(
unsigned int j = 0; j <
size_; j++)
182 map<int, int> counts;
183 SequenceContainerTools::getCounts(data, counts);
185 for (
int i = 0; i < static_cast<int>(
size_); i++)
187 t += (counts[i] + pseudoCount);
189 for (
size_t i = 0; i < size_; ++i) freq_[i] = (static_cast<double>(counts[
static_cast<int>(i)]) + pseudoCount) / t;
192 matchParametersValues(
freqSet_->getParameters());
RowMatrix< double > exchangeability_
The exchangeability matrix of the model, defined as . When the model is reversible, this matrix is symetric.
const Matrix< double > & getPij_t(double d) const
This class implements a state map where all resolved states are modeled.
RowMatrix< double > rightEigenVectors_
The matrix made of right eigen vectors (by column).
const Matrix< double > & getdPij_dt(double d) const
Vdouble eigenValues_
The vector of eigen values.
double d2Pij_dt2(size_t i, size_t j, double d) const
virtual void setFrequencies(const std::vector< double > &frequencies)=0
Set the parameters in order to match a given set of frequencies.
FrequenciesSet useful for homogeneous and stationary models, protein implementation.
virtual const std::vector< double > getFrequencies() const =0
Vdouble freq_
The vector of equilibrium frequencies.
Partial implementation of the ReversibleSubstitutionModel interface.
JCprot(const ProteicAlphabet *alpha)
Build a simple JC69 model, with original equilibrium frequencies.
const Matrix< double > & getd2Pij_dt2(double d) const
Parametrize a set of state frequencies for proteins.
RowMatrix< double > leftEigenVectors_
The matrix made of left eigen vectors (by row) if rightEigenVectors_ is non-singular.
RowMatrix< double > generator_
The generator matrix of the model.
void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)
Set equilibrium frequencies equal to the frequencies estimated from the data.
double rate_
The rate of the model (default: 1). The generator (and all its vectorial components) is independent o...
double dPij_dt(size_t i, size_t j, double d) const
size_t size_
The size of the generator, i.e. the number of states.
double Pij_t(size_t i, size_t j, double d) const
ProteinFrequenciesSet * freqSet_