本文整理汇总了C++中TopologyNode::setTaxon方法的典型用法代码示例。如果您正苦于以下问题:C++ TopologyNode::setTaxon方法的具体用法?C++ TopologyNode::setTaxon怎么用?C++ TopologyNode::setTaxon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopologyNode
的用法示例。
在下文中一共展示了TopologyNode::setTaxon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: simulateTree
/** Simulate the tree conditioned on the time of origin */
void HeterogeneousRateBirthDeath::simulateTree( void )
{
// Get the rng
RandomNumberGenerator* rng = GLOBAL_RNG;
// Create the time tree object (topology + times)
Tree *psi = new Tree();
// Root the topology by setting the appropriate flag
psi->setRooted( true );
// Create the root node and a vector of nodes
TopologyNode* root = new TopologyNode();
std::vector<TopologyNode* > nodes;
nodes.push_back(root);
// Draw a random tree history
buildRandomBinaryHistory(nodes);
// Set the tip names
for (size_t i=0; i<num_taxa; i++)
{
size_t index = size_t( floor(rng->uniform01() * nodes.size()) );
// Get the node from the list
TopologyNode* node = nodes.at(index);
// Remove the randomly drawn node from the list
nodes.erase(nodes.begin()+long(index) );
// Set taxon
node->setTaxon( taxa[i] );
}
// Initialize the topology by setting the root
psi->setRoot(root, true);
// Now simulate the speciation times counted from originTime
std::vector<double> intNodeTimes;
double t_or = root_age->getValue();
intNodeTimes.push_back( 0.0 ); // For time of mrca
for ( size_t i=0; i<num_taxa-2; i++ )
{
double t = rng->uniform01() * t_or;
intNodeTimes.push_back( t );
}
// Sort the speciation times from 0.0 (root node) to the largest value
std::sort( intNodeTimes.begin(), intNodeTimes.end() );
// Attach times
nodes.clear();
nodes.push_back( root );
attachTimes(psi, nodes, 0, intNodeTimes, t_or);
for (size_t i = 0; i < num_taxa; ++i)
{
TopologyNode& node = psi->getTipNode(i);
psi->getNode( node.getIndex() ).setAge( 0.0 );
}
// Finally store the new value
value = psi;
branch_histories.setTree( psi );
}