bpp-phyl  2.2.0
bpp::DRASRTreeLikelihoodData Class Reference

discrete Rate Across Sites, (simple) Recursive likelihood data structure. More...

#include <Bpp/Phyl/Likelihood/DRASRTreeLikelihoodData.h>

+ Inheritance diagram for bpp::DRASRTreeLikelihoodData:
+ Collaboration diagram for bpp::DRASRTreeLikelihoodData:

Public Member Functions

 DRASRTreeLikelihoodData (const TreeTemplate< Node > *tree, size_t nbClasses, bool usePatterns=true)
 
 DRASRTreeLikelihoodData (const DRASRTreeLikelihoodData &data)
 
DRASRTreeLikelihoodDataoperator= (const DRASRTreeLikelihoodData &data)
 
virtual ~DRASRTreeLikelihoodData ()
 
DRASRTreeLikelihoodDataclone () const
 
void setTree (const TreeTemplate< Node > *tree)
 Set the tree associated to the data. More...
 
DRASRTreeLikelihoodNodeDatagetNodeData (int nodeId)
 
const DRASRTreeLikelihoodNodeDatagetNodeData (int nodeId) const
 
size_t getArrayPosition (int parentId, int sonId, size_t currentPosition) const
 
size_t getRootArrayPosition (size_t currentPosition) const
 
const std::vector< size_t > & getArrayPositions (int parentId, int sonId) const
 
std::vector< size_t > & getArrayPositions (int parentId, int sonId)
 
size_t getArrayPosition (int parentId, int sonId, size_t currentPosition)
 
VVVdouble & getLikelihoodArray (int nodeId)
 
VVVdouble & getDLikelihoodArray (int nodeId)
 
VVVdouble & getD2LikelihoodArray (int nodeId)
 
size_t getNumberOfDistinctSites () const
 
size_t getNumberOfSites () const
 
size_t getNumberOfStates () const
 
size_t getNumberOfClasses () const
 
void initLikelihoods (const SiteContainer &sites, const SubstitutionModel &model) throw (Exception)
 
std::vector< size_t > & getRootArrayPositions ()
 
const std::vector< size_t > & getRootArrayPositions () const
 
unsigned int getWeight (size_t pos) const
 
const std::vector< unsigned int > & getWeights () const
 
const Alphabet * getAlphabet () const
 
const TreeTemplate< Node > * getTree () const
 

Protected Member Functions

virtual void initLikelihoods (const Node *node, const SiteContainer &sequences, const SubstitutionModel &model) throw (Exception)
 This method initializes the leaves according to a sequence file. likelihood is set to 1 for the state corresponding to the sequence site, otherwise it is set to 0. More...
 
virtual SitePatternsinitLikelihoodsWithPatterns (const Node *node, const SiteContainer &sequences, const SubstitutionModel &model) throw (Exception)
 This method initializes the leaves according to a sequence file. More...
 

Protected Attributes

std::vector< size_t > rootPatternLinks_
 Links between sites and patterns. More...
 
std::vector< unsigned int > rootWeights_
 The frequency of each site. More...
 
const TreeTemplate< Node > * tree_
 
const Alphabet * alphabet_
 

Private Attributes

std::map< int, DRASRTreeLikelihoodNodeDatanodeData_
 This contains all likelihood values used for computation. More...
 
std::map< int, std::map< int, std::vector< size_t > > > patternLinks_
 This map defines the pattern network. More...
 
SiteContainer * shrunkData_
 
size_t nbSites_
 
size_t nbStates_
 
size_t nbClasses_
 
size_t nbDistinctSites_
 
bool usePatterns_
 

Detailed Description

discrete Rate Across Sites, (simple) Recursive likelihood data structure.

Definition at line 128 of file DRASRTreeLikelihoodData.h.

Constructor & Destructor Documentation

◆ DRASRTreeLikelihoodData() [1/2]

bpp::DRASRTreeLikelihoodData::DRASRTreeLikelihoodData ( const TreeTemplate< Node > *  tree,
size_t  nbClasses,
bool  usePatterns = true 
)
inline

Definition at line 159 of file DRASRTreeLikelihoodData.h.

Referenced by clone().

◆ DRASRTreeLikelihoodData() [2/2]

bpp::DRASRTreeLikelihoodData::DRASRTreeLikelihoodData ( const DRASRTreeLikelihoodData data)
inline

Definition at line 165 of file DRASRTreeLikelihoodData.h.

References shrunkData_.

