Imported Upstream version 0.1.12a
authorCharles Plessy <plessy@debian.org>
Fri, 3 Dec 2010 04:24:39 +0000 (13:24 +0900)
committerCharles Plessy <plessy@debian.org>
Fri, 3 Dec 2010 04:24:39 +0000 (13:24 +0900)
NEWS
bam2bcf_indel.c
bam_index.c
bam_plcmd.c
bamtk.c
bcftools/bcf.c
bcftools/call1.c
bcftools/ld.c
bcftools/vcfutils.pl
samtools.1
samtools.txt

diff --git a/NEWS b/NEWS
index 478e718c79963a052e682bbc33cfa0de695076e0..6b4d8aac5ede779b7efee6e02969dea40926275c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,29 @@
+Beta release 0.1.12a (2 December, 2010)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This is another bug fix release:
+
+ * Fixed a memory violation in mpileup, which causes segfault. Release
+   0.1.9 and above are affected.
+
+ * Fixed a memory violation in the indel caller, which does not causes
+   segfault, but may potentially affect deletion calls in an unexpected
+   way. Release 0.1.10 and above are affected.
+
+ * Fixed a bug in computing r-square in bcftools. Few are using this
+   functionality and it only has minor effect.
+
+ * Fixed a memory leak in bam_fetch().
+
+ * Fixed a bug in writing meta information to the BAM index for the last
+   sequence. This bug is invisible to most users, but it is a bug anyway.
+
+ * Fixed a bug in bcftools which causes false "DP4=0,0,0,0" annotations.
+
+(0.1.12: 2 December 2010, r862)
+
+
+
 Beta release 0.1.11 (21 November, 2010)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
index 819c1e7b1371296b7da5536939fab691f53c1722..16241d0c0399fb7e727951f2d8f64d86798e25d1 100644 (file)
@@ -112,7 +112,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
                                          const void *rghash)
 {
        extern void ks_introsort_uint32_t(int, uint32_t*);
-       int i, s, j, k, t, n_types, *types, max_rd_len, left, right, max_ins, *score1, *score2;
+       int i, s, j, k, t, n_types, *types, max_rd_len, left, right, max_ins, *score1, *score2, max_ref2;
        int N, K, l_run, ref_type, n_alt;
        char *inscns = 0, *ref2, *query;
        khash_t(rg) *hash = (khash_t(rg)*)rghash;
@@ -236,7 +236,8 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
                free(inscns_aux);
        }
        // compute the likelihood given each type of indel for each read
-       ref2  = calloc(right - left + max_ins + 2, 1);
+       max_ref2 = right - left + 2 + 2 * (max_ins > -types[0]? max_ins : -types[0]);
+       ref2  = calloc(max_ref2, 1);
        query = calloc(right - left + max_rd_len + max_ins + 2, 1);
        score1 = calloc(N * n_types, sizeof(int));
        score2 = calloc(N * n_types, sizeof(int));
@@ -264,6 +265,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
                }
                for (; j < right && ref[j]; ++j)
                        ref2[k++] = bam_nt16_nt4_table[bam_nt16_table[(int)ref[j]]];
+               for (; k < max_ref2; ++k) ref2[k] = 4;
                if (j < right) right = j;
                // align each read to ref2
                for (s = K = 0; s < n; ++s) {
index f60a6f874b106f03c655d1207dddf21c4df7fc48..328f011c16ccf4a9a558702317ecdecfbcc5212a 100644 (file)
@@ -212,7 +212,7 @@ bam_index_t *bam_index_core(bamFile fp)
        }
        if (save_tid >= 0) {
                insert_offset(idx->index[save_tid], save_bin, save_off, bam_tell(fp));
-               insert_offset(idx->index[save_tid], BAM_MAX_BIN, off_beg, off_end);
+               insert_offset(idx->index[save_tid], BAM_MAX_BIN, off_beg, bam_tell(fp));
                insert_offset(idx->index[save_tid], BAM_MAX_BIN, n_mapped, n_unmapped);
        }
        merge_chunks(idx);
@@ -698,6 +698,7 @@ int bam_fetch(bamFile fp, const bam_index_t *idx, int tid, int beg, int end, voi
        b = bam_init1();
        iter = bam_iter_query(idx, tid, beg, end);
        while ((ret = bam_iter_read(fp, iter, b)) >= 0) func(b, data);
+       bam_iter_destroy(iter);
        bam_destroy1(b);
        return (ret == -1)? 0 : ret;
 }
