X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bam_plcmd.c;h=51dece53796f23563c2943e77c8482f70ddef1d5;hb=694a8aef02cb6314c8440c2b325981f4e7f13167;hp=ed00d2e80202fde96d5c5aecfc28aa8ff39e5bd6;hpb=a71383ee344af03b1d8084a7ed8752a12f68e8e7;p=samtools.git diff --git a/bam_plcmd.c b/bam_plcmd.c index ed00d2e..51dece5 100644 --- a/bam_plcmd.c +++ b/bam_plcmd.c @@ -208,6 +208,11 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn) bam_header_t *h_tmp; data[i] = calloc(1, sizeof(mplp_aux_t)); data[i]->fp = strcmp(fn[i], "-") == 0? bam_dopen(fileno(stdin), "r") : bam_open(fn[i], "r"); + if ( !data[i]->fp ) + { + fprintf(stderr, "[%s] failed to open %s: %s\n", __func__, fn[i], strerror(errno)); + exit(1); + } data[i]->conf = conf; h_tmp = bam_header_read(data[i]->fp); data[i]->h = i? h : h_tmp; // for i==0, "h" has not been set yet @@ -218,11 +223,11 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn) bam_index_t *idx; idx = bam_index_load(fn[i]); if (idx == 0) { - fprintf(stderr, "[%s] fail to load index for %d-th input.\n", __func__, i+1); + fprintf(stderr, "[%s] fail to load index for %s\n", __func__, fn[i]); exit(1); } if (bam_parse_region(h_tmp, conf->reg, &tid, &beg, &end) < 0) { - fprintf(stderr, "[%s] malformatted region or wrong seqname for %d-th input.\n", __func__, i+1); + fprintf(stderr, "[%s] malformatted region or wrong seqname for %s\n", __func__, fn[i]); exit(1); } if (i == 0) tid0 = tid, beg0 = beg, end0 = end;