◆ ~DRASRTreeLikelihoodData()

virtual bpp::DRASRTreeLikelihoodData::~DRASRTreeLikelihoodData ( )
inlinevirtual

Definition at line 196 of file DRASRTreeLikelihoodData.h.

References shrunkData_.

Member Function Documentation

◆ clone()

◆ getAlphabet()

const Alphabet* bpp::AbstractTreeLikelihoodData::getAlphabet ( ) const
inlinevirtualinherited

◆ getArrayPosition() [1/2]

size_t bpp::DRASRTreeLikelihoodData::getArrayPosition ( int  parentId,
int  sonId,
size_t  currentPosition 
) const
inlinevirtual

Implements bpp::TreeLikelihoodData.

Definition at line 228 of file DRASRTreeLikelihoodData.h.

References patternLinks_.

◆ getArrayPosition() [2/2]

size_t bpp::DRASRTreeLikelihoodData::getArrayPosition ( int  parentId,
int  sonId,
size_t  currentPosition 
)
inline

Definition at line 244 of file DRASRTreeLikelihoodData.h.

References patternLinks_.

◆ getArrayPositions() [1/2]

◆ getArrayPositions() [2/2]

std::vector<size_t>& bpp::DRASRTreeLikelihoodData::getArrayPositions ( int  parentId,
int  sonId 
)
inline

Definition at line 240 of file DRASRTreeLikelihoodData.h.

References patternLinks_.

◆ getD2LikelihoodArray()

◆ getDLikelihoodArray()

◆ getLikelihoodArray()

VVVdouble& bpp::DRASRTreeLikelihoodData::getLikelihoodArray ( int  nodeId)
inline

Definition at line 249 of file DRASRTreeLikelihoodData.h.

References nodeData_.

Referenced by bpp::RHomogeneousTreeLikelihood::computeDownSubtreeD2Likelihood(), bpp::RNonHomogeneousTreeLikelihood::computeDownSubtreeD2Likelihood(), bpp::RHomogeneousTreeLikelihood::computeDownSubtreeDLikelihood(), bpp::RNonHomogeneousTreeLikelihood::computeDownSubtreeDLikelihood(), bpp::RHomogeneousTreeLikelihood::computeSubtreeLikelihood(), bpp::RNonHomogeneousTreeLikelihood::computeSubtreeLikelihood(), bpp::RNonHomogeneousMixedTreeLikelihood::computeSubtreeLikelihood(), bpp::RNonHomogeneousTreeLikelihood::computeTreeD2Likelihood(), bpp::RHomogeneousTreeLikelihood::computeTreeD2Likelihood(), bpp::RNonHomogeneousTreeLikelihood::computeTreeDLikelihood(), bpp::RHomogeneousTreeLikelihood::computeTreeDLikelihood(), bpp::RHomogeneousTreeLikelihood::displayLikelihood(), bpp::RNonHomogeneousTreeLikelihood::displayLikelihood(), bpp::RHomogeneousTreeLikelihood::getLikelihoodForASiteForARateClass(), bpp::RNonHomogeneousTreeLikelihood::getLikelihoodForASiteForARateClass(), bpp::RHomogeneousTreeLikelihood::getLikelihoodForASiteForARateClassForAState(), bpp::RNonHomogeneousTreeLikelihood::getLikelihoodForASiteForARateClassForAState(), bpp::RHomogeneousTreeLikelihood::getLogLikelihoodForASiteForARateClass(), bpp::RNonHomogeneousTreeLikelihood::getLogLikelihoodForASiteForARateClass(), bpp::RHomogeneousTreeLikelihood::getLogLikelihoodForASiteForARateClassForAState(), and bpp::RNonHomogeneousTreeLikelihood::getLogLikelihoodForASiteForARateClassForAState().

◆ getNodeData() [1/2]

DRASRTreeLikelihoodNodeData& bpp::DRASRTreeLikelihoodData::getNodeData ( int  nodeId)
inlinevirtual

Implements bpp::TreeLikelihoodData.

Definition at line 220 of file DRASRTreeLikelihoodData.h.

References nodeData_.

◆ getNodeData() [2/2]

const DRASRTreeLikelihoodNodeData& bpp::DRASRTreeLikelihoodData::getNodeData ( int  nodeId) const
inlinevirtual

Implements bpp::TreeLikelihoodData.

Definition at line 224 of file DRASRTreeLikelihoodData.h.

References nodeData_.

◆ getNumberOfClasses()

