A library for working with phylogenetic and population genetic data.
v0.32.0
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 &&)=default
 
 TaxopathGenerator (TaxopathGenerator const &)=default
 
 ~TaxopathGenerator ()=default
 
bool append_delimiter () const
 Return whether currently a delimiter is appended to the taxonomic path string. More...
 
TaxopathGeneratorappend_delimiter (bool value)
 Set whether to append the delimiter string to the generated string. More...
 
std::string delimiter () const
 Return the currelty set value used to join the taxonomic path string elements. More...
 
TaxopathGeneratordelimiter (std::string const &value)
 Set the string used to join the taxonomic path string elements. More...
 
TaxonField field () const
 Return the currelty set field to use for describing a Taxon. More...
 
TaxopathGeneratorfield (TaxonField value)
 Set the string field to use for Taxon input. More...
 
std::string operator() (Taxon const &taxon) const
 Shortcut function alias for to_string( Taxon ). More...
 
std::string operator() (Taxopath const &taxopath) const
 Shortcut function alias for to_string( Taxopath ). More...
 
TaxopathGeneratoroperator= (TaxopathGenerator &&)=default
 
TaxopathGeneratoroperator= (TaxopathGenerator const &)=default
 
std::string to_string (Taxon const &taxon) const
 Return a string representation of a Taxon. More...
 
std::string to_string (Taxopath const &taxopath) const
 Return a string representation of a Taxopath. More...
 
bool trim_nested_duplicates () const
 Return the currently set value whether to trim nested duplicates of taxa names. 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...
 

Public Types

enum  TaxonField { kName, kRank, kId }
 

Constructor & Destructor Documentation

◆ TaxopathGenerator() [1/3]

TaxopathGenerator ( )
default

◆ ~TaxopathGenerator()

~TaxopathGenerator ( )
default

◆ TaxopathGenerator() [2/3]

TaxopathGenerator ( TaxopathGenerator const &  )
default

◆ TaxopathGenerator() [3/3]

Member Function Documentation

◆ append_delimiter() [1/2]

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.

◆ append_delimiter() [2/2]

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.

◆ delimiter() [1/2]

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.

◆ delimiter() [2/2]

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.

◆ field() [1/2]

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.

◆ field() [2/2]

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.

◆ operator()() [1/2]

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.

◆ operator()() [2/2]

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.

◆ operator=() [1/2]

TaxopathGenerator& operator= ( TaxopathGenerator &&  )
default

◆ operator=() [2/2]

TaxopathGenerator& operator= ( TaxopathGenerator const &  )
default

◆ to_string() [1/2]

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.

◆ to_string() [2/2]

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.

◆ trim_nested_duplicates() [1/2]

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.

◆ trim_nested_duplicates() [2/2]

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.

Member Enumeration Documentation

◆ TaxonField

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: