bpp-phyl  2.2.0
bpp::DecompositionSubstitutionCount Class Reference

Analytical substitution count using the eigen decomposition method. More...

#include <Bpp/Phyl/Mapping/DecompositionSubstitutionCount.h>

+ Inheritance diagram for bpp::DecompositionSubstitutionCount:
+ Collaboration diagram for bpp::DecompositionSubstitutionCount:

Public Member Functions

 DecompositionSubstitutionCount (const ReversibleSubstitutionModel *model, SubstitutionRegister *reg, const AlphabetIndex2 *weights=0)
 
 DecompositionSubstitutionCount (const DecompositionSubstitutionCount &dsc)
 
DecompositionSubstitutionCountoperator= (const DecompositionSubstitutionCount &dsc)
 
virtual ~DecompositionSubstitutionCount ()
 
DecompositionSubstitutionCountclone () const
 
double getNumberOfSubstitutions (size_t initialState, size_t finalState, double length, size_t type=1) const
 Get the number of susbstitutions on a branch, given the initial and final states, and the branch length. More...
 
Matrix< double > * getAllNumbersOfSubstitutions (double length, size_t type=1) const
 Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length. More...
 
std::vector< double > getNumberOfSubstitutionsForEachType (size_t initialState, size_t finalState, double length) const
 Get the numbers of susbstitutions on a branch for all types, for an initial and final states, given the branch length. More...
 
void setSubstitutionModel (const SubstitutionModel *model)
 Set the substitution model. More...
 
bool hasSubstitutionRegister () const
 
void setSubstitutionRegister (SubstitutionRegister *reg)
 attribution of a SubstitutionRegister More...
 
const SubstitutionRegistergetSubstitutionRegister () const
 
SubstitutionRegistergetSubstitutionRegister ()
 
virtual size_t getNumberOfSubstitutionTypes () const
 Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes(). More...
 
virtual const Alphabet * getAlphabet () const
 Short cut function, equivalent to getSubstitutionRegister()->getAlphabet(). More...
 
virtual size_t getNumberOfStates () const
 Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize(). More...
 
void setWeights (const AlphabetIndex2 *weights, bool ownWeights)
 
bool hasWeights () const
 
const AlphabetIndex2 * getWeights () const
 

Protected Member Functions

void computeCounts_ (double length) const
 
void jFunction_ (const std::vector< double > &lambda, double t, RowMatrix< double > &result) const
 
void substitutionRegisterHasChanged () throw (Exception)
 
void weightsHaveChanged () throw (Exception)
 

Protected Attributes

std::auto_ptr< SubstitutionRegisterregister_
 
const AlphabetIndex2 * weights_
 
bool ownWeights_
 

Private Member Functions

void resetStates_ ()
 
void resetBMatrices_ ()
 
void initBMatrices_ ()
 
void fillBMatrices_ ()
 
void computeEigen_ ()
 
void computeProducts_ ()
 

Private Attributes

const ReversibleSubstitutionModelmodel_
 
size_t nbStates_
 
RowMatrix< double > jMat_
 
RowMatrix< double > v_
 
RowMatrix< double > vInv_
 
std::vector< double > lambda_
 
std::vector< RowMatrix< double > > bMatrices_
 
std::vector< RowMatrix< double > > insideProducts_
 
std::vector< RowMatrix< double > > counts_
 
double currentLength_
 

Detailed Description

Analytical substitution count using the eigen decomposition method.

The codes is adapted from the original R code by Paula Tataru and Asger Hobolth. Only reversible models are supported for now.

Author
Julien Dutheil

Definition at line 58 of file DecompositionSubstitutionCount.h.

Constructor & Destructor Documentation

◆ DecompositionSubstitutionCount() [1/2]

DecompositionSubstitutionCount::DecompositionSubstitutionCount ( const ReversibleSubstitutionModel model,
SubstitutionRegister reg,
const AlphabetIndex2 *  weights = 0 
)

◆ DecompositionSubstitutionCount() [2/2]

bpp::DecompositionSubstitutionCount::DecompositionSubstitutionCount ( const DecompositionSubstitutionCount dsc)
inline