size_t bpp::DRASRTreeLikelihoodData::getNumberOfClasses ( ) const
inline

Definition at line 267 of file DRASRTreeLikelihoodData.h.

References nbClasses_.

◆ getNumberOfDistinctSites()

size_t bpp::DRASRTreeLikelihoodData::getNumberOfDistinctSites ( ) const
inlinevirtual
Returns
The number of non redundant patterns.

Implements bpp::TreeLikelihoodData.

Definition at line 264 of file DRASRTreeLikelihoodData.h.

References nbDistinctSites_.

◆ getNumberOfSites()

size_t bpp::DRASRTreeLikelihoodData::getNumberOfSites ( ) const
inlinevirtual
Returns
The total number of sites.

Implements bpp::TreeLikelihoodData.

Definition at line 265 of file DRASRTreeLikelihoodData.h.

References nbSites_.

◆ getNumberOfStates()

size_t bpp::DRASRTreeLikelihoodData::getNumberOfStates ( ) const
inlinevirtual
Returns
Get the number of states used in the model.

Implements bpp::TreeLikelihoodData.

Definition at line 266 of file DRASRTreeLikelihoodData.h.

References nbStates_.

◆ getRootArrayPosition()

◆ getRootArrayPositions() [1/2]

std::vector<size_t>& bpp::AbstractTreeLikelihoodData::getRootArrayPositions ( )
inlineinherited

◆ getRootArrayPositions() [2/2]

const std::vector<size_t>& bpp::AbstractTreeLikelihoodData::getRootArrayPositions ( ) const
inlineinherited

◆ getTree()

const TreeTemplate<Node>* bpp::AbstractTreeLikelihoodData::getTree ( ) const
inlinevirtualinherited

◆ getWeight()

unsigned int bpp::AbstractTreeLikelihoodData::getWeight ( size_t  pos) const
inlinevirtualinherited
Returns
The frequency of a given pattern.

Implements bpp::TreeLikelihoodData.

Definition at line 127 of file AbstractTreeLikelihoodData.h.

References bpp::AbstractTreeLikelihoodData::rootWeights_.

Referenced by bpp::DRTreeLikelihoodTools::getPosteriorStateFrequencies().

◆ getWeights()

◆ initLikelihoods() [1/2]

void DRASRTreeLikelihoodData::initLikelihoods ( const SiteContainer &  sites,
const SubstitutionModel model 
)
throw (Exception
)

◆ initLikelihoods() [2/2]

void DRASRTreeLikelihoodData::initLikelihoods ( const Node node,
const SiteContainer &  sequences,
const SubstitutionModel model 
)
throw (Exception
)
protectedvirtual

This method initializes the leaves according to a sequence file. likelihood is set to 1 for the state corresponding to the sequence site, otherwise it is set to 0.

All likelihood arrays at each nodes are initialized according to alphabet size and sequences length, and filled with 1.

NB: This method is recursive.

Parameters
nodeThe node defining the subtree to analyse.
sequencesThe data to be used for initialization.
modelThe model to use.

Definition at line 94 of file DRASRTreeLikelihoodData.cpp.

References bpp::DRASRTreeLikelihoodNodeData::getD2LikelihoodArray(), bpp::DRASRTreeLikelihoodNodeData::getDLikelihoodArray(), bpp::Node::getId(), bpp::DRASRTreeLikelihoodNodeData::getLikelihoodArray(), and bpp::DRASRTreeLikelihoodNodeData::setNode().

◆ initLikelihoodsWithPatterns()

SitePatterns * DRASRTreeLikelihoodData::initLikelihoodsWithPatterns ( const Node node,
const SiteContainer &  sequences,
const SubstitutionModel model 
)
throw (Exception
)
protectedvirtual

This method initializes the leaves according to a sequence file.

likelihood is set to 1 for the state corresponding to the sequence site, otherwise it is set to 0.

All likelihood arrays at each nodes are initialized according to alphabet size and sequences length, and filled with 1.

NB: This method is recursive.

Parameters
nodeThe node defining the subtree to analyse.
sequencesThe data to be used for initialization.
modelThe model to use.
Returns
The shrunk sub-dataset + indices for the subtree defined by node.

Definition at line 191 of file DRASRTreeLikelihoodData.cpp.

References bpp::DRASRTreeLikelihoodNodeData::getD2LikelihoodArray(), bpp::DRASRTreeLikelihoodNodeData::getDLikelihoodArray(), bpp::Node::getId(), bpp::SitePatterns::getIndices(), bpp::DRASRTreeLikelihoodNodeData::getLikelihoodArray(), bpp::PatternTools::getSequenceSubset(), bpp::SitePatterns::getSites(), and bpp::DRASRTreeLikelihoodNodeData::setNode().

