|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
50 std::vector< std::string > elements;
56 if( elements.size() == 0 ) {
57 assert( taxopath ==
"" );
62 if( trim_whitespaces_ ) {
63 for(
auto& r : elements ) {
69 if( elements.front() ==
"" ) {
70 throw std::runtime_error(
"Cannot use Taxopath if first Taxon is empty." );
74 if( remove_trailing_delimiter_ && elements.back() ==
"" ) {
79 std::string prev_name;
80 for(
size_t i = 0; i < elements.size(); ++i ) {
81 auto& name = elements[i];
86 assert( i > 0 && prev_name !=
"" );
99 std::vector<std::string> elements;
103 Taxon const* r = &taxon;
104 while( r !=
nullptr ) {
105 elements.push_back( r->
name() );
110 std::reverse( elements.begin(), elements.end() );
Taxon const * parent() const
Return a pointer to the parent of this taxon, or a nullptr if this is the top level taxon.
std::string trim(std::string const &s, std::string const &delimiters)
Return a copy of the input string, with trimmed white spaces (or any other delimiters).
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.
std::vector< std::string > split(std::string const &str, char delimiter, const bool trim_empty)
Spilt a string into parts, given a delimiter char.
Helper class to store a taxonomic path.
Provides some commonly used string utility functions.
Taxopath parse(std::string const &taxopath) const
Parse a taxonomic path string into a Taxopath object and return it.
std::string const & name() const
Return the name of this taxon.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.