|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
83 if( taxopath.
empty() ) {
84 throw std::runtime_error(
85 "Cannot add empty Taxopath to Taxonomy."
94 for(
size_t i = 0; i < taxopath.
size(); ++i ) {
99 if( ( expect_parents ) &&
100 ( i < taxopath.
size() - 1 ) &&
103 throw std::runtime_error(
104 "Not all super-taxa of the Taxon in the Taxopath are present in the given Taxonomy."
108 cur_taxon = &cur_taxon->
add_child( taxopath[i] );
114 return dynamic_cast< Taxon&
>( *cur_taxon );
123 if( taxopath.
empty() ) {
131 for(
auto const& name : taxopath ) {
135 cur_taxon = &cur_taxon->
get_child( name );
141 return dynamic_cast< Taxon const*
>( cur_taxon );
150 auto const& ctax =
static_cast< Taxonomy const&
>( tax );
size_t size() const
Return the number of elements of this Taxopath.
bool empty() const
Return whether the Taxopath is empty, i.e., does not contain any elements.
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.
bool has_child(std::string name) const
Return whether an immediate child Taxon with the given name exists.
Taxon & add_child(Taxon const &child, bool merge_duplicates=true)
Add a child Taxon as a copy of a given Taxon and return it.
Helper class to store a taxonomic path.
Provides some commonly used string utility functions.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Taxon & add_from_taxopath(Taxonomy &taxonomy, Taxopath const &taxopath, bool expect_parents)
Add a Taxon to a Taxonomy, using the taxonomic elements of a Taxopath.
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
Taxon const & get_child(std::string name) const
Return the child Taxon with a given name if it exists, or throw otherwise.
Taxon const * find_taxon_by_taxopath(Taxonomy const &tax, Taxopath const &taxopath)
Find a Taxon in a Taxonomy, given its Taxopath.