A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
taxonomy/functions/entropy.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TAXONOMY_FUNCTIONS_ENTROPY_H_
2 #define GENESIS_TAXONOMY_FUNCTIONS_ENTROPY_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
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 
35 
36 #include <string>
37 
38 namespace genesis {
39 namespace taxonomy {
40 
41 // =================================================================================================
42 // Forwad Declarations
43 // =================================================================================================
44 
45 class Taxon;
46 class Taxonomy;
47 
48 // =================================================================================================
49 // Prune Settings
50 // =================================================================================================
51 
56 {
66 
78 
93  size_t min_border_level = 0;
94 
102  bool allow_approximation = false;
103 };
104 
105 // =================================================================================================
106 // Prune Functions
107 // =================================================================================================
108 
172 void prune_by_entropy(
173  Taxonomy& taxonomy,
174  size_t target_taxonomy_size,
175  PruneByEntropySettings settings = {}
176 );
177 
190  Taxonomy& taxonomy,
191  size_t min_subtaxonomy_size
192 );
193 
199  Taxonomy const& taxonomy,
201 );
202 
211 void remove_pruned_taxonomy_children( Taxonomy& taxonomy );
212 
217 std::string print_pruned_taxonomy( Taxonomy const& taxonomy );
218 
237 bool validate_pruned_taxonomy( Taxonomy const& taxonomy );
238 
239 } // namespace taxonomy
240 } // namespace genesis
241 
242 #endif // include guard
size_t max_subtaxonomy_size
Maximal size of a sub-taxonomy of the pruned Taxonomy. Default is 0.
bool validate_pruned_taxonomy(Taxonomy const &taxonomy)
Validate that the pruning status of a Taxonomy is valid.
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
void remove_pruned_taxonomy_children(Taxonomy &taxonomy)
Remove the children of all Taxa that are pruned, i.e, that have prune status == kOutside.
size_t min_subtaxonomy_size
Minimal size of a sub-taxonomy of the pruned Taxonomy. Default is 0.
size_t count_taxa_with_prune_status(Taxonomy const &taxonomy, EntropyTaxonData::PruneStatus status)
Return the number of Taxa that have a certain prune status.
bool allow_approximation
Allow some approximation in order to get closer to the target pruning size.
Store settings for the Taxonomy pruning algorithm prune_by_entropy().
void prune_by_entropy(Taxonomy &taxonomy, size_t target_taxonomy_size, PruneByEntropySettings settings)
Prune a Taxonomy so that the result (approximately) contains a desired number of "leaf" Taxa...
size_t min_border_level
Minimum level of the Taxa that are considered inside for pruning. Default is 0.
void expand_small_subtaxonomies(Taxonomy &taxonomy, size_t min_subtaxonomy_size)
Expand the leaves of a pruned Taxonomy if their sub-taxonomies are smaller than the given threshold...
std::string print_pruned_taxonomy(Taxonomy const &taxonomy)
Print a Taxonomy, highlighting those Taxa that are the pruning border, i.e., where we cut off the sub...