mapgd  0.4
A program for the Maximum-likelihood analysis of population genomic data.
 All Data Structures Functions Variables Friends Groups Pages
linkage_data.h
1 #ifndef _LINKAGE_H_
2 #define _LINKAGE_H_
3 
4 #include <iostream>
5 #include <cfloat>
6 #include <iomanip>
7 #include <vector>
8 
9 #include "typedef.h"
10 #include "data.h"
11 #include "stream_tools.h"
12 
14 
25 class Linkage : public virtual Double_indexed_data {
26 private:
27  void read(std::istream& str);
29  void write(std::ostream& str) const;
30  static const Registration registered;
31  static Data * create(const std::vector <std::string> &columns){
32  return new Linkage(columns);
33  };
34  //We are comparing site X to site Y, so we need a total of four ids.
35  id0_t id0;
36  id1_t id1;
37 
38  float_t p_;
39  float_t q_;
40 
41  float_t D_;
42  float_t Ni_;
43  float_t fit_;
44  float_t null_;
45 public:
46  using Double_indexed_data::get_abs_pos1;
48 
49  using Double_indexed_data::set_abs_pos1;
51 
52  char delim;
53 
54  Linkage();
55  Linkage(const std::vector <std::string> &) : Linkage(){};
56 
57  static const std::string file_name;
58  static const std::string table_name;
59  static const bool binary;
60 
61  std::string header(void) const;
62  size_t size(void) const;
63 
64  const std::string get_file_name(void) const;
65  const std::string get_table_name(void) const;
66  const bool get_binary(void) const;
67 
68  const std::string sql_header(void) const;
69  const std::string sql_column_names(void) const;
70  const std::string sql_values(void) const;
71 
72  void set_D(const float_t &);
73  void set_fit(const float_t &);
74  void set_null(const float_t &);
75  void set_Ni(const float_t &);
76  void set_p(const float_t &);
77  void set_q(const float_t &);
78 
79  float_t ll (void) const;
80  float_t dist (void) const;
81  float_t D (void) const;
82  float_t Dmax (void) const;
83  float_t Dmin (void) const;
84  float_t Dsq (void) const;
85  float_t Dprime (void) const;
86  float_t r (void) const;
87  float_t rsq (void) const;
88  float_t adj_D (void) const;
89  float_t adj_Dsq (void) const;
90  float_t adj_Dprime (void) const;
91  float_t adj_r (void) const;
92  float_t adj_rsq (void) const;
93  float_t adj_Dmax (void) const;
94  float_t adj_Dmin (void) const;
95 
96 /*
97  id0_t id0; //!< The scaffold of site X
98  id1_t id1; //!< The pos of site X
99 
100  id1_t id1_y_; //!< the pos of site Y
101 
102  float_t p_; //!< freq_major site numero uno
103  float_t q_; //!< freq_major site numero dos
104 
105  float_t D_; //!< the magnitude of the ld, j0
106  float_t Ni_; //!< The number of individuals used in the calculation
107  float_t fit_; //!< fit statistic (thar be ld here!)
108  float_t null_; //!< null statistic (i.e. no ld)
109 */
110 
111 
112  //TODO SHIT!
113  Linkage & operator=(const Linkage &lhs){
114 // (Indexed_data)(this)->abs_pos_=(Indexed_data)(&lhs)->abs_pos_;
115  this->abs_pos1_=lhs.abs_pos1_;
116  this->abs_pos2_=lhs.abs_pos2_;
117 
118  this->id0=lhs.id0;
119  this->id1=lhs.id1;
120 
121  this->p_=lhs.p_;
122  this->q_=lhs.q_;
123 
124  this->D_=lhs.D_;
125  this->Ni_=lhs.Ni_;
126  this->fit_=lhs.fit_;
127  this->null_=lhs.null_;
128  return *this;
129  }
130 
131 };
132 
133 #endif
const std::string sql_column_names(void) const
Destination table in Db.
Definition: linkage_data.cc:54
float_t Ni_
The number of individuals used in the calculation.
Definition: linkage_data.h:42
const std::string sql_values(void) const
Destination table in Db.
Definition: linkage_data.cc:61
const std::string get_table_name(void) const
The default extension for files.
Definition: linkage_data.cc:81
void read(std::istream &str)
The read function must be defined in the child class.
Definition: linkage_data.cc:16
static const std::string file_name
delegating the constructor ftw.
Definition: linkage_data.h:55
const bool get_binary(void) const
The default extension for files.
Definition: linkage_data.cc:200
char delim
< Set the absolute position of the Locus.
Definition: linkage_data.h:52
float_t null_
null statistic (i.e. no ld)
Definition: linkage_data.h:44
Definition: data.h:176
static const bool binary
Returns the destination table name.
Definition: linkage_data.h:59
float_t D_
the magnitude of the ld, j0
Definition: linkage_data.h:41
static const std::string table_name
Destination table in Db.
Definition: linkage_data.h:58
A class to store linkage information.
Definition: linkage_data.h:25
float_t p_
freq_major site numero uno
Definition: linkage_data.h:38
const std::string sql_header(void) const
Destination table in Db.
Definition: linkage_data.cc:47
void write(std::ostream &str) const
! the write function must be ? by the child class.
Definition: linkage_data.cc:23
float_t fit_
fit statistic (thar be ld here!)
Definition: linkage_data.h:43
Linkage & operator=(const Linkage &lhs)
Definition: linkage_data.h:113
void set_abs_pos2(const id1_t &)
Indexed data needs to associate each datum with a position in the genome.
Definition: data.cc:148
id0_t id0
The scaffold of site X.
Definition: linkage_data.h:33
id1_t id1
The pos of site X.
Definition: linkage_data.h:36
A class which registers a child of Data in Data::new_data_.
Definition: data.h:222
A class which can be written as flat text file or into an SQL database.
Definition: data.h:34
size_t size(void) const
The size of the class in bytes.
Definition: linkage_data.cc:68
id1_t get_abs_pos2(void) const
Indexed data needs to associate each datum with a position in the genome.
Definition: data.cc:133
const std::string get_file_name(void) const
The default extension for files.
Definition: linkage_data.cc:75
float_t q_
freq_major site numero dos
Definition: linkage_data.h:39