A library for working with phylogenetic and population genetic data.
v0.27.0
taxopath_generator.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TAXONOMY_FORMATS_TAXOPATH_GENERATOR_H_
2 #define GENESIS_TAXONOMY_FORMATS_TAXOPATH_GENERATOR_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 Lucas Czech and HITS gGmbH
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 #include <string>
35 #include <vector>
36 
37 namespace genesis {
38 namespace taxonomy {
39 
40 // =================================================================================================
41 // Forward Declarations
42 // =================================================================================================
43 
44 class Taxon;
45 class Taxopath;
46 
47 // =================================================================================================
48 // Taxopath Generator
49 // =================================================================================================
50 
75 {
76 public:
77 
78  enum class TaxonField
79  {
80  kName,
81  kRank,
82  kId
83  };
84 
85  // -------------------------------------------------------------------------
86  // Constructors and Rule of Five
87  // -------------------------------------------------------------------------
88 
89  TaxopathGenerator() = default;
90  ~TaxopathGenerator() = default;
91 
92  TaxopathGenerator( TaxopathGenerator const& ) = default;
93  TaxopathGenerator( TaxopathGenerator&& ) = default;
94 
95  TaxopathGenerator& operator= ( TaxopathGenerator const& ) = default;
97 
98  // -------------------------------------------------------------------------
99  // Generating
100  // -------------------------------------------------------------------------
101 
107  std::string to_string( Taxopath const& taxopath ) const;
108 
115  std::string operator() ( Taxopath const& taxopath ) const;
116 
122  std::string to_string( Taxon const& taxon ) const;
123 
130  std::string operator() ( Taxon const& taxon ) const;
131 
132  // -------------------------------------------------------------------------
133  // Properties
134  // -------------------------------------------------------------------------
135 
143 
149  TaxonField field() const;
150 
157  TaxopathGenerator& delimiter( std::string const& value );
158 
164  std::string delimiter() const;
165 
181 
187  bool trim_nested_duplicates() const;
188 
198  TaxopathGenerator& append_delimiter( bool value );
199 
205  bool append_delimiter() const;
206 
207  // -------------------------------------------------------------------------
208  // Data Members
209  // -------------------------------------------------------------------------
210 
211 private:
212 
213  TaxonField field_ = TaxonField::kName;
214  std::string delimiter_ = ";";
215  bool trim_nested_duplicates_ = false;
216  bool append_delimiter_ = false;
217 
218 };
219 
220 } // namespace taxonomy
221 } // namespace genesis
222 
223 #endif // include guard
genesis::taxonomy::TaxopathGenerator::TaxonField::kId
@ kId
genesis::taxonomy::TaxopathGenerator::operator=
TaxopathGenerator & operator=(TaxopathGenerator const &)=default
genesis::taxonomy::TaxopathGenerator::field
TaxonField field() const
Return the currelty set field to use for describing a Taxon.
Definition: taxopath_generator.cpp:150
genesis::taxonomy::TaxopathGenerator::TaxonField
TaxonField
Definition: taxopath_generator.hpp:78
genesis::taxonomy::TaxopathGenerator::append_delimiter
bool append_delimiter() const
Return whether currently a delimiter is appended to the taxonomic path string.
Definition: taxopath_generator.cpp:183
genesis::taxonomy::Taxon
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.
Definition: taxon.hpp:76
genesis::taxonomy::TaxopathGenerator::TaxopathGenerator
TaxopathGenerator()=default
genesis::taxonomy::TaxopathGenerator
Helper class to generate a taxonomic path string from a Taxopath object or a Taxon.
Definition: taxopath_generator.hpp:74
genesis::taxonomy::TaxopathGenerator::TaxonField::kName
@ kName
genesis::taxonomy::Taxopath
Helper class to store a taxonomic path.
Definition: taxopath.hpp:83
genesis::taxonomy::TaxopathGenerator::trim_nested_duplicates
bool trim_nested_duplicates() const
Return the currently set value whether to trim nested duplicates of taxa names.
Definition: taxopath_generator.cpp:172
genesis::taxonomy::TaxopathGenerator::delimiter
std::string delimiter() const
Return the currelty set value used to join the taxonomic path string elements.
Definition: taxopath_generator.cpp:161
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::taxonomy::TaxopathGenerator::TaxonField::kRank
@ kRank
genesis::taxonomy::TaxopathGenerator::to_string
std::string to_string(Taxopath const &taxopath) const
Return a string representation of a Taxopath.
Definition: taxopath_generator.cpp:49
genesis::taxonomy::TaxopathGenerator::operator()
std::string operator()(Taxopath const &taxopath) const
Shortcut function alias for to_string( Taxopath ).
Definition: taxopath_generator.cpp:78
genesis::taxonomy::TaxopathGenerator::~TaxopathGenerator
~TaxopathGenerator()=default