[med-svn] [Git][med-team/sambamba][master] 9 commits: New upstream version 0.6.7

Andreas Tille gitlab at salsa.debian.org
Tue Mar 20 10:09:36 UTC 2018


Andreas Tille pushed to branch master at Debian Med / sambamba


Commits:
5cd2ab08 by Andreas Tille at 2018-03-20T09:37:02+01:00
New upstream version 0.6.7
- - - - -
5c026a19 by Andreas Tille at 2018-03-20T09:37:03+01:00
Update upstream source from tag 'upstream/0.6.7'

Update to upstream version '0.6.7'
with Debian dir 45d691ff9436a6de18ec044d8bf31f61e67c0cf1
- - - - -
044ed46e by Andreas Tille at 2018-03-20T09:37:50+01:00
New upstream version

- - - - -
88940cdb by Andreas Tille at 2018-03-20T10:47:46+01:00
Use dh-lang

- - - - -
86b4f5b4 by Andreas Tille at 2018-03-20T10:48:07+01:00
Standards-Version: 4.1.3

- - - - -
29f2478c by Andreas Tille at 2018-03-20T10:48:21+01:00
debhelper 11

- - - - -
e94024ba by Andreas Tille at 2018-03-20T10:49:08+01:00
enable hardening options

- - - - -
9ff860ee by Andreas Tille at 2018-03-20T10:53:40+01:00
move bash_completion scripts to new location

- - - - -
22e9c9d8 by Andreas Tille at 2018-03-20T11:08:47+01:00
Upload to unstable

- - - - -


27 changed files:

- + .drone.yml.template
- + .github/issue_template.md
- .gitignore
- .gitmodules
- .travis.yml → .travis.yml.macos
- Makefile
- + Makefile.docker
- Makefile.guix
- README.md
- bioconda_yaml_gen.py
- debian/changelog
- debian/compat
- debian/control
- debian/patches/01_add_meson.patch
- debian/rules
- gen_ldc_version_info.py
- .run_tests.sh → run_tests.sh
- sambamba/depth.d
- sambamba/markdup.d
- sambamba/pileup.d
- sambamba/slice.d
- sambamba/sort.d
- sambamba/utils/common/readstorage.d
- + test/chr2_chr3_test_region.bed
- .test_suite.sh → test_suite.sh
- utils/strip_bcf_header.d
- utils/version_.d


Changes:

=====================================
.drone.yml.template
=====================================
--- /dev/null
+++ b/.drone.yml.template
@@ -0,0 +1,21 @@
+# this YAML file can be used with drone tool (https://github.com/drone/drone)
+# TODO remove dropbox dependency
+# Usage: copy to .drone.yml, edit dropbox access token, run 'drone exec'
+build:
+  image: lomereiter/centos-ldc:latest
+  commands:
+    - export LANG=C
+    - export PATH=/opt/llvm/bin:/usr/local/bin:$PATH
+    - /usr/bin/scl enable devtoolset-4 --
+    - yum install -y git
+    - llvm-config --version
+    - ldc2 --version
+    - gcc --version
+    - git submodule update --init
+    - git clone https://github.com/dlang/undeaD
+    - make sambamba-ldmd2-64
+    - curl -L "https://dl.dropboxusercontent.com/u/7916095/shunit2-2.0.3.tgz" | tar zx
+    - ./.run_tests.sh
+    - readelf -V build/sambamba | grep 'Name:' | grep GLIBC
+    - export ACCESS_TOKEN=# !!! PUT YOUR DROPBOX TOKEN HERE !!!
+    - ./.dropbox.sh build/sambamba


=====================================
.github/issue_template.md
=====================================
--- /dev/null
+++ b/.github/issue_template.md
@@ -0,0 +1,23 @@
+<!--
+
+If you are reporting a bug, please provide:
+
+* version of sambamba
+
+* version of samtools if the issue is with pileup tool
+
+* the command line or bash script used (feel free to shorten paths and filenames)
+
+* whenever possible, a set of BAM/BED files to reproduce the issue
+  * bonus points if you try to minimize the test case yourself, as issues are often localized:
+    - try to use sambamba slice to first extract the reference where the error occurs
+    - if that succeeds (the error is still reproducible), continue to crop the file in binary-search fashion
+  * suggestions regarding privacy concerns for human data:
+    - try to minimize the test case (few variants => much harder to tell anything about the patient)
+    - write a script that changes the reference and/or applies a fixed shift to all record & record mate positions
+    - apply a random base permutation, e.g. A->C, C->T, T->A, G->G
+    
+You can also suggest a new feature, but please understand that neither of maintainers uses sambamba in daily jobs anymore.
+As such, while it has some chances to get picked up by another person, if you possess any programming skills whatsoever, we encourage you to try your hand at it! (Feel free to ask us questions about the codebase or D quirks over email)
+      
+-->


=====================================
.gitignore
=====================================
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
 build/
