Debian Codegraph @

bwa-apache2/bwtsw2_main.c

raw
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <math.h>
6 #include "bwt.h"
7 #include "bwtsw2.h"
8 #include "utils.h"
9 #include "bwa.h"
10
11 int bwa_bwtsw2(int argc, char *argv[])
12 {
13 bsw2opt_t *opt;
14 bwaidx_t *idx;
15 int c;
16
17 opt = bsw2_init_opt();
18 srand48(11);
19 while ((c = getopt(argc, argv, "q:r:a:b:t:T:w:d:z:m:s:c:N:Hf:MI:SG:C")) >= 0) {
20 switch (c) {
21 case 'q': opt->q = atoi(optarg); break;
22 case 'r': opt->r = atoi(optarg); break;
23 case 'a': opt->a = atoi(optarg); break;
24 case 'b': opt->b = atoi(optarg); break;
25 case 'w': opt->bw = atoi(optarg); break;
26 case 'T': opt->t = atoi(optarg); break;
27 case 't': opt->n_threads = atoi(optarg); break;
28 case 'z': opt->z = atoi(optarg); break;
29 case 's': opt->is = atoi(optarg); break;
30 case 'm': opt->mask_level = atof(optarg); break;
31 case 'c': opt->coef = atof(optarg); break;
32 case 'N': opt->t_seeds = atoi(optarg); break;
33 case 'M': opt->multi_2nd = 1; break;
34 case 'H': opt->hard_clip = 1; break;
35 case 'f': xreopen(optarg, "w", stdout); break;
36 case 'I': opt->max_ins = atoi(optarg); break;
37 case 'S': opt->skip_sw = 1; break;
38 case 'C': opt->cpy_cmt = 1; break;
39 case 'G': opt->max_chain_gap = atoi(optarg); break;
40 default: return 1;
41 }
42 }
43 opt->qr = opt->q + opt->r;
44
45 if (optind + 2 > argc) {
46 fprintf(stderr, "\n");
47 fprintf(stderr, "Usage: bwa bwasw [options] <target.prefix> <query.fa> [query2.fa]\n\n");
48 fprintf(stderr, "Options: -a INT score for a match [%d]\n", opt->a);
49 fprintf(stderr, " -b INT mismatch penalty [%d]\n", opt->b);
50 fprintf(stderr, " -q INT gap open penalty [%d]\n", opt->q);
51 fprintf(stderr, " -r INT gap extension penalty [%d]\n", opt->r);
52 fprintf(stderr, " -w INT band width [%d]\n", opt->bw);
53 fprintf(stderr, " -m FLOAT mask level [%.2f]\n", opt->mask_level);
54 fprintf(stderr, "\n");
55 fprintf(stderr, " -t INT number of threads [%d]\n", opt->n_threads);
56 fprintf(stderr, " -f FILE file to output results to instead of stdout\n");
57 fprintf(stderr, " -H in SAM output, use hard clipping instead of soft clipping\n");
58 fprintf(stderr, " -C copy FASTA/Q comment to SAM output\n");
59 fprintf(stderr, " -M mark multi-part alignments as secondary\n");
60 fprintf(stderr, " -S skip Smith-Waterman read pairing\n");
61 fprintf(stderr, " -I INT ignore pairs with insert >=INT for inferring the size distr [%d]\n", opt->max_ins);
62 fprintf(stderr, "\n");
63 fprintf(stderr, " -T INT score threshold divided by a [%d]\n", opt->t);
64 fprintf(stderr, " -c FLOAT coefficient of length-threshold adjustment [%.1f]\n", opt->coef);
65 fprintf(stderr, " -z INT Z-best [%d]\n", opt->z);
66 fprintf(stderr, " -s INT maximum seeding interval size [%d]\n", opt->is);
67 fprintf(stderr, " -N INT # seeds to trigger rev aln; 2*INT is also the chaining threshold [%d]\n", opt->t_seeds);
68 fprintf(stderr, " -G INT maximum gap size during chaining [%d]\n", opt->max_chain_gap);
69 fprintf(stderr, "\n");
70 fprintf(stderr, "Note: For long Illumina, 454 and Sanger reads, assembly contigs, fosmids and\n");
71 fprintf(stderr, " BACs, the default setting usually works well. For the current PacBio\n");
72 fprintf(stderr, " reads (end of 2010), '-b5 -q2 -r1 -z10' is recommended. One may also\n");
73 fprintf(stderr, " increase '-z' for better sensitivity.\n");
74 fprintf(stderr, "\n");
75
76 return 1;
77 }
78
79 // adjust opt for opt->a
80 opt->t *= opt->a;
81 opt->coef *= opt->a;
82
83 if ((idx = bwa_idx_load(argv[optind], BWA_IDX_BWT|BWA_IDX_BNS)) == 0) return 1;
84 bsw2_aln(opt, idx->bns, idx->bwt, argv[optind+1], optind+2 < argc? argv[optind+2] : 0);
85 bwa_idx_destroy(idx);
86 free(opt);
87
88 return 0;
89 }