Debian Codegraph @

debian/patches/bcf_seqlib.patch

raw symbols SCIP
1 Description: Try to take over patches from libSeqLib which needs separate bfc.h
2 FIXME: Please check the FIXME at the end. I think I did things wrong to put a
3 static declaration into header file but I had no better idea to make
4 ec1buf_init known in libSeqLib
5 Author: Andreas Tille <[email protected]>
6 Last-Update: Thu, 02 Feb 2017 10:57:56 +0100
7
8 --- a/bfc.c
9 +++ b/bfc.c
10 @@ -7,24 +7,12 @@
11 #include "kmer.h"
12 #include "internal.h"
13 #include "fml.h"
14 +#include "bfc.h"
15
16 /*******************
17 *** BFC options ***
18 *******************/
19
20 -typedef struct {
21 - int n_threads, q, k, l_pre;
22 - int min_cov; // a k-mer is considered solid if the count is no less than this
23 -
24 - int max_end_ext;
25 - int win_multi_ec;
26 - float min_trim_frac;
27 -
28 - // these ec options cannot be changed on the command line
29 - int w_ec, w_ec_high, w_absent, w_absent_high;
30 - int max_path_diff, max_heap;
31 -} bfc_opt_t;
32 -
33 void bfc_opt_init(bfc_opt_t *opt)
34 {
35 memset(opt, 0, sizeof(bfc_opt_t));
36 @@ -46,26 +34,6 @@ void bfc_opt_init(bfc_opt_t *opt)
37 opt->max_heap = 100;
38 }
39
40 -/**********************
41 - *** K-mer counting ***
42 - **********************/
43 -
44 -#define CNT_BUF_SIZE 256
45 -
46 -typedef struct { // cache to reduce locking
47 - uint64_t y[2];
48 - int is_high;
49 -} insbuf_t;
50 -
51 -typedef struct {
52 - int k, q;
53 - int n_seqs;
54 - const fml_seq1_t *seqs;
55 - bfc_ch_t *ch;
56 - int *n_buf;
57 - insbuf_t **buf;
58 -} cnt_step_t;
59 -
60 bfc_kmer_t bfc_kmer_null = {{0,0,0,0}};
61
62 static int bfc_kmer_bufclear(cnt_step_t *cs, int forced, int tid)
63 @@ -127,34 +95,6 @@ struct bfc_ch_s *fml_count(int n, const
64 return cs.ch;
65 }
66
67 -/***************
68 - *** Correct ***
69 - ***************/
70 -
71 -#define BFC_MAX_KMER 63
72 -#define BFC_MAX_BF_SHIFT 37
73 -
74 -#define BFC_MAX_PATHS 4
75 -#define BFC_EC_HIST 5
76 -#define BFC_EC_HIST_HIGH 2
77 -
78 -#define BFC_EC_MIN_COV_COEF .1
79 -
80 -/**************************
81 - * Sequence struct for ec *
82 - **************************/
83 -
84 -#include "kvec.h"
85 -
86 -typedef struct { // NOTE: unaligned memory
87 - uint8_t b:3, q:1, ob:3, oq:1;
88 - uint8_t dummy;
89 - uint16_t lcov:6, hcov:6, solid_end:1, high_end:1, ec:1, absent:1;
90 - int i;
91 -} ecbase_t;
92 -
93 -typedef kvec_t(ecbase_t) ecseq_t;
94 -
95 static int bfc_seq_conv(const char *s, const char *q, int qthres, ecseq_t *seq)
96 {
97 int i, l;
98 @@ -264,53 +204,6 @@ uint64_t bfc_ec_best_island(int k, const
99 return max > 0? (uint64_t)(max_i - max - k + 1) << 32 | max_i : 0;
100 }
101
102 -/********************
103 - * Correct one read *
104 - ********************/
105 -
106 -#include "ksort.h"
107 -
108 -#define ECCODE_MISC 1
109 -#define ECCODE_MANY_N 2
110 -#define ECCODE_NO_SOLID 3
111 -#define ECCODE_UNCORR_N 4
112 -#define ECCODE_MANY_FAIL 5
113 -
114 -typedef struct {
115 - uint32_t ec_code:3, brute:1, n_ec:14, n_ec_high:14;
116 - uint32_t n_absent:24, max_heap:8;
117 -} ecstat_t;
118 -
119 -typedef struct {
120 - uint8_t ec:1, ec_high:1, absent:1, absent_high:1, b:4;
121 -} bfc_penalty_t;
122 -
123 -typedef struct {
124 - int tot_pen;
125 - int i; // base position
126 - int k; // position in the stack
127 - int32_t ecpos_high[BFC_EC_HIST_HIGH];
128 - int32_t ecpos[BFC_EC_HIST];
129 - bfc_kmer_t x;
130 -} echeap1_t;
131 -
132 -typedef struct {
133 - int parent, i, tot_pen;
134 - uint8_t b;
135 - bfc_penalty_t pen;
136 - uint16_t cnt;
137 -} ecstack1_t;
138 -
139 -typedef struct {
140 - const bfc_opt_t *opt;
141 - const bfc_ch_t *ch;
142 - kvec_t(echeap1_t) heap;
143 - kvec_t(ecstack1_t) stack;
144 - ecseq_t seq, tmp, ec[2];
145 - int mode;
146 - ecstat_t ori_st;
147 -} bfc_ec1buf_t;
148 -
149 #define heap_lt(a, b) ((a).tot_pen > (b).tot_pen)
150 KSORT_INIT(ec, echeap1_t, heap_lt)
151
152 @@ -567,19 +460,6 @@ ecstat_t bfc_ec1(bfc_ec1buf_t *e, char *
153 return s;
154 }
155
156 -/********************
157 - * Error correction *
158 - ********************/
159 -
160 -typedef struct {
161 - const bfc_opt_t *opt;
162 - const bfc_ch_t *ch;
163 - bfc_ec1buf_t **e;
164 - int64_t n_processed;
165 - int n_seqs, flt_uniq;
166 - fml_seq1_t *seqs;
167 -} ec_step_t;
168 -
169 static uint64_t max_streak(int k, const bfc_ch_t *ch, const fml_seq1_t *s)
170 {
171 int i, l;
172 @@ -663,6 +543,18 @@ float fml_correct_core(const fml_opt_t *
173 return kcov;
174 }
175
176 +// Added by jwala for use in libSeqLib
177 +void kmer_correct(ec_step_t * es, int mode, bfc_ch_t * ch) {
178 + int i = 0;
179 + es->e = (bfc_ec1buf_t**)calloc(es->opt->n_threads, sizeof(void*)); //jwala added cast
180 + for (i = 0; i < es->opt->n_threads; ++i)
181 + es->e[i] = ec1buf_init(es->opt, ch), es->e[i]->mode = mode;
182 + kt_for(es->opt->n_threads, worker_ec, es, es->n_seqs);
183 + for (i = 0; i < es->opt->n_threads; ++i)
184 + ec1buf_destroy(es->e[i]);
185 + free(es->e);
186 +}
187 +
188 float fml_correct(const fml_opt_t *opt, int n, fml_seq1_t *seq)
189 {
190 return fml_correct_core(opt, 0, n, seq);
191 --- /dev/null
192 +++ b/bfc.h
193 @@ -0,0 +1,153 @@
194 +#ifndef AC_BFC_H__
195 +#define AC_BFC_H__
196 +
197 +#include <stdlib.h>
198 +#include <string.h>
199 +#include <assert.h>
200 +#include <limits.h>
201 +#include <stdio.h>
202 +#include "htab.h"
203 +/* #include "kmer.h" ... this is actually included by htab.h */
204 +#include "internal.h"
205 +#include "fml.h"
206 +#include "khash.h"
207 +
208 +/* Andreas Tille <[email protected]>: Its not clear where jwala took this from and what its purpose might be - commenting out for the moment
209 +#define _cnt_eq(a, b) ((a)>>14 == (b)>>14)
210 +#define _cnt_hash(a) ((a)>>14)
211 +KHASH_INIT(cnt, uint64_t, char, 0, _cnt_hash, _cnt_eq)
212 +typedef khash_t(cnt) cnthash_t;
213 +
214 +struct bfc_ch_s {
215 + int k;
216 + cnthash_t **h;
217 + // private
218 + int l_pre;
219 +};
220 +*/
221 +
222 +typedef struct {
223 + int n_threads, q, k, l_pre;
224 + int min_cov; // a k-mer is considered solid if the count is no less than this
225 +
226 + int max_end_ext;
227 + int win_multi_ec;
228 + float min_trim_frac;
229 +
230 + // these ec options cannot be changed on the command line
231 + int w_ec, w_ec_high, w_absent, w_absent_high;
232 + int max_path_diff, max_heap;
233 +} bfc_opt_t;
234 +
235 +/**********************
236 + *** K-mer counting ***
237 + **********************/
238 +
239 +#define CNT_BUF_SIZE 256
240 +
241 +typedef struct { // cache to reduce locking
242 + uint64_t y[2];
243 + int is_high;
244 +} insbuf_t;
245 +
246 +typedef struct {
247 + int k, q;
248 + int n_seqs;
249 + const fml_seq1_t *seqs;
250 + bfc_ch_t *ch;
251 + int *n_buf;
252 + insbuf_t **buf;
253 +} cnt_step_t;
254 +
255 +/***************
256 + *** Correct ***
257 + ***************/
258 +
259 +#define BFC_MAX_KMER 63
260 +#define BFC_MAX_BF_SHIFT 37
261 +
262 +#define BFC_MAX_PATHS 4
263 +#define BFC_EC_HIST 5
264 +#define BFC_EC_HIST_HIGH 2
265 +
266 +#define BFC_EC_MIN_COV_COEF .1
267 +
268 +/**************************
269 + * Sequence struct for ec *
270 + **************************/
271 +
272 +#include "kvec.h"
273 +
274 +typedef struct { // NOTE: unaligned memory
275 + uint8_t b:3, q:1, ob:3, oq:1;
276 + uint8_t dummy;
277 + uint16_t lcov:6, hcov:6, solid_end:1, high_end:1, ec:1, absent:1;
278 + int i;
279 +} ecbase_t;
280 +
281 +typedef kvec_t(ecbase_t) ecseq_t;
282 +
283 +/********************
284 + * Correct one read *
285 + ********************/
286 +
287 +#include "ksort.h"
288 +
289 +#define ECCODE_MISC 1
290 +#define ECCODE_MANY_N 2
291 +#define ECCODE_NO_SOLID 3
292 +#define ECCODE_UNCORR_N 4
293 +#define ECCODE_MANY_FAIL 5
294 +
295 +typedef struct {
296 + uint32_t ec_code:3, brute:1, n_ec:14, n_ec_high:14;
297 + uint32_t n_absent:24, max_heap:8;
298 +} ecstat_t;
299 +
300 +typedef struct {
301 + uint8_t ec:1, ec_high:1, absent:1, absent_high:1, b:4;
302 +} bfc_penalty_t;
303 +
304 +typedef struct {
305 + int tot_pen;
306 + int i; // base position
307 + int k; // position in the stack
308 + int32_t ecpos_high[BFC_EC_HIST_HIGH];
309 + int32_t ecpos[BFC_EC_HIST];
310 + bfc_kmer_t x;
311 +} echeap1_t;
312 +
313 +typedef struct {
314 + int parent, i, tot_pen;
315 + uint8_t b;
316 + bfc_penalty_t pen;
317 + uint16_t cnt;
318 +} ecstack1_t;
319 +
320 +typedef struct {
321 + const bfc_opt_t *opt;
322 + const bfc_ch_t *ch;
323 + kvec_t(echeap1_t) heap;
324 + kvec_t(ecstack1_t) stack;
325 + ecseq_t seq, tmp, ec[2];
326 + int mode;
327 + ecstat_t ori_st;
328 +} bfc_ec1buf_t;
329 +
330 +/********************
331 + * Error correction *
332 + ********************/
333 +
334 +typedef struct {
335 + const bfc_opt_t *opt;
336 + const bfc_ch_t *ch;
337 + bfc_ec1buf_t **e;
338 + int64_t n_processed;
339 + int n_seqs, flt_uniq;
340 + fml_seq1_t *seqs;
341 +} ec_step_t;
342 +
343 +void kmer_correct(ec_step_t * es, int mode, bfc_ch_t * ch);
344 +void bfc_opt_init(bfc_opt_t *opt);
345 +
346 +#endif