A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2018 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
PqueryName & name_at(size_t index)
Return the PqueryName at a certain index.
Definition: pquery.cpp:198
Pquery & operator=(Pquery const &)=default
void clear()
Clear all data stored in this Pquery, i.e., clear all PqueryNames and all PqueryPlacements.
Definition: pquery.cpp:43
size_t name_size() const
Return the number of PqueryNames stored in this Pquery.
Definition: pquery.cpp:193
std::vector< PqueryPlacement >::const_iterator const_iterator_placements
Definition: pquery.hpp:94
A pquery holds a set of PqueryPlacements and a set of PqueryNames.
Definition: pquery.hpp:82
iterator_names end_names()
Definition: pquery.cpp:147
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
void remove_placement_at(size_t index)
Remove the PqueryPlacement at a certain index position within this Pquery.
Definition: pquery.cpp:128
One placement position of a Pquery on a Tree.
PqueryPlacement & placement_at(size_t index)
Return the PqueryPlacement at a certain index.
Definition: pquery.cpp:118
iterator_placements end_placements()
Definition: pquery.cpp:58
void clear_names()
Delete all PqueryNames of this Pquery.
Definition: pquery.cpp:213
std::vector< PqueryPlacement >::iterator iterator_placements
Definition: pquery.hpp:93
std::vector< PqueryPlacement > & expose_placements()
Definition: pquery.cpp:83
utils::Range< iterator_placements > placements()
Return a Range iterator to the PqueryPlacements.
Definition: pquery.cpp:73
A name of a Pquery and its multiplicity.
Definition: name.hpp:55
size_t placement_size() const
Return the number of PqueryPlacements stored in this Pquery.
Definition: pquery.cpp:113
std::vector< PqueryName >::const_iterator const_iterator_names
Definition: pquery.hpp:97
iterator_names begin_names()
Definition: pquery.cpp:142
void remove_name_at(size_t index)
Remove the PqueryName at a certain index position within this Pquery.
Definition: pquery.cpp:208
std::vector< PqueryName > PqueryNames
Definition: pquery.hpp:91
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
iterator_placements begin_placements()
Definition: pquery.cpp:53
std::vector< PqueryName >::iterator iterator_names
Definition: pquery.hpp:96
void clear_placements()
Delete all PqueryPlacements of this Pquery.
Definition: pquery.cpp:133
utils::Range< iterator_names > names()
Return a Range iterator to the PqueryNames.
Definition: pquery.cpp:162
std::vector< PqueryName > & expose_names()
Definition: pquery.cpp:172
std::vector< PqueryPlacement > PqueryPlacements
Definition: pquery.hpp:90
Header of PqueryPlacement class.