]> git.donarmstrong.com Git - samtools.git/blobdiff - bam2bcf.c
works
[samtools.git] / bam2bcf.c
index ed78ea6c7048fb9d21248cb4812726c77e3afd45..a51a406f249c05834b0d8e20f49403d5ed29a3b6 100644 (file)
--- a/bam2bcf.c
+++ b/bam2bcf.c
@@ -87,9 +87,9 @@ int bcf_call_glfgen(int _n, const bam_pileup1_t *pl, int ref_base, bcf_callaux_t
                if (min_dist > p->qpos) min_dist = p->qpos;
                if (min_dist > CAP_DIST) min_dist = CAP_DIST;
                r->anno[1<<2|is_diff<<1|0] += baseQ;
-               r->anno[1<<2|is_diff<<1|1] += baseQ * baseQ;
+               r->anno[1<<2|is_diff<<1|1] += baseQ * baseQ;    // FIXME: signed int is not enough for thousands of samples
                r->anno[2<<2|is_diff<<1|0] += mapQ;
-               r->anno[2<<2|is_diff<<1|1] += mapQ * mapQ;
+               r->anno[2<<2|is_diff<<1|1] += mapQ * mapQ;              // FIXME: signed int is not enough for thousands of samples
                r->anno[3<<2|is_diff<<1|0] += min_dist;
                r->anno[3<<2|is_diff<<1|1] += min_dist * min_dist;
        }
@@ -196,7 +196,7 @@ int bcf_call_combine(int n, const bcf_callret1_t *calls, int ref_base /*4-bit*/,
                for (j = 0; j < 4; ++j)
                        qsum[j] += calls[i].qsum[j];
     int qsum_tot=0;
-    for (j=0; j<4; j++) qsum_tot += qsum[j];
+    for (j=0; j<4; j++) { qsum_tot += qsum[j]; call->qsum[j] = 0; }
        for (j = 0; j < 4; ++j) qsum[j] = qsum[j] << 2 | j;
        // find the top 2 alleles
        for (i = 1; i < 4; ++i) // insertion sort
@@ -210,7 +210,7 @@ int bcf_call_combine(int n, const bcf_callret1_t *calls, int ref_base /*4-bit*/,
                if ((qsum[i]&3) != ref4) {
                        if (qsum[i]>>2 != 0) 
             {
-                call->qsum[j] = (float)(qsum[i]>>2)/qsum_tot;
+                if ( j<4 ) call->qsum[j] = (float)(qsum[i]>>2)/qsum_tot; // ref N can make j>=4
                 call->a[j++]  = qsum[i]&3;
             }
                        else break;
@@ -313,7 +313,7 @@ int bcf_call2bcf(int tid, int pos, bcf_call_t *bc, bcf1_t *b, bcf_callret1_t *bc
        }
        kputc('\0', &s);
        // INFO
-       if (bc->ori_ref < 0) kputs("INDEL;", &s);
+       if (bc->ori_ref < 0) ksprintf(&s,"INDEL;IS=%d,%f;", bca->max_support, bca->max_frac);
        kputs("DP=", &s); kputw(bc->ori_depth, &s); kputs(";I16=", &s);
        for (i = 0; i < 16; ++i) {
                if (i) kputc(',', &s);