Commit 3b9a3a8a authored by Matthias Klumpp's avatar Matthias Klumpp
Browse files

New upstream version 0.7.1

parent 22dc4a79
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -7,6 +7,3 @@
[submodule "BioD"]
	path = BioD
	url = https://github.com/biod/BioD.git
[submodule "undeaD"]
	path = undeaD
	url = https://github.com/biod/undeaD.git
+9 −3
Original line number Diff line number Diff line
@@ -15,14 +15,20 @@
After checking out the source from github with git submodules is is
possibleto install the build tools with GNU Guix

    guix package -i gcc gdb bash ld-wrapper ldc which python2 git
    guix package -i gcc-toolchain gdb bash ld-wrapper ldc which python2 git

Even better, with Guix, you can create a light-weight container in the source tree
and run our development setup
and run our development setup (gold was added lately by ldc)

    guix environment -C guix --ad-hoc gcc gdb bash ld-wrapper ldc which python git
    guix environment -C guix --ad-hoc gcc-toolchain gdb bash ld-wrapper ldc which python git binutils-gold vim
    make clean
    make -j 4
    make check

this way all dependencies are isolated.

## Build Sambamba with Debian

Make sure the environment is minimal with something like

    env -i /bin/bash --login --noprofile --norc
+30 −25
Original line number Diff line number Diff line
@@ -26,59 +26,61 @@ ifeq ($(UNAME_S),Darwin)
  SYS = OSX
else
  SYS = LINUX
  LINK_OBJ = utils/ldc_version_info_.o
endif

DFLAGS      = -wi -I. -IBioD -IundeaD/src -g
DFLAGS      = -wi -I. -IBioD -g -J.

DLIBS       = $(LIBRARY_PATH)/libphobos2-ldc.a $(LIBRARY_PATH)/libdruntime-ldc.a
DLIBS_DEBUG = $(LIBRARY_PATH)/libphobos2-ldc-debug.a $(LIBRARY_PATH)/libdruntime-ldc-debug.a
LIBS        = htslib/libhts.a lz4/lib/liblz4.a -L-L$(LIBRARY_PATH) -L-lpthread -L-lm
LIBS_STATIC = $(LIBRARY_PATH)/libc.a $(DLIBS) htslib/libhts.a $(LIBRARY_PATH)/liblz4.a
SRC         = $(wildcard main.d utils/*.d thirdparty/*.d cram/*.d) $(wildcard undeaD/src/undead/*.d) $(wildcard BioD/bio/*/*.d BioD/bio/*/*/*.d BioD/bio2/*.d BioD/bio2/*/*.d) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d)
OBJ         = $(SRC:.d=.o) utils/ldc_version_info_.o
OUT         = bin/sambamba
LIBS        = htslib/libhts.a lz4/lib/liblz4.a -L-L$(LIBRARY_PATH) -L-lpthread -L-lm -L-lz
LIBS_STATIC = $(LIBRARY_PATH)/libc.a $(DLIBS) htslib/libhts.a $(LIBRARY_PATH)/liblz4.a -L-lz
SRC         = utils/ldc_version_info_.d utils/lz4.d utils/strip_bcf_header.d $(sort $(wildcard BioD/contrib/undead/*.d BioD/contrib/undead/*/*.d)) utils/version_.d $(sort $(wildcard thirdparty/*.d cram/*.d) $(wildcard BioD/bio/*/*.d BioD/bio/*/*/*.d BioD/bio/*/*/*/*.d BioD/bio/*/*/*/*/*.d) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d))
OBJ         = $(SRC:.d=.o)
OUT         = bin/sambamba-$(shell cat VERSION)

STATIC_LIB_PATH=-Lhtslib -Llz4

.PHONY: all debug release static clean test

all: release

debug:                             DFLAGS += -O0 -d-debug -link-debuglib

profile:                           DFLAGS += -fprofile-instr-generate=profile.raw

release static profile pgo-static: DFLAGS += -O3 -release -enable-inlining -boundscheck=off
coverage:                          DFLAGS += -cov

