Beispiel #1
0
size_t total_taxa_count( Taxonomy const& tax )
{
    size_t count = tax.size();
    for( auto const& t : tax ) {
        count += total_taxa_count( t );
    }
    return count;
}
Beispiel #2
0
std::vector< size_t > taxa_count_levels( Taxonomy const& tax )
{
    if( tax.size() == 0 ) {
        return std::vector< size_t >();
    }

    std::vector< size_t > result( 1, 0 );
    result[ 0 ] = tax.size();

    for( auto const& child : tax ) {
        auto cres = taxa_count_levels( child );

        if( result.size() < cres.size() + 1 ) {
            result.resize( cres.size() + 1, 0 );
        }

        for( size_t i = 0; i < cres.size(); ++i ) {
            result[ i+1 ] += cres[ i ];
        }
    }
    return result;
}
Beispiel #3
0
size_t taxa_count_at_level( Taxonomy const& tax, size_t level )
{
    // Recursive implementation, because we are lazy.
    size_t count = 0;
    if( level == 0 ) {
        count += tax.size();
    } else {
        for( auto& c : tax ) {
            count += taxa_count_at_level( c, level - 1 );
        }
    }
    return count;
}