Skip to content

Commit 7f276bf

Browse files
committed
integrate mutations into all likelihood vectors (i.e., regions) of a node
1 parent dab930e commit 7f276bf

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

tree/phylonode.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ class PhyloNode {
264264
Set the index of the node likelihood
265265
*/
266266
void setNodeLhIndex(const cmaple::NumSeqsType node_lh_index);
267+
268+
/**
269+
Integrate mutations (local ref) to all lh vectors
270+
@throw std::logic\_error if unexpected values/behaviors found during the
271+
operations
272+
*/
273+
template <const cmaple::StateType num_states>
274+
auto integrateMutAllRegions(std::unique_ptr<SeqRegions>& mutations,
275+
const Alignment* aln, const bool inverse = false) -> void;
267276

268277
/**
269278
Get a vector of the indexes of neighbors
@@ -382,6 +391,29 @@ void cmaple::PhyloNode::computeTotalLhAtNode(
382391
}
383392
}
384393

394+
template <const StateType num_states>
395+
auto cmaple::PhyloNode::integrateMutAllRegions(
396+
std::unique_ptr<SeqRegions>& mutations,
397+
const Alignment* aln, const bool inverse) -> void
398+
{
399+
// lower regions
400+
setPartialLh(TOP, getPartialLh(TOP)->integrateMutations<num_states>(mutations, aln, inverse));
401+
402+
// upper left/right regions
403+
if (isInternal())
404+
{
405+
setPartialLh(LEFT, getPartialLh(LEFT)->integrateMutations<num_states>(mutations, aln, inverse));
406+
setPartialLh(RIGHT, getPartialLh(RIGHT)->integrateMutations<num_states>(mutations, aln, inverse));
407+
}
408+
409+
// mid-branch regions
410+
if (getMidBranchLh())
411+
{
412+
assert(getUpperLength() > 0);
413+
setMidBranchLh(getMidBranchLh()->integrateMutations<num_states>(mutations, aln, inverse));
414+
}
415+
}
416+
385417
} // namespace cmaple
386418

387419
// just for testing

tree/tree.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,13 @@ bool isDiffFromOrigPlacement(
21172117

21182118
// NHANLT: Debug aLRT
21192119
// void log_current(std::stack<cmaple::Index>& node_stack_aLRT);
2120+
2121+
/**
2122+
Make a local reference at a node
2123+
*/
2124+
template <const StateType num_states>
2125+
auto makeReferenceNode(PhyloNode& node, const cmaple::Index node_index,
2126+
const int old_num_desc) -> void;
21202127
};
21212128

21222129
/*!

0 commit comments

Comments
 (0)