A toolkit for working with phylogenetic data.
v0.24.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
Data class for PlacementTreeEdges. Stores the branch length of the edge, and the edge_num, as defined in the jplace standard.
virtual ~PlacementNodeData() override=default
void reset_edge_num(EdgeNumType val)
Force to set the edge_num to a certain value.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
int EdgeNumType
Data type used for the edge_num() property of the edges in a PlacementTree.
tree::Tree PlacementTree
Alias for a tree::Tree used for a tree with information needed for storing Pqueries. This kind of tree is used by Sample.
virtual std::unique_ptr< BaseNodeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
virtual std::unique_ptr< BaseEdgeData > recreate() const override
Polymorphically create a default-constructed instance of this class with the same derived type as it ...
virtual std::unique_ptr< BaseEdgeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
static std::unique_ptr< PlacementEdgeData > create()
virtual std::unique_ptr< BaseNodeData > clone() const override
Polymorphically copy an instance of this class. Use instead of copy constructor.
Data class for PlacementTreeNodes. Stores a node name.
Common class containing the commonly needed data for tree nodes.
static std::unique_ptr< PlacementNodeData > create()
PlacementNodeData & operator=(PlacementNodeData &&)=delete
Header of Tree class.
EdgeNumType edge_num() const
Return the edge_num of this edge. This value is defined by the jplace standard.
Common class containing the commonly needed data for tree edges.