A toolkit for working with phylogenetic data.
v0.24.0
placement/pquery/placement.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_PLACEMENT_PQUERY_PLACEMENT_H_
2 #define GENESIS_PLACEMENT_PQUERY_PLACEMENT_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 
35 
36 namespace genesis {
37 
38 // =================================================================================================
39 // Forward Declarations
40 // =================================================================================================
41 
42 namespace tree {
43 
44  class TreeEdge;
45 
46 }
47 
48 namespace placement {
49 
50  using PlacementTreeEdge = tree::TreeEdge;
51 
52  class PlacementEdgeData;
53  class PlacementNodeData;
54  class Pquery;
55 
56 }
57 
58 // =================================================================================================
59 // Pquery Placement
60 // =================================================================================================
61 
62 namespace placement {
63 
76 {
77 public:
78 
79  // -------------------------------------------------------------------
80  // Constructor and Rule of Five
81  // -------------------------------------------------------------------
82 
87  : likelihood(0.0)
88  , like_weight_ratio(0.0)
89  , proximal_length(0.0)
90  , pendant_length(0.0)
91  , edge_(nullptr)
92  {}
93 
98  : likelihood(0.0)
99  , like_weight_ratio(0.0)
100  , proximal_length(0.0)
101  , pendant_length(0.0)
102  , edge_(&edge)
103  {}
104 
105  ~PqueryPlacement() = default;
106 
107  PqueryPlacement( PqueryPlacement const& ) = default;
108  PqueryPlacement( PqueryPlacement&& ) = default;
109 
110  PqueryPlacement& operator= ( PqueryPlacement const& ) = default;
111  PqueryPlacement& operator= ( PqueryPlacement&& ) = default;
112 
113  // -------------------------------------------------------------------
114  // Public Property Data Members
115  // -------------------------------------------------------------------
116 
117  // Yes, the following members are public data members. It's neither nice nor consistent,
118  // but makes life so much easier for the moment. Maybe we'll fix that in the future...
119 
125  double likelihood;
126 
138 
156 
166 
167  // Additional properties that are defined by the `jplace` standard. They are currently not used
168  // by any genesis function, so we completely ignore them in order to save memory.
169  // double parsimony;
170  // double post_prob;
171  // double marginal_like; // or marginal_prob in jplace version 1
172  // std::string classification;
173  // double map_ratio;
174  // double map_overlap;
175 
176  // -------------------------------------------------------------------
177  // Properties
178  // -------------------------------------------------------------------
179 
187  {
188  return edge_->data<PlacementEdgeData>().edge_num();
189  }
190 
194  PlacementTreeEdge const& edge() const
195  {
196  return *edge_;
197  }
198 
203  {
204  return *edge_;
205  }
206 
216  {
217  edge_ = &edge;
218  }
219 
220  // -------------------------------------------------------------------
221  // Data Members
222  // -------------------------------------------------------------------
223 
224 private:
225 
226  PlacementTreeEdge* edge_;
227 };
228 
229 } // namespace placement
230 } // namespace genesis
231 
232 #endif // include guard
PlacementTreeEdge const & edge() const
Get the PlacementTreeEdge where this PqueryPlacement is placed.
double proximal_length
Distance of this placement to the next node towards the root.
Data class for PlacementTreeEdges. Stores the branch length of the edge, and the edge_num, as defined in the jplace standard.
PlacementEdgeData::EdgeNumType edge_num() const
Get the edge_num where this PqueryPlacement is placed.
One placement position of a Pquery on a Tree.
PlacementTreeEdge & edge()
Get the PlacementTreeEdge where this PqueryPlacement is placed.
PqueryPlacement()
Default constructor. Sets all values to 0.
tree::TreeEdge PlacementTreeEdge
Alias for tree::TreeEdge used in a PlacementTree. See PlacementEdgeData for the data stored on the ed...
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.
PqueryPlacement(PlacementTreeEdge &edge)
Constructor that takes the edge where this placement is being placed at.
void reset_edge(PlacementTreeEdge &edge)
Set the PlacementTreeEdge at which this PqueryPlacement is placed.
double pendant_length
Length of the attached branch of this placement.
double like_weight_ratio
Likelihood weight ratio of this placement.
double likelihood
Total likelihood of the tree with this placement attached to it.