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) {
|
||||
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);
|
||||
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) {
|
||||
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);
|
||||
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) {
|
||||
fprintf(stderr, "[%s] fail to locate the index\n", __func__);
|
||||
free(opt);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
bwa_aln_core(prefix, argv[optind+1], opt);
|
||||
free(opt); free(prefix);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ int bwa_bwtsw2(int argc, char *argv[])
|
|||
case 'S': opt->skip_sw = 1; break;
|
||||
case 'C': opt->cpy_cmt = 1; break;
|
||||
case 'G': opt->max_chain_gap = atoi(optarg); break;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
opt->qr = opt->q + opt->r;
|
||||
|
|
@ -79,7 +80,7 @@ int bwa_bwtsw2(int argc, char *argv[])
|
|||
opt->t *= 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);
|
||||
bwa_idx_destroy(idx);
|
||||
free(opt);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ int main_mem(int argc, char *argv[])
|
|||
else if (c == 'R') {
|
||||
if ((rg_line = bwa_set_rg(optarg)) == 0) return 1; // FIXME: memory leak
|
||||
} else if (c == 's') opt->split_width = atoi(optarg);
|
||||
else return 1;
|
||||
}
|
||||
if (opt->n_threads < 1) opt->n_threads = 1;
|
||||
if (optind + 1 >= argc) {
|
||||
|
|
@ -164,6 +165,7 @@ int main_fastmap(int argc, char *argv[])
|
|||
case 'p': print_seq = 1; break;
|
||||
case 'w': min_iwidth = atoi(optarg); break;
|
||||
case 'l': min_len = atoi(optarg); break;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
if (optind + 1 >= argc) {
|
||||
|
|
@ -173,7 +175,7 @@ int main_fastmap(int argc, char *argv[])
|
|||
|
||||
fp = xzopen(argv[optind + 1], "r");
|
||||
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);
|
||||
while (kseq_read(seq) >= 0) {
|
||||
err_printf("SQ\t%s\t%ld", seq->name.s, seq->seq.l);
|
||||
|
|
|
|||
Loading…
Reference in New Issue