forked from maip/novo_muta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulation_model.h
74 lines (66 loc) · 2.59 KB
/
simulation_model.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @file simulation_model.h
* @author Melissa Ip
*
* The SimulationModel class is used to validate TrioModel results using
* default parameter values described in the TrioModel class. It generates a
* random family pedigree based on population priors and calculates the
* probability of mutation using the generated sample (sequencing reads are
* drawn from the Dirichlet multinomial).
*/
#ifndef SIMULATION_MODEL_H
#define SIMULATION_MODEL_H
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <time.h>
#include <gsl/gsl_randist.h> // Already included in utility.h.
#include <gsl/gsl_rng.h>
#include "trio_model.h"
/**
* SimulationModel class header. See top of file for a complete description.
*/
class SimulationModel {
public:
// No default constructor, because all parameters are given through command line inputs.
SimulationModel(unsigned int coverage,
double population_mutation_rate,
double germline_mutation_rate,
double somatic_mutation_rate);
void Seed(); // Seeds random number generator.
void Free();
void WriteProbability(const string &file_name, int size); // Generates random samples and probabilities in text file.
void WriteMutationCounts(const string &file_name, int size);
void PrintMutationCounts(int size); // Simulates trios to stdout.
unsigned int coverage() const; // Get and set functions.
void set_coverage(unsigned int coverage);
double population_mutation_rate() const;
void set_population_mutation_rate(double rate);
double germline_mutation_rate() const;
void set_germline_mutation_rate(double rate);
double somatic_mutation_rate() const;
void set_somatic_mutation_rate(double rate);
bool has_mutation() const;
void set_has_mutation(bool has_mutation);
gsl_rng* generator() const;
private:
int Mutate(int genotype_idx, bool is_germline=false,
int parent_genotype_idx=-1);
int GetChildGenotype(int mother_genotype, int father_genotype);
int GetChildAllele(int parent_genotype);
ReadData DirichletMultinomialSample(int genotype_idx);
MatrixXi GetGenotypesMatrix(int size);
TrioVector GetRandomTrios(int size);
int RandomDiscreteChoice(size_t K, const RowVectorXd &probabilities);
RowVectorXi RandomDiscreteChoice(size_t K, const RowVectorXd &probabilities,
int size);
// Instance member variables.
TrioModel params_; // Default initialization.
unsigned int coverage_;
bool has_mutation_;
vector<bool> has_mutation_vec_;
vector<bool> mutation_table_[kTrioCount];
gsl_rng *generator_;
};
#endif