Merge pull request #685 from macs3-project/feat/macs3/fragsupport
[MACS.git] / MACS3 / fermi-lite / example.c
blob5cf65dd8a60b73cebb001e919f9ea9d04e946349
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include "fml.h"
6 int main(int argc, char *argv[])
8 fml_opt_t opt;
9 int c, n_seqs, n_utg, gfa_out = 0;
10 bseq1_t *seqs;
11 fml_utg_t *utg;
13 fml_opt_init(&opt);
14 while ((c = getopt(argc, argv, "gOAe:l:r:t:c:d:v:")) >= 0) {
15 if (c == 'e') opt.ec_k = atoi(optarg);
16 else if (c == 'l') opt.min_asm_ovlp = atoi(optarg);
17 else if (c == 'r') opt.mag_opt.min_dratio1 = atof(optarg);
18 else if (c == 'A') opt.mag_opt.flag |= MAG_F_AGGRESSIVE;
19 else if (c == 'O') opt.mag_opt.flag &= ~MAG_F_POPOPEN;
20 else if (c == 'd') opt.mag_opt.max_bdiff = atoi(optarg);
21 else if (c == 't') opt.n_threads = atoi(optarg);
22 else if (c == 'g') gfa_out = 1;
23 else if (c == 'v') fm_verbose = atoi(optarg);
24 else if (c == 'c') {
25 char *p;
26 opt.min_cnt = strtol(optarg, &p, 10);
27 if (*p == ',') opt.max_cnt = strtol(p + 1, &p, 10);
30 if (argc == optind) {
31 fprintf(stderr, "Usage: fml-asm [options] <in.fq>\n");
32 fprintf(stderr, "Options:\n");
33 fprintf(stderr, " -e INT k-mer length for error correction (0 for auto; -1 to disable) [%d]\n", opt.ec_k);
34 fprintf(stderr, " -c INT1[,INT2] range of k-mer & read count thresholds for ec and graph cleaning [%d,%d]\n", opt.min_cnt, opt.max_cnt);
35 fprintf(stderr, " -l INT min overlap length during initial assembly [%d]\n", opt.min_asm_ovlp);
36 fprintf(stderr, " -r FLOAT drop an overlap if its length is below maxOvlpLen*FLOAT [%g]\n", opt.mag_opt.min_dratio1);
37 fprintf(stderr, " -t INT number of threads (don't use multi-threading for small data sets) [%d]\n", opt.n_threads);
38 fprintf(stderr, " -d INT retain a bubble if one side is longer than the other side by >INT-bp [%d]\n", opt.mag_opt.max_bdiff);
39 fprintf(stderr, " -A discard heterozygotes (apply this to assemble bacterial genomes; override -O)\n");
40 fprintf(stderr, " -O don't apply aggressive tip trimming\n");
41 fprintf(stderr, " -g output the assembly graph in the GFA format\n");
42 return 1;
44 seqs = bseq_read(argv[optind], &n_seqs);
45 utg = fml_assemble(&opt, n_seqs, seqs, &n_utg);
46 if (!gfa_out) fml_utg_print(n_utg, utg);
47 else fml_utg_print_gfa(n_utg, utg);
48 fml_utg_destroy(n_utg, utg);
49 return 0;