A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TaxopathGenerator Class Reference

#include <genesis/taxonomy/formats/taxopath_generator.hpp>

Detailed Description

Helper class to generate a taxonomic path string from a Taxopath object or a Taxon.

This class bundles the parameters used for generating a taxonomic path string. This is needed in order to allow customization of the generation process. The result of the process is a string representation of the taxonomic path, with all names of the super-taxa of the given taxon (and the taxon itself), concatenated using the delimiter().

For example, the Taxon

Tax_1
    Tax_2
        Tax_2
            Tax_4

might result in a string representation

Tax_1;Tax_2;;Tax_4;

The same result is also obtained from a Taxopath [ "Tax_1", "Tax_2", "Tax_2", "Tax_4" ].

Definition at line 74 of file taxopath_generator.hpp.

Public Member Functions

 TaxopathGenerator ()=default
 
 TaxopathGenerator (TaxopathGenerator const &)=default
 
 TaxopathGenerator (TaxopathGenerator &&)=default
 
 ~TaxopathGenerator ()=default
 
TaxopathGeneratorappend_delimiter (bool value)
 Set whether to append the delimiter string to the generated string. More...
 
bool append_delimiter () const
 Return whether currently a delimiter is appended to the taxonomic path string. More...
 
TaxopathGeneratordelimiter (std::string const &value)
 Set the string used to join the taxonomic path string elements. More...
 
std::string delimiter () const
 Return the currelty set value used to join the taxonomic path string elements. More...
 
TaxopathGeneratorfield (TaxonField value)
 Set the string field to use for Taxon input. More...
 
TaxonField field () const
 Return the currelty set field to use for describing a Taxon. More...
 
std::string operator() (Taxopath const &taxopath) const
 Shortcut function alias for to_string( Taxopath ). More...
 
std::string operator() (Taxon const &taxon) const
 Shortcut function alias for to_string( Taxon ). More...
 
TaxopathGeneratoroperator= (TaxopathGenerator const &)=default
 
TaxopathGeneratoroperator= (TaxopathGenerator &&)=default
 
std::string to_string (Taxopath const &taxopath) const
 Return a string representation of a Taxopath. More...
 
std::string to_string (Taxon const &taxon) const
 Return a string representation of a Taxon. More...
 
TaxopathGeneratortrim_nested_duplicates (bool value)
 Set whether lower level taxa are omitted if they are the same as the next higher level one. More...
 
bool trim_nested_duplicates () const
 Return the currently set value whether to trim nested duplicates of taxa names. More...
 

Public Types

enum  TaxonField { kName, kRank, kId }
 

Constructor & Destructor Documentation

TaxopathGenerator ( )
default
~TaxopathGenerator ( )
default
TaxopathGenerator ( TaxopathGenerator const &  )
default

Member Function Documentation

TaxopathGenerator & append_delimiter ( bool  value)

Set whether to append the delimiter string to the generated string.

In many taxonomic databases, the string representation ends with the delimiter char, for example

Animalia;Vertebrata;Mammalia;Carnivora;

This setting determines whether this last delimiter is appended or not.

Definition at line 177 of file taxopath_generator.cpp.

bool append_delimiter ( ) const

Return whether currently a delimiter is appended to the taxonomic path string.

See the setter for details.

Definition at line 183 of file taxopath_generator.cpp.

TaxopathGenerator & delimiter ( std::string const &  value)

Set the string used to join the taxonomic path string elements.

This value is used in between the elements of the taxonomic path string. Default is ';', as this is the usual value in many databases. See Taxopath for details.

Definition at line 155 of file taxopath_generator.cpp.

std::string delimiter ( ) const

Return the currelty set value used to join the taxonomic path string elements.

See the setter for details.

Definition at line 161 of file taxopath_generator.cpp.

TaxopathGenerator & field ( TaxonField  value)

Set the string field to use for Taxon input.

The Taxon class stores three strings that describe a taxon: its name, its rank, and an ID. Using this setting, one can chose which of the fields to use when generating a taxopath.

Definition at line 144 of file taxopath_generator.cpp.

Return the currelty set field to use for describing a Taxon.

See the setter for details.

Definition at line 150 of file taxopath_generator.cpp.

std::string operator() ( Taxopath const &  taxopath) const

Shortcut function alias for to_string( Taxopath ).

This shortcut enables to use a TaxopathGenerator object as functor.

Definition at line 78 of file taxopath_generator.cpp.

std::string operator() ( Taxon const &  taxon) const

Shortcut function alias for to_string( Taxon ).

This shortcut enables to use a TaxopathGenerator object as functor.

Definition at line 135 of file taxopath_generator.cpp.

TaxopathGenerator& operator= ( TaxopathGenerator const &  )
default
TaxopathGenerator& operator= ( TaxopathGenerator &&  )
default
std::string to_string ( Taxopath const &  taxopath) const

Return a string representation of a Taxopath.

This generator function uses the settings of this class to generate the string.

Definition at line 49 of file taxopath_generator.cpp.

std::string to_string ( Taxon const &  taxon) const

Return a string representation of a Taxon.

This generator function uses the settings of this class to generate the string.

Definition at line 83 of file taxopath_generator.cpp.

TaxopathGenerator & trim_nested_duplicates ( bool  value)

Set whether lower level taxa are omitted if they are the same as the next higher level one.

If set to true, lower level names are set to empty if they are the same as higher level names. Default is false, that is, nothing is trimmed.

Example: For a Taxopath

[ "Tax_1", "Tax_1", "Tax_2" ]

the generator function returns Tax_1;Tax_1;Tax_2, and respectively Tax_1;;Tax_2 with trimming nested duplicates.

Definition at line 166 of file taxopath_generator.cpp.

bool trim_nested_duplicates ( ) const

Return the currently set value whether to trim nested duplicates of taxa names.

See the setter for details.

Definition at line 172 of file taxopath_generator.cpp.

Member Enumeration Documentation

enum TaxonField
strong
Enumerator
kName 
kRank 
kId 

Definition at line 78 of file taxopath_generator.hpp.


The documentation for this class was generated from the following files: