A toolkit for working with phylogenetic data.
v0.22.1
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 
126  iterator_placements begin_placements();
127  const_iterator_placements begin_placements() const;
128 
129  iterator_placements end_placements();
130  const_iterator_placements end_placements() const;
131 
138 
144  utils::Range<const_iterator_placements> placements() const;
145 
146  std::vector<PqueryPlacement>& expose_placements();
147 
148  // -------------------------------------------------------------------
149  // Placement Accessors and Modifiers
150  // -------------------------------------------------------------------
151 
164  PqueryPlacement& add_placement( PlacementTreeEdge& edge );
165 
173  PqueryPlacement& add_placement( PqueryPlacement const& val );
174 
185  PqueryPlacement& add_placement(
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 
226  iterator_names begin_names();
227  const_iterator_names begin_names() const;
228 
229  iterator_names end_names();
230  const_iterator_names end_names() const;
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
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
One placement position of a Pquery on a Tree.
std::vector< PqueryPlacement >::iterator iterator_placements
Definition: pquery.hpp:93
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
A name of a Pquery and its multiplicity.
Definition: name.hpp:55
std::vector< PqueryName >::const_iterator const_iterator_names
Definition: pquery.hpp:97
std::vector< PqueryName > PqueryNames
Definition: pquery.hpp:91
std::vector< PqueryName >::iterator iterator_names
Definition: pquery.hpp:96
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops...
Definition: range.hpp:46
std::vector< PqueryPlacement > PqueryPlacements
Definition: pquery.hpp:90
Header of PqueryPlacement class.