@@ -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
0 commit comments