43 #include <Bpp/Seq/Container/SiteContainerTools.h> 46 #include <Bpp/Phyl/TreeTemplate.h> 53 unsigned int nClust = 0;
54 double h = heights[node];
58 for (
int i = 0; i < static_cast<int>(node->getNumberOfSons()); ++i) {
59 nClust += getNumberOfClusters_((*node)[i], heights);
67 if (!block.hasProperty(treeProperty_))
68 throw Exception(
"CountClustersMafStatistics::compute. No property available for " + treeProperty_);
70 TreeTemplate<Node> tree(dynamic_cast<const Tree&>(block.getProperty(treeProperty_)));
72 throw Exception(
"CountClustersMafStatistics::compute. Cluster count only works with a rooted tree.");
74 map<const Node*, double> heights;
75 TreeTemplateTools::getHeights(*tree.getRootNode(), heights);
76 unsigned int nClust = getNumberOfClusters_(tree.getRootNode(), heights);
77 result_.setValue(
"NbClusters", nClust);
78 }
catch (bad_cast& e) {
79 throw Exception(
"CountClustersMafStatistics::compute. A property was found for '" + treeProperty_ +
"' but does not appear to contain a phylogenetic tree.");
unsigned int getNumberOfClusters_(const Node *node, std::map< const Node *, double > &heights)
void compute(const MafBlock &block)