release static pgo-static:         DFLAGS += -O3 -release -enable-inlining -boundscheck=off -L-lz

static:                            DFLAGS += -static -L-Bstatic

pgo-static:                        DFLAGS += -fprofile-instr-use=profile.data

all: release

lz4-static: lz4/lib/liblz4.a

lz4/lib/liblz4.a: lz4/lib/lz4.c lz4/lib/lz4hc.c lz4/lib/lz4frame.c lz4/lib/xxhash.c
	cd lz4/lib && gcc -O3 -c lz4.c lz4hc.c lz4frame.c xxhash.c && $(AR) rcs liblz4.a lz4.o lz4hc.o lz4frame.o xxhash.o

htslib-static:
	cd htslib && $(MAKE)
	cd htslib && $(MAKE) -j8

ldc-version-info:
utils/ldc_version_info_.d:
	python3 ./gen_ldc_version_info.py $(shell which ldmd2) > utils/ldc_version_info_.d
	cat utils/ldc_version_info_.d

utils/ldc_version_info_.o: ldc-version-info
	$(D_COMPILER) $(DFLAGS) -c utils/ldc_version_info_.d -od=$(dir $@)
ldc_version_info: utils/ldc_version_info_.d

build-setup: lz4-static htslib-static ldc-version-info
build-setup: ldc_version_info lz4-static htslib-static
	mkdir -p bin/

default debug release static: $(OUT)

profile: release
	./bin/sambamba sort /gnu/data/in_raw.bam -p > /dev/null
coverage: debug

profile: debug
	$(OUT) sort /gnu/data/in_raw.bam -p > /dev/null
	ldc-profdata merge -output=profile.data profile.raw
	rm ./bin/sambamba ./bin/sambamba.o # trigger rebuild
	rm $(OUT) ./bin/sambamba.o # trigger rebuild

default: all

@@ -86,17 +88,18 @@ default: all
%.o: %.d
	$(D_COMPILER) $(DFLAGS) -c $< -od=$(dir $@)

singleobj:
singleobj: build-setup
	$(info compile single object...)
	$(D_COMPILER) -singleobj $(DFLAGS) -c -of=bin/sambamba.o $(SRC)
	$(D_COMPILER) -singleobj $(DFLAGS) -c -of=$(OUT).o $(SRC)

# ---- Link step
$(OUT): build-setup singleobj utils/ldc_version_info_.o
$(OUT): singleobj
	$(info linking...)
	$(D_COMPILER) $(DFLAGS) -of=bin/sambamba bin/sambamba.o $(LINK_OBJ) $(LIBS)
	$(D_COMPILER) $(DFLAGS) -of=$(OUT) $(OUT).o $(LINK_OBJ) $(LIBS)

test:
	./run_tests.sh
test: $(OUT)
	$(OUT) --version
	./run_tests.sh $(OUT)

check: test

@@ -106,16 +109,18 @@ debug-strip:
	objcopy --add-gnu-debuglink=sambamba.debug bin/sambamba
	mv sambamba.debug bin/

pgo-static: profile static debug-strip
pgo-static: static debug-strip

install:
	install -m 0755 bin/sambamba $(prefix)/bin

