|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
46 : children_( other.children_ )
52 : children_( std::move( other.children_ ))
59 children_ = other.children_;
66 children_ = std::move( other.children_ );
77 swap( lhs.children_, rhs.children_ );
86 return children_.size();
91 return children_.end() != std::find_if(
94 [ &name ] (
Taxon const& r ) {
95 return r.name() == name;
102 for(
auto const& c : children_ ) {
103 if( c.name() == name ) {
107 throw std::runtime_error(
"Taxon has no child named '" + name +
"'." );
112 for(
auto& c : children_ ) {
113 if( c.name() == name ) {
117 throw std::runtime_error(
"Taxon has no child named '" + name +
"'." );
132 if( index >= children_.size() ) {
133 throw std::invalid_argument(
134 "Index out of bounds for accessing Taxonomy children: " +
std::to_string( index ) +
138 auto it = std::next( children_.begin(), index );
144 if( index >= children_.size() ) {
145 throw std::invalid_argument(
146 "Index out of bounds for accessing Taxonomy children: " +
std::to_string( index ) +
150 auto it = std::next( children_.begin(), index );
166 auto it = children_.begin();
168 while( it != children_.end() ) {
169 if( it->name() == name ) {
175 throw std::runtime_error(
"Taxon has no child named '" + name +
"'." );
194 auto it = std::find_if(
197 [ &name ] (
Taxon const& r ) {
198 return r.name() == name;
201 if( it == children_.end() ) {
202 throw std::runtime_error(
"Taxon has no child named '" + name +
"'." );
204 children_.erase( it );
215 if( index >= children_.size() ) {
216 throw std::runtime_error(
"Invalid Taxon index." );
219 auto it = children_.begin();
220 std::advance( it, index );
221 children_.erase( it );
235 return children_.begin();
240 return children_.end();
245 return children_.cbegin();
250 return children_.cend();
255 return children_.cbegin();
260 return children_.cend();
271 for(
auto& c : children_ ) {
272 if( c.name() == child.
name() ) {
275 for(
auto& child_children : child ) {
284 children_.push_back( child );
290 return children_.back();
295 for(
auto& taxon : children_ ) {
296 taxon.parent_ = parent;
void remove_at(size_t index)
Remove a child Taxon at a certain index.
void remove_child(std::string const &name)
Remove a child Taxon with a certain name.
std::list< Taxon >::const_iterator const_iterator
Taxon & add_child_(Taxon const &child, bool merge_duplicates) override
Virtual implementation function for adding a child taxon.
Taxonomy & operator=(Taxonomy const &)
Copy assignment operator.
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.
void reset_parent_pointers_(Taxon *parent)
Internal helper function that resets the parent pointer of all stored Taxa.
size_t index_of(std::string const &name) const
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.
std::string to_string(GenomeLocus const &locus)
Taxon const & operator[](std::string name) const
Return the child Taxon with a given name if it exists, or throw otherwise.
void swap(Taxon &lhs, Taxon &rhs)
iterator end()
Return an iterator to the end of the child taxa.
std::string const & name() const
Return the name of this taxon.
iterator begin()
Return an iterator to the beginning of the child taxa.
const_iterator cbegin() const
Return a const iterator to the beginning of the child taxa.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
void merge_duplicates(Sample &smp)
Look for Pqueries with the same name and merge them.
virtual Taxon & add_child_(Taxon const &child, bool merge_duplicates)
Virtual implementation function for adding a child Taxon.
void swap(Taxonomy &lhs, Taxonomy &rhs)
Swapperator for Taxonomy.
size_t size() const
Return the number of immediate child Taxa.
Taxon const & get_child(std::string name) const
Return the child Taxon with a given name if it exists, or throw otherwise.
const_iterator cend() const
Return a const iterator to the end of the child taxa.
std::list< Taxon >::iterator iterator
void clear_children()
Remove all children.
Taxon const & at(size_t index) const
Return the child Taxon at the given index.