Egglib 2.1.11
C++ library reference manual
Arg.hpp
1 /*
2  Copyright 2009-2010 Stéphane De Mita, Mathieu Siol
3 
4  This file is part of the EggLib library.
5 
6  EggLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  EggLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with EggLib. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #ifndef EGGLIB_ARG_HPP
22 #define EGGLIB_ARG_HPP
23 
24 
25 #include "Current.hpp"
26 #include "Edge.hpp"
27 #include <string>
28 
29 
45 namespace egglib {
46 
47  class Random;
48 
60  class Arg {
61 
62  public:
63 
69  Arg();
70 
71 
80  void set(Current* current, unsigned int numberOfSegments);
81 
82 
93  void reset(Current* current);
94 
95 
104  Arg(Current* current, unsigned int numberOfSegments);
105 
106 
112  virtual ~Arg();
113 
114 
118  double time() const;
119 
120 
124  void addTime(double increment);
125 
126 
138  void coalescence(double incr, unsigned int pop, unsigned int index1, unsigned int index2);
139 
140 
152  void coalescence(double incr, unsigned int pop, Random* random);
153 
154 
162  void recombination(double incr, Random* random);
163 
164 
184  Edge* mute(unsigned int segment, double treePosition);
185 
186 
195  inline double ageUltimateMRCA() const {
196  return _time;
197  }
198 
199 
211  inline double ageMRCA(unsigned int segmentIndex) {
212  return _MRCA[segmentIndex]->bottom;
213  }
214 
226  inline const Edge* MRCA(unsigned int segmentIndex) {
227  return _MRCA[segmentIndex];
228  }
229 
231 
232  inline const Edge* uMRCA() {
233  return edges[numberOfEdges-1];
234  }
235 
236 
238  unsigned int numberOfSegments;
239 
243  std::string newick(unsigned int segment);
244 
245 
247  unsigned int numberOfSamples;
248 
249 
253  double totalLength;
254 
258  double* segmentLengths;
259 
261  unsigned int numberOfEdges;
262 
265 
267  void set_actualNumberOfSites(unsigned int actualNumberOfSites);
268 
269 
270  private:
271 
273  Arg(const Arg&) { }
274 
276  Arg& operator=(const Arg&) { return *this; }
277 
278  void init_stable_parameters();
279  void init_variable_parameters();
280  void clear();
281  void addEdge(Edge*);
282  std::string rnewick(Edge* edge, unsigned int segment, double cache);
283 
284  Current* current;
285  double _time;
286  Edge** edges;
287 
288  void findMRCA(unsigned int segmentIndex);
289  void computeTotalLength();
290  void computeSegmentLength(unsigned int segmentIndex);
291 
292  unsigned int* numberOfEdgesPerSegment;
293  Edge** _MRCA;
294 
295  EdgePool edgePool;
296  };
297 
298 }
299 
300 #endif
void reset(Current *current)
Object reset method.
Definition: Arg.cpp:104
Pseudo-random number generator.
Definition: Random.hpp:41
double bottom
Time position of the branch's bottom.
Definition: Edge.hpp:129
void addTime(double increment)
Increments the time counter.
Definition: Arg.cpp:148
const Edge * MRCA(unsigned int segmentIndex)
MRCA for each segment.
Definition: Arg.hpp:226
void set(Current *current, unsigned int numberOfSegments)
Object initialization.
Definition: Arg.cpp:77
double ageUltimateMRCA() const
Age of the uMRCA.
Definition: Arg.hpp:195
Represents the current set of populations.
Definition: Current.hpp:34
double * segmentLengths
Segment-specific tree length.
Definition: Arg.hpp:258
void recombination(double incr, Random *random)
Performs a recombination event.
Definition: Arg.cpp:200
void coalescence(double incr, unsigned int pop, unsigned int index1, unsigned int index2)
Performs a coalescence event.
Definition: Arg.cpp:153
unsigned int numberOfSamples
Number of initial lineages.
Definition: Arg.hpp:247
double totalLength
Total tree length (summed over all segments)
Definition: Arg.hpp:253
const Edge * uMRCA()
Ultimate MRCA.
Definition: Arg.hpp:232
unsigned int numberOfEdges
Current number of Edges in the tree (including the MRCA node)
Definition: Arg.hpp:261
virtual ~Arg()
Destructor.
Definition: Arg.cpp:61
void set_actualNumberOfSites(unsigned int actualNumberOfSites)
Set the number of actual sites in all branches.
Definition: Arg.cpp:344
std::string newick(unsigned int segment)
Formats the newick-formatted tree for a segment.
Definition: Arg.cpp:273
Edge of the ancestral recombination graph.
Definition: Edge.hpp:49
unsigned int numberOfSegments
the number of recombining segments
Definition: Arg.hpp:238
Definition: ABC.cpp:37
Edge * mute(unsigned int segment, double treePosition)
Places a mutation.
Definition: Arg.cpp:243
unsigned int numberOfRecombinationEvents
Total number of recombination events that occurred.
Definition: Arg.hpp:264
Arg()
Default constructor.
Definition: Arg.cpp:48
Ancestral recombination graph.
Definition: Arg.hpp:60
double ageMRCA(unsigned int segmentIndex)
Age of the MRCA for a given segment.
Definition: Arg.hpp:211
double time() const
Gets the current value of the time counter.
Definition: Arg.cpp:143

Hosted by 
Get EggLib at SourceForge.net. Fast, secure and Free Open Source software downloads