]> git.donarmstrong.com Git - samtools.git/blobdiff - bam_plcmd.c
* samtools-0.1.9-9 (r810)
[samtools.git] / bam_plcmd.c
index 0fbc9303c25744ebde8d1b0e269c539d5c4f5325..ad6134b3ee7cdeb179c3a86fd46658b0aef83aef 100644 (file)
@@ -556,7 +556,7 @@ typedef struct {
 static int mplp_func(void *data, bam1_t *b)
 {
        extern int bam_realn(bam1_t *b, const char *ref);
-       extern int bam_prob_realn(bam1_t *b, const char *ref);
+       extern int bam_prob_realn_core(bam1_t *b, const char *ref, int);
        extern int bam_cap_mapQ(bam1_t *b, char *ref, int thres);
        mplp_aux_t *ma = (mplp_aux_t*)data;
        int ret, skip = 0;
@@ -565,7 +565,7 @@ static int mplp_func(void *data, bam1_t *b)
                ret = ma->iter? bam_iter_read(ma->fp, ma->iter, b) : bam_read1(ma->fp, b);
                if (ret < 0) break;
                skip = 0;
-               if (has_ref && (ma->flag&MPLP_REALN)) bam_prob_realn(b, ma->ref);
+               if (has_ref && (ma->flag&MPLP_REALN)) bam_prob_realn_core(b, ma->ref, 1);
                if (has_ref && ma->capQ_thres > 10) {
                        int q = bam_cap_mapQ(b, ma->ref, ma->capQ_thres);
                        if (q < 0) skip = 1;
@@ -739,12 +739,13 @@ static int mpileup(mplp_conf_t *conf, int n, char **fn)
                        if (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);
-                               bcf_call_combine(gplp.n, bcr, -1, &bc);
-                               b = calloc(1, sizeof(bcf1_t));
-                               bcf_call2bcf(tid, pos, &bc, b, (conf->flag&(MPLP_FMT_DP|MPLP_FMT_SP))? bcr : 0,
-                                                        (conf->flag&MPLP_FMT_SP), bca, ref);
-                               bcf_write(bp, bh, b);
-                               bcf_destroy(b);
+                               if (bcf_call_combine(gplp.n, bcr, -1, &bc) >= 0) {
+                                       b = calloc(1, sizeof(bcf1_t));
+                                       bcf_call2bcf(tid, pos, &bc, b, (conf->flag&(MPLP_FMT_DP|MPLP_FMT_SP))? bcr : 0,
+                                                                (conf->flag&MPLP_FMT_SP), bca, ref);
+                                       bcf_write(bp, bh, b);
+                                       bcf_destroy(b);
+                               }
                        }
                } else {
                        printf("%s\t%d\t%c", h->target_name[tid], pos + 1, (ref && pos < ref_len)? ref[pos] : 'N');