bpp-phyl3
3.0.0
|
Double recursive implementation of interface TreeParsimonyScore. More...
#include <Bpp/Phyl/Parsimony/DRTreeParsimonyScore.h>
Public Member Functions | |
DRTreeParsimonyScore (std::shared_ptr< TreeTemplate< Node >> tree, std::shared_ptr< const SiteContainerInterface > data, bool verbose=true, bool includeGaps=false) | |
DRTreeParsimonyScore (std::shared_ptr< TreeTemplate< Node >> tree, std::shared_ptr< const SiteContainerInterface > data, std::shared_ptr< const StateMapInterface > statesMap, bool verbose=true) | |
DRTreeParsimonyScore (const DRTreeParsimonyScore &tp) | |
DRTreeParsimonyScore & | operator= (const DRTreeParsimonyScore &tp) |
virtual | ~DRTreeParsimonyScore () |
DRTreeParsimonyScore * | clone () const override |
unsigned int | getScore () const override |
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 override |
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... | |
const Tree & | tree () const override |
Get the tree for which scores are computed. More... | |
virtual const TreeTemplate< Node > & | treeTemplate () const |
virtual std::shared_ptr< const TreeTemplate< Node > > | getTreeTemplate () const |
std::vector< unsigned int > | getScorePerSite () const override |
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... | |
const StateMapInterface & | stateMap () const override |
Get the state map associated to this instance. More... | |
std::shared_ptr< const StateMapInterface > | getStateMap () const override |
Get the state map associated to this instance. More... | |
virtual void | topologyChangePerformed (const TopologyChangeEvent &event) |
Notify a topology change event. More... | |
Thee NNISearchable interface. | |
double | getTopologyValue () const override |
Get the current score of this NNISearchable object. More... | |
double | testNNI (int nodeId) const override |
Send the score of a NNI movement, without performing it. More... | |
void | doNNI (int nodeId) override |
Perform a NNI movement. More... | |
const Tree & | topology () const override |
Get the tree associated to this NNISearchable object. More... | |
void | topologyChangeTested (const TopologyChangeEvent &event) override |
Notify a topology change event. More... | |
void | topologyChangeSuccessful (const TopologyChangeEvent &event) override |
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... | |
virtual Tree & | tree_ () |
virtual TreeTemplate< Node > & | treeTemplate_ () |
virtual std::shared_ptr< TreeTemplate< Node > > | getTreeTemplate_ () |
Private Member Functions | |
void | init_ (std::shared_ptr< const SiteContainerInterface > data, bool verbose) |
Private Attributes | |
std::unique_ptr< DRTreeParsimonyData > | parsimonyData_ |
size_t | nbDistinctSites_ |
std::shared_ptr< TreeTemplate< Node > > | treePtr_ |
std::shared_ptr< const SiteContainerInterface > | data_ |
std::shared_ptr< const Alphabet > | alphabet_ |
std::shared_ptr< const StateMapInterface > | statesMap_ |
size_t | nbStates_ |
Double recursive implementation of interface TreeParsimonyScore.
Uses a DRTreeParsimonyData object for data storage.
Definition at line 21 of file DRTreeParsimonyScore.h.
DRTreeParsimonyScore::DRTreeParsimonyScore | ( | std::shared_ptr< TreeTemplate< Node >> | tree, |
std::shared_ptr< const SiteContainerInterface > | data, | ||
bool | verbose = true , |
||
bool | includeGaps = false |
||
) |
DRTreeParsimonyScore::DRTreeParsimonyScore | ( | std::shared_ptr< TreeTemplate< Node >> | tree, |
std::shared_ptr< const SiteContainerInterface > | data, | ||
std::shared_ptr< const StateMapInterface > | statesMap, | ||
bool | verbose = true |
||
) |
Definition at line 29 of file DRTreeParsimonyScore.cpp.
References init_().
DRTreeParsimonyScore::DRTreeParsimonyScore | ( | const DRTreeParsimonyScore & | tp | ) |
Definition at line 57 of file DRTreeParsimonyScore.cpp.
References bpp::AbstractTreeParsimonyScore::getTreeTemplate(), and parsimonyData_.
|
virtual |
Definition at line 78 of file DRTreeParsimonyScore.cpp.
|
inlineoverridevirtual |
Implements bpp::NNISearchable.
Definition at line 48 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 82 of file DRTreeParsimonyScore.cpp.
References computeScoresForNode(), computeScoresPostorder(), computeScoresPreorder(), parsimonyData_, and bpp::AbstractTreeParsimonyScore::treeTemplate().
Referenced by init_(), and 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 202 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 scores of 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 238 of file DRTreeParsimonyScore.cpp.
Referenced by computeScoresForNode(), computeScoresPostorderForNode(), computeScoresPreorderForNode(), and testNNI().
|
protectedvirtual |
Compute scores (postorder algorithm).
Definition at line 92 of file DRTreeParsimonyScore.cpp.
References computeScoresPostorderForNode(), bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getId(), 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 123 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 145 of file DRTreeParsimonyScore.cpp.
References computeScoresPreorderForNode(), bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getFather(), bpp::Node::getId(), 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 181 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().
|
overridevirtual |
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 351 of file DRTreeParsimonyScore.cpp.
References bpp::Node::addSon(), bpp::Node::getFather(), bpp::Node::getSon(), bpp::Node::getSonPosition(), bpp::Node::hasFather(), bpp::Node::removeSon(), and bpp::AbstractTreeParsimonyScore::treeTemplate_().
|
overridevirtual |
Get the score for the current tree, i.e. the total minimum number of changes in the tree.
Implements bpp::TreeParsimonyScoreInterface.
Definition at line 221 of file DRTreeParsimonyScore.cpp.
References nbDistinctSites_, and parsimonyData_.
Referenced by getTopologyValue(), and testNNI().
|
overridevirtual |
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::TreeParsimonyScoreInterface.
Definition at line 232 of file DRTreeParsimonyScore.cpp.
References parsimonyData_.
|
overridevirtualinherited |
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::TreeParsimonyScoreInterface.
Definition at line 69 of file AbstractTreeParsimonyScore.cpp.
References bpp::AbstractTreeParsimonyScore::data_, and bpp::TreeParsimonyScoreInterface::getScoreForSite().
|
inlineoverridevirtualinherited |
Get the state map associated to this instance.
Implements bpp::TreeParsimonyScoreInterface.
Definition at line 54 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::statesMap_.
Referenced by init_().
|
inlineoverridevirtual |
Get the current score of this NNISearchable object.
Implements bpp::NNISearchable.
Definition at line 133 of file DRTreeParsimonyScore.h.
References getScore().
|
inlinevirtualinherited |
Definition at line 51 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::treePtr_.
Referenced by DRTreeParsimonyScore(), and operator=().
|
inlineprotectedvirtualinherited |
Definition at line 59 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::treePtr_.
|
private |
Definition at line 41 of file DRTreeParsimonyScore.cpp.
References computeScores(), bpp::ApplicationTools::displayResult(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::AbstractTreeParsimonyScore::getStateMap(), nbDistinctSites_, parsimonyData_, and bpp::TextTools::toString().
Referenced by DRTreeParsimonyScore().
DRTreeParsimonyScore & DRTreeParsimonyScore::operator= | ( | const DRTreeParsimonyScore & | tp | ) |
Definition at line 67 of file DRTreeParsimonyScore.cpp.
References bpp::AbstractTreeParsimonyScore::getTreeTemplate(), nbDistinctSites_, and parsimonyData_.
|
inlineoverridevirtualinherited |
Get the state map associated to this instance.
Implements bpp::TreeParsimonyScoreInterface.
Definition at line 53 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::statesMap_.
|
overridevirtual |
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 276 of file DRTreeParsimonyScore.cpp.
References computeScoresFromArrays(), bpp::DRTreeParsimonyNodeData::getBitsetsArrayForNeighbor(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeTemplateTools::getRemainingNeighbors(), getScore(), bpp::DRTreeParsimonyNodeData::getScoresArrayForNeighbor(), bpp::Node::getSon(), bpp::Node::getSonPosition(), bpp::Node::hasFather(), nbDistinctSites_, parsimonyData_, and bpp::AbstractTreeParsimonyScore::treeTemplate().
|
inlineoverridevirtual |
Get the tree associated to this NNISearchable object.
Implements bpp::NNISearchable.
Definition at line 139 of file DRTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::tree().
|
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 67 of file TopologySearch.h.
References bpp::TopologyListener::topologyChangeSuccessful(), and bpp::TopologyListener::topologyChangeTested().
|
inlineoverridevirtual |
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 147 of file DRTreeParsimonyScore.h.
|
inlineoverridevirtual |
Notify a topology change event.
event | The topology change event. |
Implements bpp::TopologyListener.
Definition at line 141 of file DRTreeParsimonyScore.h.
References computeScores(), and parsimonyData_.
|
inlineoverridevirtualinherited |
Get the tree for which scores are computed.
Implements bpp::TreeParsimonyScoreInterface.
Definition at line 49 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::treePtr_.
Referenced by topology().
|
inlineprotectedvirtualinherited |
Definition at line 57 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::treePtr_.
|
inlinevirtualinherited |
Definition at line 50 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::treePtr_.
Referenced by computeScores(), and testNNI().
|
inlineprotectedvirtualinherited |
Definition at line 58 of file AbstractTreeParsimonyScore.h.
References bpp::AbstractTreeParsimonyScore::treePtr_.
Referenced by doNNI().
|
privateinherited |
Definition at line 26 of file AbstractTreeParsimonyScore.h.
Referenced by bpp::AbstractTreeParsimonyScore::AbstractTreeParsimonyScore().
|
privateinherited |
Definition at line 25 of file AbstractTreeParsimonyScore.h.
Referenced by bpp::AbstractTreeParsimonyScore::getScorePerSite(), and bpp::AbstractTreeParsimonyScore::init_().
|
private |
Definition at line 27 of file DRTreeParsimonyScore.h.
Referenced by getScore(), init_(), operator=(), and testNNI().
|
privateinherited |
Definition at line 28 of file AbstractTreeParsimonyScore.h.
Referenced by bpp::AbstractTreeParsimonyScore::AbstractTreeParsimonyScore().
|
private |
Definition at line 26 of file DRTreeParsimonyScore.h.
Referenced by computeScores(), computeScoresPostorder(), computeScoresPreorder(), DRTreeParsimonyScore(), getScore(), getScoreForSite(), init_(), operator=(), testNNI(), and topologyChangeTested().
|
privateinherited |
Definition at line 27 of file AbstractTreeParsimonyScore.h.
Referenced by bpp::AbstractTreeParsimonyScore::AbstractTreeParsimonyScore(), bpp::AbstractTreeParsimonyScore::getStateMap(), and bpp::AbstractTreeParsimonyScore::stateMap().
|
privateinherited |
Definition at line 24 of file AbstractTreeParsimonyScore.h.
Referenced by bpp::AbstractTreeParsimonyScore::getTreeTemplate(), bpp::AbstractTreeParsimonyScore::getTreeTemplate_(), bpp::AbstractTreeParsimonyScore::init_(), bpp::AbstractTreeParsimonyScore::tree(), bpp::AbstractTreeParsimonyScore::tree_(), bpp::AbstractTreeParsimonyScore::treeTemplate(), and bpp::AbstractTreeParsimonyScore::treeTemplate_().