]> git.donarmstrong.com Git - samtools.git/blobdiff - bam_plcmd.c
Merge remote branch 'remotes/master/master' into fb-annots
[samtools.git] / bam_plcmd.c
index 8935c5a2f52437057596f6e35ab74dc85a2a569c..9c4f273dcbfe2c3576e9c6ea0e2d7661839bbb85 100644 (file)
@@ -220,6 +220,10 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
         }
                data[i]->conf = conf;
                h_tmp = bam_header_read(data[i]->fp);
+        if ( !h_tmp ) {
+            fprintf(stderr,"[%s] fail to read the header of %s\n", __func__, fn[i]);
+            exit(1);
+        }
                data[i]->h = i? h : h_tmp; // for i==0, "h" has not been set yet
                bam_smpl_add(sm, fn[i], (conf->flag&MPLP_IGNORE_RG)? 0 : h_tmp->text);
                rghash = bcf_call_add_rg(rghash, h_tmp->text, conf->pl_list);
@@ -317,7 +321,7 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                        ref16 = bam_nt16_table[_ref0];
                        for (i = 0; i < gplp.n; ++i)
                                bcf_call_glfgen(gplp.n_plp[i], gplp.plp[i], ref16, bca, bcr + i);
-                       bcf_call_combine(gplp.n, bcr, ref16, &bc);
+                       bcf_call_combine(gplp.n, bcr, bca, ref16, &bc);
                        bcf_call2bcf(tid, pos, &bc, b, bcr, conf->fmt_flag, 0, 0);
                        bcf_write(bp, bh, b);
                        bcf_destroy(b);
@@ -325,7 +329,7 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                        if (!(conf->flag&MPLP_NO_INDEL) && total_depth < max_indel_depth && bcf_call_gap_prep(gplp.n, gplp.n_plp, gplp.plp, pos, bca, ref, rghash) >= 0) {
                                for (i = 0; i < gplp.n; ++i)
                                        bcf_call_glfgen(gplp.n_plp[i], gplp.plp[i], -1, bca, bcr + i);
-                               if (bcf_call_combine(gplp.n, bcr, -1, &bc) >= 0) {
+                               if (bcf_call_combine(gplp.n, bcr, bca, -1, &bc) >= 0) {
                                        b = calloc(1, sizeof(bcf1_t));
                                        bcf_call2bcf(tid, pos, &bc, b, bcr, conf->fmt_flag, bca, ref);
                                        bcf_write(bp, bh, b);