A library for working with phylogenetic and population genetic data.
v0.27.0
placement/function/operators.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_PLACEMENT_FUNCTION_OPERATORS_H_
2 #define GENESIS_PLACEMENT_FUNCTION_OPERATORS_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 
35 
36 #include <iosfwd>
37 #include <string>
38 
39 namespace genesis {
40 
41 // =================================================================================================
42 // Forward Declarations
43 // =================================================================================================
44 
45 namespace tree {
46 
47  class Tree;
48  class TreeSet;
49 
50  class CommonNodeData;
51  class CommonEdgeData;
52 
53  using CommonTree = Tree;
54  using MassTree = Tree;
55 }
56 
57 namespace placement {
58  class PlacementEdgeData;
59  class PlacementNodeData;
60 
61  class Sample;
62  class SampleSet;
63 }
64 
65 namespace placement {
66 
67 // =================================================================================================
68 // Comparision and Equality
69 // =================================================================================================
70 
84 bool compatible_trees( PlacementTree const& lhs, PlacementTree const& rhs );
85 
93 bool compatible_trees( Sample const& lhs, Sample const& rhs );
94 
95 // =================================================================================================
96 // Conversion
97 // =================================================================================================
98 
107 
118  Sample const& smp, double const sign, double const scaler, tree::MassTree& target
119 );
120 
127 std::pair< tree::MassTree, double > convert_sample_to_mass_tree( Sample const& sample, bool normalize );
128 
132 std::pair< tree::TreeSet, std::vector<double> >
133 convert_sample_set_to_mass_trees( SampleSet const& sample_set, bool normalize );
134 
135 // =================================================================================================
136 // Output
137 // =================================================================================================
138 
142 std::ostream& operator << ( std::ostream& out, Sample const& smp );
143 
148 std::string print_tree( Sample const& smp );
149 
150 } // namespace placement
151 } // namespace genesis
152 
153 #endif // include guard
genesis::placement::convert_sample_to_mass_tree
std::pair< tree::MassTree, double > convert_sample_to_mass_tree(Sample const &sample, bool normalize)
Convert a Sample to a tree::MassTree.
Definition: placement/function/operators.cpp:174
placement_tree.hpp
genesis::tree::MassTree
Tree MassTree
Alias for a Tree that stores masses on its TreeEdges.
Definition: placement/function/operators.hpp:54
genesis::placement::add_sample_to_mass_tree
double add_sample_to_mass_tree(Sample const &smp, double const sign, double const scaler, tree::MassTree &target)
Helper function to copy masses from a Sample to a MassTree.
Definition: placement/function/operators.cpp:132
genesis::tree::Tree
Class for representing phylogenetic trees.
Definition: tree/tree.hpp:97
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::tree::CommonTree
Tree CommonTree
Alias for a Tree with data types CommonNodeData and CommonEdgeData.
Definition: placement/function/distances.hpp:55
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::convert_sample_set_to_mass_trees
std::pair< tree::TreeSet, std::vector< double > > convert_sample_set_to_mass_trees(SampleSet const &sample_set, bool normalize)
Convert all Samples in a SampleSet to tree::MassTrees.
Definition: placement/function/operators.cpp:185
genesis::placement::print_tree
std::string print_tree(Sample const &smp)
Return a simple view of the Tree of a Sample with information about the Pqueries on it.
Definition: placement/function/operators.cpp:275
genesis::placement::convert_common_tree_to_placement_tree
PlacementTree convert_common_tree_to_placement_tree(tree::CommonTree const &source_tree)
Convert a CommonTree into a PlacementTree.
Definition: placement/function/operators.cpp:105
genesis::utils::normalize
void normalize(Histogram &h, double total)
Definition: operations.cpp:61
genesis::placement::operator<<
std::ostream & operator<<(std::ostream &out, Sample const &smp)
Print a table of all Pqueries with their Placements and Names to the stream.
Definition: placement/function/operators.cpp:238
genesis::placement::compatible_trees
bool compatible_trees(PlacementTree const &lhs, PlacementTree const &rhs)
Return whether two PlacementTrees are compatible.
Definition: placement/function/operators.cpp:63