From f2f3968e11eead9ce5601b01890bc2339ff951e9 Mon Sep 17 00:00:00 2001 From: Charles Plessy Date: Fri, 3 Dec 2010 13:24:39 +0900 Subject: [PATCH] Imported Upstream version 0.1.12a --- NEWS | 26 ++++++++++++++++++++++++++ bam2bcf_indel.c | 6 ++++-- bam_index.c | 3 ++- bam_plcmd.c | 3 ++- bamtk.c | 2 +- bcftools/bcf.c | 2 +- bcftools/call1.c | 2 +- bcftools/ld.c | 2 +- bcftools/vcfutils.pl | 18 +++++++++++++++++- samtools.1 | 2 +- samtools.txt | 2 +- 11 files changed, 57 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 478e718..6b4d8aa 100644 --- 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) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/bam2bcf_indel.c b/bam2bcf_indel.c index 819c1e7..16241d0 100644 --- a/bam2bcf_indel.c +++ b/bam2bcf_indel.c @@ -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) { diff --git a/bam_index.c b/bam_index.c index f60a6f8..328f011 100644 --- a/bam_index.c +++ b/bam_index.c @@ -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; } diff --git a/bam_plcmd.c b/bam_plcmd.c index e3f73aa..002297a 100644 --- a/bam_plcmd.c +++ b/bam_plcmd.c @@ -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 4c2a4a2..79635d6 100644 --- 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[]); diff --git a/bcftools/bcf.c b/bcftools/bcf.c index fd5c0c9..6e45695 100644 --- a/bcftools/bcf.c +++ b/bcftools/bcf.c @@ -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; diff --git a/bcftools/call1.c b/bcftools/call1.c index 5e4fc9f..f293a6c 100644 --- a/bcftools/call1.c +++ b/bcftools/call1.c @@ -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; } diff --git a/bcftools/ld.c b/bcftools/ld.c index aa7ec07..dc84d4b 100644 --- a/bcftools/ld.c +++ b/bcftools/ld.c @@ -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; diff --git a/bcftools/vcfutils.pl b/bcftools/vcfutils.pl index 6cc168f..cd86b0f 100755 --- a/bcftools/vcfutils.pl +++ b/bcftools/vcfutils.pl @@ -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}] \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 [samples]\n/) if (@ARGV == 0); my ($fh, %h); diff --git a/samtools.1 b/samtools.1 index e059560..57f1aff 100644 --- a/samtools.1 +++ b/samtools.1 @@ -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 diff --git a/samtools.txt b/samtools.txt index 5e4bb2a..4cbcef7 100644 --- a/samtools.txt +++ b/samtools.txt @@ -556,4 +556,4 @@ SEE ALSO -samtools-0.1.11 21 November 2010 samtools(1) +samtools-0.1.12 2 December 2010 samtools(1) -- 2.30.2