A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2017 Lucas Czech
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() = 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  // -------------------------------------------------------------------
142  // Constructor and Rule of Five
143  // -------------------------------------------------------------------
144 
145 public:
146 
147  virtual ~PlacementEdgeData() = default;
148 
149  // Move ctor and assignment.
150  PlacementEdgeData( PlacementEdgeData&& ) = delete;
152 
153 protected:
154 
155  PlacementEdgeData() = default;
156 
157  // Copy ctor and assignment.
158  PlacementEdgeData( PlacementEdgeData const& ) = default;
159  PlacementEdgeData& operator= ( PlacementEdgeData const& ) = default;
160 
161 public:
162 
163  static std::unique_ptr< PlacementEdgeData > create()
164  {
165  return std::unique_ptr< PlacementEdgeData >( new PlacementEdgeData() );
166  }
167 
168  virtual std::unique_ptr< BaseEdgeData > recreate() const override
169  {
170  return std::unique_ptr< PlacementEdgeData >( new PlacementEdgeData() );
171  }
172 
173  virtual std::unique_ptr< BaseEdgeData > clone() const override
174  {
175  return std::unique_ptr< PlacementEdgeData >( new PlacementEdgeData( *this ));
176  }
177 
178  // -----------------------------------------------------
179  // Data Functions
180  // -----------------------------------------------------
181 
182  int edge_num() const;
183  void reset_edge_num( int val );
184 
185  // -----------------------------------------------------
186  // Data Members
187  // -----------------------------------------------------
188 
189 private:
190 
191  int edge_num_;
192 };
193 
194 } // namespace placement
195 } // namespace genesis
196 
197 #endif // include guard
Data class for PlacementTreeEdges. Stores the branch length of the edge, and the edge_num, as defined in the jplace standard.
Default class containing the commonly needed data for tree nodes.
void reset_edge_num(int val)
Force to set the edge_num to a certain value.
Default class containing the commonly needed data for tree edges.
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.
static std::unique_ptr< PlacementNodeData > create()
PlacementEdgeData & operator=(PlacementEdgeData &&)=delete
PlacementNodeData & operator=(PlacementNodeData &&)=delete
Header of Tree class.
int edge_num() const
Return the edge_num of this edge. This value is defined by the jplace standard.