A toolkit for working with phylogenetic data.
v0.24.0
tree/bipartition/functions.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_BIPARTITION_FUNCTIONS_H_
2 #define GENESIS_TREE_BIPARTITION_FUNCTIONS_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2020 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 
34 #include "genesis/tree/tree.hpp"
37 
38 #include <string>
39 #include <vector>
40 
41 namespace genesis {
42 namespace tree {
43 
44 // =================================================================================================
45 // Bipartition Helper Functions
46 // =================================================================================================
47 
51 std::vector<Bipartition> bipartition_set( Tree const& tree );
52 
53 std::vector<size_t> node_to_leaf_map( Tree const& tree );
54 
59 utils::Bitvector leaf_node_bitvector( Tree const& tree, std::vector<TreeNode const*> leaf_nodes );
60 
61 std::vector<size_t> get_subtree_edges( TreeLink const& subtree );
62 
73 Bipartition find_smallest_subtree(
74  Tree const& tree,
75  std::vector<Bipartition> const& bipartitions,
76  std::vector<TreeNode const*> const& nodes
77 );
78 
79 // =================================================================================================
80 // Monophyletic Subtree Functions
81 // =================================================================================================
82 
110 std::vector<size_t> find_monophyletic_subtree_edges(
111  Tree const& tree,
112  std::vector<Bipartition> const& bipartitions,
113  std::vector<TreeNode const*> const& nodes,
114  bool include_splitting_edges = true,
115  bool include_leaf_edges = true
116 );
117 
118 std::vector<size_t> find_monophyletic_subtree_edges(
119  Tree const& tree,
120  std::vector<TreeNode const*> const& nodes,
121  bool include_splitting_edges = true,
122  bool include_leaf_edges = true
123 );
124 
125 std::vector<size_t> find_monophyletic_subtree_edges(
126  Tree const& tree,
127  std::vector< std::string > const& node_names,
128  bool include_splitting_edges = true,
129  bool include_leaf_edges = true
130 );
131 
132 // =================================================================================================
133 // Whole Clade Functions
134 // =================================================================================================
135 
136 std::vector<size_t> get_clade_edges(
137  Tree const& tree,
138  std::vector< tree::TreeNode const* > const& nodes
139 );
140 
141 std::vector<size_t> get_clade_edges(
142  Tree const& tree,
143  std::vector< std::string > const& node_names
144 );
145 
146 } // namespace tree
147 } // namespace genesis
148 
149 #endif // include guard
Bipartition find_smallest_subtree(Tree const &tree, std::vector< Bipartition > const &bipartitions, std::vector< TreeNode const *> const &nodes)
Find the smallest subtree (measured in number of nodes) that contains all given nodes.
std::vector< size_t > get_clade_edges(Tree const &tree, std::vector< tree::TreeNode const * > const &nodes)
utils::Bitvector leaf_node_bitvector(Tree const &tree, std::vector< TreeNode const *> leaf_nodes)
Return a Bitvector that has as many entries as the tree has leaf nodes, and is true where the given l...
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
std::vector< size_t > node_to_leaf_map(Tree const &tree)
std::vector< Bipartition > bipartition_set(Tree const &tree)
std::vector< size_t > get_subtree_edges(TreeLink const &subtree)
std::vector< size_t > find_monophyletic_subtree_edges(Tree const &tree, std::vector< Bipartition > const &bipartitions, std::vector< TreeNode const *> const &nodes, bool include_splitting_edges, bool include_leaf_edges)
Find clades of the tree that are monophyletic with respect to the given list of nodes, that is, clades that only contain nodes from that list. Return all edge indices of those clades.
Header of Tree class.
std::vector< std::string > node_names(Tree const &tree, bool leaves_only)
Returns a list of all TreeNode names of a Tree.