bpp-phyl  2.1.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:

List of all members.

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.
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)
VVVdoublegetLikelihoodArray (int nodeId)
VVVdoublegetDLikelihoodArray (int nodeId)
VVVdoublegetD2LikelihoodArray (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 AlphabetgetAlphabet () 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.
virtual SitePatternsinitLikelihoodsWithPatterns (const Node *node, const SiteContainer &sequences, const SubstitutionModel &model) throw (Exception)
 This method initializes the leaves according to a sequence file.

Protected Attributes

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

Private Attributes

std::map< int,
DRASRTreeLikelihoodNodeData
nodeData_
 This contains all likelihood values used for computation.
std::map< int, std::map< int,
std::vector< size_t > > > 
patternLinks_
 This map defines the pattern network.
SiteContainershrunkData_
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

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().

Definition at line 196 of file DRASRTreeLikelihoodData.h.

References shrunkData_.


Member Function Documentation

const Alphabet* bpp::AbstractTreeLikelihoodData::getAlphabet ( ) const [inline, virtual, inherited]
size_t bpp::DRASRTreeLikelihoodData::getArrayPosition ( int  parentId,
int  sonId,
size_t  currentPosition 
) const [inline, virtual]

Implements bpp::TreeLikelihoodData.

Definition at line 228 of file DRASRTreeLikelihoodData.h.

References patternLinks_.

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

Definition at line 244 of file DRASRTreeLikelihoodData.h.

References patternLinks_.

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

Definition at line 240 of file DRASRTreeLikelihoodData.h.

References patternLinks_.

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().

Implements bpp::TreeLikelihoodData.

Definition at line 220 of file DRASRTreeLikelihoodData.h.

References nodeData_.

const DRASRTreeLikelihoodNodeData& bpp::DRASRTreeLikelihoodData::getNodeData ( int  nodeId) const [inline, virtual]

Implements bpp::TreeLikelihoodData.

Definition at line 224 of file DRASRTreeLikelihoodData.h.

References nodeData_.

Definition at line 267 of file DRASRTreeLikelihoodData.h.

References nbClasses_.

size_t bpp::DRASRTreeLikelihoodData::getNumberOfDistinctSites ( ) const [inline, virtual]
Returns:
The number of non redundant patterns.

Implements bpp::TreeLikelihoodData.

Definition at line 264 of file DRASRTreeLikelihoodData.h.

References nbDistinctSites_.

size_t bpp::DRASRTreeLikelihoodData::getNumberOfSites ( ) const [inline, virtual]
Returns:
The total number of sites.

Implements bpp::TreeLikelihoodData.

Definition at line 265 of file DRASRTreeLikelihoodData.h.

References nbSites_.

size_t bpp::DRASRTreeLikelihoodData::getNumberOfStates ( ) const [inline, virtual]
Returns:
Get the number of states used in the model.

Implements bpp::TreeLikelihoodData.

Definition at line 266 of file DRASRTreeLikelihoodData.h.

References nbStates_.

std::vector<size_t>& bpp::AbstractTreeLikelihoodData::getRootArrayPositions ( ) [inline, inherited]
const std::vector<size_t>& bpp::AbstractTreeLikelihoodData::getRootArrayPositions ( ) const [inline, inherited]
const TreeTemplate<Node>* bpp::AbstractTreeLikelihoodData::getTree ( ) const [inline, virtual, inherited]
unsigned int bpp::AbstractTreeLikelihoodData::getWeight ( size_t  pos) const [inline, virtual, inherited]
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().

void DRASRTreeLikelihoodData::initLikelihoods ( const Node node,
const SiteContainer sequences,
const SubstitutionModel model 
) throw (Exception) [protected, virtual]

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(), bpp::Sequence::getValue(), and bpp::DRASRTreeLikelihoodNodeData::setNode().

SitePatterns * DRASRTreeLikelihoodData::initLikelihoodsWithPatterns ( const Node node,
const SiteContainer sequences,
const SubstitutionModel model 
) throw (Exception) [protected, virtual]

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::SiteContainer::getNumberOfSites(), bpp::SiteContainer::getSequence(), bpp::PatternTools::getSequenceSubset(), bpp::SitePatterns::getSites(), bpp::Sequence::getValue(), and bpp::DRASRTreeLikelihoodNodeData::setNode().

DRASRTreeLikelihoodData& bpp::DRASRTreeLikelihoodData::operator= ( const DRASRTreeLikelihoodData data) [inline]
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::Node::getId(), 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

Definition at line 154 of file DRASRTreeLikelihoodData.h.

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

Definition at line 152 of file DRASRTreeLikelihoodData.h.

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

Definition at line 153 of file DRASRTreeLikelihoodData.h.

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

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().

std::map<int, std::map<int, std::vector<size_t> > > bpp::DRASRTreeLikelihoodData::patternLinks_ [mutable, private]

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=().

std::vector<size_t> bpp::AbstractTreeLikelihoodData::rootPatternLinks_ [protected, inherited]

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=().

Definition at line 156 of file DRASRTreeLikelihoodData.h.

Referenced by operator=().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends