예제 #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);
    }
}
예제 #2
0
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;
    }

}
예제 #3
0
void Func_simTree::setAges(RevBayesCore::TimeTree *t, RevBayesCore::TopologyNode &n)
{
    
    if ( n.isTip() )
    {
        t->setAge(n.getIndex(), 0.0);
    }
    else
    {
        RevBayesCore::TopologyNode &left = n.getChild( 0 );
        setAges(t, left);
        
        RevBayesCore::TopologyNode &right = n.getChild( 1 );
        setAges(t, right);
        
        double a = t->getAge(left.getIndex());
        double b = t->getAge(right.getIndex());
        double max = (a > b ? a : b);
        
        t->setAge(n.getIndex(), max + 1.0);
    }
    
}