5 #ifndef BPP_PHYL_LIKELIHOOD_DATAFLOW_LIKELIHOODCALCULATIONSINGLEPROCESS_H
6 #define BPP_PHYL_LIKELIHOOD_DATAFLOW_LIKELIHOODCALCULATIONSINGLEPROCESS_H
48 class ForwardLikelihoodTree;
49 class BackwardLikelihoodTree;
120 std::shared_ptr<ForwardLikelihoodTree>
flt;
125 std::shared_ptr<BackwardLikelihoodTree>
blt;
130 std::shared_ptr<ConditionalLikelihoodDAG>
clt;
135 std::shared_ptr<SiteLikelihoodsDAG>
lt;
169 std::shared_ptr<const SubstitutionProcessInterface>
process_;
170 std::shared_ptr<const AlignmentDataInterface>
psites_;
218 std::shared_ptr<const AlignmentDataInterface> sites,
219 std::shared_ptr<const SubstitutionProcessInterface> process);
222 std::shared_ptr<const SubstitutionProcessInterface> process);
232 std::shared_ptr<const AlignmentDataInterface> sites,
249 throw bpp::Exception(
"LikelihoodCalculationSingleProcess clone should not happen.");
252 void setData(std::shared_ptr<const AlignmentDataInterface> sites)
288 throw Exception(
"LikelihoodCalculationSingleProcess::makeLikelihoods : data not set.");
342 std::shared_ptr<const AlignmentDataInterface>
getData()
const
427 return (uint)(
rootWeights_->targetValue()(Eigen::Index(pos)));
546 auto allIndex =
process_->parametrizablePhyloTree().getAllNodesIndexes();
548 for (
auto id: allIndex)
static ValueRef< R > create(Context &c, NodeRefVec &&deps, const Dimension< R > &dim)
Build a new CWisePattern node.
Context for dataflow node construction.
DF Nodes used in the process. ProcessTree is used without any rate multiplier.
std::shared_ptr< ConfiguredFrequencySet > rootFreqsNode_
std::shared_ptr< ProcessTree > treeNode_
std::shared_ptr< ConfiguredDistribution > ratesNode_
std::shared_ptr< ConfiguredModel > modelNode_
std::shared_ptr< ConditionalLikelihoodDAG > clt
for each node n: clt[n] = flt[n] * dlt[n]
std::shared_ptr< SiteLikelihoodsDAG > lt
for each node n: clt[n] = sum_states(clt[n][s])
std::shared_ptr< SiteLikelihoodsTree > speciesLt
for each node n: lt[n] = sum_{state s} flt[n][s]
std::shared_ptr< BackwardLikelihoodTree > blt
backward likelihood tree (only computed when needed)
std::shared_ptr< ForwardLikelihoodTree > flt
std::shared_ptr< ProcessTree > phyloTree
SiteLikelihoodsRef getLikelihoodsAtNodeForClass(uint nodeId, size_t nCat)
Get shrunked conditional likelihood matrix at Node (ie just above the node), for a given rate class.
std::shared_ptr< SiteLikelihoodsTree > getSiteLikelihoodsTree_(size_t nCat)
LikelihoodCalculationSingleProcess * clone() const
std::shared_ptr< const SubstitutionProcessInterface > getSubstitutionProcess() const
const SubstitutionProcessInterface & substitutionProcess() const
Return the ref to the SubstitutionProcess.
ValueRef< PatternType > rootPatternLinks_
ValueRef< MatrixLik > expandMatrix(ValueRef< MatrixLik > matrix)
ValueRef< Eigen::RowVectorXd > rFreqs_
ConditionalLikelihoodRef getLikelihoodsAtNode(uint nodeId, bool shrunk=false)
std::shared_ptr< ConditionalLikelihoodTree > condLikelihoodTree_
size_t getNumberOfClasses() const
size_t getRootArrayPosition(size_t currentPosition) const
std::shared_ptr< ForwardLikelihoodTree > getForwardLikelihoodTree(size_t nCat)
std::shared_ptr< const SubstitutionProcessInterface > process_
ProcessNodes processNodes_
AllRatesSiteLikelihoods getSiteLikelihoodsForAllClasses(bool shrunk=false)
Output array (Classes X Sites) of likelihoods for all sites & classes.
ValueRef< Eigen::RowVectorXd > getRootFreqs()
std::shared_ptr< const AlignmentDataInterface > psites_
LikelihoodCalculationSingleProcess(Context &context, std::shared_ptr< const AlignmentDataInterface > sites, std::shared_ptr< const SubstitutionProcessInterface > process)
const AlignmentDataInterface & data() const
unsigned int getWeight(size_t pos) const
std::shared_ptr< const StateMapInterface > getStateMap() const
std::shared_ptr< SiteWeights > rootWeights_
The frequency of each site.
ConditionalLikelihoodRef getBackwardLikelihoodsAtEdgeForClass(uint edgeId, size_t nCat)
ConditionalLikelihoodRef getForwardLikelihoodsAtNodeForClass(uint nodeId, size_t nCat)
std::shared_ptr< BackwardLikelihoodTree > getBackwardLikelihoodTree(size_t nCat)
const PatternType & getRootArrayPositions() const
size_t getNumberOfSites() const
void makeLikelihoodsAtNode_(uint nodeId)
Compute the likelihood at a given node in the tree, which number may not be the same number in the DA...
void setData(std::shared_ptr< const AlignmentDataInterface > sites)
const AlignmentDataInterface & shrunkData() const
ValueRef< PatternType > getRootPatternLinks() const
void cleanAllLikelihoods()
void makeLikelihoodsAtDAGNode_(uint nodeId)
Compute the likelihood at a given node in the DAG,.
void makeLikelihoodsTree()
make backward likelihood tree (only computed when needed)
std::shared_ptr< const AlignmentDataInterface > getShrunkData() const
ValueRef< Eigen::RowVectorXd > catProb_
size_t getNumberOfDistinctSites() const
ValueRef< RowLik > expandVector(ValueRef< RowLik > vector)
const StateMapInterface & stateMap() const
std::shared_ptr< AlignmentDataInterface > shrunkData_
const DAGindexes & getEdgesIds(uint speciesId, size_t nCat) const
Get indexes of the non-empty edges in the Likelihood DAG that have a given species index for a given ...
ConditionalLikelihoodRef getBackwardLikelihoodsAtNodeForClass(uint nodeId, size_t nCat)
const DAGindexes & getNodesIds(uint speciesId) const
Get indexes of the nodes in the Likelihood DAG that have a given species index.
std::shared_ptr< SiteWeights > getRootWeights()
ConditionalLikelihoodRef getConditionalLikelihoodsAtNodeForClass(uint nodeId, size_t nCat)
void makeForwardLikelihoodTree_()
void makeLikelihoodsAtRoot_()
RowLik getSiteLikelihoodsForAClass(size_t nCat, bool shrunk=false)
Get site likelihoods for a rate category.
std::shared_ptr< ProcessTree > getTreeNode(size_t nCat)
Get process tree for a rate category.
void setNumericalDerivateConfiguration(double delta, const NumericalDerivativeType &config)
Set derivation procedure (see DataFlowNumeric.h)
std::vector< RateCategoryTrees > vRateCatTrees_
void setClockLike(double rate=1)
std::shared_ptr< const AlignmentDataInterface > getData() const
virtual bool isInitialized() const
Map the states of a given alphabet which have a model state.
This interface describes the substitution process along the tree and sites of the alignment.
std::string toString(T t)
Defines the basic types of data flow nodes.
std::shared_ptr< Value< T > > ValueRef
Shared pointer alias for Value<T>.
std::vector< uint > DAGindexes
Helper: create a map with mutable dataflow nodes for each branch of the tree. The map is indexed by b...
ValueRef< MatrixLik > ConditionalLikelihoodRef
ExtendedFloatMatrixXd MatrixLik
Eigen::Matrix< size_t, -1, 1 > PatternType
ValueRef< RowLik > SiteLikelihoodsRef
Basic matrix dimension type.