Tools for working with SAM/BAM/CRAM data
Clone or download
pjotrp Merge pull request #375 from emi80/patch-1
Fix subsample command description typo in main.d
Latest commit f248fea Nov 3, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update Apr 17, 2017
BioD @ 4f1a7d2 - Added test for --sort-picard Oct 17, 2018
contrib/shunit2-2.0.3 shunit2: add sources in tree for unit testing Oct 3, 2018
cram Conflicting cram_content_type enums with ldc 1.11. Sep 13, 2018
deb fix #79; bump version Jun 20, 2014
doc Architecture doc and started on bgzf Nov 22, 2017
etc/bash_completion.d ditto Dec 1, 2013
htslib @ 2f3c3ea update to latest htslib Apr 2, 2015
lz4 @ b3692db Reintroducing lz4 because Debian recently dropped lz4frames.h and rel… Jul 30, 2018
man fix formatting Oct 24, 2016
sambamba Fix subsample command description typo in main.d Nov 2, 2018
scripts Move main.d and randomize_bases.d out of root Jan 1, 2018
test - Added test for --sort-picard Oct 17, 2018
thirdparty improved sort performance (needs testing) Nov 16, 2013
undeaD @ 9be9387 Getting rid of D deprecation warnings Oct 3, 2018
utils Preparing for release Oct 3, 2018
.gitignore Dropped BioD and lz4 dirs. Moved bio2 into BioD May 13, 2018
.gitmodules Submodule link Oct 3, 2018
.travis.yml Travis: fixing tests on Linux Oct 3, 2018
.travis.yml.macos Travis: disable for now Nov 20, 2017 Add test for fixed issue #356 Oct 3, 2018
LICENSE license under GPL v2+ Aug 6, 2012
Makefile Fix linking of utils/ldc_version_info_.d Oct 7, 2018
Makefile.docker Makefile for LDC Docker images Nov 20, 2017
Makefile.guix Preparing for LLVM6 based release Sep 10, 2018
Makefile.old Updated Make instructions and simplified the main Makefile. The follo… Feb 5, 2018 README: badges Oct 14, 2018 --sort-picard in release notes Oct 17, 2018
dub.json Makefile: undeaD gets loaded by dub Nov 24, 2017 Update version info script to use python3 Oct 3, 2018 Travis: fixing tests on Linux Oct 3, 2018
sambamba-ldmd-debug.rsp Save version strings from build chain and display in usage Nov 17, 2016
sambamba-ldmd-release.rsp Makefile: fixed standard make file to support Dlang ./undeaD lib Feb 23, 2017

Build Status AnacondaBadge DL BrewBadge GuixBadge DebianBadge


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.

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 recent performance comparison shows that sambamba holds its ground and can do better in different configurations. Here are some comparison metrics. For 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+).

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

  • faster large machine sort, see performance
  • 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 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

Even though Sambamba started out as a samtools clone we are now in the process of adding new functionality - also in the BioD project. 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 data and we aim to make it easy to parse and process BAM files.

Sambamba is free and open source software, licensed under GPLv2+. See manual pages online to know more about what is available and how to use it.

For more information on Sambamba contact the mailing list (see Getting help).

Binary installation

Install stable release

For those not in the mood to learn/install new package managers, there are Github source and binary releases. Simply download the tarball, unpack it and run it according to the accompanying release notes.

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

Ther should be binary downloads for Linux and MacOS.

With Conda use the bioconda channel.

GNU Guix install


A reproducible GNU Guix package for sambamba is available. The development version is packaged here.

Debian GNU/Linux install


See also Debian package status.

Homebrew install


Users of Homebrew can also use the formula from homebrew-bio.

brew install brewsci/bio/sambamba

It should work for Linux and MacOS.

Getting help

Sambamba has a mailing list for installation help and general discussion.

Reporting a sambamba bug or issue

Before posting an issue search the issue tracker and mailing list first. It is likely someone may have encountered something similar. Also try running the latest version of sambamba to make sure it has not been fixed already. Support/installation questions should be aimed at the mailing list. The issue tracker is for development issues around the software itself. When reporting an issue include the output of the program and the contents of the output directory.

