Egglib 2.1.11
C++ library reference manual
BppDiversity.hpp
1 /*
2  Copyright 2008-2009,2013 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 #ifndef EGGLIB_BPPDIVERSITY_HPP
21 #define EGGLIB_BPPDIVERSITY_HPP
22 
23 #include <vector>
24 #include <Bpp/Seq/Alphabet/DNA.h>
25 #include <Bpp/Seq/Alphabet/RNA.h>
26 #include <Bpp/Seq/Alphabet/ProteicAlphabet.h>
27 #include <Bpp/Seq/Alphabet/CodonAlphabet.h>
28 #include <Bpp/Seq/GeneticCode/StandardGeneticCode.h>
29 #include <Bpp/Seq/GeneticCode/VertebrateMitochondrialGeneticCode.h>
30 #include <Bpp/Seq/GeneticCode/InvertebrateMitochondrialGeneticCode.h>
31 #include <Bpp/Seq/GeneticCode/EchinodermMitochondrialGeneticCode.h>
32 #include <Bpp/PopGen/SequenceStatistics.h>
33 #include "Align.hpp"
34 
35 namespace egglib {
36 
45  class BppDiversity {
46  public:
47 
51  BppDiversity();
52 
53 
57  virtual ~BppDiversity();
58 
59 
90  void load(Align& align, unsigned int dataType=1);
91 
92 
94  bool hasOutgroup() const;
95 
97  unsigned int S() const;
98 
100  unsigned int Sinf() const;
101 
103  unsigned int Ssin() const;
104 
106  unsigned int eta() const;
107 
109  unsigned int Sext() const;
110 
112  double He() const;
113 
115  double He2() const;
116 
118  //double GC() const;
119 
121  double tW() const;
122 
124  double T83() const;
125 
127  unsigned int K() const;
128 
130  double H() const;
131 
133  unsigned int Ti() const;
134 
136  unsigned int Tv() const;
137 
139  double TiTv() const;
140 
142  unsigned int nstop() const;
143 
145  unsigned int ncodon1mut() const;
146 
148  unsigned int nsyn() const;
149 
151  double tWS() const;
152 
154  double tWNS() const;
155 
157  double PiS() const;
158 
160  double PiNS() const;
161 
163  double Ssites() const;
164 
166  double NSsites() const;
167 
169  unsigned int SS() const;
170 
172  unsigned int SNS() const;
173 
175  const std::vector<unsigned int>& MK() const;
176 
178  double NI() const;
179 
181  double D() const;
182 
184  double Deta() const;
185 
187  double Dfl() const;
188 
190  double Dflstar() const;
191 
193  double F() const;
194 
196  double Fstar() const;
197 
199  double rhoH() const;
200 
201 
202  protected:
203 
204  // Initializes to default values
205  void reset();
206 
207  /* \brief Compute within-population statistics
208  *
209  * \param align the sequence alignment to analyze.
210  *
211  */
212  void computeSingle(bpp::AlignedSequenceContainer& align);
213 
214 
215  /* \brief Compute between-population statistics
216  *
217  * \param align1 the ingroup sequence alignment.
218  * \param align2 the outgroup sequence alignment.
219  *
220  */
221  void computeDouble(bpp::AlignedSequenceContainer& ingroup, bpp::AlignedSequenceContainer& outgroup);
222 
223 
224  // Bio++ stuff
225  bpp::DNA dna;
226  bpp::GeneticCode* p_code;
227  bpp::StandardGeneticCode* p_code4;
228  bpp::VertebrateMitochondrialGeneticCode* p_code5;
229  bpp::InvertebrateMitochondrialGeneticCode* p_code6;
230  bpp::EchinodermMitochondrialGeneticCode* p_code7;
231 
232  unsigned int v_Ss;
233  unsigned int v_Sinf;
234  unsigned int v_Ssin;
235  unsigned int v_eta;
236  unsigned int v_Sext;
237  double v_He;
238  double v_He2;
239  //double v_GC;
240  double v_tW;
241  double v_T83;
242  unsigned int v_K;
243  double v_H;
244  unsigned int v_Ti;
245  unsigned int v_Tv;
246  double v_TiTv;
247  unsigned int v_nstop;
248  unsigned int v_ncodon1mut;
249  unsigned int v_nsyn;
250  double v_tWS;
251  double v_tWNS;
252  double v_PiS;
253  double v_PiNS;
254  double v_Ssites;
255  double v_NSsites;
256  unsigned int v_SS;
257  unsigned int v_SNS;
258  std::vector<unsigned int> v_MK;
259  double v_NI;
260  double v_D;
261  double v_Deta;
262  double v_Dfl;
263  double v_Dflstar;
264  double v_F;
265  double v_Fstar;
266  double v_rhoH;
267 
268  // true if data loaded
269  bool b_loaded;
270  bool b_outgroup; // implies loaded
271  bool b_coding; // implies coding
272 
273 
274  private:
275 
277  BppDiversity(const BppDiversity& source) { }
278 
280  BppDiversity& operator=(const BppDiversity& source) { return *this; }
281 
282  };
283 }
284 
285 #endif
unsigned int K() const
Number of haplotypes.
Definition: BppDiversity.cpp:251
unsigned int Ti() const
Number of transitions.
Definition: BppDiversity.cpp:261
double Ssites() const
Average number of synonymous sites (if coding)
Definition: BppDiversity.cpp:318
unsigned int SNS() const
Non-synonymous polymorphic sites (if coding)
Definition: BppDiversity.cpp:336
double F() const
Fu's F (if an outgroup was used)
Definition: BppDiversity.cpp:377
double Dflstar() const
Fu and Li's D*.
Definition: BppDiversity.cpp:372
BppDiversity()
Builds an object.
Definition: BppDiversity.cpp:35
double T83() const
Tajima theta.
Definition: BppDiversity.cpp:246
double NSsites() const
Average number of non-synonymous sites (if coding)
Definition: BppDiversity.cpp:324
unsigned int S() const
Number of polymorphic sites.
Definition: BppDiversity.cpp:200
virtual ~BppDiversity()
Destroys an object.
Definition: BppDiversity.cpp:27
unsigned int eta() const
Minimal number of mutations.
Definition: BppDiversity.cpp:215
unsigned int ncodon1mut() const
Number of codon sites with one change (if coding)
Definition: BppDiversity.cpp:282
double He() const
Heterozygosity.
Definition: BppDiversity.cpp:226
unsigned int Tv() const
Number of transversions.
Definition: BppDiversity.cpp:266
unsigned int Ssin() const
Number of singleton sites.
Definition: BppDiversity.cpp:210
const std::vector< unsigned int > & MK() const
McDonald-Kreitman test table, as a vector (if coding + outgroup)
Definition: BppDiversity.cpp:342
double PiNS() const
Non-synonymous Pi (if coding)
Definition: BppDiversity.cpp:312
double H() const
Haplotypic diversity.
Definition: BppDiversity.cpp:256
double He2() const
Squared heterozygosity.
Definition: BppDiversity.cpp:231
unsigned int nstop() const
Number of codon sites with a stop codon (if coding)
Definition: BppDiversity.cpp:276
double Dfl() const
Fu and Li's D (if an outgroup was used)
Definition: BppDiversity.cpp:366
double Fstar() const
Fu's F*.
Definition: BppDiversity.cpp:383
double tW() const
Watterson theta.
Definition: BppDiversity.cpp:241
double TiTv() const
Transition/transversion ratio.
Definition: BppDiversity.cpp:271
unsigned int nsyn() const
Number of codon sites with a synonymous change (if coding)
Definition: BppDiversity.cpp:288
unsigned int SS() const
Aynonymous polymorphic sites (if coding)
Definition: BppDiversity.cpp:330
double tWNS() const
Non-synonymous Watterson theta (if coding)
Definition: BppDiversity.cpp:300
bool hasOutgroup() const
true if an ougroup was available
Definition: BppDiversity.cpp:196
double rhoH() const
Hudson's estimator of rho (recombination rate)
Definition: BppDiversity.cpp:388
Computes diversity statistics using third-party library Bio++.
Definition: BppDiversity.hpp:45
double NI() const
Neutrality index (if coding + outgroup)
Definition: BppDiversity.cpp:349
unsigned int Sinf() const
Number of parsimony informative sites.
Definition: BppDiversity.cpp:205
Definition: ABC.cpp:37
Handles a sequence alignment.
Definition: Align.hpp:76
unsigned int Sext() const
Mutations on external branches (if an outgroup was used)
Definition: BppDiversity.cpp:220
double tWS() const
Synonymous Watterson theta (if coding)
Definition: BppDiversity.cpp:294
double Deta() const
Tajima's D computed with eta instead of S.
Definition: BppDiversity.cpp:361
double D() const
Tajima's D.
Definition: BppDiversity.cpp:356
void load(Align &align, unsigned int dataType=1)
Performs polymorphism analysis using Bio++ tools.
Definition: BppDiversity.cpp:97
double PiS() const
Synonymous Pi (if coding)
Definition: BppDiversity.cpp:306

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