A library for working with phylogenetic and population genetic data.
v0.27.0
placement/function/helper.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_PLACEMENT_FUNCTION_HELPER_H_
2 #define GENESIS_PLACEMENT_FUNCTION_HELPER_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 
37 
38 #include <unordered_map>
39 #include <vector>
40 
41 namespace genesis {
42 namespace placement {
43 
44 // =================================================================================================
45 // Forward Declarations
46 // =================================================================================================
47 
48 struct PqueryPlain;
49 
50 // =================================================================================================
51 // Helper Functions
52 // =================================================================================================
53 
60 std::unordered_map<int, PlacementTreeEdge*> edge_num_to_edge_map( PlacementTree const& tree );
61 
68 std::unordered_map<int, PlacementTreeEdge*> edge_num_to_edge_map( Sample const& smp );
69 
77 std::vector<std::vector< Pquery const* >> pqueries_per_edge(
78  Sample const& sample,
79  bool only_max_lwr_placements = false
80 );
81 
96 std::vector< std::vector< PqueryPlacement const* >> placements_per_edge(
97  Sample const& smp,
98  bool only_max_lwr_placements = false
99 );
100 
111 std::vector<PqueryPlacement const*> placements_per_edge(
112  Sample const& smp,
113  PlacementTreeEdge const& edge
114 );
115 
122 std::vector<size_t> placement_count_per_edge( Sample const& sample );
123 
124 utils::Matrix<size_t> placement_count_per_edge( SampleSet const& sample_set );
125 
139 std::vector<PqueryPlain> plain_queries( Sample const & smp );
140 
141 // =================================================================================================
142 // Verification
143 // =================================================================================================
144 
163 void rectify_values( Sample& sample );
164 
171 void rectify_values( SampleSet& sset );
172 
183 void reset_edge_nums( PlacementTree& tree );
184 
201 bool has_consecutive_edge_nums( PlacementTree const& tree );
202 
213 bool has_correct_edge_nums( PlacementTree const& tree );
214 
226 bool validate( Sample const& smp, bool check_values = false, bool break_on_values = false );
227 
228 } // namespace placement
229 } // namespace genesis
230 
231 #endif // include guard
genesis::placement::placement_count_per_edge
std::vector< size_t > placement_count_per_edge(Sample const &sample)
Return a vector that contains the number of PqueryPlacements per edge of the tree of the Sample.
Definition: placement/function/helper.cpp:158
genesis::placement::has_correct_edge_nums
bool has_correct_edge_nums(PlacementTree const &tree)
Verify that the tree has correctly set edge nums.
Definition: placement/function/helper.cpp:323
genesis::placement::pqueries_per_edge
std::vector< std::vector< Pquery const * > > pqueries_per_edge(Sample const &sample, bool only_max_lwr_placements)
Return a mapping from each edge to the Pqueries on that edge.
Definition: placement/function/helper.cpp:71
sample_set.hpp
genesis::placement::plain_queries
std::vector< PqueryPlain > plain_queries(Sample const &smp)
Return a plain representation of all pqueries of this map.
Definition: placement/function/helper.cpp:195
genesis::placement::rectify_values
void rectify_values(Sample &sample)
Correct invalid values of the PqueryPlacements and PqueryNames as good as possible.
Definition: placement/function/helper.cpp:229
genesis::placement::has_consecutive_edge_nums
bool has_consecutive_edge_nums(PlacementTree const &tree)
Verify that the PlacementTree has no duplicate edge_nums and that they form consecutive numbers start...
Definition: placement/function/helper.cpp:300
genesis::placement::edge_num_to_edge_map
std::unordered_map< int, PlacementTreeEdge * > edge_num_to_edge_map(PlacementTree const &tree)
Return a mapping of edge_num integers to the corresponding PlacementTreeEdge object.
Definition: placement/function/helper.cpp:55
matrix.hpp
genesis::placement::PlacementTree
tree::Tree PlacementTree
Alias for a tree::Tree used for a tree with information needed for storing Pqueries....
Definition: placement/formats/edge_color.hpp:54
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::placement::PlacementTreeEdge
tree::TreeEdge PlacementTreeEdge
Alias for tree::TreeEdge used in a PlacementTree. See PlacementEdgeData for the data stored on the ed...
Definition: jplace_reader.hpp:57
genesis::placement::reset_edge_nums
void reset_edge_nums(PlacementTree &tree)
Reset all edge nums of a PlacementTree.
Definition: placement/function/helper.cpp:285
genesis::placement::placements_per_edge
std::vector< std::vector< PqueryPlacement const * > > placements_per_edge(Sample const &smp, bool only_max_lwr_placements)
Return a mapping from each PlacementTreeEdges to the PqueryPlacements that are placed on that edge.
Definition: placement/function/helper.cpp:106
sample.hpp
genesis::placement::validate
bool validate(Sample const &smp, bool check_values, bool break_on_values)
Validate the integrity of the pointers, references and data in a Sample object.
Definition: placement/function/helper.cpp:343