Check list:

  1. I have found and issue with sambamba
  2. I have searched for it on the issue tracker (also check closed issues)
  3. I have searched for it on the mailing list
  4. I have tried the latest release of sambamba
  5. I have read and agreed to below code of conduct
  6. If it is a support/install question I have posted it to the mailing list
  7. If it is software development related I have posted a new issue on the issue tracker or added to an existing one
  8. In the message I have included the output of my sambamba run
  9. In the message I have included the relevant files in the output directory
  10. I have made available the data to reproduce the problem (optional)

To find bugs the sambamba software developers may ask to install a development version of the software. They may also ask you for your data and will treat it confidentially. Please always remember that sambamba is written and maintained by volunteers with good intentions. Our time is valuable too. By helping us as much as possible we can provide this tool for everyone to use.

Code of conduct

By using sambamba and communicating with its communtity you implicitely agree to abide by the code of conduct as published by the Software Carpentry initiative.

Compiling Sambamba

Note: in general there is no need to compile sambamba. You can use a recent binary install as listed above.

The preferred method for compiling Sambamba is with the LDC compiler which targets LLVM. LLVM versions 6 is faster than earlier editions.

Compilation dependencies


Compiling for Linux

The LDC compiler's github repository provides binary images. The current preferred release for sambamba is LDC - the LLVM D compiler (>= 1.6.1). After installing LDC from with, for example

tar xvJf ldc2-1.7.0-linux-x86_64.tar.xz
export PATH=$HOME/ldc2-1.7.0-linux-x86_64/bin:$PATH
export LIBRARY_PATH=$HOME/ldc2-1.7.0-linux-x86_64/lib
git clone --recursive
cd sambamba

To build a development/debug version run

make clean && make debug

To run the test fetch shunit2 from and put it in the path so you can run

make check

See also

GNU Guix

To build sambamba the LDC compiler is also available in GNU Guix:

guix package -i ldc

Compiling for Mac OS X

Sambamba builds on MacOS. We have a Travis integration test as an example. It can be something like

    brew install ldc
    git clone --recursive
    cd sambamba


Sambamba development and issue tracker is on github. Developer documentation can be found in the source code and the development documentation.

Debugging and troubleshooting

Segfaults on certain Intel Xeons

Important note: some popular Xeon processors segfault under heavy hyper threading - which Sambamba utilizes. Please read this when encountering seemingly random crashes.

Dump core

In a crash sambamba can dump a core file. To make this happen set

ulimit -c unlimited

and run your command. Send us the core file so we can reproduce the state at time of segfault.

Use catchsegv

Another option is to use catchsegv

catchsegv ./build/sambamba command

this will show state on stdout which can be sent to us.

Using gdb

In case of crashes it's helpful to have GDB stacktraces (bt command). A full stacktrace for all threads:

thread apply all backtrace full

Note that GDB should be made aware of D garbage collector:

handle SIGUSR1 SIGUSR2 nostop noprint

A binary relocatable install of sambamba with debug information and all dependencies can be fetched from the binary link above. Unpack the tarball and run the contained script with TARGET

./ ~/sambamba-test

Run sambamba in gdb with

gdb -ex 'handle SIGUSR1 SIGUSR2 nostop noprint' \
  --args ~/sambamba-test/sambamba-*/bin/sambamba view --throw-error


Sambamba is distributed under GNU Public License v2+.


If you are using Sambamba in your research and want to support 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. Bioinformatics, 2015.

Bibtex reference

  author = {Tarasov, Artem and Vilella, Albert J. and Cuppen, Edwin and Nijman, Isaac J. and Prins, Pjotr},
  title = {Sambamba: fast processing of NGS alignment formats},
  journal = {Bioinformatics},
  volume = {31},
  number = {12},
  pages = {2032-2034},
  year = {2015},
  doi = {10.1093/bioinformatics/btv098},
  URL = { +}