Skip to content

Commit

Permalink
enable multi-threaded bam read for lumpy_filter
Browse files Browse the repository at this point in the history
also run lumpy_tests in travis

closes arq5x#41
  • Loading branch information
brentp committed Mar 13, 2017
1 parent 8b1eea2 commit 302f14d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ ssshtest
data/
data.tar.gz
src/utils/BamTools
lumpy_tests/*/*.bam
lumpy_tests/*/*.bai
lumpy_tests/*/*.histo
lumpy_tests/*/*.stats
lumpy_tests/*/*.vcf
lumpy_tests/*/*.bedpe
src/filter/lumpy_filter
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "scripts/bamkit"]
path = scripts/bamkit
url = https://github.com/cc2qe/bamkit.git
[submodule "lib/htslib"]
path = lib/htslib
url = https://github.com/samtools/htslib.git
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ script:
- ./scripts/lumpyexpress -h
- python scripts/cnvanator_to_bedpes.py --cnvkit -b 100 --del_o delo2 --dup_o dupo2 -c data/example.cns
- bash test/functional-test.sh
- cd lumpy_tests && bash test.sh

install:
- sudo apt-get update
- sudo apt-get install libssl-dev gettext gettext-base libtool autoconf
- unset PYTHONPATH
- unset PYTHONHOME
- unset PYTHONUSER
Expand All @@ -25,4 +27,5 @@ install:
- conda config --add channels bioconda
- conda create -q -n travis python=$TRAVIS_PYTHON_VERSION pysam samtools htslib bedtools
- source activate travis
- autoconf --version
- make
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ UTIL_SUBDIRS = $(SRC_DIR)/utils/bedFile \
$(SRC_DIR)/utils/sqlite3


all: lumpyexpress lumpy lumpy_filter
all: lumpy_filter lumpyexpress lumpy

lumpy:
[ -d $(OBJ_DIR) ] || mkdir -p $(OBJ_DIR)
Expand All @@ -65,11 +65,16 @@ lumpy:
done

lumpy_filter: htslib
[ -d $(BIN_DIR) ] || mkdir -p $(BIN_DIR)
$(MAKE) --no-print-directory -C src/filter/
cp src/filter/lumpy_filter $(BIN_DIR)


htslib:
$(MAKE) --no-print-directory -C lib/htslib
$(shell cd lib/htslib && autoreconf)
cd lib/htslib && \
./configure --disable-bz2 --disable-lzma --enable-libcurl
CFLAGS="$(CFLAGS) -DBGZF" $(MAKE) -C lib/htslib --no-print-directory CFLAGS="-DBGZF_MT"

lumpyexpress:
[ -d $(BIN_DIR) ] || mkdir -p $(BIN_DIR)
Expand Down
1 change: 1 addition & 0 deletions lib/htslib
Submodule htslib added at d2d9c7
2 changes: 1 addition & 1 deletion src/filter/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

all:
$(CC) -I../../lib/htslib/ -o lumpy_filter filter.c ../../lib/htslib/libhts.a -lpthread -lz
$(CC) -I../../lib/htslib/ -o lumpy_filter filter.c ../../lib/htslib/libhts.a -lcrypto -lcurl -lpthread -lz

14 changes: 12 additions & 2 deletions src/filter/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdbool.h>

#include "htslib/sam.h"
#include "htslib/bgzf.h"

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
Expand Down Expand Up @@ -186,14 +187,18 @@ int count_tags(char *sa_tag)

int main(int argc, char **argv)
{
if (argc != 4)
if (argc < 4)
errx(1,
"usage\t:%s <bam> <split out> <discord out>",
"usage\t:%s <bam> <split out> <discord out> (optional #threads)",
argv[0]);

char *bam_file_name = argv[1];
char *split_file_name = argv[2];
char *disc_file_name = argv[3];
int threads = 2;
if (argc == 5) {
threads = atoi(argv[4]);
}

samFile *disc = sam_open(disc_file_name, "wb");

Expand All @@ -203,6 +208,11 @@ int main(int argc, char **argv)
if(in == NULL)
errx(1, "Unable to open BAM/SAM file.");

// TODO: handle cram.
if (threads > 1) {
bgzf_mt(in->fp.bgzf, threads, 256);
}

hts_idx_t *idx = sam_index_load(in, bam_file_name);
if(idx == NULL)
errx(1,"Unable to open BAM/SAM index.");
Expand Down

0 comments on commit 302f14d

Please sign in to comment.