Repository navigation
Expand file tree
/
Copy pathoptions.c
More file actions
139 lines (132 loc) · 3.76 KB
/
Copy pathoptions.c
File metadata and controls
139 lines (132 loc) · 3.76 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
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
133
134
135
136
137
138
139
#include <string.h>
#include "mgpriv.h"
#include "sys.h"
void mg_idxopt_init(mg_idxopt_t *io)
{
memset(io, 0, sizeof(mg_idxopt_t));
io->k = 15;
io->w = 10;
io->bucket_bits = 14;
}
void mg_mapopt_init(mg_mapopt_t *mo)
{
memset(mo, 0, sizeof(mg_mapopt_t));
mo->seed = 11;
mo->occ_max1 = 100;
mo->occ_max1_frac = 2e-4f;
mo->occ_weight = 20;
mo->max_gap = 10000;
mo->max_gap_ref = -1;
mo->max_gap_pre = 1000;
mo->max_frag_len = 800;
mo->max_lc_skip = 25, mo->max_gc_skip = 25, mo->max_lc_iter = 10000;
mo->bw = 2000;
mo->mini_batch_size = 500000000;
mo->div = 0.1f;
mo->chn_pen_gap = 1.0f, mo->chn_pen_skip = 0.05f;
mo->min_lc_cnt = 2, mo->min_lc_score = 30;
mo->min_gc_cnt = 3, mo->min_gc_score = 50;
mo->mask_level = 0.5f;
mo->sub_diff = 6;
mo->best_n = 5;
mo->pri_ratio = 0.8f;
mo->ref_bonus = 0;
mo->pe_ori = 0; // FF
mo->min_cov_mapq = 20;
mo->min_cov_blen = 1000;
}
void mg_ggopt_gen_sc_mat(int8_t mat[25], int32_t a, int32_t b)
{
int i, j, m = 5;
a = a < 0? -a : a;
b = b > 0? -b : b;
for (i = 0; i < m - 1; ++i) {
for (j = 0; j < m - 1; ++j)
mat[i * m + j] = i == j? a : b;
mat[i * m + m - 1] = -1;
}
for (j = 0; j < m; ++j)
mat[(m - 1) * m + j] = -1;
}
void mg_ggopt_init(mg_ggopt_t *go)
{
memset(go, 0, sizeof(mg_ggopt_t));
go->algo = MG_G_NONE;
go->flag |= MG_G_NO_QOVLP;
go->min_map_len = 100000;
go->min_depth_len = 10000;
go->min_mapq = 5;
go->min_var_len = 100;
go->match_pen = 10;
// for ggs
go->ggs_shrink_pen = 9;
go->ggs_min_end_cnt = 10;
go->ggs_min_end_frac = 0.1f;
mg_ggopt_gen_sc_mat(go->scmat, 2, -4);
go->gapo = 4, go->gapo2 = 24;
go->gape = 2, go->gape2 = 1;
go->ggs_max_iden = 0.80f;
go->ggs_min_inv_iden = 0.98f;
}
int mg_opt_set(const char *preset, mg_idxopt_t *io, mg_mapopt_t *mo, mg_ggopt_t *go)
{
if (preset == 0) {
mg_idxopt_init(io);
mg_mapopt_init(mo);
mg_ggopt_init(go);
} else if (strcmp(preset, "lr") == 0) {
io->k = 15, io->w = 10;
mo->bw = 2000, mo->max_gap = 5000;
} else if (strcmp(preset, "asm") == 0 || strcmp(preset, "ggs") == 0) {
io->k = 19, io->w = 10;
mo->flag |= MG_M_RMQ;
mo->max_gap = mo->bw = 100000;
mo->max_gap_pre = 10000;
mo->min_lc_cnt = 3, mo->min_lc_score = 40;
mo->min_gc_cnt = 5, mo->min_gc_score = 1000;
mo->min_cov_mapq = 5;
mo->min_cov_blen = 100000;
mo->max_lc_skip = 50;
mo->div = 0.01f;
if (strcmp(preset, "ggs") == 0)
go->algo = MG_G_GGSIMPLE, mo->best_n = 0;
} else if (strcmp(preset, "se") == 0 || strcmp(preset, "sr") == 0) {
io->k = 21, io->w = 10;
mo->flag |= MG_M_SR | MG_M_HEAP_SORT | MG_M_2_IO_THREADS;
mo->occ_max1 = 1000;
mo->max_gap = 100, mo->bw = 100;
mo->pri_ratio = 0.5f;
mo->min_lc_cnt = 2, mo->min_lc_score = 25;
mo->min_gc_cnt = 3, mo->min_gc_score = 40;
mo->mini_batch_size = 50000000;
mo->min_cov_blen = 50;
mo->chn_pen_gap = 0.2f;
mo->ref_bonus = 1;
if (strcmp(preset, "sr") == 0) {
mo->flag |= MG_M_FRAG_MODE | MG_M_FRAG_MERGE;
mo->pe_ori = 0<<1|1; // FR
}
} else return -1;
return 0;
}
int mg_opt_check(const mg_idxopt_t *io, const mg_mapopt_t *mo, const mg_ggopt_t *go)
{
if ((mo->flag & MG_M_FRAG_MODE) && !(mo->flag & MG_M_FRAG_MERGE)) {
if (mg_verbose >= 1)
fprintf(stderr, "[ERROR]\033[1;31m the fragment-without-merge mode is not implemented\033[0m\n");
return -1;
}
return 0;
}
void mg_opt_update(const mg_idx_t *gi, mg_mapopt_t *mo, mg_ggopt_t *go)
{
float f[2];
int32_t q[2];
f[0] = 0.05f, f[1] = mo->occ_max1_frac;
mg_idx_cal_quantile(gi, 2, f, q);
if (q[0] + 1 > mo->occ_weight) mo->occ_weight = q[0] + 1;
if (q[1] + 1 > mo->occ_max1) mo->occ_max1 = q[1] + 1;
if (mg_verbose >= 3)
fprintf(stderr, "[M::%s::%.3f*%.2f] occ_weight=%d, occ_max1=%d; 95 percentile: %d\n", __func__,
realtime() - mg_realtime0, cputime() / (realtime() - mg_realtime0), mo->occ_weight, mo->occ_max1, q[0]);
}