]> git.donarmstrong.com Git - samtools.git/blobdiff - bcftools/vcfout.c
* improved kstring (added kstrtok)
[samtools.git] / bcftools / vcfout.c
index 51cfef1479f869d665417cfa2a837b86376a56ad..dfcb25a4c0a40cadda0cadf1c702545e0aa1a01b 100644 (file)
@@ -77,7 +77,7 @@ static double test_hwe(const double g[3])
 
 extern double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two);
 
-static double test_fisher(bcf1_t *b, const char *key, int d[4])
+static double test_fisher(bcf1_t *b, const char *key, int d[4], int is_single)
 {
        double left, right, two;
        char *p;
@@ -90,7 +90,7 @@ static double test_fisher(bcf1_t *b, const char *key, int d[4])
                ++p;
        }
        kt_fisher_exact(d[0], d[1], d[2], d[3], &left, &right, &two);
-       return two;
+       return is_single? right : two;
 }
 
 static void rm_info(int n_smpl, bcf1_t *b, const char *key)
@@ -111,8 +111,8 @@ static int update_bcf1(int n_smpl, bcf1_t *b, const bcf_p1aux_t *pa, const bcf_p
        double p_hwe, p_dp, p_ed, r = is_var? pr->p_ref : 1. - pr->p_ref;
 
        p_hwe = test_hwe(pr->g);
-       p_ed = test_fisher(b, "ED4=", d);
-       p_dp = test_fisher(b, "DP4=", d);
+       p_ed = test_fisher(b, "ED4=", d, 1);
+       p_dp = test_fisher(b, "DP4=", d, 0);
        rm_info(n_smpl, b, "ED4=");
 
        memset(&s, 0, sizeof(kstring_t));
@@ -126,7 +126,7 @@ static int update_bcf1(int n_smpl, bcf1_t *b, const bcf_p1aux_t *pa, const bcf_p
                if (b->info[0]) kputc(';', &s);
                ksprintf(&s, "AF1=%.3lf;AFE=%.3lf", 1.-pr->f_em, 1.-pr->f_exp);
        }
-       if (p_hwe <= .2) ksprintf(&s, ";HWE=%.3lf", p_hwe);
+       if (p_hwe <= .2) ksprintf(&s, ";GC=%.2lf,%.2lf,%.2lf;HWE=%.3lf", pr->g[2], pr->g[1], pr->g[0], p_hwe);
        if (p_dp >= 0. && p_dp <= .2) ksprintf(&s, ";TDP=%.3lf", p_dp);
        if (p_ed >= 0. && p_ed <= .2) ksprintf(&s, ";TED=%.3lf", p_ed);
        kputc('\0', &s);
@@ -172,7 +172,18 @@ int bcfview(int argc, char *argv[])
                }
        }
        if (argc == optind) {
-               fprintf(stderr, "Usage: bcftools view [-cGPb] [-l list] <in.bcf> [reg]\n");
+               fprintf(stderr, "\n");
+               fprintf(stderr, "Usage:   bcftools view [options] <in.bcf> [reg]\n\n");
+               fprintf(stderr, "Options: -c        SNP calling\n");
+               fprintf(stderr, "         -b        output BCF instead of VCF\n");
+               fprintf(stderr, "         -G        suppress all individual genotype information\n");
+               fprintf(stderr, "         -L        discard the PL genotype field\n");
+               fprintf(stderr, "         -v        output potential variant sites only\n");
+               fprintf(stderr, "         -l FILE   list of sites to output [all sites]\n");
+               fprintf(stderr, "         -t FLOAT  scaled mutation rate [%.4lg]\n", vc.theta);
+               fprintf(stderr, "         -p FLOAT  variant if P(ref|D)<FLOAT [%.3lg]\n", vc.pref);
+               fprintf(stderr, "         -P STR    type of prior: full, cond2, flat [full]\n");
+               fprintf(stderr, "\n");
                return 1;
        }