-undeaD/
 shunit*
 /*.sam
 /*.bam


=====================================
.gitmodules
=====================================
--- a/.gitmodules
+++ b/.gitmodules
@@ -7,3 +7,6 @@
 [submodule "lz4"]
 	path = lz4
 	url = https://github.com/Cyan4973/lz4
+[submodule "undeaD"]
+	path = undeaD
+	url = https://github.com/dlang/undeaD


=====================================
.travis.yml → .travis.yml.macos
=====================================
--- a/.travis.yml
+++ b/.travis.yml.macos
@@ -17,14 +17,13 @@ before_install:
   - export PATH=$(pwd)/${LDC_VERSION}/bin:${PATH}
   - export LIBRARY_PATH=$(pwd)/${LDC_VERSION}/lib:${LIBRARY_PATH}
   - git submodule update --init --recursive
-  - git clone https://github.com/dlang/undeaD.git
   - wget https://github.com/craigcitro/r-travis/raw/master/scripts/dropbox.sh
   - chmod +x dropbox.sh
-  - curl -L "https://dl.dropboxusercontent.com/u/7916095/shunit2-2.0.3.tgz" | tar zx
+  - curl -L https://www.dropbox.com/s/7mmiwmc1wm8cuos/shunit2-2.0.3.tgz?dl=1 | tar zx
 
 script:
   - make sambamba-ldmd2-64
-  - ./.run_tests.sh
+  - ./run_tests.sh
 
 after_success:
   - tar cjvf sambamba_osx.tar.bz2 ./build/sambamba


=====================================
Makefile
=====================================
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ endef
 
 else
 
-LINK_CMD=gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(STATIC_LIB_SUBCMD) -l:libphobos2-ldc.a -l:libdruntime-ldc.a  -lrt -lpthread -lm
+LINK_CMD=gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(STATIC_LIB_SUBCMD) -lphobos2-ldc -ldruntime-ldc  -lrt -lpthread -lm -ldl
 DMD_STATIC_LIBS=-L-Lhtslib -L-l:libhts.a -L-l:libphobos2.a -L-Llz4/lib -L-l:liblz4.a
 
 define split-debug


=====================================
Makefile.docker
=====================================
--- /dev/null
+++ b/Makefile.docker
@@ -0,0 +1,79 @@
+# Docker makefile
+#
+# To build sambamba using a Docker image
+#
+#   make -f Makefile.docker
+#
+# To run with the DMD compiler instead:
+#
+#   make DRUN="dlanguage/dmd dmd" -f Makefile.docker
+#
+# run with
+#
+#   ./build/sambamba
+#
+# Note: you'll need to set the correct LIB_PATHS for libz and libz4 your system
+
+
+DRUN=dlanguage/ldc ldc2
+# Mount the lib search paths on Docker for libz and libz4
+LIBZ_LIB_PATH=/gnu/store/yd7bplsvf9nj72wn2z6n38rq9hfmjgd9-zlib-1.2.11/lib
+LIBZ4_LIB_PATH=/gnu/store/2n80sdqh39y3sgrfyd97ag0sjx5bx9dl-lz4-1.8.0/lib
+
+CWD=$(shell pwd)
+D_COMPILER=docker run -v $(LIBZ_LIB_PATH):$(LIBZ_LIB_PATH) -v $(LIBZ4_LIB_PATH):$(LIBZ4_LIB_PATH) -v $(CWD):/src $(DRUN)
+
+DFLAGS = -wi -I. -IBioD -IundeaD/src
+LIBS   = htslib/libhts.a -L-L$(LIBZ4_LIB_PATH) -L-L$(LIBZ_LIB_PATH) -L-L$(LDC_LIB_PATH) -L-L$(CWD)/lib -L-lrt -L-lpthread -L-lm -L-lz -L-llz4
+SRC    = $(wildcard main.d utils/*.d thirdparty/*.d cram/*.d) $(wildcard undeaD/src/undead/*.d) $(wildcard BioD/bio/*/*.d BioD/bio/*/*/*.d) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d)
+OBJ    = $(SRC:.d=.o) utils/ldc_version_info_.o
+OUT    = build/sambamba
+
+.PHONY: all
+
+debug: DFLAGS += -O0 -g -d-debug -link-debuglib
+
+all: debug
+
+htslib-static:
+	cd htslib && $(MAKE)
+
+ldc-version-info:
+	./gen_ldc_version_info.py $(shell which ldmd2) > utils/ldc_version_info_.d
+
+utils/ldc_version_info_.o: ldc-version-info
+	$(D_COMPILER) $(DFLAGS) -c utils/ldc_version_info_.d -od=$(dir $@)
+
+build-setup: htslib-static ldc-version-info
+	mkdir -p build/
+
+guix guix-debug default debug release static profile: $(OUT)
+
+# ---- Compile step
+%.o: %.d
+	$(D_COMPILER) $(DFLAGS) -c $< -od=$(dir $@)
+
+# ---- Link step
+$(OUT): build-setup $(OBJ)
+	$(D_COMPILER) $(DFLAGS) -of=build/sambamba $(OBJ) $(LIBS)
+
+test:
+	./run_tests.sh
+
+check: test
+
+debug-strip: debug
+	objcopy --only-keep-debug build/sambamba sambamba.debug
+	objcopy --strip-debug build/sambamba
+	objcopy --add-gnu-debuglink=sambamba.debug build/sambamba
+	mv sambamba.debug build/
+
+clean-d:
+	rm -rf build/*
+	rm -f $(OBJ) $(OUT) trace.{def,log}
+
+install:
+	install -m 0755 build/sambamba $(prefix)/bin
+
+clean: clean-d
+	cd htslib ; make clean


=====================================
Makefile.guix
=====================================
--- a/Makefile.guix
+++ b/Makefile.guix
@@ -17,27 +17,32 @@ DLIBS  = $(LDC_LIB_PATH)/libphobos2-ldc.a $(LDC_LIB_PATH)/libdruntime-ldc.a
 DLIBS_DEBUG = $(LDC_LIB_PATH)/libphobos2-ldc-debug.a $(LDC_LIB_PATH)/libdruntime-ldc-debug.a
 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
+LIBS_STATIC = $(LDC_LIB_PATH)/libc.a $(DLIBS) htslib/libhts.a $(LDC_LIB_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) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d)
 OBJ    = $(SRC:.d=.o) utils/ldc_version_info_.o
 OUT    = build/sambamba
 
 # The Guix targets resolve the RPATH automatically
-guix:        DFLAGS += -O -g -inline
+guix:        DFLAGS += -O -release -g # Guix strips debug flags
 
 guix-debug:  DFLAGS += -O0 -g -d-debug
 
-# The development options are run from ~/.guix-profile and need to inject the RPATH
+# The following options are run in development from ~/.guix-profile and need to inject the RPATH
 debug:       DFLAGS += -O0 -g -d-debug $(RPATH) -link-debuglib
 
-release:     DFLAGS += -O -release -inline -noboundscheck $(RPATH)
+release:     DFLAGS += -O -release $(RPATH)
+
+static:      DFLAGS += -O -release -static -L-Bstatic
 
 profile:     DFLAGS += -g -O -profile $(RPATH)
 
-guix release:             LIBS += $(DLIBS)
+guix release:   LIBS += $(DLIBS)
+
+static:         LIBS = $(LIBS_STATIC)
 
 guix-debug debug profile: LIBS += $(DLIBS_DEBUG)
 
-.PHONY: all guix guix-debug debug release profile clean test
+.PHONY: all guix guix-debug debug release static profile clean test
 
 all: debug
 
@@ -53,7 +58,7 @@ utils/ldc_version_info_.o: ldc-version-info
 build-setup: htslib-static ldc-version-info
 	mkdir -p build/
 
-guix guix-debug default debug release profile: $(OUT)
+guix guix-debug default debug release static profile: $(OUT)
 
 # ---- Compile step
 %.o: %.d
@@ -64,7 +69,9 @@ $(OUT): build-setup $(OBJ)
 	$(D_COMPILER) $(DFLAGS) -of=build/sambamba $(OBJ) $(LIBS)
 
 test:
-	./.run_tests.sh
+	./run_tests.sh
+
+check: test
 
 debug-strip: debug
 	objcopy --only-keep-debug build/sambamba sambamba.debug


=====================================
README.md
=====================================
--- a/README.md
+++ b/README.md
@@ -1,62 +1,180 @@
-[![Anaconda-Server Badge](https://anaconda.org/bioconda/sambamba/badges/installer/conda.svg)](https://conda.anaconda.org/bioconda)
+# 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)
 
-[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.13200.svg)](http://dx.doi.org/10.5281/zenodo.13200)
-# Sambamba
+## Table of Contents
+
+- [Introduction](#intro)
+- [Binary installation](#install)
+- [Getting help](#help)
+- [Compiling](#compile)
+- [Debugging and troubleshooting](#debug)
+- [License](#license)
+- [Credits](#credits)
+
+<a name="intro"></a>
+# Introduction
 
 Sambamba is a high performance modern robust and fast tool (and
 library), written in the D programming language, for working with SAM
-and BAM files.  Current parallelised functionality is an important
+and BAM files.  Current functionality is an important
 subset of samtools functionality, including view, index, sort,
-markdup, and depth.
+markdup, and depth. Most tools support piping: just specify `/dev/stdin`
+or `/dev/stdout` as filenames.
 
-Because of efficient use of modern multicore CPUs, usually `sambamba` is much faster
-than `samtools`. For example, indexing a 2.5 Gb BAM file (fully cached into RAM)
-on a 8 core machine utilizes all cores at 64% CPU:
+For almost 5 years the main advantage over `samtools` was parallelized BAM reading.
+Finally in March 2017 `samtools` 1.4 was released, reaching parity on this.
+That said, we still have quite a few interesting features to offer:
 
-    time sambamba index merged_NIT20120138_F3_20130715.bam -t8
+- faster `sort` (no benchmarks yet, sorry)
+- 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
 
-      real    0m17.398s
-      user    1m25.841s
-      sys     0m3.752s
+Sambamba is free and open source software, licensed under GPLv2+.
+See manual pages [online](https://lomereiter.github.io/sambamba/docs/sambamba-view.html)
+to know more about what is available and how to use it.
 
-meanwhile samtools is *4x* slower:
+For more information on Sambamba you can contact Artem Tarasov and Pjotr Prins.
 
-    time samtools index merged_NIT20120138_F3_20130715.bam
+<a name="install"></a>
+# Binary installation
+## Install stable release
 
-      real    1m8.083s
-      user    1m6.640s
-      sys     0m1.448s
+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
 
-In practice, the speedup is usually smaller since I/O becomes a bottleneck.
-Even so, it makes a big difference, shifting the focus to I/O optimization, i.e.
-less temporary files, more UNIX pipes, faster disk storage, tweaking filesystem, etc.
-Most tools in `sambamba` support piping: just specify `/dev/stdin` or `/dev/stdout` as filenames.
+```sh
+wget https://github.com/biod/sambamba/releases/download/v0.6.6/sambamba_v0.6.6_linux.tar.bz2
+tar xvjf sambamba_v0.6.6_linux.tar.bz2
+./sambamba_v0.6.6
 
-Notice that `samtools` implements parallel BAM compression in `sort` and `merge`,
-but `sambamba` should be faster for these tasks (given same amount of memory)
-due to more cache-friendly approach to parallelization.
-If it is not the case for you, please file a bug.
+    sambamba 0.6.6
 
-Sambamba is free and open source software, licensed under GPLv2+.
-See manual pages [online](https://lomereiter.github.io/sambamba/docs/sambamba-view.html)
-to know more about what is available and how to use it.
+        Usage: sambamba [command] [args...]
 
-For more information on Sambamba you can contact Artem Tarasov and Pjotr Prins.
+        Available commands: 'view', 'index', 'merge', 'sort',
+                             'flagstat', 'slice', 'markdup', 'depth', 'mpileup'
+        To get help on a particular command, just call it without args.
+```
+
+## Install latest pre-release
+
+A *latest* pre-release of sambamba 0.6.7 for Linux that includes debug
+information and *all* dependencies is available from this
+[link](http://test-gn2.genenetwork.org/ipfs/QmakasNfZhdbPA3xJYNxNX7at5FtYnS4hUNnvDbzxhZf2J). This
+24Mb download reflects the development edition and includes recent
+versions of libraries, samtools and bcftools. It should install on any
+Linux distribution, including old ones on HPC clusters.
+
+Install the tarball by unpacking it and running the contained install
+script with a target directory e.g.
+
+```sh
+wget http://test-gn2.genenetwork.org/ipfs/QmakasNfZhdbPA3xJYNxNX7at5FtYnS4hUNnvDbzxhZf2J/hb13hjys1064jmb6z17yc1f822hv9zsz-sambamba-0.6.7-pre1-7cff065-x86_64.tar.bz2
+tar xvjf QmakasNfZhdbPA3xJYNxNX7at5FtYnS4hUNnvDbzxhZf2J/hb13hjys1064jmb6z17yc1f822hv9zsz-sambamba-0.6.7-pre1-7cff065-x86_64.tar.bz2
+./install.sh ~/sambamba-test
+~/sambamba-test/bin/sambamba
 
-# Binaries
+    sambamba 0.6.7-pre1
 
-If you are already a Conda user, please use [`bioconda`](https://bioconda.github.io/) channel.
-If you are not, strongly consider becoming one.
+    Usage: sambamba [command] [args...]
+
+        Available commands: 'view', 'index', 'merge', 'sort',
+                            'flagstat', 'slice', 'markdup', 'depth', 'mpileup'
+
+```
+
+Binaries are also available through the following packaging tools (note the version numbers):
+
+## Bioconda install
+
+[![Install with CONDA](https://anaconda.org/bioconda/sambamba/badges/installer/conda.svg)](https://anaconda.org/bioconda/sambamba)
+
+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).
+
+## Debian GNU/Linux install
+
+Debian: see Debian packages.
+
+## Homebrew install
 
 Users of Homebrew can also use the formula from `homebrew-science`.
 
-For those not in the mood to learn/install new package managers, there are of course Github [releases](https://github.com/lomereiter/sambamba/releases).
 
+<a name="help"></a>
+# Getting help
+
+Sambamba has a
+[mailing list](https://groups.google.com/forum/#!forum/sambamba-discussion)
+for installation help and general discussion.
+
+## Reporting a sambamba bug or issue
+
+Before posting an issue search the issue tracker and
+[mailing list](https://groups.google.com/forum/#!forum/sambamba-discussion)
+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 .log.txt file in the
+output directory.
+
+## Check list:
+
+1. [X] I have found and issue with sambamba
+2. [ ] I have searched for it on the [issue tracker](https://github.com/biod/sambamba/issues) (also check closed issues)
+3. [ ] I have searched for it on the [mailing list](https://groups.google.com/forum/#!forum/sambamba-discussion)
+4. [ ] I have tried the latest [release](https://github.com/biod/sambamba/releases) 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](https://groups.google.com/forum/#!forum/sambamba-discussion)
+7. [ ] If it is software development related I have posted a new issue on the [issue tracker](https://github.com/biod/sambamba/issues) 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 .log.txt file 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](https://software-carpentry.org/conduct/) as
+published by the Software Carpentry initiative.
+
+
+<a name="compile"></a>
 # 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.
 
+## Compilation dependencies
+
+- zlib
+- htslib (submodule)
+- lz4 (submodule)
+- BioD (submodule)
+- undeaD (submodule)
+- python2
+
 ## Compiling for Linux
 
 The LDC compiler's github repository also provides binary images. The current
@@ -64,16 +182,18 @@ preferred release for sambamba is LDC - the LLVM D compiler (>= 1.1.0). After
 installing LDC:
 
 ```sh
-    git clone --recursive https://github.com/lomereiter/sambamba.git
+    git clone --recursive https://github.com/biod/sambamba.git
     cd sambamba
     git clone https://github.com/dlang/undeaD
     make sambamba-ldmd2-64
 ```
 
-Installing LDC only means unpacking an archive and setting some environmental variables, e.g. unpacking into `$HOME`:
+Installing LDC only means unpacking an archive and setting some
+environmental variables, e.g. unpacking into `$HOME`:
+
 ```sh
 cd
-wget https://github.com/ldc-developers/ldc/releases/download/$ver/ldc2-$ver-linux-x86_64.tar.xz
+wget https://github.com/ldc-developers/ldc/releases/download/v$ver/ldc2-$ver-linux-x86_64.tar.xz
 tar xJf ldc2-$ver-linux-x86_64.tar.xz
 export PATH=~/ldc2-$ver-linux-x86_64/bin/:$PATH
 export LIBRARY_PATH=~/ldc2-$ver-linux-x86_64/lib/
@@ -81,48 +201,71 @@ export LIBRARY_PATH=~/ldc2-$ver-linux-x86_64/lib/
 
 ### GNU Guix
 
-A GNU Guix package for LDC is also available
+To build sambamba the LDC compiler is also available in GNU Guix:
 
 ```sh
 guix package -i ldc
 ```
 
-
 ## Compiling for Mac OS X
 
 ```sh
     brew install ldc
-    git clone --recursive https://github.com/lomereiter/sambamba.git
+    git clone --recursive https://github.com/biod/sambamba.git
     cd sambamba
     git clone https://github.com/dlang/undeaD
     make sambamba-ldmd2-64
 ```
 
-# Troubleshooting
+## Development
 
-In case of crashes it's helpful to have GDB stacktraces (`bt` command). A full stacktrace
-for all threads:
+Sambamba development and issue tracker is on
+[github](https://github.com/biod/sambamba). Developer
+documentation can be found in the source code and the [development
+documentation](https://github.com/biod/sambamba-dev-docs).
+
+<a name="debug"></a>
+# Debugging and troubleshooting
+
+## Dump core
+
+In a crash sambamba can dump a core. To make this happen set
 
+```sh
+ulimit -c unlimited
 ```
-thread apply all backtrace full
+
+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
+
+```sh
+catchsegv ./build/sambamba command
 ```
 
-Note that GDB should be made aware of D garbage collector:
+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:
+
 ```
-handle SIGUSR1 SIGUSR2 nostop noprint
+thread apply all backtrace full
 ```
 
-A binary relocatable install of sambamba with debug information can be fetched from
+Note that GDB should be made aware of D garbage collector:
 
-```sh
-wget http://biogems.info/contrib/genenetwork/s7l4l5jnrwvvyr3pva242yakvmbfpm06-sambamba-0.6.6-pre3-6ae174b-debug-x86_64.tar.bz2
-md5sum ca64fd6f2fa2ba901937afc6b189e98d
-mkdir tmp
-tar xvjf ../*sambamba*.tar.bz2
-cd tmp
+```
+handle SIGUSR1 SIGUSR2 nostop noprint
 ```
 
-unpack the tarball and run the contained install.sh script with TARGET
+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 install.sh script with TARGET
 
 ```
 ./install.sh ~/sambamba-test
@@ -134,19 +277,29 @@ Run sambamba in gdb with
 gdb --args ~/sambamba-test/sambamba-*/bin/sambamba view --throw-error
 ```
 
-# Development
+<a name="license"></a>
+# License
 
-Sambamba development and issue tracker is on
-[github](https://github.com/lomereiter/sambamba). Developer
-documentation can be found in the source code and the [development
-documentation](https://github.com/lomereiter/sambamba-dev-docs).
+Sambamba is distributed under GNU Public License v2+.
 
-# Copyright
+<a name="credits"></a>
+# Credit
 
-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:
 
-# Citation
+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.
 
-If you are using Sambamba in your research, please cite the following article:
+```bibtex
 
