Example #1
0
void T92GCBranchTree::recursiveUpdate(const RevBayesCore::TopologyNode &from)    {

    size_t index = from.getIndex();

    double gc = 0.5;
    if (from.isRoot())    {
        gc = rootgc->getValue();
    }
    else    {        
        gc = gctree->getValue()[index];
    }

    RateMatrix_HKY& matrix = static_cast<RateMatrix_HKY&>( (*value)[index] );
    std::vector<double> v(4);
    v[0] = v[3] = 0.5 * (1 - gc);
    v[1] = v[2] = 0.5 * gc;
    matrix.setStationaryFrequenciesByCopy(v);
    matrix.setKappa(kappa->getValue());
    
    // simulate the val for each child (if any)
    size_t numChildren = from.getNumberOfChildren();
    for (size_t i = 0; i < numChildren; ++i) {
        const TopologyNode& child = from.getChild(i);
        recursiveUpdate(child);
    }
}
void BranchLengthTree::reverseParentChild(RevBayesCore::TopologyNode &n)
{
    
    if ( !n.isRoot() )
    {
        TopologyNode &p = n.getParent();
        reverseParentChild( p );
        p.removeChild( &n );
        p.setParent( &n );
        n.addChild( &p );
		
		// swap branch lengths
		double parent_branch_length = branchLengths[p.getIndex()];
		double child_branch_length = branchLengths[n.getIndex()];
		branchLengths[p.getIndex()] = child_branch_length;
		branchLengths[n.getIndex()] = parent_branch_length;
    }

}