index e3f73aaddd03a14343a82084ee060d9c41ba42d4..002297a1229678a256e9045f420b89d5f273b1ea 100644 (file)
@@ -563,9 +563,10 @@ static int mplp_func(void *data, bam1_t *b)
        mplp_aux_t *ma = (mplp_aux_t*)data;
        int ret, skip = 0;
        do {
-               int has_ref = (ma->ref && ma->ref_id == b->core.tid)? 1 : 0;
+               int has_ref;
                ret = ma->iter? bam_iter_read(ma->fp, ma->iter, b) : bam_read1(ma->fp, b);
                if (ret < 0) break;
+               has_ref = (ma->ref && ma->ref_id == b->core.tid)? 1 : 0;
                skip = 0;
                if (has_ref && (ma->flag&MPLP_REALN)) bam_prob_realn_core(b, ma->ref, 1);
                if (has_ref && ma->capQ_thres > 10) {
diff --git a/bamtk.c b/bamtk.c
index 4c2a4a282b7d351999f05c5e12d7d891acf93ba2..79635d6bf1bca8bad00abdaa5f926b35a3fc59a0 100644 (file)
--- a/bamtk.c
+++ b/bamtk.c
@@ -9,7 +9,7 @@
 #endif
 
 #ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.11 (r851)"
+#define PACKAGE_VERSION "0.1.12a (r862)"
 #endif
 
 int bam_taf2baf(int argc, char *argv[]);
index fd5c0c9ae24971f15168f488452afe2077258dd0..6e45695cfb8c35a22dc4699728e445129293a699 100644 (file)
@@ -181,7 +181,7 @@ int bcf_read(bcf_t *bp, const bcf_hdr_t *h, bcf1_t *b)
        }
        bgzf_read(bp->fp, b->str, b->l_str);
        l = 12 + b->l_str;
-       bcf_sync(b);
+       if (bcf_sync(b) < 0) return -2;
        for (i = 0; i < b->n_gi; ++i) {
                bgzf_read(bp->fp, b->gi[i].data, b->gi[i].len * h->n_smpl);
                l += b->gi[i].len * h->n_smpl;
index 5e4fc9fbc267928260c678ef3ce62f942fcebc7b..f293a6cf94e611a9f9ff50d83ab1b69c660e15d7 100644 (file)
@@ -129,7 +129,7 @@ static int test16(bcf1_t *b, anno16_t *a)
        if ((p = strstr(b->info, "I16=")) == 0) return -1;
        p += 4;
        for (i = 0; i < 16; ++i) {
-               anno[i] = strtol(p, &p, 10);
+               errno = 0; anno[i] = strtol(p, &p, 10);
                if (anno[i] == 0 && (errno == EINVAL || errno == ERANGE)) return -2;
                ++p;
        }
index aa7ec072b2c7fc2e60ea3d1fe8145711a8841d28..dc84d4b02d836f0a07a0736588dd1142485d10cf 100644 (file)
@@ -80,7 +80,7 @@ double bcf_ld_freq(const bcf1_t *b0, const bcf1_t *b1, double f[4])
                memcpy(flast, f, 4 * sizeof(double));
                freq_iter(n_smpl, pdg, f);
                for (i = 0; i < 4; ++i) {
-                       double x = fabs(f[0] - flast[0]);
+                       double x = fabs(f[i] - flast[i]);
                        if (x > eps) eps = x;
                }
                if (eps < LD_ITER_EPS) break;
index 6cc168fb363f59541511429b6e6538e0263acbe1..cd86b0fba041a77bb9d887473fa68cb853f1c597 100755 (executable)
@@ -14,11 +14,27 @@ sub main {
   my $command = shift(@ARGV);
   my %func = (subsam=>\&subsam, listsam=>\&listsam, fillac=>\&fillac, qstats=>\&qstats, varFilter=>\&varFilter,
                          hapmap2vcf=>\&hapmap2vcf, ucscsnp2vcf=>\&ucscsnp2vcf, filter4vcf=>\&varFilter, ldstats=>\&ldstats,
-                         gapstats=>\&gapstats);
+                         gapstats=>\&gapstats, splitchr=>\&splitchr);
   die("Unknown command \"$command\".\n") if (!defined($func{$command}));
   &{$func{$command}};
 }
 
+sub splitchr {
+  my %opts = (l=>5000000);
+  getopts('l:', \%opts);
+  my $l = $opts{l};
+  die(qq/Usage: vcfutils.pl splitchr [-l $opts{l}] <in.fa.fai>\n/) if (@ARGV == 0 && -t STDIN);
+  while (<>) {
+       my @t = split;
+       my $last = 0;
+       for (my $i = 0; $i < $t[1];) {
+         my $e = ($t[1] - $i) / $l < 1.1? $t[1] : $i + $l;
+         print "$t[0]:".($i+1)."-$e\n";
+         $i = $e;
+       }
+  }
+}
+
 sub subsam {
   die(qq/Usage: vcfutils.pl subsam <in.vcf> [samples]\n/) if (@ARGV == 0);
   my ($fh, %h);
index e0595607196e577f15227c5cef8af0c9f51de2d6..57f1aff50065ef54c470436108a5c69da8c73d84 100644 (file)
@@ -1,4 +1,4 @@
-.TH samtools 1 "21 November 2010" "samtools-0.1.11" "Bioinformatics tools"
+.TH samtools 1 "2 December 2010" "samtools-0.1.12" "Bioinformatics tools"
 .SH NAME
 .PP
 samtools - Utilities for the Sequence Alignment/Map (SAM) format
index 5e4bb2a64ce1abc8aae92e6d03e651861cadb85b..4cbcef7ad9e3f86e9c79a7a2d5daa335f59f9ce5 100644 (file)
@@ -556,4 +556,4 @@ SEE ALSO
 
 
 
-samtools-0.1.11                21 November 2010                    samtools(1)
+samtools-0.1.12                 2 December 2010                    samtools(1)