A library for working with phylogenetic and population genetic data.
v0.27.0
placement_tree.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_PLACEMENT_PLACEMENT_TREE_H_
2 #define GENESIS_PLACEMENT_PLACEMENT_TREE_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2019 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 <string>
35 
37 #include "genesis/tree/tree.hpp"
38 
39 namespace genesis {
40 namespace placement {
41 
42 // =================================================================================================
43 // Typedefs
44 // =================================================================================================
45 
57 using PlacementTree = tree::Tree;
58 
64 
70 
75 
76 // =================================================================================================
77 // Placement Tree Node Data
78 // =================================================================================================
79 
88 {
89  // -------------------------------------------------------------------
90  // Constructor and Rule of Five
91  // -------------------------------------------------------------------
92 
93 public:
94 
95  virtual ~PlacementNodeData() override = default;
96 
97  // Move ctor and assignment.
100 
101 protected:
102 
103  PlacementNodeData() = default;
104 
105  // Copy ctor and assignment.
106  PlacementNodeData( PlacementNodeData const& ) = default;
107  PlacementNodeData& operator= ( PlacementNodeData const& ) = default;
108 
109 public:
110 
111  static std::unique_ptr< PlacementNodeData > create()
112  {
113  return std::unique_ptr< PlacementNodeData >( new PlacementNodeData() );
114  }
115 
116  virtual std::unique_ptr< BaseNodeData > recreate() const override
117  {
118  return std::unique_ptr< PlacementNodeData >( new PlacementNodeData() );
119  }
120 
121  virtual std::unique_ptr< BaseNodeData > clone() const override
122  {
123  return std::unique_ptr< PlacementNodeData >( new PlacementNodeData( *this ));
124  }
125 
126 };
127 
128 // =================================================================================================
129 // Placement Tree Edge Data
130 // =================================================================================================
131 
140 {
141 public:
142 
143  // -------------------------------------------------------------------
144  // Typedefs and Enums
145  // -------------------------------------------------------------------
146 
150  using EdgeNumType = int;
151 
152  // -------------------------------------------------------------------
153  // Constructor and Rule of Five
154  // -------------------------------------------------------------------
155 
156  virtual ~PlacementEdgeData() override = default;
157 
158  // Move ctor and assignment.
159  PlacementEdgeData( PlacementEdgeData&& ) = delete;
161 
162 protected:
163 
164  PlacementEdgeData() = default;
165 
166  // Copy ctor and assignment.
167  PlacementEdgeData( PlacementEdgeData const& ) = default;
168  PlacementEdgeData& operator= ( PlacementEdgeData const& ) = default;
169 
170 public:
171 
172  static std::unique_ptr< PlacementEdgeData > create()
173  {
174  return std::unique_ptr< PlacementEdgeData >( new PlacementEdgeData() );
175  }
176 
177  virtual std::unique_ptr< BaseEdgeData > recreate() const override
178  {
179  return std::unique_ptr< PlacementEdgeData >( new PlacementEdgeData() );
180  }
181 
182  virtual std::unique_ptr< BaseEdgeData > clone() const override
183  {
184  return std::unique_ptr< PlacementEdgeData >( new PlacementEdgeData( *this ));
185  }
186 
187  // -----------------------------------------------------
188  // Data Functions
189  // -----------------------------------------------------
190 
195  {
196  return edge_num_;
197  }
198 
206  {
207  edge_num_ = val;
208  }
209 
210  // -----------------------------------------------------
211  // Data Members
212  // -----------------------------------------------------
213 
214 private:
215 
216  EdgeNumType edge_num_;
217 };
218 
219 } // namespace placement
220 } // namespace genesis
221 
222 #endif // include guard
genesis::placement::PlacementNodeData::clone
virtual std::unique_ptr< BaseNodeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
Definition: placement_tree.hpp:121
genesis::placement::PlacementNodeData::PlacementNodeData
PlacementNodeData()=default
genesis::placement::PlacementEdgeData::edge_num
EdgeNumType edge_num() const
Return the edge_num of this edge. This value is defined by the jplace standard.
Definition: placement_tree.hpp:194
genesis::placement::PlacementEdgeData::~PlacementEdgeData
virtual ~PlacementEdgeData() override=default
tree.hpp
Header of Tree class.
genesis::placement::PlacementEdgeData::create
static std::unique_ptr< PlacementEdgeData > create()
Definition: placement_tree.hpp:172
genesis::placement::PlacementEdgeData::clone
virtual std::unique_ptr< BaseEdgeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
Definition: placement_tree.hpp:182
genesis::placement::PlacementNodeData::operator=
PlacementNodeData & operator=(PlacementNodeData &&)=delete
genesis::placement::PlacementEdgeData
Data class for PlacementTreeEdges. Stores the branch length of the edge, and the edge_num,...
Definition: placement_tree.hpp:139
genesis::placement::PlacementEdgeData::PlacementEdgeData
PlacementEdgeData()=default
genesis::placement::PlacementEdgeData::reset_edge_num
void reset_edge_num(EdgeNumType val)
Force to set the edge_num to a certain value.
Definition: placement_tree.hpp:205
genesis::placement::PlacementNodeData
Data class for PlacementTreeNodes. Stores a node name.
Definition: placement_tree.hpp:87
genesis::placement::PlacementNodeData::~PlacementNodeData
virtual ~PlacementNodeData() override=default
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::TreeEdge
Definition: edge.hpp:60
genesis::tree::TreeNode
Definition: tree/tree/node.hpp:58
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
tree.hpp
genesis::placement::PlacementEdgeData::operator=
PlacementEdgeData & operator=(PlacementEdgeData &&)=delete
genesis::tree::CommonEdgeData
Common class containing the commonly needed data for tree edges.
Definition: tree/common_tree/tree.hpp:144
genesis::tree::CommonNodeData
Common class containing the commonly needed data for tree nodes.
Definition: tree/common_tree/tree.hpp:79
genesis::placement::PlacementNodeData::recreate
virtual std::unique_ptr< BaseNodeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
Definition: placement_tree.hpp:116
genesis::placement::PlacementEdgeData::EdgeNumType
int EdgeNumType
Data type used for the edge_num() property of the edges in a PlacementTree.
Definition: placement_tree.hpp:150
genesis::placement::PlacementEdgeData::recreate
virtual std::unique_ptr< BaseEdgeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
Definition: placement_tree.hpp:177
genesis::placement::PlacementNodeData::create
static std::unique_ptr< PlacementNodeData > create()
Definition: placement_tree.hpp:111