Ensure exit status of 1 if given invalid options or index files are not found.
Added missing default cases in option scanning. Ensure exit value is 1 if bwa_idx_load or bwa_idx_infer_prefix fail. These changes extend the previous one, which only fixed the mem aligner.
This commit is contained in:
parent
e88529687f
commit
0aa7e0a402
2
bwape.c
2
bwape.c
|
|
@ -765,7 +765,7 @@ int bwa_sai2sam_pe(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if ((prefix = bwa_idx_infer_prefix(argv[optind])) == 0) {
|
if ((prefix = bwa_idx_infer_prefix(argv[optind])) == 0) {
|
||||||
fprintf(stderr, "[%s] fail to locate the index\n", __func__);
|
fprintf(stderr, "[%s] fail to locate the index\n", __func__);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
bwa_sai2sam_pe_core(prefix, argv + optind + 1, argv + optind+3, popt, rg_line);
|
bwa_sai2sam_pe_core(prefix, argv + optind + 1, argv + optind+3, popt, rg_line);
|
||||||
free(prefix); free(popt);
|
free(prefix); free(popt);
|
||||||
|
|
|
||||||
2
bwase.c
2
bwase.c
|
|
@ -611,7 +611,7 @@ int bwa_sai2sam_se(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if ((prefix = bwa_idx_infer_prefix(argv[optind])) == 0) {
|
if ((prefix = bwa_idx_infer_prefix(argv[optind])) == 0) {
|
||||||
fprintf(stderr, "[%s] fail to locate the index\n", __func__);
|
fprintf(stderr, "[%s] fail to locate the index\n", __func__);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
bwa_sai2sam_se_core(prefix, argv[optind+1], argv[optind+2], n_occ, rg_line);
|
bwa_sai2sam_se_core(prefix, argv[optind+1], argv[optind+2], n_occ, rg_line);
|
||||||
free(prefix);
|
free(prefix);
|
||||||
|
|
|
||||||
2
bwtaln.c
2
bwtaln.c
|
|
@ -306,7 +306,7 @@ int bwa_aln(int argc, char *argv[])
|
||||||
if ((prefix = bwa_idx_infer_prefix(argv[optind])) == 0) {
|
if ((prefix = bwa_idx_infer_prefix(argv[optind])) == 0) {
|
||||||
fprintf(stderr, "[%s] fail to locate the index\n", __func__);
|
fprintf(stderr, "[%s] fail to locate the index\n", __func__);
|
||||||
free(opt);
|
free(opt);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
bwa_aln_core(prefix, argv[optind+1], opt);
|
bwa_aln_core(prefix, argv[optind+1], opt);
|
||||||
free(opt); free(prefix);
|
free(opt); free(prefix);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ int bwa_bwtsw2(int argc, char *argv[])
|
||||||
case 'S': opt->skip_sw = 1; break;
|
case 'S': opt->skip_sw = 1; break;
|
||||||
case 'C': opt->cpy_cmt = 1; break;
|
case 'C': opt->cpy_cmt = 1; break;
|
||||||
case 'G': opt->max_chain_gap = atoi(optarg); break;
|
case 'G': opt->max_chain_gap = atoi(optarg); break;
|
||||||
|
default: return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
opt->qr = opt->q + opt->r;
|
opt->qr = opt->q + opt->r;
|
||||||
|
|
@ -79,7 +80,7 @@ int bwa_bwtsw2(int argc, char *argv[])
|
||||||
opt->t *= opt->a;
|
opt->t *= opt->a;
|
||||||
opt->coef *= opt->a;
|
opt->coef *= opt->a;
|
||||||
|
|
||||||
if ((idx = bwa_idx_load(argv[optind], BWA_IDX_BWT|BWA_IDX_BNS)) == 0) return 0;
|
if ((idx = bwa_idx_load(argv[optind], BWA_IDX_BWT|BWA_IDX_BNS)) == 0) return 1;
|
||||||
bsw2_aln(opt, idx->bns, idx->bwt, argv[optind+1], optind+2 < argc? argv[optind+2] : 0);
|
bsw2_aln(opt, idx->bns, idx->bwt, argv[optind+1], optind+2 < argc? argv[optind+2] : 0);
|
||||||
bwa_idx_destroy(idx);
|
bwa_idx_destroy(idx);
|
||||||
free(opt);
|
free(opt);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ int main_mem(int argc, char *argv[])
|
||||||
else if (c == 'R') {
|
else if (c == 'R') {
|
||||||
if ((rg_line = bwa_set_rg(optarg)) == 0) return 1; // FIXME: memory leak
|
if ((rg_line = bwa_set_rg(optarg)) == 0) return 1; // FIXME: memory leak
|
||||||
} else if (c == 's') opt->split_width = atoi(optarg);
|
} else if (c == 's') opt->split_width = atoi(optarg);
|
||||||
|
else return 1;
|
||||||
}
|
}
|
||||||
if (opt->n_threads < 1) opt->n_threads = 1;
|
if (opt->n_threads < 1) opt->n_threads = 1;
|
||||||
if (optind + 1 >= argc) {
|
if (optind + 1 >= argc) {
|
||||||
|
|
@ -164,6 +165,7 @@ int main_fastmap(int argc, char *argv[])
|
||||||
case 'p': print_seq = 1; break;
|
case 'p': print_seq = 1; break;
|
||||||
case 'w': min_iwidth = atoi(optarg); break;
|
case 'w': min_iwidth = atoi(optarg); break;
|
||||||
case 'l': min_len = atoi(optarg); break;
|
case 'l': min_len = atoi(optarg); break;
|
||||||
|
default: return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (optind + 1 >= argc) {
|
if (optind + 1 >= argc) {
|
||||||
|
|
@ -173,7 +175,7 @@ int main_fastmap(int argc, char *argv[])
|
||||||
|
|
||||||
fp = xzopen(argv[optind + 1], "r");
|
fp = xzopen(argv[optind + 1], "r");
|
||||||
seq = kseq_init(fp);
|
seq = kseq_init(fp);
|
||||||
idx = bwa_idx_load(argv[optind], BWA_IDX_BWT|BWA_IDX_BNS);
|
if ((idx = bwa_idx_load(argv[optind], BWA_IDX_BWT|BWA_IDX_BNS)) == 0) return 1;
|
||||||
itr = smem_itr_init(idx->bwt);
|
itr = smem_itr_init(idx->bwt);
|
||||||
while (kseq_read(seq) >= 0) {
|
while (kseq_read(seq) >= 0) {
|
||||||
err_printf("SQ\t%s\t%ld", seq->name.s, seq->seq.l);
|
err_printf("SQ\t%s\t%ld", seq->name.s, seq->seq.l);
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,7 @@ int main_pemerge(int argc, char *argv[])
|
||||||
else if (c == 'Q') opt->q_thres = atoi(optarg);
|
else if (c == 'Q') opt->q_thres = atoi(optarg);
|
||||||
else if (c == 't') opt->n_threads = atoi(optarg);
|
else if (c == 't') opt->n_threads = atoi(optarg);
|
||||||
else if (c == 'T') min_ovlp = atoi(optarg);
|
else if (c == 'T') min_ovlp = atoi(optarg);
|
||||||
|
else return 1;
|
||||||
}
|
}
|
||||||
if (flag == 0) flag = 3;
|
if (flag == 0) flag = 3;
|
||||||
opt->flag = flag;
|
opt->flag = flag;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue