5 #include "../SitePatterns.h"
18 nodeData_(data.nodeData_),
19 leafData_(data.leafData_),
20 rootBitsets_(data.rootBitsets_),
21 rootScores_(data.rootScores_),
23 nbSites_(data.nbSites_),
24 nbStates_(data.nbStates_),
25 nbDistinctSites_(data.nbDistinctSites_)
53 shared_ptr<const SiteContainerInterface> sites,
54 shared_ptr<const StateMapInterface> stateMap)
56 nbStates_ = stateMap->getNumberOfModelStates();
57 nbSites_ = sites->getNumberOfSites();
65 throw Exception(
"DRTreeParsimonyData::init : Data must be plain alignments.");
75 auto sequences = make_shared<AlignedSequenceContainer>(*
shrunkData_);
76 init_(
tree().getRootNode(), sequences, stateMap);
87 shared_ptr<const SiteContainerInterface> sites,
88 shared_ptr<const StateMapInterface> stateMap)
90 auto alphabet = sites->getAlphabet();
96 seq = &sites->sequence(node->
getName());
110 Bitset* leafData_bitsets_i = &(*leafData_bitsets)[i];
111 for (
unsigned int s = 0; s <
nbStates_; s++)
116 vector<int> states = alphabet->getAlias(state);
117 for (
size_t j = 0; j < states.size(); j++)
119 if (stateMap->getAlphabetStateAsInt(s) == states[j])
120 (*leafData_bitsets_i)[s].flip();
133 for (
int n = (node->
hasFather() ? -1 : 0); n < nbSons; n++)
135 const Node* neighbor = (*node)[n];
146 for (
unsigned int l = 0; l < nbSonNodes; l++)
176 for (
int n = (node->
hasFather() ? -1 : 0); n < nbSons; n++)
178 const Node* neighbor = (*node)[n];
189 for (
unsigned int l = 0; l < nbSonNodes; l++)
const int & getValue(size_t pos) const override
Partial implementation of the TreeParsimonyData interface.
const TreeTemplate< Node > & tree() const override
std::vector< size_t > rootPatternLinks_
AbstractTreeParsimonyData & operator=(const AbstractTreeParsimonyData &atpd)
std::vector< unsigned int > rootWeights_
Parsimony data structure for double-recursive (DR) algorithm.
DRTreeParsimonyNodeData & nodeData(int nodeId) override
std::unique_ptr< SiteContainerInterface > shrunkData_
void reInit_(const Node *node)
std::vector< Bitset > rootBitsets_
void init(std::shared_ptr< const SiteContainerInterface > sites, std::shared_ptr< const StateMapInterface > stateMap)
void init_(const Node *node, std::shared_ptr< const SiteContainerInterface > sites, std::shared_ptr< const StateMapInterface > stateMap)
std::map< int, DRTreeParsimonyLeafData > leafData_
DRTreeParsimonyData & operator=(const DRTreeParsimonyData &data)
DRTreeParsimonyData(std::shared_ptr< const TreeTemplate< Node >> tree)
DRTreeParsimonyLeafData & leafData(int nodeId)
std::vector< unsigned int > rootScores_
std::map< int, DRTreeParsimonyNodeData > nodeData_
Parsimony data structure for a leaf.
std::vector< Bitset > & getBitsetsArray()
void setNode(const Node *node)
Set the node associated to this data.
Parsimony data structure for a node.
std::vector< Bitset > & getBitsetsArrayForNeighbor(int neighborId)
std::vector< unsigned int > & getScoresArrayForNeighbor(int neighborId)
void setNode(const Node *node)
Set the node associated to this data.
void eraseNeighborArrays()
The phylogenetic node class.
virtual std::string getName() const
Get the name associated to this node, if there is one, otherwise throw a NodeException.
virtual int getId() const
Get the node's id.
virtual const Node * getSon(size_t pos) const
virtual bool isLeaf() const
virtual bool hasFather() const
Tell if this node has a father node.
virtual size_t getNumberOfSons() const
Data structure for site patterns.
const std::vector< unsigned int > & getWeights() const
const IndicesType & getIndices() const
std::unique_ptr< AlignmentDataInterface > getSites() const
Defines the basic types of data flow nodes.