clean: clean-d
	cd htslib ; $(MAKE) clean
	rm lz4/lib/*.[oa]
	rm -f profile.data
	rm -f profile.raw

clean-d:
	rm -rf bin/*
	rm -vf utils/ldc_version_info_.d
	rm -f $(OBJ) $(OUT) trace.{def,log}
+48 −34
Original line number Diff line number Diff line
# GNU Guix makefile. GNU Guix is the package manager for GNU and we
# use it for sambamba development and deployment. Normally use the
# standard Makefile instead because it compiles into a singleobj.
# standard Makefile instead because it compiles into a singleobj which
# gives better performance. This Makefile is for development purposes.
#
# To build sambamba on GNU Guix:
#
@@ -10,33 +11,30 @@
#
#   ./bin/sambamba
#
# certain paths may need to be set, e.g.
# But it is preferred to run in a Guix environment/container. For more
# information see INSTALL.md
#
#   make UNDEAD_PATH=../undeaD/src -f Makefile.guix
#
# For more information see INSTALL.md
#
# The following two are modified by the Guix package:
D_COMPILER=ldc2
ifndef GUIX
  GUIX=$(HOME)/.guix-profile
endif
LDC_LIB_PATH=$(GUIX)/lib
BIOD_PATH=./BioD

# DLIBS       = $(LIBRARY_PATH)/libphobos2-ldc.a $(LIBRARY_PATH)/libdruntime-ldc.a
# DLIBS_DEBUG = $(LIBRARY_PATH)/libphobos2-ldc-debug.a $(LIBRARY_PATH)/libdruntime-ldc-debug.a

UNDEAD_PATH=../undeaD/src
BIOD_PATH=../BioD

DFLAGS = -wi -I. -I$(BIOD_PATH) -IundeaD/src -I$(UNDEAD_PATH)
DFLAGS = -wi -I. -I$(BIOD_PATH) -J.
# DLIBS  = $(LDC_LIB_PATH)/libphobos2-ldc.a $(LDC_LIB_PATH)/libdruntime-ldc.a
# DLIBS_DEBUG = -debuglib=phobos2-ldc-debug,druntime-ldc-debug $(LDC_LIB_PATH)/libphobos2-ldc-debug.a $(LDC_LIB_PATH)/libdruntime-ldc-debug.a -link-debuglib
DLIBS_DEBUG = -debuglib=phobos2-ldc-debug-shared,druntime-ldc-debug-shared -link-debuglib -L-lphobos2-ldc-debug-shared -L-ldruntime-ldc-debug-shared
RPATH  = -L--rpath=$(dir $(realpath $(LDC_LIB_PATH)/libz.so)):$(dir $(realpath $(LDC_LIB_PATH)/liblz4.so))
LIBS   = htslib/libhts.a -L-L$(LDC_LIB_PATH) -L-lrt -L-lpthread -L-lm -L-lz -L-llz4
# DLIBS_DEBUG = -debuglib=phobos2-ldc-debug-shared,druntime-ldc-debug-shared -link-debuglib -L-lphobos2-ldc-debug-shared -L-ldruntime-ldc-debug-shared
# RPATH  = -L--rpath=$(dir $(realpath $(LDC_LIB_PATH)/libz.so)):$(dir $(realpath $(LDC_LIB_PATH)/liblz4.so))
RPATH = -L--rpath=$(LIBRARY_PATH)
LIBS   = htslib/libhts.a -L-L$(LDC_LIB_PATH) -L-lrt -L-lpthread -L-lm -L-lz lz4/lib/liblz4.a

# LIBS   = htslib/libhts.a -L-lrt -L-lpthread -L-lm -L-lz -L-llz4
LIBS_STATIC = $(DLIBS) htslib/libhts.a $(LDC_LIB_PATH)/liblz4.a
SRC         = $(wildcard main.d utils/*.d thirdparty/*.d cram/*.d) $(wildcard undeaD/src/undead/*.d undeaD/src/undead/*/*.d) $(wildcard BioD/bio/*/*.d BioD/bio/*/*/*.d BioD/bio2/*.d BioD/bio2/*/*.d) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d)
OBJ    = $(SRC:.d=.o)
OUT    = bin/sambamba
LIBS_STATIC = $(DLIBS) htslib/libhts.a lz4/lib/liblz4.a
SRC         = $(wildcard main.d utils/*.d thirdparty/*.d cram/*.d) $(wildcard BioD/contrib/undead/*.d BioD/contrib/undead/*/*.d) $(wildcard BioD/bio/*/*.d BioD/bio/*/*/*.d BioD/bio/*/*/*/*.d BioD/bio/*/*/*/*/*.d BioD/bio/*/*/*/*/*/*/*.d) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d)
OBJ    = $(SRC:.d=.o) utils/ldc_version_info_.o
OUT    = bin/sambamba-$(shell cat VERSION)
static: OUT += -static

.PHONY: all guix guix-debug debug release static profile clean test

@@ -52,7 +50,9 @@ release static: DFLAGS += -O3 -release $(RPATH) -enable-inlining -Hkeep-all-

static:             DFLAGS += -static -L-Bstatic -L-L/gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/lib/

profile:     DFLAGS += -g -O -profile $(RPATH)
profile:            DFLAGS += -g -O -fprofile-instr-generate=profile.raw $(RPATH)

profile:            LIBS += -L=-lprofile_rt

guix release:       LIBS += $(DLIBS)

@@ -67,12 +67,25 @@ all: debug
# sambamba/subsample.d: bio2/pileup.d

utils/ldc_version_info_.d:
	./gen_ldc_version_info.py $(shell which ldc2) > utils/ldc_version_info_.d
	python3 ./gen_ldc_version_info.py $(shell which ldmd2) > utils/ldc_version_info_.d
	cat utils/ldc_version_info_.d

ldc_version_info: utils/ldc_version_info_.d

lz4/lib/liblz4.a: lz4/lib/lz4.c lz4/lib/lz4hc.c lz4/lib/lz4frame.c lz4/lib/xxhash.c
	cd lz4/lib && gcc -O3 -c lz4.c lz4hc.c lz4frame.c xxhash.c && $(AR) rcs liblz4.a lz4.o lz4hc.o lz4frame.o xxhash.o

lz4-static: lz4/lib/liblz4.a

build-setup: ldc_version_info lz4-static htslib-static
	mkdir -p bin/

# utils/ldc_version_info_.o: utils/ldc_version_info_.d
# 	$(D_COMPILER) $(DFLAGS) -c utils/ldc_version_info_.d -od=$(dir $@)

utils/ldc_version_info_.o: utils/ldc_version_info_.d
	$(D_COMPILER) $(DFLAGS) -c utils/ldc_version_info_.d -od=$(dir $@)
guix guix-debug default debug release static profile: ldc_version_info $(OUT)

guix guix-debug default debug release static profile: $(OUT)
debug profile release: lz4-static

# ---- Compile step
%.o: %.d
@@ -80,12 +93,12 @@ guix guix-debug default debug release static profile: $(OUT)

# ---- Link step
$(OUT): $(OBJ)
	cd htslib && $(MAKE)
	cd htslib && $(MAKE) -j 4
	mkdir -p bin/
	$(D_COMPILER) $(DFLAGS) -of=bin/sambamba $(OBJ) $(LIBS)
	$(D_COMPILER) $(DFLAGS) -of=$(OUT) $(OBJ) $(LIBS)

test:	clean-tests
	./run_tests.sh
	./run_tests.sh $(OUT)

biod:
	cd $(BIOD_PATH)/src_ragel && make
@@ -103,6 +116,7 @@ install:

clean-c:
	cd htslib ; make clean
	rm -v lz4/lib/*.[oa]

clean-d:
	rm -v $(OBJ) $(OUT) trace.{def,log}
@@ -111,4 +125,4 @@ clean-d:
clean-tests:
	rm -rf output/*

clean: clean-d clean-tests
clean: clean-c clean-d clean-tests
+47 −38
Original line number Diff line number Diff line
[![Build Status](https://travis-ci.org/biod/sambamba.svg?branch=master)](https://travis-ci.org/biod/sambamba) [![Anaconda-Server Badge](https://anaconda.org/bioconda/sambamba/badges/installer/conda.svg)](https://conda.anaconda.org/bioconda) [![DL](https://anaconda.org/bioconda/sambamba/badges/downloads.svg)](https://anaconda.org/bioconda/sambamba)
g[![Build Status](https://travis-ci.org/biod/sambamba.svg?branch=master)](https://travis-ci.org/biod/sambamba) [![AnacondaBadge](https://anaconda.org/bioconda/sambamba/badges/installer/conda.svg)](https://anaconda.org/bioconda/sambamba) [![DL](https://anaconda.org/bioconda/sambamba/badges/downloads.svg)](https://anaconda.org/bioconda/sambamba) [![BrewBadge](https://img.shields.io/badge/%F0%9F%8D%BAbrew-sambamba-brightgreen.svg)](https://github.com/brewsci/homebrew-bio)
[![GuixBadge](https://img.shields.io/badge/gnuguix-sambamba-brightgreen.svg)](https://www.gnu.org/software/guix/packages/S/)
[![DebianBadge](https://badges.debian.net/badges/debian/testing/sambamba/version.svg)](https://packages.debian.org/testing/sambamba)

# sambamba
# SAMBAMBA

Table of Contents
=================

   * [sambamba](#sambamba)
      * [Table of Contents](#table-of-contents)
   * [Introduction](#introduction)
   * [Binary installation](#binary-installation)
      * [Install stable release](#install-stable-release)
@@ -38,41 +38,45 @@ Table of Contents

Sambamba is a high performance highly parallel robust and fast tool
(and library), written in the D programming language, for working with
SAM and BAM files. Because of its efficiency is an important work
horse running in many sequencing centres around the world
today.
SAM and BAM files. Because of its efficiency Sambamba is an important
work horse running in many sequencing centres around the world today.
As of November 2019, Sambamba has been cited over
[277 times](http://scholar.google.nl/citations?hl=en&user=5ijHQRIAAAAJ)
and has been installed from Conda over
[120K times](https://anaconda.org/bioconda/sambamba).

Current functionality is an important subset of samtools
functionality, including view, index, sort, markdup, and depth. Most
tools support piping: just specify `/dev/stdin` or `/dev/stdout` as
filenames. When we started writing sambamba (in 2012) the main
advantage over `samtools` was parallelized BAM reading and writing.
In March 2017 `samtools` 1.4 was released, reaching parity on this. A
In March 2017 `samtools` 1.4 was released, reaching parity at least on
architecture. A
[recent performance comparison](https://github.com/guigolab/sambamBench-nf)
shows that sambamba holds its ground and can do better in different
configurations. Here are some comparison
shows that sambamba still holds its ground and can even do better.
Here are some comparison
[metrics](https://public-docs.crg.es/rguigo/Data/epalumbo/sambamba_ws_report.html). For
example for flagstat sambamba is 1.4x faster than samtools. For index
example, for flagstat sambamba is 1.4x faster than samtools. For index
they are similar. For Markdup almost 6x faster and for view 4x
faster. For sort sambamba has been beaten, though sambamba is up to 2x
faster than samtools on large RAM machines (120GB+).
faster. For sort sambamba has been beaten, though sambamba is notably
up to 2x faster than samtools on large RAM machines (120GB+).

In addition sambamba has a few interesting features to offer, in particular

- faster large machine `sort`, see [performance](./test/benchmark/stats.org)
- fast large machine `sort`, see [performance](./test/benchmark/stats.org)
- automatic index creation when writing any coordinate-sorted file
- `view -L <bed file>` utilizes BAM index to skip unrelated chunks
- `depth` allows to measure base, sliding window, or region coverages
  - [Chanjo](https://www.chanjo.co/) builds upon this and gets you to exon/gene levels of abstraction
- `markdup`, a fast implementation of Picard algorithm
- `slice` quickly extracts a region into a new file, tweaking only first/last chunks
- and more
- and more (you'll have to try)

Even though Sambamba started out as a samtools clone we are now in the
process of adding new functionality - also in the
[BioD project](https://github.com/biod/BioD). The D language is
extremely suitable for high performance computing. At this point we
think that the BAM format is here to stay for processing sequencing
extremely suitable for high performance computing (HPC). At this point
we think that the BAM format is here to stay for processing sequencing
data and we aim to make it easy to parse and process BAM files.

Sambamba is free and open source software, licensed under GPLv2+.
@@ -88,39 +92,42 @@ For more information on Sambamba contact the mailing list (see [Getting help](#g
For those not in the mood to learn/install new package managers, there
are Github source and binary
[releases](https://github.com/biod/sambamba/releases). Simply download
the tarball, unpack it and run it. For example
the tarball, unpack it and run it according to the accompanying
release notes.

```bash
wget https://github.com/biod/sambamba/releases/download/v0.6.8/sambamba_v0.6.8_linux.tar.bz2
tar xvjf sambamba_v0.6.8_linux.tar.bz2
./sambamba_v0.6.8

    sambamba 0.6.8

        Usage: sambamba [command] [args...]

        Available commands: 'view', 'index', 'merge', 'sort',
                             'flagstat', 'slice', 'markdup', 'depth', 'mpileup'
        To get help on a particular command, just call it without args.
```
Below package managers Conda, GNU Guix, Debian and Homebrew also
provide recent binary installs for Linux.  For MacOS you may use Conda
or Homebrew.

## Bioconda install

[![Install with CONDA](https://anaconda.org/bioconda/sambamba/badges/installer/conda.svg)](https://anaconda.org/bioconda/sambamba)

Ther should be binary downloads for Linux and MacOS.

With Conda use the [`bioconda`](https://bioconda.github.io/) channel.

## GNU Guix install

A [GNU Guix package](https://www.gnu.org/software/guix/packages/s.html) for sambamba is available. The development version is packaged [here](https://gitlab.com/genenetwork/guix-bioinformatics/blob/master/gn/packages/sambamba.scm).
[![GuixBadge](https://img.shields.io/badge/gnuguix-sambamba--0.6.8-brightgreen.svg)](https://www.gnu.org/software/guix/packages/S/)

A reproducible [GNU Guix package](https://www.gnu.org/software/guix/packages/s.html) for sambamba is available. The development version is packaged [here](https://gitlab.com/genenetwork/guix-bioinformatics/blob/master/gn/packages/sambamba.scm).

## Debian GNU/Linux install

Debian: see [Debian packages](https://tracker.debian.org/pkg/sambamba).
[![DebianBadge](https://badges.debian.net/badges/debian/testing/sambamba/version.svg)](https://packages.debian.org/testing/sambamba)

See also Debian package [status](https://tracker.debian.org/pkg/sambamba).

## Homebrew install

Users of Homebrew can also use the formula from `homebrew-science`.
[![BrewBadge](https://img.shields.io/badge/%F0%9F%8D%BAbrew-sambamba-brightgreen.svg)](https://github.com/brewsci/homebrew-bio)

Users of Homebrew can also use the formula from [homebrew-bio](https://github.com/brewsci/homebrew-bio).

    brew install brewsci/bio/sambamba

It should work for Linux and MacOS.

<a name="help"></a>
# Getting help
@@ -284,7 +291,8 @@ command). A full stacktrace for all threads:
thread apply all backtrace full
```

Note that GDB should be made aware of D garbage collector:
Note that GDB should be made aware of D garbage collector which emits
SIGUSR signals and gdb needs to ignore them with

```
handle SIGUSR1 SIGUSR2 nostop noprint
@@ -308,13 +316,14 @@ gdb -ex 'handle SIGUSR1 SIGUSR2 nostop noprint' \
<a name="license"></a>
# License

Sambamba is distributed under GNU Public License v2+.
Sambamba is generously distributed under GNU Public License v2+.

<a name="credits"></a>
# Credit

If you are using Sambamba in your research and want to support future
work on Sambamba, please cite the following publication:
Citations are the bread and butter of Science.  If you are using
Sambamba in your research and want to support our future work on
Sambamba, please cite the following publication:

A. Tarasov, A. J. Vilella, E. Cuppen, I. J. Nijman, and P. Prins. [Sambamba: fast processing of NGS alignment formats](https://doi.org/10.1093/bioinformatics/btv098). Bioinformatics, 2015.

Loading