A library for working with phylogenetic and population genetic data.
v0.32.0
pquery.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_PLACEMENT_PQUERY_H_
2 #define GENESIS_PLACEMENT_PQUERY_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 <memory>
35 #include <string>
36 #include <vector>
37 
40 
42 
43 namespace genesis {
44 
45 // =================================================================================================
46 // Forward Declarations
47 // =================================================================================================
48 
49 namespace tree {
50 
51  class TreeEdge;
52 
53 }
54 
55 namespace placement {
56 
57  class PlacementEdgeData;
58  class PlacementNodeData;
59 
60 }
61 
62 // =================================================================================================
63 // Pquery
64 // =================================================================================================
65 
66 namespace placement {
67 
82 class Pquery
83 {
84 public:
85 
86  // -------------------------------------------------------------------
87  // Typedefs
88  // -------------------------------------------------------------------
89 
90  typedef std::vector<PqueryPlacement> PqueryPlacements;
91  typedef std::vector<PqueryName> PqueryNames;
92 
93  typedef std::vector<PqueryPlacement>::iterator iterator_placements;
94  typedef std::vector<PqueryPlacement>::const_iterator const_iterator_placements;
95 
96  typedef std::vector<PqueryName>::iterator iterator_names;
97  typedef std::vector<PqueryName>::const_iterator const_iterator_names;
98 
99  // -------------------------------------------------------------------
100  // Constructor and Rule of Five
101  // -------------------------------------------------------------------
102 
103  Pquery () = default;
104  ~Pquery() = default;
105 
106  Pquery( Pquery const& ) = default;
107  Pquery( Pquery&& ) = default;
108 
109  Pquery& operator= ( Pquery const& ) = default;
110  Pquery& operator= ( Pquery&& ) = default;
111 
112  // -------------------------------------------------------------------
113  // General Modifiers
114  // -------------------------------------------------------------------
115 
120  void clear();
121 
122  // -------------------------------------------------------------------
123  // Placement Iterators
124  // -------------------------------------------------------------------
125 
128 
131 
138 
145 
146  std::vector<PqueryPlacement>& expose_placements();
147 
148  // -------------------------------------------------------------------
149  // Placement Accessors and Modifiers
150  // -------------------------------------------------------------------
151 
165 
174 
186  PlacementTreeEdge & edge,
187  PqueryPlacement const& val
188  );
189 
193  size_t placement_size() const;
194 
200  PqueryPlacement & placement_at( size_t index );
201 
207  PqueryPlacement const& placement_at( size_t index ) const;
208 
215  void remove_placement_at( size_t index );
216 
220  void clear_placements();
221 
222  // -------------------------------------------------------------------
223  // Name Iterators
224  // -------------------------------------------------------------------
225 
228 
231 
238 
245 
246  std::vector<PqueryName>& expose_names();
247 
248  // -------------------------------------------------------------------
249  // Name Accessors and Modifiers
250  // -------------------------------------------------------------------
251 
258  PqueryName& add_name( std::string name = "", double multiplicity = 1.0 );
259 
266  PqueryName& add_name( PqueryName const& other );
267 
271  size_t name_size() const;
272 
278  PqueryName & name_at( size_t index );
279 
285  PqueryName const& name_at( size_t index ) const;
286 
293  void remove_name_at( size_t index );
294 
298  void clear_names();
299 
300  // -------------------------------------------------------------------
301  // Data Members
302  // -------------------------------------------------------------------
303 
304 private:
305 
306  std::vector<PqueryPlacement> placements_;
307  std::vector<PqueryName> names_;
308 
309 };
310 
311 } // namespace placement
312 } // namespace genesis
313 
314 #endif // include guard
genesis::placement::Pquery::clear_placements
void clear_placements()
Delete all PqueryPlacements of this Pquery.
Definition: pquery.cpp:133
genesis::placement::Pquery::name_size
size_t name_size() const
Return the number of PqueryNames stored in this Pquery.
Definition: pquery.cpp:193
placement.hpp
Header of PqueryPlacement class.
genesis::placement::Pquery::remove_name_at
void remove_name_at(size_t index)
Remove the PqueryName at a certain index position within this Pquery.
Definition: pquery.cpp:208
genesis::placement::Pquery::begin_names
iterator_names begin_names()
Definition: pquery.cpp:142
genesis::placement::Pquery::Pquery
Pquery()=default
genesis::placement::Pquery::operator=
Pquery & operator=(Pquery const &)=default
genesis::placement::Pquery::remove_placement_at
void remove_placement_at(size_t index)
Remove the PqueryPlacement at a certain index position within this Pquery.
Definition: pquery.cpp:128
genesis::placement::Pquery::name_at
PqueryName & name_at(size_t index)
Return the PqueryName at a certain index.
Definition: pquery.cpp:198
name.hpp
genesis::placement::Pquery::begin_placements
iterator_placements begin_placements()
Definition: pquery.cpp:53
genesis::placement::Pquery::iterator_placements
std::vector< PqueryPlacement >::iterator iterator_placements
Definition: pquery.hpp:93
genesis::placement::Pquery::clear
void clear()
Clear all data stored in this Pquery, i.e., clear all PqueryNames and all PqueryPlacements.
Definition: pquery.cpp:43
genesis::placement::Pquery::~Pquery
~Pquery()=default
genesis::placement::Pquery::placement_at
PqueryPlacement & placement_at(size_t index)
Return the PqueryPlacement at a certain index.
Definition: pquery.cpp:118
genesis::placement::Pquery
A pquery holds a set of PqueryPlacements and a set of PqueryNames.
Definition: pquery.hpp:82
range.hpp
genesis::placement::Pquery::add_name
PqueryName & add_name(std::string name="", double multiplicity=1.0)
Create a new PqueryName using the provided parameters, add it to the Pquery and return it.
Definition: pquery.cpp:181
genesis::placement::Pquery::end_names
iterator_names end_names()
Definition: pquery.cpp:147
genesis::placement::Pquery::PqueryNames
std::vector< PqueryName > PqueryNames
Definition: pquery.hpp:91
genesis::placement::Pquery::const_iterator_placements
std::vector< PqueryPlacement >::const_iterator const_iterator_placements
Definition: pquery.hpp:94
genesis::tree::TreeEdge
Definition: edge.hpp:60
genesis::utils::Range
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops.
Definition: range.hpp:46
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
genesis::placement::Pquery::names
utils::Range< iterator_names > names()
Return a Range iterator to the PqueryNames.
Definition: pquery.cpp:162
genesis::placement::Pquery::placements
utils::Range< iterator_placements > placements()
Return a Range iterator to the PqueryPlacements.
Definition: pquery.cpp:73
genesis::placement::Pquery::placement_size
size_t placement_size() const
Return the number of PqueryPlacements stored in this Pquery.
Definition: pquery.cpp:113
genesis::placement::Pquery::clear_names
void clear_names()
Delete all PqueryNames of this Pquery.
Definition: pquery.cpp:213
genesis::placement::Pquery::iterator_names
std::vector< PqueryName >::iterator iterator_names
Definition: pquery.hpp:96
genesis::placement::Pquery::PqueryPlacements
std::vector< PqueryPlacement > PqueryPlacements
Definition: pquery.hpp:90
genesis::placement::Pquery::expose_names
std::vector< PqueryName > & expose_names()
Definition: pquery.cpp:172
genesis::placement::PqueryName
A name of a Pquery and its multiplicity.
Definition: name.hpp:55
genesis::placement::Pquery::end_placements
iterator_placements end_placements()
Definition: pquery.cpp:58
genesis::placement::PqueryPlacement
One placement position of a Pquery on a Tree.
Definition: placement/pquery/placement.hpp:75
genesis::placement::Pquery::add_placement
PqueryPlacement & add_placement(PlacementTreeEdge &edge)
Create a new PqueryPlacement at a given PlacementTreeEdge, add it to the Pquery and return it.
Definition: pquery.cpp:92
genesis::placement::Pquery::const_iterator_names
std::vector< PqueryName >::const_iterator const_iterator_names
Definition: pquery.hpp:97
genesis::placement::Pquery::expose_placements
std::vector< PqueryPlacement > & expose_placements()
Definition: pquery.cpp:83