]> git.donarmstrong.com Git - samtools.git/commitdiff
* 0.1.12-r924:126
authorHeng Li <lh3@live.co.uk>
Mon, 28 Feb 2011 20:24:04 +0000 (20:24 +0000)
committerHeng Li <lh3@live.co.uk>
Mon, 28 Feb 2011 20:24:04 +0000 (20:24 +0000)
 * fixed a bug in phase (due to recent changes)
 * fixed a bug in vcf2fq

bam.h
bcftools/vcfutils.pl
phase.c

diff --git a/bam.h b/bam.h
index 752d0bda7dea595c3c9014968fee9cd02057662b..41f8d95d5b642c5e5f683e34cfbaf12764d1ac78 100644 (file)
--- a/bam.h
+++ b/bam.h
@@ -40,7 +40,7 @@
   @copyright Genome Research Ltd.
  */
 
-#define BAM_VERSION "0.1.12-r921:124"
+#define BAM_VERSION "0.1.12-r924:126"
 
 #include <stdint.h>
 #include <stdlib.h>
index 12807c6d40d0af9b05fbdfd8d3065b68623ac0be..6ced66a2893e9b98884774e88607e9f2060af3d1 100755 (executable)
@@ -201,7 +201,7 @@ Note: This command discards indels. Output: QUAL #non-indel #SNPs #transitions #
          my @x;
          $x[0] = sprintf("%.4f", $c[1]-$c[2]? $c[2] / ($c[1] - $c[2]) : 100);
          $x[1] = sprintf("%.4f", $hsize? $c[3] / $hsize : 0);
-         $x[2] = sprintf("%.4f", $c[1] ? $c[3] / $c[1] : 0);
+         $x[2] = sprintf("%.4f", $c[3] / $c[1]);
          my $a = $c[1] - $lc[1];
          my $b = $c[2] - $lc[2];
          $x[3] = sprintf("%.4f", $a-$b? $b / ($a-$b) : 100);
@@ -512,7 +512,7 @@ Options: -d INT    minimum depth          [$opts{d}]
          $q = chr($q <= 126? $q : 126);
          $seq .= $b;
          $qual .= $q;
-       } else { # an INDEL
+       } elsif ($t[4] ne '.') { # an INDEL
          push(@gaps, [$t[1], length($t[3])]);
        }
        $last_pos = $t[1];
diff --git a/phase.c b/phase.c
index 5fc4ce77d94ed3046082abf7a9525caf3362f7c3..aa88921c3c6a45f85231a5011e3cccd3bae2d433 100644 (file)
--- a/phase.c
+++ b/phase.c
@@ -34,7 +34,7 @@ typedef struct {
 typedef struct {
        int8_t seq[MAX_VARS]; // TODO: change to dynamic memory allocation!
        int vpos, beg, end;
-       uint32_t vlen:16, single:1, flip:1, phase:1, phased:1;
+       uint32_t vlen:16, single:1, flip:1, phase:1, phased:1, ambig:1;
        uint32_t in:16, out:16; // in-phase and out-phase
 } frag_t, *frag_p;
 
@@ -176,7 +176,8 @@ static uint64_t *fragphase(int vpos, const int8_t *path, nseq_t *hash, int flip)
                        }
                        f->phase = c[0] > c[1]? 0 : 1;
                        f->in = c[f->phase]; f->out = c[1 - f->phase];
-                       if (f->in && f->out && f->in <= f->out + 1) f->phased = 0;
+                       f->phased = f->in == f->out? 0 : 1;
+                       f->ambig = (f->in && f->out && f->in <= f->out + 1)? 1 : 0;
                        // fix chimera
                        f->flip = 0;
                        if (flip && c[0] >= 3 && c[1] >= 3) {
@@ -321,8 +322,9 @@ static void dump_aln(phaseg_t *g, int min_pos, const nseq_t *hash)
                if (k == kh_end(hash)) which = 3;
                else {
                        frag_t *f = &kh_val(hash, k);
-                       if (f->phased && f->flip) which = 2;
-                       else if (f->phased == 0) which = 2;
+                       if (f->ambig) which = 2;
+                       else if (f->phased && f->flip) which = 2;
+                       else if (f->phased == 0) which = 3;
                        else { // phased and not flipped
                                char c = 'Y';
                                which = f->phase;
@@ -652,7 +654,7 @@ int main_phase(int argc, char *argv[])
                                memset(f->seq, 0, MAX_VARS);
                                f->beg = p->b->core.pos;
                                f->end = bam_calend(&p->b->core, bam1_cigar(p->b));
-                               f->vpos = vpos, f->vlen = 1, f->seq[0] = c, f->single = f->phased = f->flip = 0;
+                               f->vpos = vpos, f->vlen = 1, f->seq[0] = c, f->single = f->phased = f->flip = f->ambig = 0;
                        }
                }
                if (dophase) {