Simulating Mating Alliances as a Reproductive Tactic for Populations
 All Classes Functions Variables Friends
genetics.h
1 #ifndef DEF_GENETICS
2 #define DEF_GENETICS
3 #include "boost/multi_array.hpp"
4 #include <cassert>
5 #include "population.h"
6 
7 // file to make genetic stuff
8 
9 
10 typedef boost::multi_array<typeDNA, 2> array_type;
11 // site frequency spectrum SFS
12 
13 class DNA
14 {
15  public:
16  // *** constructor destructor *
17  DNA();
18  template <class T>
19  explicit DNA(Population<T> *pop)
20  {
21  N = pop -> get_nbHuman();
22  nbXcell = pop->get_crumbMt();
23  nbS = pop->get_sizeMt();
24  assert(nbXcell*32 == nbS);
25  if(N==1)
26  tab.resize(boost::extents[2][nbXcell]); // pb with multui_array
27  else
28  tab.resize(boost::extents[N][nbXcell]);
29  int nbFemale = pop -> get_nbFemale();
30  int currentG = pop -> get_generation();
31  currentG &= 1;
32  for(int i(0); i<N; ++i)
33  {
34  for(int j(0) ;j<nbXcell ;++j)
35  {
36  if(i < nbFemale)
37  tab[i][j] = pop -> female[currentG][i].mtDna[j];
38  else
39  tab[i][j] = pop -> male[currentG][i-nbFemale].mtDna[j];
40  }
41  }
42  }
43  DNA(Population<Humandna>* pop, int tdna);
44  DNA(DNA const & a);
45  DNA(DNA const & a, DNA const & b);
46  DNA(typeDNA* input,int size);
47  DNA(array_type const & input,int sizeN, int sizeX);
48  DNA(std::vector< std::vector<typeDNA> > input);
49  // DNA(typeDNA* input);
50  ~DNA();
51  friend std::ostream &operator<<(std::ostream&,DNA const&);
52  friend DNA operator+(DNA const&,DNA const&);
53  DNA& operator=(DNA const&);
54  int get_N() const;
55  int get_nbXcell() const;
56  int get_nbS() const;
57  long poly_sites() const;
58  double prop_poly_sites() const;
59  double mean_pw_diff() const;
60  double theta_waterson() const; //** Return Watterson's Theta for the population */
61  double theta_hom() const; //** Return a theta computed from the homozygiosity */
62  double theta_pi() const;
63  int nb_of_haplotypes() const;
64  DNA haplotypes() const;
65  std::vector<double> hap_frequency() const;
66  std::vector<double> site_frequency(int site) const;
67  double heterozigosity_hap() const;
68  double heterozigosity_sites() const;
69  double Neff(double theta, double mu) const;
70  double tajima_D() const;
71  std::vector<double> site_frequency_DNA(int site) const;
72  typeDNA dist_two(int a, int b) const;
73  void SFS(std::string filename) const;
74  void SFS_DNA(std::string filename) const;
75  void output_diversity(std::ofstream&) const;
76  void output_diversity_with_time(std::ofstream&,int Ntheo, int timeG) const;
77  void output_diversity(std::ofstream & fs, int Ntheo) const;
78  void output_arlequin(std::string filename) const;
79  void output_fasta(std::string filename) const;
80  private:
81  std::ostream & print(std::ostream&) const;
82  int N;
83  int nbXcell;
84  int nbS;
85  array_type tab;
86 };
87 std::vector< std::vector<typeDNA> > input_fasta(std::string filename);
88 void output_diversity_headline(std::ofstream &);
89 void output_diversity_headline_with_time(std::ofstream &);
90 #endif
void SFS_DNA(std::string filename) const
Definition: genetics.cpp:731
void output_diversity(std::ofstream &) const
typeDNA dist_two(int a, int b) const
Definition: genetics.cpp:615
int get_nbXcell() const
Definition: genetics.cpp:277
std::vector< double > site_frequency(int site) const
Definition: genetics.cpp:470
Definition: population.h:14
std::vector< double > site_frequency_DNA(int site) const
Definition: genetics.cpp:701
DNA haplotypes() const
Definition: genetics.cpp:416
DNA(Population< T > *pop)
Definition: genetics.h:19
double heterozigosity_hap() const
Definition: genetics.cpp:519
int nb_of_haplotypes() const
Definition: genetics.cpp:347
double tajima_D() const
Definition: genetics.cpp:605
double heterozigosity_sites() const
Definition: genetics.cpp:538
void output_fasta(std::string filename) const
Definition: genetics.cpp:790
std::vector< double > hap_frequency() const
Definition: genetics.cpp:353
long poly_sites() const
Definition: genetics.cpp:287
void output_arlequin(std::string filename) const
Definition: genetics.cpp:756
double Neff(double theta, double mu) const
Definition: genetics.cpp:565
DNA & operator=(DNA const &)
Definition: genetics.cpp:247
double prop_poly_sites() const
Definition: genetics.cpp:306
double mean_pw_diff() const
Definition: genetics.cpp:313
Definition: genetics.h:13
int get_sizeMt() const
Definition: population.h:409
void SFS(std::string filename) const
Definition: genetics.cpp:687
double theta_waterson() const
Definition: genetics.cpp:570
void output_diversity_with_time(std::ofstream &, int Ntheo, int timeG) const
Definition: genetics.cpp:677
int get_nbS() const
Definition: genetics.cpp:282

Home