Skip to content

Commit

Permalink
Ensure exit status of 1 if given invalid options or index files are n…
Browse files Browse the repository at this point in the history
…ot 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.
  • Loading branch information
Rob Davies committed Apr 29, 2013
1 parent e885296 commit 0aa7e0a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bwape.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion bwase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion bwtaln.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion bwtsw2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion fastmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions pemerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ int main_pemerge(int argc, char *argv[])
else if (c == 'Q') opt->q_thres = atoi(optarg);
else if (c == 't') opt->n_threads = atoi(optarg);
else if (c == 'T') min_ovlp = atoi(optarg);
else return 1;
}
if (flag == 0) flag = 3;
opt->flag = flag;
Expand Down

0 comments on commit 0aa7e0a

Please sign in to comment.