mapgd  0.4
A program for the Maximum-likelihood analysis of population genomic data.
 All Data Structures Functions Variables Friends Groups Pages
quartet.h
1 #ifndef QUARTET_H_
2 #define QUARTET_H_
3 
4 #include "typedef.h"
5 #include "base.h"
6 
7 #include <sstream>
8 #include <cstring>
9 #include <iostream>
10 #include <iomanip>
11 
13 
16 typedef struct quartet {
17  count_t base[5];
18  bool masked;
19  char delim;
20 
23  quartet (){
24  masked=false;
25  memset(base, 0, 5*sizeof(count_t) );
26  delim='/';
27  }
28 
31  quartet(const count_t &A, const count_t &C, const count_t &G, const count_t &T, const count_t &N) {
32  base[0]=A;
33  base[1]=C;
34  base[2]=G;
35  base[3]=T;
36  base[4]=N;
37  masked=false;
38  }
39 
42  quartet& operator+=(const quartet& x) {
43  memcpy(base, x.base, 5*sizeof(count_t) );
44  return *this;
45  }
46 
49  inline quartet operator+(const quartet& x) const {
50  return quartet(base[0]+x.base[0], base[1]+x.base[1], base[2]+x.base[2], base[3]+x.base[3], base[4]+x.base[4]);
51  }
52 
55  quartet& operator=(const count_t& x) {
56  memset (base, x, 5*sizeof(count_t) );
57  return *this;
58  }
59 
60  quartet& operator=(const quartet& rhs)
61  {
62  //memset (base, 0, 5*sizeof(count_t) );
63  memcpy(base, rhs.base, 5*sizeof(count_t) );
64  masked=rhs.masked;
65  delim=rhs.delim;
66  return *this;
67  }
68 /* count_t operator[](const int &x) const {
69  return base[x];
70  }*/
71  count_t operator[](const gt_t &x) const {
72  return base[x];
73  }
74 
75  count_t operator[](const Base &x) const {
76  return base[x.base];
77  }
78 } quartet_t;
79 
81 count_t count(const quartet_t&);
82 
84 void mask(quartet_t&);
85 
87 void unmask(quartet_t&);
88 
89 //writet(stream, quartet_t&);
90 //writet(stream, quartet_t&);
91 
92 std::ostream& operator<< (std::ostream& out, const quartet& q);
93 std::istream& operator>> (std::istream& in, quartet& q);
94 #endif
A class converts human readable bases to bit flags.
Definition: base.h:16
A class that stores quartet information.
Definition: quartet.h:16
count_t base[5]
The count of the number of occurnaces of bases. What nucleotieds this cout represents is stored at th...
Definition: quartet.h:17
bool masked
A flag that indicates whether or not functions should use information from this quartet_t. Functions may ignore this flag if such behavior is desired.
Definition: quartet.h:18
quartet & operator=(const count_t &x)
Definition: quartet.h:55
quartet()
Definition: quartet.h:23
quartet & operator+=(const quartet &x)
Definition: quartet.h:42
gt_t base
Represents a single base.
Definition: base.h:32
quartet(const count_t &A, const count_t &C, const count_t &G, const count_t &T, const count_t &N)
Definition: quartet.h:31
quartet operator+(const quartet &x) const
Definition: quartet.h:49