From 05cb7b5bb86b37e82a3ea7868b76031866303da2 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Mon, 23 Aug 2010 18:46:52 +0000 Subject: [PATCH] print QUAL as floating numbers --- bcftools/bcf.c | 2 +- bcftools/vcfout.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bcftools/bcf.c b/bcftools/bcf.c index e375a1f..8801cea 100644 --- a/bcftools/bcf.c +++ b/bcftools/bcf.c @@ -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]) { diff --git a/bcftools/vcfout.c b/bcftools/vcfout.c index f54fde5..e02e364 100644 --- a/bcftools/vcfout.c +++ b/bcftools/vcfout.c @@ -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; } -- 2.39.2