bpp-phyl
2.2.0
|
Double recursive implementation of interface TreeParsimonyScore. More...
#include <Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h>
Public Member Functions | |
DRTreeParsimonyScore (const Tree &tree, const SiteContainer &data, bool verbose=true, bool includeGaps=false) throw (Exception) | |
DRTreeParsimonyScore (const Tree &tree, const SiteContainer &data, const StateMap *statesMap, bool verbose=true) throw (Exception) | |
DRTreeParsimonyScore (const DRTreeParsimonyScore &tp) | |
DRTreeParsimonyScore & | operator= (const DRTreeParsimonyScore &tp) |
virtual | ~DRTreeParsimonyScore () |
DRTreeParsimonyScore * | clone () const |
unsigned int | getScore () const |
Get the score for the current tree, i.e. the total minimum number of changes in the tree. More... | |
unsigned int | getScoreForSite (size_t site) const |
Get the score for a given site for the current tree, i.e. the total minimum number of changes in the tree for this site. More... | |
virtual const Tree & | getTree () const |
Get the tree for wich scores are computed. More... | |
virtual std::vector< unsigned int > | getScoreForEachSite () const |
Get the score for each site for the current tree, i.e. the total minimum number of changes in the tree for each site. More... | |
virtual const StateMap & | getStateMap () const |
virtual void | topologyChangePerformed (const TopologyChangeEvent &event) |
Notify a topology change event. More... | |
Thee NNISearchable interface. | |
double | getTopologyValue () const throw (Exception) |
Get the current score of this NNISearchable object. More... | |
double | testNNI (int nodeId) const throw (NodeException) |
Send the score of a NNI movement, without performing it. More... | |
void | doNNI (int nodeId) throw (NodeException) |
Perform a NNI movement. More... | |
const Tree & | getTopology () const |
Get the tree associated to this NNISearchable object. More... | |
void | topologyChangeTested (const TopologyChangeEvent &event) |
Notify a topology change event. More... | |
void | topologyChangeSuccessful (const TopologyChangeEvent &event) |
Tell that a topology change is definitive. More... | |
Static Public Member Functions | |
static void | computeScoresPostorderForNode (const DRTreeParsimonyNodeData &pData, std::vector< Bitset > &rBitsets, std::vector< unsigned int > &rScores) |
Compute bitsets and scores for each site for a node, in postorder. More... | |
static void | computeScoresPreorderForNode (const DRTreeParsimonyNodeData &pData, const Node *source, std::vector< Bitset > &rBitsets, std::vector< unsigned int > &rScores) |
Compute bitsets and scores for each site for a node, in preorder. More... | |
static void | computeScoresForNode (const DRTreeParsimonyNodeData &pData, std::vector< Bitset > &rBitsets, std::vector< unsigned int > &rScores) |
Compute bitsets and scores for each site for a node, in all directions. More... | |
static void | computeScoresFromArrays (const std::vector< const std::vector< Bitset > *> &iBitsets, const std::vector< const std::vector< unsigned int > *> &iScores, std::vector< Bitset > &oBitsets, std::vector< unsigned int > &oScores) |
Compute bitsets and scores from an array of arrays. More... | |
Protected Member Functions | |
virtual void | computeScores () |
Compute all scores. More... | |
virtual void | computeScoresPreorder (const Node *) |
Compute scores (preorder algorithm). More... | |
virtual void | computeScoresPostorder (const Node *) |
Compute scores (postorder algorithm). More... | |
const TreeTemplate< Node > * | getTreeP_ () const |
TreeTemplate< Node > * | getTreeP_ () |
Private Member Functions | |
void | init_ (const SiteContainer &data, bool verbose) |
Private Attributes | |
DRTreeParsimonyData * | parsimonyData_ |
size_t | nbDistinctSites_ |
Double recursive implementation of interface TreeParsimonyScore.
Uses a DRTreeParsimonyData object for data storage.
Definition at line 55 of file DRTreeParsimonyScore.h.
DRTreeParsimonyScore::DRTreeParsimonyScore | ( | const Tree & | tree, |
const SiteContainer & | data, | ||
bool | verbose = true , |
||
bool | includeGaps = false |
||
) | |||
throw | ( | Exception | |
) |
Definition at line 52 of file DRTreeParsimonyScore.cpp.
Referenced by clone().
DRTreeParsimonyScore::DRTreeParsimonyScore | ( | const Tree & | tree, |
const SiteContainer & | data, | ||
const StateMap * | statesMap, | ||
bool | verbose = true |
||
) | |||
throw | ( | Exception | |
) |
Definition at line 65 of file DRTreeParsimonyScore.cpp.
DRTreeParsimonyScore::DRTreeParsimonyScore | ( | const DRTreeParsimonyScore & | tp | ) |
Definition at line 94 of file DRTreeParsimonyScore.cpp.
References bpp::AbstractTreeParsimonyScore::getTreeP_(), parsimonyData_, and bpp::DRTreeParsimonyData::setTree().
|
virtual |
Definition at line 115 of file DRTreeParsimonyScore.cpp.
References parsimonyData_.
|
inlinevirtual |
Implements bpp::NNISearchable.
Definition at line 89 of file DRTreeParsimonyScore.h.
References DRTreeParsimonyScore().
|
protectedvirtual |
Compute all scores.
Call the computeScoresPreorder and computeScoresPostorder methods, and then initialize rootBitsets_ and rootScores_.
Definition at line 121 of file DRTreeParsimonyScore.cpp.
References computeScoresForNode(), computeScoresPostorder(), computeScoresPreorder(), bpp::DRTreeParsimonyData::getNodeData(), bpp::DRTreeParsimonyData::getRootBitsets(), bpp::DRTreeParsimonyData::getRootScores(), bpp::AbstractTreeParsimonyScore::getTree(), bpp::AbstractTreeParsimonyScore::getTreeP_(), and parsimonyData_.
Referenced by topologyChangeTested().
|
static |
Compute bitsets and scores for each site for a node, in all directions.
pData | The node data to use. |
rBitsets | The bitset array where to store the resulting bitsets. |
rScores | The score array where to write the resulting scores. |
Definition at line 239 of file DRTreeParsimonyScore.cpp.
References computeScoresFromArrays(), bpp::Node::degree(), bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getId(), bpp::Node::getNeighbors(), bpp::DRTreeParsimonyNodeData::getNode(), and bpp::DRTreeParsimonyNodeData::getScoresArrayForNeighbor().
Referenced by computeScores().
|
static |
Compute bitsets and scores from an array of arrays.
This method is the more general score computation. Depending on what is passed as input, it may computes scroes fo a subtree or the whole tree.
iBitsets | The vector of bitset arrays to use. |
iScores | The vector of score arrays to use. |
oBitsets | The bitset array where to store the resulting bitsets. |
oScores | The score array where to write the resulting scores. |
Definition at line 275 of file DRTreeParsimonyScore.cpp.
Referenced by computeScoresForNode(), computeScoresPostorderForNode(), and computeScoresPreorderForNode().
|
protectedvirtual |
Compute scores (postorder algorithm).
Definition at line 131 of file DRTreeParsimonyScore.cpp.
References computeScoresPostorderForNode(), bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getId(), bpp::DRTreeParsimonyData::getLeafData(), bpp::DRTreeParsimonyData::getNodeData(), bpp::Node::getNumberOfSons(), bpp::DRTreeParsimonyNodeData::getScoresArrayForNeighbor(), bpp::Node::getSon(), bpp::Node::isLeaf(), and parsimonyData_.
Referenced by computeScores().
|
static |
Compute bitsets and scores for each site for a node, in postorder.
pData | The node data to use. |
rBitsets | The bitset array where to store the resulting bitsets. |
rScores | The score array where to write the resulting scores. |
Definition at line 161 of file DRTreeParsimonyScore.cpp.
References computeScoresFromArrays(), bpp::Node::degree(), bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getFather(), bpp::Node::getId(), bpp::Node::getNeighbors(), bpp::DRTreeParsimonyNodeData::getNode(), and bpp::DRTreeParsimonyNodeData::getScoresArrayForNeighbor().
Referenced by computeScoresPostorder().
|
protectedvirtual |
Compute scores (preorder algorithm).
Definition at line 183 of file DRTreeParsimonyScore.cpp.
References computeScoresPreorderForNode(), bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getFather(), bpp::Node::getId(), bpp::DRTreeParsimonyData::getLeafData(), bpp::DRTreeParsimonyData::getNodeData(), bpp::Node::getNumberOfSons(), bpp::DRTreeParsimonyNodeData::getScoresArrayForNeighbor(), bpp::Node::getSon(), bpp::Node::hasFather(), bpp::Node::isLeaf(), and parsimonyData_.
Referenced by computeScores().
|
static |
Compute bitsets and scores for each site for a node, in preorder.
pData | The node data to use. |
source | The node where we are coming from. |
rBitsets | The bitset array where to store the resulting bitsets. |
rScores | The score array where to write the resulting scores. |
Definition at line 218 of file DRTreeParsimonyScore.cpp.
References computeScoresFromArrays(), bpp::Node::degree(), bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getId(), bpp::Node::getNeighbors(), bpp::DRTreeParsimonyNodeData::getNode(), and bpp::DRTreeParsimonyNodeData::getScoresArrayForNeighbor().
Referenced by computeScoresPreorder().
|
virtual |
Perform a NNI movement.
nodeId | The id of the node defining the NNI movement. |
NodeException | If the node does not define a valid NNI. |
Implements bpp::NNISearchable.
Definition at line 385 of file DRTreeParsimonyScore.cpp.
References bpp::Node::addSon(), bpp::Node::getFather(), bpp::Node::getSon(), bpp::Node::getSonPosition(), bpp::Node::hasFather(), and bpp::Node::removeSon().
|
virtual |
Get the score for the current tree, i.e. the total minimum number of changes in the tree.
Implements bpp::TreeParsimonyScore.
Definition at line 258 of file DRTreeParsimonyScore.cpp.
References bpp::DRTreeParsimonyData::getRootScore(), bpp::AbstractTreeParsimonyData::getWeight(), nbDistinctSites_, and parsimonyData_.
Referenced by getTopologyValue().
|
virtualinherited |
Get the score for each site for the current tree, i.e. the total minimum number of changes in the tree for each site.
Implements bpp::TreeParsimonyScore.
Definition at line 99 of file AbstractTreeParsimonyScore.cpp.
|
virtual |
Get the score for a given site for the current tree, i.e. the total minimum number of changes in the tree for this site.
site | The corresponding site. |
Implements bpp::TreeParsimonyScore.
Definition at line 269 of file DRTreeParsimonyScore.cpp.
References bpp::AbstractTreeParsimonyData::getRootArrayPosition(), bpp::DRTreeParsimonyData::getRootScore(), and parsimonyData_.
|
inlinevirtualinherited |
Definition at line 113 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::statesMap_.
|
inlinevirtual |
Get the tree associated to this NNISearchable object.
Implements bpp::NNISearchable.
Definition at line 181 of file DRTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::getTree().
|
inlinevirtual |
Get the current score of this NNISearchable object.
Implements bpp::NNISearchable.
Definition at line 174 of file DRTreeParsimonyScore.h.
References getScore().
|
inlinevirtualinherited |
Get the tree for wich scores are computed.
Implements bpp::TreeParsimonyScore.
Definition at line 111 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::tree_.
Referenced by computeScores(), and getTopology().
|
inlineprotectedinherited |
Definition at line 116 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::tree_.
Referenced by computeScores(), DRTreeParsimonyScore(), and operator=().
|
inlineprotectedinherited |
Definition at line 117 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::tree_.
|
private |
Definition at line 78 of file DRTreeParsimonyScore.cpp.
DRTreeParsimonyScore & DRTreeParsimonyScore::operator= | ( | const DRTreeParsimonyScore & | tp | ) |
Definition at line 104 of file DRTreeParsimonyScore.cpp.
References bpp::DRTreeParsimonyData::clone(), bpp::AbstractTreeParsimonyScore::getTreeP_(), nbDistinctSites_, bpp::AbstractTreeParsimonyScore::operator=(), parsimonyData_, and bpp::DRTreeParsimonyData::setTree().
|
virtual |
Send the score of a NNI movement, without performing it.
This methods sends the score variation. This variation must be negative if the new point is better, i.e. the object is to be used with a minimizing optimization (for consistence with Optimizer objects).
nodeId | The id of the node defining the NNI movement. |
NodeException | If the node does not define a valid NNI. |
Implements bpp::NNISearchable.
Definition at line 313 of file DRTreeParsimonyScore.cpp.
References bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeTemplateTools::getRemainingNeighbors(), bpp::DRTreeParsimonyNodeData::getScoresArrayForNeighbor(), bpp::Node::getSon(), bpp::Node::getSonPosition(), and bpp::Node::hasFather().
|
inlinevirtualinherited |
Notify a topology change event.
This method is to be invoked after one or several NNI are performed. It allows appropriate recomputations.
In most case, this is the same as topologyChangeTested() + topologyChangeSuccessful().
event | The topology change event. |
Definition at line 105 of file TopologySearch.h.
References bpp::TopologyListener::topologyChangeSuccessful(), and bpp::TopologyListener::topologyChangeTested().
|
inlinevirtual |
Tell that a topology change is definitive.
This method is called after the topologyChangeTested() method.
event | The topology change event. |
Implements bpp::TopologyListener.
Definition at line 189 of file DRTreeParsimonyScore.h.
|
inlinevirtual |
Notify a topology change event.
event | The topology change event. |
Implements bpp::TopologyListener.
Definition at line 183 of file DRTreeParsimonyScore.h.
References computeScores(), parsimonyData_, and bpp::DRTreeParsimonyData::reInit().
|
private |
Definition at line 61 of file DRTreeParsimonyScore.h.
Referenced by getScore(), and operator=().
|
private |
Definition at line 60 of file DRTreeParsimonyScore.h.
Referenced by computeScores(), computeScoresPostorder(), computeScoresPreorder(), DRTreeParsimonyScore(), getScore(), getScoreForSite(), operator=(), topologyChangeTested(), and ~DRTreeParsimonyScore().