Definition at line 74 of file DecompositionSubstitutionCount.h.

◆ ~DecompositionSubstitutionCount()

virtual bpp::DecompositionSubstitutionCount::~DecompositionSubstitutionCount ( )
inlinevirtual

Definition at line 106 of file DecompositionSubstitutionCount.h.

Member Function Documentation

◆ clone()

DecompositionSubstitutionCount* bpp::DecompositionSubstitutionCount::clone ( ) const
inlinevirtual

◆ computeCounts_()

◆ computeEigen_()

◆ computeProducts_()

void DecompositionSubstitutionCount::computeProducts_ ( )
private

◆ fillBMatrices_()

◆ getAllNumbersOfSubstitutions()

Matrix< double > * DecompositionSubstitutionCount::getAllNumbersOfSubstitutions ( double  length,
size_t  type = 1 
) const
virtual

Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length.

Parameters
lengthThe length of the branch.
typeThe type of susbstitution to count.
Returns
A matrix with all numbers of substitutions for each initial and final states.

Implements bpp::SubstitutionCount.

Definition at line 182 of file DecompositionSubstitutionCount.cpp.

References computeCounts_(), counts_, and currentLength_.

◆ getAlphabet()

virtual const Alphabet* bpp::SubstitutionCount::getAlphabet ( ) const
inlinevirtualinherited

Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().

Returns
The alphabet associated to this substitution count.

Definition at line 112 of file SubstitutionCount.h.

References bpp::SubstitutionRegister::getAlphabet(), and bpp::SubstitutionCount::getSubstitutionRegister().

◆ getNumberOfStates()

virtual size_t bpp::SubstitutionCount::getNumberOfStates ( ) const
inlinevirtualinherited

Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().

Returns
The number of states in the model/alphabet.

Definition at line 119 of file SubstitutionCount.h.

References bpp::SubstitutionRegister::getAlphabet(), and bpp::SubstitutionCount::getSubstitutionRegister().

◆ getNumberOfSubstitutions()

double DecompositionSubstitutionCount::getNumberOfSubstitutions ( size_t  initialState,
size_t  finalState,
double  length,
size_t  type = 1 
) const
virtual

Get the number of susbstitutions on a branch, given the initial and final states, and the branch length.

Parameters
initialStateThe initial state.
finalStateThe final state.
lengthThe length of the branch.
typeThe type of substitution to count.
Returns
The number of substitutions on a branch of specified length and according to initial and final states.

Implements bpp::SubstitutionCount.

Definition at line 212 of file DecompositionSubstitutionCount.cpp.

References computeCounts_(), counts_, and currentLength_.

◆ getNumberOfSubstitutionsForEachType()

std::vector< double > DecompositionSubstitutionCount::getNumberOfSubstitutionsForEachType ( size_t  initialState,
size_t  finalState,
double  length 
) const
virtual

Get the numbers of susbstitutions on a branch for all types, for an initial and final states, given the branch length.

Parameters
initialStateThe initial state.
finalStateThe final state.
lengthThe length of the branch.
Returns
A matrix with all numbers of substitutions for each initial and final states.

Implements bpp::SubstitutionCount.

Definition at line 226 of file DecompositionSubstitutionCount.cpp.

References computeCounts_(), counts_, currentLength_, and bpp::SubstitutionCount::getNumberOfSubstitutionTypes().

◆ getNumberOfSubstitutionTypes()

◆ getSubstitutionRegister() [1/2]

const SubstitutionRegister* bpp::AbstractSubstitutionCount::getSubstitutionRegister ( ) const
inlinevirtualinherited
Returns
The SubstitutionRegister object associated to this instance. The register contains the description of the various substitutions types that are mapped.

Implements bpp::SubstitutionCount.

Definition at line 206 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ getSubstitutionRegister() [2/2]

SubstitutionRegister* bpp::AbstractSubstitutionCount::getSubstitutionRegister ( )
inlinevirtualinherited
Returns
The SubstitutionRegister object associated to this instance. The register contains the description of the various substitutions types that are mapped.

