A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
placement/function/distances.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_PLACEMENT_FUNCTION_DISTANCES_H_
2 #define GENESIS_PLACEMENT_FUNCTION_DISTANCES_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 
36 
37 #include <vector>
38 
39 namespace genesis {
40 
41 // =================================================================================================
42 // Forward Declarations
43 // =================================================================================================
44 
45 namespace tree {
46 
47  class Tree;
48 
49  class TreeEdge;
50  class TreeNode;
51 
52  class DefaultNodeData;
53  class DefaultEdgeData;
54 
55  using DefaultTree = Tree;
56 }
57 
58 namespace placement {
59 
60  class Pquery;
61  class PqueryPlacement;
62  struct PqueryPlain;
63 
64  class PlacementEdgeData;
65  class PlacementNodeData;
66 
67  class Sample;
68  class SampleSet;
69 }
70 
71 namespace placement {
72 
73 // =================================================================================================
74 // Pquery to Pquery Distances
75 // =================================================================================================
76 
128 double pquery_distance(
129  PqueryPlain const& pquery_a,
130  PqueryPlain const& pquery_b,
131  utils::Matrix<double> const& node_distances,
132  bool with_pendant_length = false
133 );
134 
142 double pquery_distance(
143  Pquery const& pquery_a,
144  Pquery const& pquery_b,
145  utils::Matrix<double> const& node_distances,
146  bool with_pendant_length = false
147 );
148 
155 double placement_distance(
156  PqueryPlacement const& place_a,
157  PqueryPlacement const& place_b,
158  utils::Matrix<double> const& node_distances
159 );
160 
169  Pquery const& pquery_a,
170  Pquery const& pquery_b,
171  utils::Matrix<size_t> const& node_path_lengths
172 );
173 
184  PqueryPlacement const& place_a,
185  PqueryPlacement const& place_b,
186  utils::Matrix<size_t> const& node_path_lengths
187 );
188 
189 // =================================================================================================
190 // Pquery to Tree Element Distances
191 // =================================================================================================
192 
200 double pquery_distance(
201  Pquery const& pquery,
202  tree::TreeNode const& node,
203  utils::Matrix<double> const& node_distances
204 );
205 
212 double placement_distance(
213  PqueryPlacement const& placement,
214  tree::TreeNode const& node,
215  utils::Matrix<double> const& node_distances
216 );
217 
218 // /**
219 // * @brief Calculate the weighted discrete distance between the PqueryPlacement%s of a Pquery and a
220 // * tree::TreeNode, in number of nodes, using the `like_weight_ratio` of the PqueryPlacement%s
221 // * for weighing.
222 // *
223 // * The Matrix @p node_path_lengths has to come from tree::node_path_length_matrix().
224 // */
225 // double pquery_path_length_distance(
226 // Pquery const& pquery,
227 // tree::TreeNode const& node,
228 // utils::Matrix<size_t> const& node_path_lengths
229 // );
230 //
231 // /**
232 // * @brief
233 // *
234 // * The Matrix @p node_path_lengths has to come from tree::node_path_length_matrix().
235 // */
236 // size_t placement_path_length_distance(
237 // PqueryPlacement const& placement,
238 // tree::TreeNode const& node,
239 // utils::Matrix<size_t> const& node_path_lengths
240 // );
241 
250  Pquery const& pquery,
251  tree::TreeEdge const& edge,
252  utils::Matrix<size_t> const& edge_path_lengths
253 );
254 
262  PqueryPlacement const& placement,
263  tree::TreeEdge const& edge,
264  utils::Matrix<size_t> const& edge_path_lengths
265 );
266 
267 } // namespace placement
268 } // namespace genesis
269 
270 #endif // include guard
size_t placement_path_length_distance(PqueryPlacement const &place_a, PqueryPlacement const &place_b, utils::Matrix< size_t > const &node_path_lengths)
double pquery_distance(PqueryPlain const &pquery_a, PqueryPlain const &pquery_b, utils::Matrix< double > const &node_distances, bool with_pendant_length)
Calculate the weighted distance between two plain pqueries. It is mainly a helper method for distance...
double pquery_path_length_distance(Pquery const &pquery_a, Pquery const &pquery_b, utils::Matrix< size_t > const &node_path_lengths)
Calculate the weighted discrete distance between two Pqueries, measured as the pairwise distance in n...
Class for representing phylogenetic trees.
Definition: tree/tree.hpp:95
double placement_distance(PqueryPlacement const &place_a, PqueryPlacement const &place_b, utils::Matrix< double > const &node_distances)
Calculate the distance between two PqueryPlacements, using their positin on the tree::TreeEdges, measured in branch length units.