◆ operator=()

◆ setTree()

void bpp::DRASRTreeLikelihoodData::setTree ( const TreeTemplate< Node > *  tree)
inline

Set the tree associated to the data.

All node data will be actualized accordingly by calling the setNode() method on the corresponding nodes.

Warning
: the old tree and the new tree must be two clones! And particularly, they have to share the same topology and nodes id.
Parameters
treeThe tree to be associated to this data.

Definition at line 210 of file DRASRTreeLikelihoodData.h.

References bpp::TreeTemplate< N >::getNode(), nodeData_, and bpp::AbstractTreeLikelihoodData::tree_.

Referenced by bpp::RHomogeneousTreeLikelihood::operator=(), bpp::RNonHomogeneousTreeLikelihood::operator=(), bpp::RHomogeneousTreeLikelihood::RHomogeneousTreeLikelihood(), and bpp::RNonHomogeneousTreeLikelihood::RNonHomogeneousTreeLikelihood().

Member Data Documentation

◆ alphabet_

const Alphabet* bpp::AbstractTreeLikelihoodData::alphabet_
protectedinherited

◆ nbClasses_

size_t bpp::DRASRTreeLikelihoodData::nbClasses_
private

Definition at line 154 of file DRASRTreeLikelihoodData.h.

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

◆ nbDistinctSites_

size_t bpp::DRASRTreeLikelihoodData::nbDistinctSites_
private

Definition at line 155 of file DRASRTreeLikelihoodData.h.

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

◆ nbSites_

size_t bpp::DRASRTreeLikelihoodData::nbSites_
private

Definition at line 152 of file DRASRTreeLikelihoodData.h.

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

◆ nbStates_

size_t bpp::DRASRTreeLikelihoodData::nbStates_
private

Definition at line 153 of file DRASRTreeLikelihoodData.h.

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

◆ nodeData_

std::map<int, DRASRTreeLikelihoodNodeData> bpp::DRASRTreeLikelihoodData::nodeData_
mutableprivate

This contains all likelihood values used for computation.

Definition at line 136 of file DRASRTreeLikelihoodData.h.

Referenced by getD2LikelihoodArray(), getDLikelihoodArray(), getLikelihoodArray(), getNodeData(), operator=(), and setTree().

◆ patternLinks_

std::map<int, std::map<int, std::vector<size_t> > > bpp::DRASRTreeLikelihoodData::patternLinks_
mutableprivate

This map defines the pattern network.

Let n1 be the id of a node in the tree, and n11 and n12 the ids of its sons. Providing the likelihood array is known for nodes n11 and n12, the likelihood array for node n1 and site i (likelihood[n1][i]) must be computed
using arrays patternLinks
[n1][n11][i] and patternLinks_[n1][n12][i]. This network is intialized once for all in the constructor of this class.

The double map contains the position of the site to use (second dimension) of the likelihoods array.

Definition at line 150 of file DRASRTreeLikelihoodData.h.

Referenced by getArrayPosition(), getArrayPositions(), and operator=().

◆ rootPatternLinks_

std::vector<size_t> bpp::AbstractTreeLikelihoodData::rootPatternLinks_
protectedinherited

Links between sites and patterns.

The size of this vector is equal to the number of sites in the container, each element corresponds to a site in the container and points to the corresponding column in the likelihood array of the root node. If the container contains no repeated site, there will be a strict equivalence between each site and the likelihood array of the root node. However, if this is not the case, some pointers may point toward the same element in the likelihood array.

Definition at line 86 of file AbstractTreeLikelihoodData.h.

Referenced by bpp::AbstractTreeLikelihoodData::getRootArrayPosition(), getRootArrayPosition(), bpp::AbstractTreeLikelihoodData::getRootArrayPositions(), and bpp::AbstractTreeLikelihoodData::operator=().

◆ rootWeights_

std::vector<unsigned int> bpp::AbstractTreeLikelihoodData::rootWeights_
protectedinherited

◆ shrunkData_

SiteContainer* bpp::DRASRTreeLikelihoodData::shrunkData_
private

◆ tree_

◆ usePatterns_

bool bpp::DRASRTreeLikelihoodData::usePatterns_
private

Definition at line 156 of file DRASRTreeLikelihoodData.h.

Referenced by operator=().


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