]> git.donarmstrong.com Git - samtools.git/commitdiff
print QUAL as floating numbers
authorHeng Li <lh3@live.co.uk>
Mon, 23 Aug 2010 18:46:52 +0000 (18:46 +0000)
committerHeng Li <lh3@live.co.uk>
Mon, 23 Aug 2010 18:46:52 +0000 (18:46 +0000)
bcftools/bcf.c
bcftools/vcfout.c

index e375a1fb8791cd6b3f34cfa070d53396b158133e..8801cea00a23feaea70e7cc40a736f580e9f17c1 100644 (file)
@@ -213,7 +213,7 @@ void bcf_fmt_core(const bcf_hdr_t *h, bcf1_t *b, kstring_t *s)
        fmt_str(b->str, s); kputc('\t', s);
        fmt_str(b->ref, s); kputc('\t', s);
        fmt_str(b->alt, s); kputc('\t', s);
-       kputw(b->qual, s); kputc('\t', s);
+       ksprintf(s, "%.3g", b->qual); /*kputw(b->qual, s);*/ kputc('\t', s);
        fmt_str(b->flt, s); kputc('\t', s);
        fmt_str(b->info, s);
        if (b->fmt[0]) {
index f54fde55f8195de0746b372c1a522903cf394b54..e02e364ca1d2a3921e6900fa0cf4e0c63908d780 100644 (file)
@@ -109,7 +109,7 @@ static void rm_info(int n_smpl, bcf1_t *b, const char *key)
 static int update_bcf1(int n_smpl, bcf1_t *b, const bcf_p1aux_t *pa, const bcf_p1rst_t *pr, double pref, int flag)
 {
        kstring_t s;
-       int d[4], x, is_var = (pr->p_ref < pref);
+       int d[4], is_var = (pr->p_ref < pref);
        double p_hwe, p_dp, p_ed, r = is_var? pr->p_ref : 1. - pr->p_ref;
 
        p_hwe = test_hwe(pr->g);
@@ -133,8 +133,8 @@ static int update_bcf1(int n_smpl, bcf1_t *b, const bcf_p1aux_t *pa, const bcf_p
        kputs(b->fmt, &s); kputc('\0', &s);
        free(b->str);
        b->m_str = s.m; b->l_str = s.l; b->str = s.s;
-       x = (int)(r < 1e-100? 99 : -3.434 * log(r) + .499);
-       b->qual = x > 99? 99 : x;
+       b->qual = r < 1e-100? 99 : -3.434 * log(r);
+       if (b->qual > 99) b->qual = 99;
        bcf_sync(n_smpl, b);
        return is_var;
 }