-
Notifications
You must be signed in to change notification settings - Fork 15
/
example.c
49 lines (48 loc) · 1.19 KB
/
example.c
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
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "fermi.h"
#include "mag.h"
#ifdef FM_EXAMPLE_MAIN
int main(int argc, char *argv[])
#else
int main_example(int argc, char *argv[])
#endif
{
int c, do_ec = 0, skip_unitig = 0, ec_k = -1, unitig_k = -1, do_clean = 0;
char *seq, *qual;
int64_t l;
while ((c = getopt(argc, argv, "ceUk:l:")) >= 0) {
switch (c) {
case 'e': do_ec = 1; break;
case 'U': skip_unitig = 1; break;
case 'k': ec_k = atoi(optarg); break;
case 'l': unitig_k = atoi(optarg); break;
case 'c': do_clean = 1; break;
}
}
if (optind == argc) {
fprintf(stderr, "Usage: fermi example [-ceU] [-k ecKmer] [-l utgKmer] <in.fq>\n");
return 1;
}
l = fm6_api_readseq(argv[optind], &seq, &qual);
if (do_ec) fm6_api_correct(ec_k, l, seq, qual);
if (!skip_unitig) { // construct the unitigs
mag_t *g;
free(qual);
g = fm6_api_unitig(unitig_k, l, seq);
if (do_clean) {
magopt_t *opt = mag_init_opt();
opt->flag |= MOG_F_AGGRESSIVE | MOG_F_CLEAN;
mag_g_clean(g, opt);
free(opt);
}
mag_g_print(g);
mag_g_destroy(g);
} else {
fm6_api_writeseq(l, seq, qual); // then write the (possibly corrected) reads
free(qual);
}
free(seq);
return 0;
}