-A. Tarasov, A. J. Vilella, E. Cuppen, I. J. Nijman, and P. Prins. Sambamba: fast processing of NGS alignment formats. Bioinformatics, 2015.
+ at article{doi:10.1093/bioinformatics/btv098,
+  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 = { + http://dx.doi.org/10.1093/bioinformatics/btv098}
+```


=====================================
bioconda_yaml_gen.py
=====================================
--- a/bioconda_yaml_gen.py
+++ b/bioconda_yaml_gen.py
@@ -23,7 +23,7 @@ test:
     - sambamba view
 
 about:
-  home: https://github.com/lomereiter/sambamba
+  home: https://github.com/biod/sambamba
   license: GPLv2
   summary: Tools for working with SAM/BAM data"""
 
@@ -31,7 +31,7 @@ import json
 from urllib2 import urlopen
 from hashlib import md5
 
-latest_release = json.loads(urlopen("https://api.github.com/repos/lomereiter/sambamba/releases").read())[0]
+latest_release = json.loads(urlopen("https://api.github.com/repos/biod/sambamba/releases").read())[0]
 sambamba_version = latest_release['tag_name'][1:]
 
 downloads = {}


=====================================
debian/changelog
=====================================
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,19 @@
-sambamba (0.6.6-2) UNRELEASED; urgency=medium
+sambamba (0.6.7-1) unstable; urgency=medium
 
+  [ Steffen Moeller ]
   * debian/upstream/metadata:
     - yamllint cleanliness
     - added references to registries
 
- -- Steffen Moeller <moeller at debian.org>  Mon, 25 Sep 2017 15:03:49 +0200
+  [ Andreas Tille ]
+  * New upstream version
+  * Use dh-dlang
+  * Standards-Version: 4.1.3
+  * debhelper 11
+  * enable hardening options
+  * move bash_completion scripts to new location
+
+ -- Andreas Tille <tille at debian.org>  Tue, 20 Mar 2018 10:53:49 +0100
 
 sambamba (0.6.6-1) unstable; urgency=medium
 


=====================================
debian/compat
=====================================
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-10
+11


=====================================
debian/control
=====================================
--- a/debian/control
+++ b/debian/control
@@ -1,19 +1,19 @@
 Source: sambamba
-Section: science
-Priority: optional
 Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
 Uploaders: Andreas Tille <tille at debian.org>
-Build-Depends: debhelper (>= 10.4),
-               ldc,
-               libbiod-dev (>= 0.1.0-4),
+Section: science
+Priority: optional
+Build-Depends: debhelper (>= 11~),
+               dh-dlang,
+               libbiod-dev (>= 0.1.0-5),
                libhts-dev,
                liblz4-dev,
-               libundead-dev (>= 1.0.7-1),
+               libundead-dev (>= 1.0.9-2),
                meson (>= 0.40),
                pkg-config,
                python,
                zlib1g-dev
-Standards-Version: 4.0.0
+Standards-Version: 4.1.3
 Vcs-Browser: https://anonscm.debian.org/cgit/debian-med/sambamba.git
 Vcs-Git: https://anonscm.debian.org/git/debian-med/sambamba.git
 Homepage: https://github.com/lomereiter/sambamba


=====================================
debian/patches/01_add_meson.patch
=====================================
--- a/debian/patches/01_add_meson.patch
+++ b/debian/patches/01_add_meson.patch
@@ -8,9 +8,6 @@ Subject: [PATCH] Add Meson build file
  1 file changed, 135 insertions(+)
  create mode 100644 meson.build
 
-diff --git a/meson.build b/meson.build
-new file mode 100644
-index 0000000..e7c31d9
 --- /dev/null
 +++ b/meson.build
 @@ -0,0 +1,135 @@
@@ -148,4 +145,4 @@ index 0000000..e7c31d9
 +#
 +
 +install_man(manpages)
-+install_data(['etc/bash_completion.d/sambamba'], install_dir: '/etc/bash_completion.d/')
++install_data(['etc/bash_completion.d/sambamba'], install_dir: '/usr/share/bash-completion/completions')


=====================================
debian/rules
=====================================
--- a/debian/rules
+++ b/debian/rules
@@ -1,10 +1,9 @@
 #!/usr/bin/make -f
 # DH_VERBOSE := 1
 
-# for hardening you might like to uncomment this:
-# export DEB_BUILD_MAINT_OPTIONS=hardening=+all
+export DEB_BUILD_MAINT_OPTIONS=hardening=+all
 
-export DFLAGS=-O3 -g -release
+include /usr/share/dh-dlang/dlang-flags.mk
 
 # we can not build with NEON on armhf, the Debian builders
 # don't support it.


=====================================
gen_ldc_version_info.py
=====================================
--- a/gen_ldc_version_info.py
+++ b/gen_ldc_version_info.py
@@ -1,14 +1,14 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 
 from __future__ import print_function
 import re, sys, subprocess
 
 if len(sys.argv) < 2:
-    print("Usage: {} <path to ldmd2 executable>".format(sys.argv[0]))
+    print("Usage: {0} <path to ldmd2 executable>".format(sys.argv[0]))
     sys.exit(1)
 
 ldc = sys.argv[1].replace("ldmd2", "ldc2")
-ldc_output = subprocess.check_output([ldc, "-version"])
+ldc_output = subprocess.Popen([ldc, '-version'], stdout=subprocess.PIPE).communicate()[0]
 version_re = r"""^.+\((?P<LDC>[^\)]+)\):\n\s*based on DMD (?P<DMD>\S+) and LLVM (?P<LLVM>\S+)\n(?:\s*built with (?P<BOOTSTRAP>.*)\n)?"""
 match = re.match(version_re, ldc_output, re.MULTILINE)
 
@@ -19,4 +19,4 @@ print("module utils.ldc_version_info_;")
 for component, version in match.groupdict().items():
     if version is None:
         version = "version not available"
-    print("immutable {}_VERSION_STRING = \"{}\";".format(component, version))
+    print("immutable {0}_VERSION_STRING = \"{1}\";".format(component, version))


=====================================
.run_tests.sh → run_tests.sh
=====================================
--- a/.run_tests.sh
+++ b/run_tests.sh
@@ -3,4 +3,4 @@
 # download shunit2 in order to run tests:
 # curl -L "https://dl.dropboxusercontent.com/u/7916095/shunit2-2.0.3.tgz" | tar zx --overwrite
 
-./.test_suite.sh | tee /dev/stderr | grep -q 'success rate: 100%'
+./test_suite.sh | tee /dev/stderr | grep -q 'success rate: 100%'


=====================================
sambamba/depth.d
=====================================
--- a/sambamba/depth.d
+++ b/sambamba/depth.d
@@ -1150,9 +1150,7 @@ int depth_main(string[] args) {
         if (query !is null) {
             read_filter = createFilterFromQuery(query);
         } else {
-            read_filter = createFilterFromQuery("mapping_quality > 0 and "
-                    "not duplicate and "
-                    "not failed_quality_control");
+            read_filter = createFilterFromQuery("mapping_quality > 0 and not duplicate and not failed_quality_control");
         }
 
         auto bam_filenames = args[1 .. $];


=====================================
sambamba/markdup.d
=====================================
--- a/sambamba/markdup.d
+++ b/sambamba/markdup.d
@@ -1,6 +1,6 @@
 /*
     This file is part of Sambamba.
-    Copyright (C) 2012-2016    Artem Tarasov <lomereiter at gmail.com>
+    Copyright (C) 2012-2017    Artem Tarasov <lomereiter at gmail.com>
 
     Sambamba is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ import bio.bam.reader, bio.bam.readrange, bio.bam.writer, bio.bam.referenceinfo,
        bio.bam.multireader;
 import std.traits, std.typecons, std.range, std.algorithm, std.parallelism,
        std.exception, std.file, std.typetuple, std.conv, std.array, std.bitmanip,
-       std.c.stdlib, std.datetime, undead.stream : BufferedFile, FileMode;
+       core.stdc.stdlib, std.datetime, undead.stream : BufferedFile, FileMode;
 
 /// Read + its index (0-based)
 struct IndexedBamRead {
@@ -81,14 +81,14 @@ class MallocArray(T) {
 
     /// call manually!
     void free() {
-        std.c.stdlib.free(_p);
+        core.stdc.stdlib.free(_p);
         _p = null;
     }
 
     this(size_t initial_size=16, float grow_factor=1.5) {
         enforce(initial_size >= 16);
         enforce(grow_factor >= 1.2);
-        _p = cast(T*)std.c.stdlib.malloc(initial_size * T.sizeof);
+        _p = cast(T*)core.stdc.stdlib.malloc(initial_size * T.sizeof);
         _sz = initial_size;
         _gf = grow_factor;
     }
@@ -112,7 +112,7 @@ class MallocArray(T) {
         } else {
             assert(_cur == _sz);
             _sz = cast(size_t)(_sz * _gf);
-            _p = cast(T*)std.c.stdlib.realloc(_p, _sz * T.sizeof);
+            _p = cast(T*)core.stdc.stdlib.realloc(_p, _sz * T.sizeof);
             _p[_cur++] = element;
         }
     }
@@ -576,15 +576,13 @@ struct SingleEndBasicInfo {
 }
 static assert(SingleEndBasicInfo.sizeof == 8);
 
-// 24 bytes :-(
 struct SingleEndInfo {
     SingleEndBasicInfo basic_info;
     alias basic_info this;
     ulong idx;
-    ushort score;
+    uint score;
 }
 
-// 32 bytes
 struct PairedEndsInfo {
     mixin(bitfields!(short, "library_id", 16,
                      ushort, "ref_id1", 14,
@@ -594,7 +592,7 @@ struct PairedEndsInfo {
     int coord2;
     ushort ref_id2;
 
-    ushort score; // sum of base qualities that are >= 15
+    uint score; // sum of base qualities that are >= 15
     ulong idx1, idx2;
 
     SingleEndBasicInfo read1_basic_info() @property {
@@ -608,7 +606,7 @@ struct PairedEndsInfo {
     }
 }
 
-static assert(PairedEndsInfo.sizeof == 32);
+static assert(PairedEndsInfo.sizeof == 40);
 
 bool singleEndInfoComparator(S1, S2)(auto ref S1 s1, auto ref S2 s2) {
     if (s1.library_id < s2.library_id) return true;
@@ -705,8 +703,8 @@ int computeFivePrimeCoord(R)(auto ref R read) {
     }
 }
 
-ushort computeScore(R)(auto ref R read) {
-    return reduce!"a + b"(0, read.base_qualities.filter!"a >= 15").to!ushort;
+uint computeScore(R)(auto ref R read) {
+    return reduce!"a + b"(0, read.base_qualities.filter!"a >= 15").to!uint;
 }
 
 auto collectSingleEndInfo(IndexedBamRead read, ReadGroupIndex read_group_index) {
@@ -744,7 +742,7 @@ PairedEndsInfo combine(ref SingleEndInfo s1, ref SingleEndInfo s2) {
     result.reversed2 = s2.reversed;
     result.coord1 = s1.coord;
     result.coord2 = s2.coord;
-    result.score = cast(ushort)(s1.score + s2.score);
+    result.score = cast(uint)(s1.score + s2.score);
     result.idx1 = s1.idx;
     result.idx2 = s2.idx;
     return result;
@@ -1263,7 +1261,7 @@ int markdup_main(string[] args) {
 
         // marking or removing duplicates
         bam = new MultiBamReader(args[1 .. $-1]);
-        bam.setBufferSize(io_buffer_size);
+        bam.setBufferSize(io_buffer_size / (args.length - 2));
         auto out_stream = new BufferedFile(args[$-1], FileMode.OutNew, io_buffer_size);
         auto writer = new BamWriter(out_stream, compression_level);
         writer.setFilename(args[$-1]);


=====================================
sambamba/pileup.d
=====================================
--- a/sambamba/pileup.d
+++ b/sambamba/pileup.d
@@ -747,6 +747,4 @@ int pileup_main(string[] args) {
           return 1;
         }
     }
-
-    return 0;
 }


=====================================
sambamba/slice.d
=====================================
--- a/sambamba/slice.d
+++ b/sambamba/slice.d
@@ -28,12 +28,14 @@ import bio.core.utils.stream;
 import bio.core.region;
 
 import std.array;
+import std.algorithm;
 import undead.stream;
 import std.getopt;
 import std.parallelism;
 import std.conv;
 import std.stdio;
 import std.exception;
+import sambamba.utils.common.bed;
 
 import sambamba.utils.common.overwrite;
 
@@ -103,72 +105,75 @@ BGZF blocks   ..........)[...........)[..........)[..........)[.  ...  ....)[...
 */
 
 
-void fetchRegion(BamReader bam, Region region, ref Stream stream)
+void fetchRegions(BamReader bam, Region[] regions, ref Stream stream)
 {
-    auto chr = region.reference;
-    auto beg = region.beg;
-    auto end = region.end;
-
     auto filename = bam.filename;
-
-    auto reads1 = bam[chr][beg .. end];
-
     auto eof_offset = bam.eofVirtualOffset();
 
-    VirtualOffset s1_start_offset;
-    VirtualOffset s2_start_offset;
-    VirtualOffset s2_end_offset = eof_offset;
+    // write header and reference sequence information
+    auto writer = new BamWriter(stream);
+    writer.writeSamHeader(bam.header);
+    writer.writeReferenceSequenceInfo(bam.reference_sequences);
 
-    if (reads1.empty) {
-        s1_start_offset = s2_start_offset = eof_offset;
-    } else {
-        s1_start_offset = s2_start_offset = reads1.front.start_virtual_offset;
-    }
+    foreach(Region region; regions) {
+        auto chr = region.reference;
+        auto beg = region.beg;
+        auto end = region.end;
+        auto reads1 = bam[chr][beg .. end];
 
-    // Set R1
-    auto r1 = appender!(typeof(reads1.front)[])();
+        VirtualOffset s1_start_offset;
+        VirtualOffset s2_start_offset;
+        VirtualOffset s2_end_offset = eof_offset;
 
-    while (!reads1.empty) {
-        auto front = reads1.front;
-        if (front.position < beg) {
-            r1.put(front);
-            s2_start_offset = front.end_virtual_offset;
-            reads1.popFront();
+        if (reads1.empty) {
+            s1_start_offset = s2_start_offset = eof_offset;
         } else {
-            break;
+            s1_start_offset = s2_start_offset = reads1.front.start_virtual_offset;
         }
-    }
 
-    auto reference = bam[chr];
-    if (end == uint.max)
-        end = reference.length;
-    auto reads2 = reference[end .. uint.max];
-
-    if (reads1.empty && reads2.empty) {
-        // are there any reads with position >= beg?
-        s2_end_offset = s2_start_offset;
-    } else if (!reads1.empty && reads2.empty) {
-        // are there any reads with position >= end?
-        s2_end_offset = bam[chr].endVirtualOffset();
-    } else {
-        foreach (read; reads2) {
-            s2_end_offset = read.start_virtual_offset;
-            if (read.position >= end) {
+        // Set R1
+        auto r1 = appender!(typeof(reads1.front)[])();
+
+        while (!reads1.empty) {
+            auto front = reads1.front;
+            if (front.position < beg) {
+                r1.put(front);
+                s2_start_offset = front.end_virtual_offset;
+                reads1.popFront();
+            } else {
                 break;
             }
         }
-    }
 
-    // write header and reference sequence information
-    auto writer = new BamWriter(stream);
-    writer.writeSamHeader(bam.header);
-    writer.writeReferenceSequenceInfo(bam.reference_sequences);
-    // write R1
-    foreach (read; r1.data)
-        writer.writeRecord(read);
-    writer.flush();
+        auto reference = bam[chr];
+        if (end == uint.max)
+            end = reference.length;
+        auto reads2 = reference[end .. uint.max];
+
+        if (reads1.empty && reads2.empty) {
+            // are there any reads with position >= beg?
+            s2_end_offset = s2_start_offset;
+        } else if (!reads1.empty && reads2.empty) {
+            // are there any reads with position >= end?
+            s2_end_offset = bam[chr].endVirtualOffset();
+        } else {
+            foreach (read; reads2) {
+                s2_end_offset = read.start_virtual_offset;
+                if (read.position >= end) {
+                    break;
+                }
+            }
+        }
+
+        // write R1
+        foreach (read; r1.data)
+            writer.writeRecord(read);
+        // Flush the BamWriter before our copyAsIs call.
+        writer.flush();
+
+        copyAsIs(bam, stream, s2_start_offset, s2_end_offset);
+    }
 
-    copyAsIs(bam, stream, s2_start_offset, s2_end_offset);
     // write EOF
     stream.writeExact(BAM_EOF.ptr, BAM_EOF.length);
 }
@@ -258,16 +263,18 @@ void copyAsIs(BamReader bam, Stream stream,
 
 void printUsage()
 {
-    stderr.writeln("Usage: sambamba-slice [options] <input.bam> <region>");
+    stderr.writeln("Usage: sambamba-slice [options] <input.bam> [region1 [...]]");
     stderr.writeln();
     stderr.writeln("       Fast copy of a region from indexed BAM file to a new file");
     stderr.writeln();
-    stderr.writeln("       Region is given in standard form ref:beg-end.");
+    stderr.writeln("       Regions are given in standard form ref:beg-end.");
     stderr.writeln("       In addition, region '*' denotes reads with no reference.");
     stderr.writeln("       Output is to STDOUT unless output filename is specified.");
     stderr.writeln();
     stderr.writeln("OPTIONS: -o, --output-filename=OUTPUT_FILENAME");
     stderr.writeln("            output BAM filename");
+    stderr.writeln("         -L, --regions=FILENAME");
+    stderr.writeln("            output only reads overlapping one of regions from the BED file");
 }
 
 version(standalone) {
@@ -280,17 +287,30 @@ int slice_main(string[] args) {
 
     // at least two arguments must be presented
     string output_filename = null;
+    string bed_filename = null;
 
     try {
         getopt(args,
                std.getopt.config.caseSensitive,
-               "output-filename|o", &output_filename);
+               "output-filename|o", &output_filename,
+               "regions|L",         &bed_filename);
 
-        if (args.length < 3) {
+        // Check that an input file was specified.
+        if (args.length < 2) {
             printUsage();
             return 0;
         }
 
+        // Either a bed file or a set of regions needs to be specified.
+        if (bed_filename is null && args.length < 3) {
+            throw new Exception("Must provide either a bed file or list of regions.");
+        }
+        
+        // But you can't provide both a bed file AND a set of regions.
+        if (bed_filename.length > 0 && args.length > 2) {
+            throw new Exception("specifying both region and BED filename is disallowed");
+        }
+
         protectFromOverwrite(args[1], output_filename);
 
         import std.parallelism;
@@ -315,11 +335,17 @@ int slice_main(string[] args) {
             stream = new undead.stream.BufferedFile(handle, FileMode.Out, BUFSIZE);
         }
 
-        if (args[2] == "*") {
+        if (bed_filename is null && args[2] == "*") {
             fetchUnmapped(bam, stream);
         } else {
-            auto region = parseRegion(args[2]);
-            fetchRegion(bam, region, stream);
+            Region[] regions;
+            if (bed_filename !is null) {
+                auto bam_regions = parseBed(bed_filename, bam);
+                regions = bam_regions.map!(r => Region(bam.reference(r.ref_id).name, r.start, r.end)).array;
+            } else {
+                regions = map!parseRegion(args[2 .. $]).array;
+            }
+            fetchRegions(bam, regions, stream);
         }
 
     } catch (Exception e) {


=====================================
sambamba/sort.d
=====================================
--- a/sambamba/sort.d
+++ b/sambamba/sort.d
@@ -42,8 +42,8 @@ import std.stdio;
 import std.typecons;
 import core.atomic;
 
-import std.c.stdlib;
-import std.c.string;
+import core.stdc.stdlib;
+import core.stdc.string;
 
 import sambamba.utils.common.progressbar;
 import sambamba.utils.common.overwrite;
@@ -114,13 +114,13 @@ class Sorter {
         this(size_t max_total_size) {
             max_sz = max_total_size;
             while (read_storage is null && max_sz > 65536) {
-                read_storage = cast(ubyte*)std.c.stdlib.malloc(max_sz);
+                read_storage = cast(ubyte*)core.stdc.stdlib.malloc(max_sz);
                 if (read_storage is null)
                   max_sz /= 2;
             }
             _reads_capa = 1024;
             auto sz = BamRead.sizeof * _reads_capa;
-            _reads = cast(BamRead*)std.c.stdlib.malloc(sz);
+            _reads = cast(BamRead*)core.stdc.stdlib.malloc(sz);
             if (_reads is null) {
                 throw new Exception("alloc failed: no space for read pointers");
             }
@@ -130,7 +130,7 @@ class Sorter {
             _used = 0;
             _n_reads = 0;
             if (_low_memory) {
-                auto realloc_storage = cast(ubyte*)std.c.stdlib.realloc(read_storage, max_sz / 2);
+                auto realloc_storage = cast(ubyte*)core.stdc.stdlib.realloc(read_storage, max_sz / 2);
                 if (realloc_storage !is null) {
                     max_sz /= 2;
                     read_storage = realloc_storage;
@@ -148,7 +148,7 @@ class Sorter {
                     break;
 
                 if (_n_reads == _reads_capa) {
-                    auto realloc_reads = cast(BamRead*)std.c.stdlib.realloc(_reads, 2 * _reads_capa * BamRead.sizeof);
+                    auto realloc_reads = cast(BamRead*)core.stdc.stdlib.realloc(_reads, 2 * _reads_capa * BamRead.sizeof);
                     if (realloc_reads is null) {
                         _low_memory = true;
                         stderr.writeln("realloc failed: system low on memory, limited to ", _reads_capa, " reads in buffer");
@@ -158,7 +158,7 @@ class Sorter {
                         _reads = realloc_reads;
                     }
                 }
-                std.c.string.memcpy(read_storage + _used, read.raw_data.ptr, len);
+                core.stdc.string.memcpy(read_storage + _used, read.raw_data.ptr, len);
                 _reads[_n_reads].raw_data = read_storage[_used .. _used + len];
                 _reads[_n_reads].associateWithReader(read.reader);
 
@@ -173,7 +173,7 @@ class Sorter {
                 auto len = read.raw_data.length;
                 assert(len > max_sz);
                 _n_reads = 1;
-                auto realloc_storage = cast(ubyte*)std.c.stdlib.realloc(read_storage, len);
+                auto realloc_storage = cast(ubyte*)core.stdc.stdlib.realloc(read_storage, len);
                 if (realloc_storage is null) {
                     throw new Exception("realloc failed: not enough memory for read");
                 } else {
@@ -189,8 +189,8 @@ class Sorter {
         }
 
         void free() {
-            std.c.stdlib.free(read_storage);
-            std.c.stdlib.free(_reads);
+            core.stdc.stdlib.free(read_storage);
+            core.stdc.stdlib.free(_reads);
         }
 
         BamRead[] reads() @property { return _reads[0 .. _n_reads]; }
@@ -209,9 +209,9 @@ class Sorter {
         sw.start();
         stderr.writeln("Sorting chunk #", n, "...");
         }
-        auto buf = cast(BamRead*)std.c.stdlib.malloc(chunk.length * BamRead.sizeof);
+        auto buf = cast(BamRead*)core.stdc.stdlib.malloc(chunk.length * BamRead.sizeof);
         BamRead[] tmp = buf[0 .. chunk.length];
-        scope (exit) std.c.stdlib.free(buf);
+        scope (exit) core.stdc.stdlib.free(buf);
         if (sort_by_name) {
             mergeSort!(compareReadNames, false)(chunk, task_pool, tmp);
         } else if (natural_sort) {
@@ -234,9 +234,9 @@ class Sorter {
         bam.setBufferSize(buf_size);
         bam.assumeSequentialProcessing();
 
-        auto output_buffer_ptr = cast(ubyte*)std.c.stdlib.malloc(buf_size);
+        auto output_buffer_ptr = cast(ubyte*)core.stdc.stdlib.malloc(buf_size);
         output_buffer = output_buffer_ptr[0 .. buf_size];
-        scope(exit)std.c.stdlib.free(output_buffer_ptr);
+        scope(exit)core.stdc.stdlib.free(output_buffer_ptr);
 
         if (show_progress) {
             stderr.writeln("Writing sorted chunks to temporary directory...");


=====================================
sambamba/utils/common/readstorage.d
=====================================
--- a/sambamba/utils/common/readstorage.d
+++ b/sambamba/utils/common/readstorage.d
@@ -19,8 +19,8 @@
 */
 module sambamba.utils.common.readstorage;
 
-import std.c.stdlib;
-import std.c.string;
+import core.stdc.stdlib;
+import core.stdc.string;
 import std.parallelism;
 import std.algorithm;
 import bio.core.utils.roundbuf;
@@ -33,10 +33,10 @@ struct ReadStorage {
 
     this(size_t max_total_size) {
         max_sz = max_total_size;
-        read_storage = cast(ubyte*)std.c.stdlib.malloc(max_sz);
+        read_storage = cast(ubyte*)core.stdc.stdlib.malloc(max_sz);
         _reads_capa = 1024;
         auto sz = BamRead.sizeof * _reads_capa;
-        _reads = cast(BamRead*)std.c.stdlib.malloc(sz);
+        _reads = cast(BamRead*)core.stdc.stdlib.malloc(sz);
     }
 
     void clear() {
@@ -51,10 +51,10 @@ struct ReadStorage {
             if (len + _used > max_sz)
                 break;
 
-            std.c.string.memcpy(read_storage + _used, read.raw_data.ptr, len);
+            core.stdc.string.memcpy(read_storage + _used, read.raw_data.ptr, len);
             if (_n_reads == _reads_capa) {
                 _reads_capa *= 2;
-                _reads = cast(BamRead*)std.c.stdlib.realloc(_reads, _reads_capa * BamRead.sizeof);
+                _reads = cast(BamRead*)core.stdc.stdlib.realloc(_reads, _reads_capa * BamRead.sizeof);
             }
             _reads[_n_reads].raw_data = read_storage[_used .. _used + len];
             _reads[_n_reads].associateWithReader(read.reader);
@@ -70,7 +70,7 @@ struct ReadStorage {
             auto len = read.raw_data.length;
             assert(len > max_sz);
             _n_reads = 1;
-            read_storage = cast(ubyte*)std.c.stdlib.realloc(read_storage, len);
+            read_storage = cast(ubyte*)core.stdc.stdlib.realloc(read_storage, len);
             _used = len;
             read_storage[0 .. len] = read.raw_data[];
             _reads[0].raw_data = read_storage[0 .. _used];
@@ -80,8 +80,8 @@ struct ReadStorage {
     }
 
     void free() {
-        std.c.stdlib.free(read_storage);
-        std.c.stdlib.free(_reads);
+        core.stdc.stdlib.free(read_storage);
+        core.stdc.stdlib.free(_reads);
     }
 
     BamRead[] reads() @property { return _reads[0 .. _n_reads]; }


=====================================
test/chr2_chr3_test_region.bed
=====================================
--- /dev/null
+++ b/test/chr2_chr3_test_region.bed
@@ -0,0 +1,4 @@
+2	166860000	166870000
+2	166875000	166890000
+3	100000000	170000000
+3	150000000	200000000


=====================================
.test_suite.sh → test_suite.sh
=====================================
--- a/.test_suite.sh
+++ b/test_suite.sh
@@ -20,6 +20,17 @@ testSlice() {
     assertEquals 0 $?
 }
 
+testSliceMultipleRegions() {
+    ./build/sambamba slice test/issue_204.bam 2:166860000-166870000 2:166860000-166870000 |\
+      ./build/sambamba view -c /dev/stdin > /dev/null
+    assertEquals 0 $?
+}
+
+testSliceMultipleRegionsBed() {
+    assertEquals "156" `./build/sambamba slice -L test/chr2_chr3_test_region.bed test/issue_204.bam |\
+      ./build/sambamba view -c /dev/stdin`
+}
+
 testView() {
     assertEquals "1806" `./build/sambamba view -c ex1_header.sorted.bam chr2`
     assertEquals "1464" `./build/sambamba view -c ex1_header.sorted.bam chr1`
@@ -51,8 +62,12 @@ testMarkdupEmptyFile() {
     assertEquals "0" `./build/sambamba view -c empty.dedup.bam`
 }
 
-testCramView() {
+testCramWriting() {
     ./build/sambamba view -S htslib/test/c1\#pad2.sam -T htslib/test/c1.fa -f cram -o c1_pad2.cram
+    assertEquals 0 $?
+}
+
+testCramReading() {
     ./build/sambamba view -C c1_pad2.cram >/dev/null
     assertEquals 0 $?
 }
@@ -60,11 +75,10 @@ testCramView() {
 testIndexUsage() {
     rm *.bai && rm c1_*
     ./build/sambamba view -S htslib/test/c1\#pad2.sam -T htslib/test/c1.fa -f cram -o c1_pad2.cram &&
-    ./build/sambamba index -C c1_pad2.cram && test -e c1_pad2.cram.crai
-    ./build/sambamba index -C c1_pad2.cram c1_cram_index && test -e c1_cram_index.crai
-    ./build/sambamba index ex1_header.sorted.bam && test -e ex1_header.sorted.bam.bai
-    ./build/sambamba index ex1_header.sorted.bam ex1_header.sorted.bai && test -e ex1_header.sorted.bai
-    assertEquals 0 $?
+    ./build/sambamba index -C c1_pad2.cram && test -e c1_pad2.cram.crai; assertEquals 0 $?
+    ./build/sambamba index -C c1_pad2.cram c1_cram_index && test -e c1_cram_index.crai; assertEquals 0 $?
+    ./build/sambamba index ex1_header.sorted.bam && test -e ex1_header.sorted.bam.bai; assertEquals 0 $?
+    ./build/sambamba index ex1_header.sorted.bam ex1_header.sorted.bai && test -e ex1_header.sorted.bai; assertEquals 0 $?
 }
 
 testIssue193() {


=====================================
utils/strip_bcf_header.d
=====================================
--- a/utils/strip_bcf_header.d
+++ b/utils/strip_bcf_header.d
@@ -18,6 +18,9 @@
 
 */
 module utils.strip_bcf_header;
+import undead.cstream : CFile, FileMode;
+import std.exception;
+import std.algorithm : min;
 
 // used in mpileup tool to strip the common header from partial files
 void stripBcfHeader(File input_file, File output_file) {
@@ -25,7 +28,6 @@ void stripBcfHeader(File input_file, File output_file) {
   import bio.core.bgzf.constants;
   import bio.core.bgzf.block;
   import bio.core.bgzf.compress;
-  import undead.cstream, std.exception;
 
   auto stream = new CFile(input_file.getFP(), FileMode.In);
   auto supplier = new StreamSupplier(stream);


=====================================
utils/version_.d
=====================================
--- a/utils/version_.d
+++ b/utils/version_.d
@@ -1,6 +1,6 @@
 module utils.version_;
 
-immutable string VERSION = "0.6.6";
+immutable string VERSION = "0.6.7-pre1";
 
 import bio.sam.header;
 import std.array : join;



View it on GitLab: https://salsa.debian.org/med-team/sambamba/compare/5f6e57dd5dc304ba6d4e60f893bba4d3338d7557...22e9c9d8f921fb056613cd817031d291ee147651

---
View it on GitLab: https://salsa.debian.org/med-team/sambamba/compare/5f6e57dd5dc304ba6d4e60f893bba4d3338d7557...22e9c9d8f921fb056613cd817031d291ee147651
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/debian-med-commit/attachments/20180320/c4a596ea/attachment-0001.html>


More information about the debian-med-commit mailing list