bpp-phyl
2.2.0
|
Analytical substitution count using the eigen decomposition method. More...
#include <Bpp/Phyl/Mapping/DecompositionSubstitutionCount.h>
Public Member Functions | |
DecompositionSubstitutionCount (const ReversibleSubstitutionModel *model, SubstitutionRegister *reg, const AlphabetIndex2 *weights=0) | |
DecompositionSubstitutionCount (const DecompositionSubstitutionCount &dsc) | |
DecompositionSubstitutionCount & | operator= (const DecompositionSubstitutionCount &dsc) |
virtual | ~DecompositionSubstitutionCount () |
DecompositionSubstitutionCount * | clone () 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 SubstitutionRegister * | getSubstitutionRegister () const |
SubstitutionRegister * | getSubstitutionRegister () |
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< SubstitutionRegister > | register_ |
const AlphabetIndex2 * | weights_ |
bool | ownWeights_ |
Private Member Functions | |
void | resetStates_ () |
void | resetBMatrices_ () |
void | initBMatrices_ () |
void | fillBMatrices_ () |
void | computeEigen_ () |
void | computeProducts_ () |
Private Attributes | |
const ReversibleSubstitutionModel * | model_ |
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_ |
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.
Definition at line 58 of file DecompositionSubstitutionCount.h.
DecompositionSubstitutionCount::DecompositionSubstitutionCount | ( | const ReversibleSubstitutionModel * | model, |
SubstitutionRegister * | reg, | ||
const AlphabetIndex2 * | weights = 0 |
||
) |
Definition at line 50 of file DecompositionSubstitutionCount.cpp.
References computeEigen_(), computeProducts_(), fillBMatrices_(), bpp::SubstitutionRegister::getAlphabet(), bpp::SubstitutionModel::getAlphabet(), and initBMatrices_().
Referenced by clone().
|
inline |
Definition at line 74 of file DecompositionSubstitutionCount.h.
|
inlinevirtual |
Definition at line 106 of file DecompositionSubstitutionCount.h.
|
inlinevirtual |
Implements bpp::SubstitutionCount.
Definition at line 108 of file DecompositionSubstitutionCount.h.
References DecompositionSubstitutionCount().
|
protected |
Definition at line 153 of file DecompositionSubstitutionCount.cpp.
References counts_, bpp::SubstitutionModel::getAlphabetStates(), bpp::SubstitutionModel::getPij_t(), insideProducts_, jFunction_(), jMat_, lambda_, model_, nbStates_, bpp::AbstractSubstitutionCount::register_, v_, vInv_, and bpp::AbstractWeightedSubstitutionCount::weights_.
Referenced by getAllNumbersOfSubstitutions(), getNumberOfSubstitutions(), getNumberOfSubstitutionsForEachType(), setSubstitutionModel(), substitutionRegisterHasChanged(), and weightsHaveChanged().
|
private |
Definition at line 93 of file DecompositionSubstitutionCount.cpp.
References bpp::SubstitutionModel::getColumnRightEigenVectors(), bpp::SubstitutionModel::getEigenValues(), bpp::SubstitutionModel::getRowLeftEigenVectors(), lambda_, model_, v_, and vInv_.
Referenced by DecompositionSubstitutionCount(), and setSubstitutionModel().
|
private |
Definition at line 100 of file DecompositionSubstitutionCount.cpp.
References bMatrices_, insideProducts_, nbStates_, bpp::AbstractSubstitutionCount::register_, v_, and vInv_.
Referenced by DecompositionSubstitutionCount(), setSubstitutionModel(), and substitutionRegisterHasChanged().
|
private |
Definition at line 78 of file DecompositionSubstitutionCount.cpp.
References bMatrices_, bpp::SubstitutionModel::getAlphabetStates(), model_, nbStates_, bpp::SubstitutionModel::Qij(), and bpp::AbstractSubstitutionCount::register_.
Referenced by DecompositionSubstitutionCount(), setSubstitutionModel(), and substitutionRegisterHasChanged().
|
virtual |
Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length.
length | The length of the branch. |
type | The type of susbstitution to count. |
Implements bpp::SubstitutionCount.
Definition at line 182 of file DecompositionSubstitutionCount.cpp.
References computeCounts_(), counts_, and currentLength_.
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().
Definition at line 112 of file SubstitutionCount.h.
References bpp::SubstitutionRegister::getAlphabet(), and bpp::SubstitutionCount::getSubstitutionRegister().
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().
Definition at line 119 of file SubstitutionCount.h.
References bpp::SubstitutionRegister::getAlphabet(), and bpp::SubstitutionCount::getSubstitutionRegister().
|
virtual |
Get the number of susbstitutions on a branch, given the initial and final states, and the branch length.
initialState | The initial state. |
finalState | The final state. |
length | The length of the branch. |
type | The type of substitution to count. |
Implements bpp::SubstitutionCount.
Definition at line 212 of file DecompositionSubstitutionCount.cpp.
References computeCounts_(), counts_, and currentLength_.
|
virtual |
Get the numbers of susbstitutions on a branch for all types, for an initial and final states, given the branch length.
initialState | The initial state. |
finalState | The final state. |
length | The length of the branch. |
Implements bpp::SubstitutionCount.
Definition at line 226 of file DecompositionSubstitutionCount.cpp.
References computeCounts_(), counts_, currentLength_, and bpp::SubstitutionCount::getNumberOfSubstitutionTypes().
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes().
Definition at line 105 of file SubstitutionCount.h.
References bpp::SubstitutionRegister::getNumberOfSubstitutionTypes(), and bpp::SubstitutionCount::getSubstitutionRegister().
Referenced by bpp::NaiveSubstitutionCount::getNumberOfSubstitutionsForEachType(), bpp::UniformizationSubstitutionCount::getNumberOfSubstitutionsForEachType(), getNumberOfSubstitutionsForEachType(), and bpp::ProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes().
|
inlinevirtualinherited |
Implements bpp::SubstitutionCount.
Definition at line 206 of file SubstitutionCount.h.
References bpp::AbstractSubstitutionCount::register_.
|
inlinevirtualinherited |
Implements bpp::SubstitutionCount.
Definition at line 208 of file SubstitutionCount.h.
References bpp::AbstractSubstitutionCount::register_.
|
inlinevirtualinherited |
Implements bpp::WeightedSubstitutionCount.
Definition at line 106 of file WeightedSubstitutionCount.h.
References bpp::AbstractWeightedSubstitutionCount::weights_.
|
inlinevirtualinherited |
Implements bpp::SubstitutionCount.
Definition at line 192 of file SubstitutionCount.h.
References bpp::AbstractSubstitutionCount::register_.
|
inlinevirtualinherited |
Implements bpp::WeightedSubstitutionCount.
Definition at line 105 of file WeightedSubstitutionCount.h.
References bpp::AbstractWeightedSubstitutionCount::weights_.
|
private |
Definition at line 126 of file DecompositionSubstitutionCount.cpp.
References bMatrices_, counts_, insideProducts_, nbStates_, and bpp::AbstractSubstitutionCount::register_.
Referenced by DecompositionSubstitutionCount(), setSubstitutionModel(), and substitutionRegisterHasChanged().
|
protected |
Definition at line 136 of file DecompositionSubstitutionCount.cpp.
References nbStates_.
Referenced by computeCounts_().
|
inline |
Definition at line 89 of file DecompositionSubstitutionCount.h.
References bMatrices_, counts_, currentLength_, insideProducts_, jMat_, lambda_, model_, nbStates_, bpp::AbstractWeightedSubstitutionCount::operator=(), bpp::AbstractSubstitutionCount::operator=(), v_, and vInv_.
|
private |
Definition at line 110 of file DecompositionSubstitutionCount.cpp.
References bMatrices_, counts_, insideProducts_, and bpp::AbstractSubstitutionCount::register_.
Referenced by substitutionRegisterHasChanged().
|
private |
Definition at line 118 of file DecompositionSubstitutionCount.cpp.
References jMat_, lambda_, nbStates_, v_, and vInv_.
Referenced by setSubstitutionModel().
|
virtual |
Set the substitution model.
model | A 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_().
|
inlinevirtualinherited |
attribution of a SubstitutionRegister
reg | pointer to a SubstitutionRegister |
Implements bpp::SubstitutionCount.
Definition at line 201 of file SubstitutionCount.h.
References bpp::AbstractSubstitutionCount::register_, and bpp::AbstractSubstitutionCount::substitutionRegisterHasChanged().
|
virtualinherited |
Implements bpp::WeightedSubstitutionCount.
Definition at line 44 of file WeightedSubstitutionCount.cpp.
References bpp::AbstractWeightedSubstitutionCount::ownWeights_, bpp::AbstractWeightedSubstitutionCount::weights_, and bpp::AbstractWeightedSubstitutionCount::weightsHaveChanged().
|
protectedvirtual |
Implements bpp::AbstractSubstitutionCount.
Definition at line 270 of file DecompositionSubstitutionCount.cpp.
References computeCounts_(), computeProducts_(), currentLength_, fillBMatrices_(), bpp::SubstitutionModel::getAlphabet(), initBMatrices_(), model_, bpp::AbstractSubstitutionCount::register_, and resetBMatrices_().
|
protectedvirtual |
Implements bpp::AbstractWeightedSubstitutionCount.
Definition at line 288 of file DecompositionSubstitutionCount.cpp.
References computeCounts_(), currentLength_, bpp::AbstractSubstitutionCount::register_, and bpp::AbstractWeightedSubstitutionCount::weights_.
|
private |
Definition at line 67 of file DecompositionSubstitutionCount.h.
Referenced by computeProducts_(), fillBMatrices_(), initBMatrices_(), operator=(), and resetBMatrices_().
|
mutableprivate |
Definition at line 68 of file DecompositionSubstitutionCount.h.
Referenced by computeCounts_(), getAllNumbersOfSubstitutions(), getNumberOfSubstitutions(), getNumberOfSubstitutionsForEachType(), initBMatrices_(), operator=(), and resetBMatrices_().
|
mutableprivate |
Definition at line 69 of file DecompositionSubstitutionCount.h.
Referenced by getAllNumbersOfSubstitutions(), getNumberOfSubstitutions(), getNumberOfSubstitutionsForEachType(), operator=(), setSubstitutionModel(), substitutionRegisterHasChanged(), and weightsHaveChanged().
|
private |
Definition at line 67 of file DecompositionSubstitutionCount.h.
Referenced by computeCounts_(), computeProducts_(), initBMatrices_(), operator=(), and resetBMatrices_().
|
mutableprivate |
Definition at line 65 of file DecompositionSubstitutionCount.h.
Referenced by computeCounts_(), operator=(), and resetStates_().
|
mutableprivate |
Definition at line 66 of file DecompositionSubstitutionCount.h.
Referenced by computeCounts_(), computeEigen_(), operator=(), and resetStates_().
|
private |
Definition at line 63 of file DecompositionSubstitutionCount.h.
Referenced by computeCounts_(), computeEigen_(), fillBMatrices_(), operator=(), setSubstitutionModel(), and substitutionRegisterHasChanged().
|
private |
Definition at line 64 of file DecompositionSubstitutionCount.h.
Referenced by computeCounts_(), computeProducts_(), fillBMatrices_(), initBMatrices_(), jFunction_(), operator=(), resetStates_(), and setSubstitutionModel().
|
protectedinherited |
Definition at line 72 of file WeightedSubstitutionCount.h.
Referenced by bpp::AbstractWeightedSubstitutionCount::AbstractWeightedSubstitutionCount(), bpp::AbstractWeightedSubstitutionCount::operator=(), bpp::AbstractWeightedSubstitutionCount::setWeights(), and bpp::AbstractWeightedSubstitutionCount::~AbstractWeightedSubstitutionCount().
|
protectedinherited |
Definition at line 170 of file SubstitutionCount.h.
Referenced by bpp::UniformizationSubstitutionCount::computeCounts_(), computeCounts_(), computeProducts_(), bpp::UniformizationSubstitutionCount::fillBMatrices_(), fillBMatrices_(), bpp::NaiveSubstitutionCount::getAllNumbersOfSubstitutions(), bpp::NaiveSubstitutionCount::getNumberOfSubstitutions(), bpp::AbstractSubstitutionCount::getSubstitutionRegister(), bpp::AbstractSubstitutionCount::hasSubstitutionRegister(), bpp::UniformizationSubstitutionCount::initBMatrices_(), initBMatrices_(), bpp::AbstractSubstitutionCount::operator=(), bpp::UniformizationSubstitutionCount::resetBMatrices_(), resetBMatrices_(), bpp::UniformizationSubstitutionCount::setSubstitutionModel(), setSubstitutionModel(), bpp::AbstractSubstitutionCount::setSubstitutionRegister(), bpp::UniformizationSubstitutionCount::substitutionRegisterHasChanged(), substitutionRegisterHasChanged(), bpp::UniformizationSubstitutionCount::weightsHaveChanged(), and weightsHaveChanged().
|
mutableprivate |
Definition at line 65 of file DecompositionSubstitutionCount.h.
Referenced by computeCounts_(), computeEigen_(), computeProducts_(), operator=(), and resetStates_().
|
mutableprivate |
Definition at line 65 of file DecompositionSubstitutionCount.h.
Referenced by computeCounts_(), computeEigen_(), computeProducts_(), operator=(), and resetStates_().
|
protectedinherited |
Definition at line 71 of file WeightedSubstitutionCount.h.
Referenced by bpp::AbstractWeightedSubstitutionCount::AbstractWeightedSubstitutionCount(), bpp::UniformizationSubstitutionCount::computeCounts_(), computeCounts_(), bpp::NaiveSubstitutionCount::getAllNumbersOfSubstitutions(), bpp::NaiveSubstitutionCount::getNumberOfSubstitutions(), bpp::AbstractWeightedSubstitutionCount::getWeights(), bpp::AbstractWeightedSubstitutionCount::hasWeights(), bpp::AbstractWeightedSubstitutionCount::operator=(), bpp::AbstractWeightedSubstitutionCount::setWeights(), bpp::UniformizationSubstitutionCount::weightsHaveChanged(), weightsHaveChanged(), and bpp::AbstractWeightedSubstitutionCount::~AbstractWeightedSubstitutionCount().