Implements bpp::SubstitutionCount.

Definition at line 208 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ getWeights()

const AlphabetIndex2* bpp::AbstractWeightedSubstitutionCount::getWeights ( ) const
inlinevirtualinherited

◆ hasSubstitutionRegister()

bool bpp::AbstractSubstitutionCount::hasSubstitutionRegister ( ) const
inlinevirtualinherited
Returns
Tell if a substitution register has been attached to this class.

Implements bpp::SubstitutionCount.

Definition at line 192 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ hasWeights()

bool bpp::AbstractWeightedSubstitutionCount::hasWeights ( ) const
inlinevirtualinherited

◆ initBMatrices_()

void DecompositionSubstitutionCount::initBMatrices_ ( )
private

◆ jFunction_()

void DecompositionSubstitutionCount::jFunction_ ( const std::vector< double > &  lambda,
double  t,
RowMatrix< double > &  result 
) const
protected

Definition at line 136 of file DecompositionSubstitutionCount.cpp.

References nbStates_.

Referenced by computeCounts_().

◆ operator=()

◆ resetBMatrices_()

void DecompositionSubstitutionCount::resetBMatrices_ ( )
private

◆ resetStates_()

void DecompositionSubstitutionCount::resetStates_ ( )
private

Definition at line 118 of file DecompositionSubstitutionCount.cpp.

References jMat_, lambda_, nbStates_, v_, and vInv_.

Referenced by setSubstitutionModel().

◆ setSubstitutionModel()

void DecompositionSubstitutionCount::setSubstitutionModel ( const SubstitutionModel model)
virtual

Set the substitution model.

Parameters
modelA pointer toward the substitution model to use. Only reversible models are currently supported. Setting a non-reversible model will throw an exception.

Implements bpp::SubstitutionCount.

Definition at line 244 of file DecompositionSubstitutionCount.cpp.

References computeCounts_(), computeEigen_(), computeProducts_(), currentLength_, fillBMatrices_(), bpp::SubstitutionModel::getAlphabet(), initBMatrices_(), model_, nbStates_, bpp::AbstractSubstitutionCount::register_, and resetStates_().

◆ setSubstitutionRegister()

void bpp::AbstractSubstitutionCount::setSubstitutionRegister ( SubstitutionRegister reg)
inlinevirtualinherited

◆ setWeights()

void AbstractWeightedSubstitutionCount::setWeights ( const AlphabetIndex2 *  weights,
bool  ownWeights 
)
virtualinherited

◆ substitutionRegisterHasChanged()

void DecompositionSubstitutionCount::substitutionRegisterHasChanged ( )
throw (Exception
)
protectedvirtual

◆ weightsHaveChanged()

void DecompositionSubstitutionCount::weightsHaveChanged ( )
throw (Exception
)
protectedvirtual

Member Data Documentation

◆ bMatrices_

std::vector< RowMatrix<double> > bpp::DecompositionSubstitutionCount::bMatrices_
private

◆ counts_

std::vector< RowMatrix<double> > bpp::DecompositionSubstitutionCount::counts_
mutableprivate

◆ currentLength_

◆ insideProducts_

std::vector< RowMatrix<double> > bpp::DecompositionSubstitutionCount::insideProducts_
private

◆ jMat_

RowMatrix<double> bpp::DecompositionSubstitutionCount::jMat_
mutableprivate

Definition at line 65 of file DecompositionSubstitutionCount.h.

Referenced by computeCounts_(), operator=(), and resetStates_().

◆ lambda_

std::vector<double> bpp::DecompositionSubstitutionCount::lambda_
mutableprivate

◆ model_

const ReversibleSubstitutionModel* bpp::DecompositionSubstitutionCount::model_
private

◆ nbStates_

size_t bpp::DecompositionSubstitutionCount::nbStates_
private

◆ ownWeights_

◆ register_

◆ v_

RowMatrix<double> bpp::DecompositionSubstitutionCount::v_
mutableprivate

◆ vInv_

RowMatrix<double> bpp::DecompositionSubstitutionCount::vInv_
mutableprivate

◆ weights_


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