mapgd  0.4
A program for the Maximum-likelihood analysis of population genomic data.
 All Data Structures Functions Variables Friends Groups Pages
population.h
1 #ifndef _POPULATION_H_
2 #define _POPULATION_H_
3 
4 #include <string.h>
5 #include <iostream>
6 #include <sstream>
7 #include "data.h"
8 #include "sample_name.h"
9 #include "typedef.h"
10 #include "genotype.h"
11 
13 class Population : public Indexed_data {
14 private:
15  std::vector <Genotype>::iterator igl_;
16  std::vector <std::string> sample_names_;
17  static const Registration registered;
18  static Data * create(const std::vector <std::string> & Columns){
19  return new Population(Columns);
20  }
21 public:
22 //Data block
23  std::vector <Genotype> likelihoods;
24 
25  gt_t major;
26  gt_t minor;
27  float_t m;
28  float_t f;
29 //end Data block
30  Population();
31  Population(const Sample_name &);
32  Population(const std::vector <std::string> &);
33  Population(const Population &);
34  ~Population();
35  size_t size() const;
36  void add(const Genotype &likelihood);
37  void add(const float_t &lMM, const float_t &lMm, const float_t &lmm, const count_t &N);
38  void clear();
39  std::string header(void) const;
40 
41  static const std::string table_name;
42  static const std::string file_name;
43  static const bool binary;
44  const bool get_binary() const;
45 
46  inline std::vector <std::string> get_sample_names(void) const {return sample_names_;};
47  inline void set_sample_names(const std::vector <std::string>& sample_names) {
48  sample_names_=sample_names;
49  likelihoods.resize(sample_names.size() );
50  };
51 
53 
54  void write (std::ostream&) const;
55  void read (std::istream&);
56 
57  const std::string get_file_name() const {return Population::file_name;};
58  const std::string get_table_name() const {return Population::table_name;};
59 
60  void write_binary (std::ostream&) const;
61  void read_binary (std::istream&);
62 };
63 
64 #endif
size_t size() const
Returns the number of samples.
Definition: population.cc:39
void add(const Genotype &likelihood)
append a sample to the likelihood.
Population genotypes.
Definition: population.h:13
The name of a sample (i.e. what the user called it).
Definition: sample_name.h:16
Data which has an absolute position.
Definition: data.h:144
std::vector< Genotype > likelihoods
Genotypic likelihood.
Definition: population.h:23
Population()
simple constructor.
Definition: population.cc:26
std::vector< Genotype >::iterator igl_
an iterator to allow us to iterate over the likelihoods.
Definition: population.h:15
gt_t major
identity of the major allele
Definition: population.h:25
gt_t minor
identity of the minor allele
Definition: population.h:26
~Population()
destructor.
Definition: population.cc:35
std::string header(void) const
print header.
Definition: population.cc:60
float_t m
minor allele frequency
Definition: population.h:27
void set_sample_names(const std::vector< std::string > &sample_names)
names of the samples sequenced.
Definition: population.h:47
void write(std::ostream &) const
The write function must be defined in the child class.
Definition: population.cc:74
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
float_t f
departure from HWE
Definition: population.h:28
void clear()
clear likelihoods.
Definition: genotype.h:7
std::vector< std::string > sample_names_
a vector of sample names.
Definition: population.h:16
void read(std::istream &)
The read function must be defined in the child class.
Definition: population.cc:85
static const std::string file_name
defualt file extention.
Definition: population.h:42
Population & operator=(const Population &)
names of the samples sequenced.
Definition: population.cc:45
static const std::string table_name
destination table in Db.
Definition: population.h:41