A library for working with phylogenetic and population genetic data.
v0.32.0
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
entropy_data.hpp
genesis::taxonomy::PruneByEntropySettings::max_subtaxonomy_size
size_t max_subtaxonomy_size
Maximal size of a sub-taxonomy of the pruned Taxonomy. Default is 0.
Definition: taxonomy/functions/entropy.hpp:77
genesis::taxonomy::PruneByEntropySettings::min_subtaxonomy_size
size_t min_subtaxonomy_size
Minimal size of a sub-taxonomy of the pruned Taxonomy. Default is 0.
Definition: taxonomy/functions/entropy.hpp:65
genesis::taxonomy::count_taxa_with_prune_status
size_t count_taxa_with_prune_status(Taxonomy const &taxonomy, EntropyTaxonData::PruneStatus status)
Return the number of Taxa that have a certain prune status.
Definition: taxonomy/functions/entropy.cpp:449
genesis::taxonomy::expand_small_subtaxonomies
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.
Definition: taxonomy/functions/entropy.cpp:412
genesis::taxonomy::PruneByEntropySettings
Store settings for the Taxonomy pruning algorithm prune_by_entropy().
Definition: taxonomy/functions/entropy.hpp:55
genesis::taxonomy::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,...
Definition: taxonomy/functions/entropy.cpp:59
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::remove_pruned_taxonomy_children
void remove_pruned_taxonomy_children(Taxonomy &taxonomy)
Remove the children of all Taxa that are pruned, i.e, that have prune status == kOutside.
Definition: taxonomy/functions/entropy.cpp:463
genesis::taxonomy::Taxonomy
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
Definition: taxonomy/taxonomy.hpp:96
genesis::taxonomy::validate_pruned_taxonomy
bool validate_pruned_taxonomy(Taxonomy const &taxonomy)
Validate that the pruning status of a Taxonomy is valid.
Definition: taxonomy/functions/entropy.cpp:491
genesis::taxonomy::EntropyTaxonData::PruneStatus
PruneStatus
Definition: entropy_data.hpp:61
genesis::taxonomy::print_pruned_taxonomy
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...
Definition: taxonomy/functions/entropy.cpp:472
genesis::taxonomy::PruneByEntropySettings::min_border_level
size_t min_border_level
Minimum level of the Taxa that are considered inside for pruning. Default is 0.
Definition: taxonomy/functions/entropy.hpp:93
genesis::taxonomy::PruneByEntropySettings::allow_approximation
bool allow_approximation
Allow some approximation in order to get closer to the target pruning size.
Definition: taxonomy/functions/entropy.hpp:102