-
Notifications
You must be signed in to change notification settings - Fork 26
/
bcf_filter_arg.h
132 lines (109 loc) · 2.72 KB
/
bcf_filter_arg.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef __BCF_FILTER_ARG_H
#define __BCF_FILTER_ARG_H
//extern "C" {
#include "filter.h"
//}
#include "Error.h"
#include "hts_utils.h"
// others
#define MASK_GT_MISS 0x01
#define MASK_GT_HOMREF 0x02
#define MASK_GT_HET 0x04
#define MASK_GT_HOMALT 0x08
#define MASK_GT_NONREF (MASK_GT_HET|MASK_GT_HOMALT)
#define MASK_GT_NOMISS (MASK_GT_HOMREF|MASK_GT_HET|MASK_GT_HOMALT)
#define MASK_GT_ALL (MASK_GT_MISS|MASK_GT_HOMREF|MASK_GT_HET|MASK_GT_HOMALT)
#define FLT_INCLUDE 1
#define FLT_EXCLUDE 2
struct _bcf_vfilter_arg {
std::vector<std::string> required_filters; // require at least one of the
std::string include_expr;
std::string exclude_expr;
std::vector<int32_t> req_flt_ids;
filter_t* filt;
int32_t filter_logic;
// allele frequency filters
int32_t minAC;
int32_t minMAC;
int32_t maxAC;
int32_t maxMAC;
double minAF;
double minMAF;
double maxAF;
double maxMAF;
int32_t minAN;
double minCallRate;
double minQual;
int32_t maxAlleles;
int32_t minAlleles;
bool snpOnly;
bool require_GT;
bool require_PL;
double probThin;
_bcf_vfilter_arg() {
minAC = 0;
minMAC = 0;
maxAC = INT_MAX;
maxMAC = INT_MAX;
minAF = 0;
minMAF = 0;
maxAF = 1.;
maxMAF = 1.;
minAN = 0;
minCallRate = 0;
minQual = 0;
maxAlleles = INT_MAX;
minAlleles = 0;
snpOnly = false;
filt = NULL;
filter_logic = 0;
require_GT = false;
require_PL = false;
probThin = 1.0;
}
void init(bcf_hdr_t* hdr) {
// initialize variant filter
std::string filter_str;
if ( include_expr.empty() ) {
if ( exclude_expr.empty() ) {
// do nothing
}
else {
filter_str = exclude_expr;
filter_logic |= FLT_EXCLUDE;
}
}
else {
if ( exclude_expr.empty() ) {
filter_str = include_expr;
filter_logic |= FLT_INCLUDE;
}
else {
error("[E:%s:%d %s] Cannot use both --include-expr and --exclude-expr options",__FILE__,__LINE__,__FUNCTION__);
}
}
if ( filter_logic != 0 )
filter_init(hdr, filter_str.c_str());
if ( !required_filters.empty() ) {
for(int32_t i=0; i < (int32_t)required_filters.size(); ++i) {
req_flt_ids.push_back(bcf_hdr_id2int(hdr, BCF_DT_ID, required_filters[i].c_str()));
}
}
if ( ( minAC > 0 ) || ( minMAC > 0 ) || ( minAF > 0 ) || ( minMAF > 0 ) ||
( maxAC < INT_MAX ) || ( maxMAC < INT_MAX ) || ( maxAF < 1 ) || ( maxMAF < 0 ) ||
( minAN > 0 ) || ( minCallRate > 0 ) )
require_GT = true;
}
};
struct _bcf_gfilter_arg {
int32_t minDP;
int32_t minGQ;
//int32_t minAD;
_bcf_gfilter_arg() {
minDP = 0;
minGQ = 0;
}
};
typedef struct _bcf_vfilter_arg bcf_vfilter_arg;
typedef struct _bcf_gfilter_arg bcf_gfilter_arg;
#endif