A toolkit for working with phylogenetic data.
v0.18.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-2017 Lucas Czech
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 
116  void clear();
117 
118  // -------------------------------------------------------------------
119  // Placement Iterators
120  // -------------------------------------------------------------------
121 
124 
127 
130 
131  // -------------------------------------------------------------------
132  // Placement Accessors and Modifiers
133  // -------------------------------------------------------------------
134 
137 
139  PlacementTreeEdge & edge,
140  PqueryPlacement const& val
141  );
142 
143  size_t placement_size() const;
144 
145  PqueryPlacement & placement_at( size_t index );
146  PqueryPlacement const& placement_at( size_t index ) const;
147 
148  void remove_placement_at( size_t index );
149  void clear_placements();
150 
151  // -------------------------------------------------------------------
152  // Name Iterators
153  // -------------------------------------------------------------------
154 
157 
160 
163 
164  // -------------------------------------------------------------------
165  // Name Accessors and Modifiers
166  // -------------------------------------------------------------------
167 
168  PqueryName& add_name( std::string name = "", double multiplicity = 1.0 );
169  PqueryName& add_name( PqueryName const& other );
170 
171  size_t name_size() const;
172 
173  PqueryName & name_at( size_t index );
174  PqueryName const& name_at( size_t index ) const;
175 
176  void remove_name_at( size_t index );
177  void clear_names();
178 
179  // -------------------------------------------------------------------
180  // Data Members
181  // -------------------------------------------------------------------
182 
183 private:
184 
185  std::vector<PqueryPlacement> placements_;
186  std::vector<PqueryName> names_;
187 
188 };
189 
190 } // namespace placement
191 } // namespace genesis
192 
193 #endif // include guard
PqueryName & name_at(size_t index)
Return the PqueryName at a certain index.
Definition: pquery.cpp:283
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: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
A pquery holds a set of PqueryPlacements and a set of PqueryNames.
Definition: pquery.hpp:82
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
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
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: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
std::vector< PqueryPlacement > PqueryPlacements
Definition: pquery.hpp:90
Header of PqueryPlacement class.