A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pquery.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2017 Lucas Czech
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lucas.czech@h-its.org>
20  Exelixis Lab, Heidelberg Institute for Theoretical Studies
21  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
22 */
23 
32 
35 
36 namespace genesis {
37 namespace placement {
38 
39 // =============================================================================
40 // General Modifiers
41 // =============================================================================
42 
48 {
50  clear_names();
51 }
52 
53 // =============================================================================
54 // Placement Iterators
55 // =============================================================================
56 
58 {
59  return placements_.begin();
60 }
61 
63 {
64  return placements_.end();
65 }
66 
68 {
69  return placements_.cbegin();
70 }
71 
73 {
74  return placements_.cend();
75 }
76 
83 {
84  return { placements_ };
85 }
86 
93 {
94  return { placements_ };
95 }
96 
97 // =============================================================================
98 // Placement Accessors and Modifiers
99 // =============================================================================
100 
114 {
115  placements_.emplace_back( edge );
116  return placements_.back();
117 }
118 
127 {
128  placements_.emplace_back( val );
129  return placements_.back();
130 }
131 
143  PlacementTreeEdge & edge,
144  PqueryPlacement const& val
145 ) {
146  placements_.emplace_back( val );
147  placements_.back().reset_edge( edge );
148  return placements_.back();
149 }
150 
155 {
156  return placements_.size();
157 }
158 
165 {
166  return placements_[index];
167 }
168 
174 PqueryPlacement const& Pquery::placement_at( size_t index ) const
175 {
176  return placements_[index];
177 }
178 
185 void Pquery::remove_placement_at( size_t index )
186 {
187  placements_.erase( placements_.begin() + index );
188 }
189 
194 {
195  placements_.clear();
196 }
197 
198 // =============================================================================
199 // Name Iterators
200 // =============================================================================
201 
203 {
204  return names_.begin();
205 }
206 
208 {
209  return names_.end();
210 }
211 
213 {
214  return names_.cbegin();
215 }
216 
218 {
219  return names_.cend();
220 }
221 
228 {
229  return { names_ };
230 }
231 
238 {
239  return { names_ };
240 }
241 
242 // =============================================================================
243 // Name Accessors and Modifiers
244 // =============================================================================
245 
252 PqueryName& Pquery::add_name( std::string name, double multiplicity )
253 {
254  names_.emplace_back( name, multiplicity );
255  return names_.back();
256 }
257 
265 {
266  names_.push_back( PqueryName(other) );
267  return names_.back();
268 }
269 
273 size_t Pquery::name_size() const
274 {
275  return names_.size();
276 }
277 
283 PqueryName& Pquery::name_at( size_t index )
284 {
285  return names_.at(index);
286 }
287 
293 PqueryName const& Pquery::name_at( size_t index ) const
294 {
295  return names_.at(index);
296 }
297 
304 void Pquery::remove_name_at( size_t index )
305 {
306  names_.erase( names_.begin() + index );
307 }
308 
313 {
314  names_.clear();
315 }
316 
317 } // namespace placement
318 } // namespace genesis
PqueryName & name_at(size_t index)
Return the PqueryName at a certain index.
Definition: pquery.cpp:283
void clear()
Clear all data stored in this Pquery, i.e., clear all PqueryNames and all PqueryPlacements.
Definition: pquery.cpp:47
size_t name_size() const
Return the number of PqueryNames stored in this Pquery.
Definition: pquery.cpp:273
std::vector< PqueryPlacement >::const_iterator const_iterator_placements
Definition: pquery.hpp:94
iterator_names end_names()
Definition: pquery.cpp:207
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:252
void remove_placement_at(size_t index)
Remove the PqueryPlacement at a certain index position within this Pquery.
Definition: pquery.cpp:185
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:164
iterator_placements end_placements()
Definition: pquery.cpp:62
void clear_names()
Delete all PqueryNames of this Pquery.
Definition: pquery.cpp:312
std::vector< PqueryPlacement >::iterator iterator_placements
Definition: pquery.hpp:93
Provides some valuable additions to STD.
utils::Range< iterator_placements > placements()
Return a Range iterator to the PqueryPlacements.
Definition: pquery.cpp:82
A name of a Pquery and its multiplicity.
Definition: name.hpp:61
size_t placement_size() const
Return the number of PqueryPlacements stored in this Pquery.
Definition: pquery.cpp:154
std::vector< PqueryName >::const_iterator const_iterator_names
Definition: pquery.hpp:97
iterator_names begin_names()
Definition: pquery.cpp:202
void remove_name_at(size_t index)
Remove the PqueryName at a certain index position within this Pquery.
Definition: pquery.cpp:304
PqueryPlacement & add_placement(PlacementTreeEdge &edge)
Create a new PqueryPlacement at a given PlacementTreeEdge, add it to the Pquery and return it...
Definition: pquery.cpp:113
iterator_placements begin_placements()
Definition: pquery.cpp:57
std::vector< PqueryName >::iterator iterator_names
Definition: pquery.hpp:96
void clear_placements()
Delete all PqueryPlacements of this Pquery.
Definition: pquery.cpp:193
utils::Range< iterator_names > names()
Return a Range iterator to the PqueryNames.
Definition: pquery.cpp:227