From 56ae21c41704d35a30a642fb8a3ea9e39f6460b9 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Mon, 19 Oct 2009 18:31:32 +0000 Subject: [PATCH] * samtools-0.1.6-17 (r484) * fixed a memory leak in rmdupse * fixed a bug in parsing @RG header lines * test rmdup in examples/ --- bam_import.c | 1 - bam_rmdupse.c | 3 ++- bamtk.c | 2 +- examples/Makefile | 16 ++++++++++++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bam_import.c b/bam_import.c index 1dc906e..eaa9452 100644 --- a/bam_import.c +++ b/bam_import.c @@ -211,7 +211,6 @@ int sam_header_parse_rg(bam_header_t *h) break; } if (r < p) r = p; - s = r + 3; } if (rgid->l && rglib->l) { bam_strmap_put(h->rg2lib, rgid->s, rglib->s); diff --git a/bam_rmdupse.c b/bam_rmdupse.c index 149d844..edc73a4 100644 --- a/bam_rmdupse.c +++ b/bam_rmdupse.c @@ -53,7 +53,8 @@ static inline elem_t *push_queue(queue_t *queue, const bam1_t *b, int endpos, in elem_t *p = kl_pushp(q, queue); p->discarded = 0; p->endpos = endpos; p->score = score; - p->b = bam_dup1(b); + if (p->b == 0) p->b = bam_init1(); + bam_copy1(p->b, b); return p; } diff --git a/bamtk.c b/bamtk.c index abb9015..3715308 100644 --- a/bamtk.c +++ b/bamtk.c @@ -9,7 +9,7 @@ #endif #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.1.6-16 (r483)" +#define PACKAGE_VERSION "0.1.6-17 (r484)" #endif int bam_taf2baf(int argc, char *argv[]); diff --git a/examples/Makefile b/examples/Makefile index 3fe3e5a..8f0386f 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,4 +1,4 @@ -all:../libbam.a ../samtools ex1.glf ex1.pileup.gz ex1.bam.bai ex1.glfview.gz calDepth +all:../libbam.a ../samtools ex1.glf ex1.pileup.gz ex1.bam.bai ex1f-rmduppe.bam ex1f-rmdupse.bam ex1.glfview.gz calDepth @echo; echo \# You can now launch the viewer with: \'samtools tview ex1.bam ex1.fa\'; echo; ex1.fa.fai:ex1.fa @@ -13,6 +13,18 @@ ex1.glf:ex1.bam ex1.fa ../samtools pileup -gf ex1.fa ex1.bam > ex1.glf ex1.glfview.gz:ex1.glf ../samtools glfview ex1.glf | gzip > ex1.glfview.gz +ex1a.bam:ex1.bam + ../samtools view -h ex1.bam | awk 'BEGIN{FS=OFS="\t"}{if(/^@/)print;else{$$1=$$1"a";print}}' | ../samtools view -bS - > $@ +ex1b.bam:ex1.bam + ../samtools view -h ex1.bam | awk 'BEGIN{FS=OFS="\t"}{if(/^@/)print;else{$$1=$$1"b";print}}' | ../samtools view -bS - > $@ +ex1f.rg: + (echo "@RG ID:ex1 LB:ex1"; echo "@RG ID:ex1a LB:ex1"; echo "@RG ID:ex1b LB:ex1b") > $@ +ex1f.bam:ex1.bam ex1a.bam ex1b.bam ex1f.rg + ../samtools merge -rh ex1f.rg $@ ex1.bam ex1a.bam ex1b.bam +ex1f-rmduppe.bam:ex1f.bam + ../samtools rmdup ex1f.bam $@ +ex1f-rmdupse.bam:ex1f.bam + ../samtools rmdup -S ex1f.bam $@ ../samtools: (cd ..; make samtools) @@ -24,4 +36,4 @@ calDepth:../libbam.a calDepth.c gcc -g -Wall -O2 -I.. calDepth.c -o $@ -lm -lz -L.. -lbam clean: - rm -fr *.bam *.bai *.glf* *.fai *.pileup* *~ calDepth *.dSYM \ No newline at end of file + rm -fr *.bam *.bai *.glf* *.fai *.pileup* *~ calDepth *.dSYM ex1*.rg \ No newline at end of file -- 2.39.2