Repository navigation
Expand file tree
/
Copy pathshared.h
More file actions
107 lines (94 loc) · 2.19 KB
/
Copy pathshared.h
File metadata and controls
107 lines (94 loc) · 2.19 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdint.h>
#include <zlib.h>
#include <semaphore.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "zlib.h"
#include "htslib/bgzf.h"
extern bool SIG_COND;
// Struct to store all input arguments //GZIP
typedef struct {
#ifdef _USE_BGZF
BGZF* in_glf_fh;
#else
FILE* in_glf_fh;
double **data;
#endif
char *in_glf;
char *in_glf_type;
char *init_values;
bool calc_LRT;
double *_ind_lkl;
double _global_lkl;
bool freq_fixed;
char *out_file;
uint16_t n_ind;
uint64_t n_sites;
uint64_t n_chunks;
int64_t *chunks_voffset;
uint64_t max_chunk_size;
bool approx_EM;
bool call_geno;
int max_iters;
int min_iters;
double min_epsilon;
unsigned int n_threads;
uint64_t seed;
sem_t _launch_thread_semaph;
sem_t _running_thread_semaph;
pthread_mutex_t _F_lock;
bool quick;
bool version;
unsigned int verbose;
} params;
// Output data
typedef struct {
double *site_freq;
double *site_freq_num;
double *site_freq_den;
double *site_prob_var;
double *site_tmpprob_var;
double *indF;
double *indF_num;
double *indF_den;
double *ind_lkl;
double global_lkl;
} out_data;
// Prepare structure
typedef struct {
params *pars;
uint64_t chunk_size;
uint64_t chunk_abs_start_pos;
double **chunk_data;
int iter;
unsigned int *n_run_threads;
out_data *output;
} pth_params;
// parse_args.cpp
void init_pars(params *);
int parse_cmd_args(int, char **, params *);
// read_data.cpp
int init_output(params *, out_data *);
uint64_t read_chunk(double **, params *, uint64_t);
void call_geno(double *, int, int);
int array_max_pos(double *, int);
// EM.cpp
int do_EM(params *, out_data *);
void *run_chunk(void *);
void EM_iter(params *, double **, uint64_t, uint64_t, out_data *, int);
// shared.cpp
void error(const char *, const char *);
void handler(int);
void catch_SIG();
double check_interv(double, bool);
double addProtect2(double, double);
double addProtect3(double, double, double);
double HWE_like(double *, double, double);
double site_HWE_like(double **, double *, double *, uint16_t, uint16_t, uint64_t, uint64_t);
double full_HWE_like(params *, double *, double *, uint16_t, uint16_t);