5#include "../../PatternTools.h"
16void DRASDRTreeLikelihoodData::initLikelihoods(
21 throw Exception(
"Error, only 1 sequence!");
26 throw AlphabetMismatchException(
"DRASDRTreeLikelihoodData::initLikelihoods. Data and model must have the same alphabet type.",
56 Vdouble* rootLikelihoods_i_c_ = &(*rootLikelihoods_i_)[c];
60 (*rootLikelihoods_i_c_)[x] = 1.;
91 Vdouble* leavesLikelihoods_leaf_i = &(*leavesLikelihoods_leaf)[i];
92 leavesLikelihoods_leaf_i->resize(
nbStates_);
100 test += ( *leavesLikelihoods_leaf_i)[s];
103 std::cerr <<
"WARNING!!! Likelihood will be 0 for site " << i << std::endl;
109 for (
size_t l = 0; l < nbSonNodes; l++)
122 for (
int n = (node->
hasFather() ? -1 : 0); n < nbSons; n++)
124 const Node* neighbor = (*node)[n];
125 VVVdouble* likelihoods_node_neighbor_ = &(*likelihoods_node_)[neighbor->
getId()];
134 Vdouble* leavesLikelihoods_leaf_i_ = &(*leavesLikelihoods_leaf_)[i];
135 VVdouble* likelihoods_node_neighbor_i_ = &(*likelihoods_node_neighbor_)[i];
136 likelihoods_node_neighbor_i_->resize(
nbClasses_);
139 Vdouble* likelihoods_node_neighbor_i_c_ = &(*likelihoods_node_neighbor_i_)[c];
140 likelihoods_node_neighbor_i_c_->resize(
nbStates_);
143 (*likelihoods_node_neighbor_i_c_)[s] = (*leavesLikelihoods_leaf_i_)[s];
152 VVdouble* likelihoods_node_neighbor_i_ = &(*likelihoods_node_neighbor_)[i];
153 likelihoods_node_neighbor_i_->resize(
nbClasses_);
156 Vdouble* likelihoods_node_neighbor_i_c_ = &(*likelihoods_node_neighbor_i_)[c];
157 likelihoods_node_neighbor_i_c_->resize(
nbStates_);
160 (*likelihoods_node_neighbor_i_c_)[s] = 1.;
195 for (
int n = (node->
hasFather() ? -1 : 0); n < nbSons; n++)
197 const Node* neighbor = (*node)[n];
207 Vdouble* array_i_c = &(*array_i)[c];
211 (*array_i_c)[s] = 1.;
219 for (
size_t l = 0; l < nbSonNodes; l++)
std::vector< size_t > rootPatternLinks_
Links between sites and patterns.
std::shared_ptr< const Alphabet > alphabet_
std::vector< unsigned int > rootWeights_
The frequency of each site.
std::shared_ptr< const TreeTemplate< Node > > tree_
virtual int getAlphabetStateAsInt(size_t index) const =0
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
virtual size_t getNumberOfStates() const =0
Get the number of states.
VVVdouble rootLikelihoods_
void reInit()
Rebuild likelihood arrays at inner nodes.
VVdouble rootLikelihoodsS_
void initLikelihoods(const AlignmentDataInterface &sites, const TransitionModelInterface &model)
Resize and initialize all likelihood arrays according to the given data set and substitution model.
Vdouble rootLikelihoodsSR_
std::map< int, DRASDRTreeLikelihoodNodeData > nodeData_
std::map< int, DRASDRTreeLikelihoodLeafData > leafData_
std::shared_ptr< AlignmentDataInterface > shrunkData_
Likelihood data structure for a leaf.
VVdouble & getLikelihoodArray()
void setNode(const Node *node)
Set the node associated to this data.
Likelihood data structure for a node.
void setNode(const Node *node)
Set the node associated to this data.
Vdouble & getDLikelihoodArray()
Vdouble & getD2LikelihoodArray()
const std::map< int, VVVdouble > & getLikelihoodArrays() const
VVVdouble & getLikelihoodArrayForNeighbor(int neighborId)
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 IndicesType & getIndices() const
const std::vector< unsigned int > & getWeights() const
std::unique_ptr< AlignmentDataInterface > getSites() const
virtual size_t getNumberOfSites() const=0
virtual size_t getNumberOfSequences() const =0
virtual double getStateValueAt(size_t sitePosition, const std::string &sequenceKey, int state) const =0
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
virtual size_t getSequencePosition(const std::string &sequenceKey) const =0
Interface for all transition models.
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
std::vector< VVdouble > VVVdouble
std::vector< Vdouble > VVdouble