Browse Source

Adding test

master
Pjotr Prins 3 years ago
parent
commit
8040b4f5c2
  1. 24
      Makefile
  2. 6
      RELEASE-NOTES.md
  3. 30
      test/read_bam_file.d

24
Makefile

@ -1,6 +1,10 @@
# Simple Makefile
#
# make sharedlibrary : make shared library
# make shared : make shared lib
# make lib : make static lib (nyi)
# make check
#
# You can also use 'dub' and 'dub test' instead
D_COMPILER=ldc2
DFLAGS = -wi -g -relocation-model=pic -Icontrib/undead -L-lz
@ -17,28 +21,36 @@ endif
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
SRC = $(wildcard contrib/undead/*.d) contrib/undead/*/*.d $(wildcard bio/*.d bio/*/*.d bio/*/*/*.d bio/*/*/*/*.d bio/*/*/*/*/*.d bio/*/*/*/*/*/*.d) test/unittests.d
SRC = $(wildcard contrib/undead/*.d) contrib/undead/*/*.d $(wildcard bio/*.d bio/*/*.d bio/*/*/*.d bio/*/*/*/*.d bio/*/*/*/*/*.d bio/*/*/*/*/*/*.d) test/unittests.d test/read_bam_file.d
OBJ = $(SRC:.d=.o)
BIN = bin/biod_tests
sharedlibrary: BIN = libbiod.so
shared: LIB = libbiod.so
lib: LIB = libbiod
debug check: DFLAGS += -O0 -d-debug -unittest -link-debuglib
release static: DFLAGS += -O3 -release -enable-inlining -boundscheck=off
static: DFLAGS += -static -L-Bstatic
sharedlibrary: DFLAGS += -shared
shared: DFLAGS += -shared
lib: DFLAGS += -lib
all: debug
default: all
default debug release static sharedlibrary: $(BIN)
default debug release static: $(BIN)
shared lib: $(LIB)
%.o: %.d
$(D_COMPILER) $(DFLAGS) -c $< -od=$(dir $@)
$(LIB): $(OBJ)
$(info linking lib...)
$(D_COMPILER) $(DFLAGS) $(OBJ) -of=$(LIB)
$(BIN): $(OBJ)
$(info linking...)
$(D_COMPILER) -main $(DFLAGS) $(OBJ) -of=$(BIN)
$(D_COMPILER) $(DFLAGS) $(OBJ) -of=$(BIN)
check: $(BIN)
$(info running tests...)

6
RELEASE-NOTES.md

@ -1,3 +1,9 @@
## ChangeLog v0.2.4 (2019xxxx)
+ Fixed dub and make files
+ Dub test still fails because of GC
+ Debian package (thanks https://github.com/atille https://github.com/biod/BioD/issues/50)
## ChangeLog v0.2.3 (20191119)
+ Compiles and tests pass on Debian with dub and ldc 1.17.0

30
test/read_bam_file.d

@ -0,0 +1,30 @@
import bio.std.hts.bam.reader;
import bio.std.hts.bam.pileup;
import std.stdio;
void main() {
auto bam = new BamReader("test/data/ex1_header.bam");
auto reads = bam["chr2"][150 .. 160]; // region chr2:149-158
auto pileup = makePileup(reads,
false, // reads don't contain MD tags
155, 158); // specify [start, end) interval
foreach (column; pileup) {
writeln("Reference position: ", column.position);
writeln(" Coverage: ", column.coverage);
writeln(" Reads:");
foreach (read; column.reads) {
writefln("%30s\t%s\t%.2d\t%s\t%2s/%2s\t%2s/%2s\t%10s\t%s %s",
read.name,
read.current_base,
read.current_base_quality,
read.cigar_operation,
read.cigar_operation_offset + 1, read.cigar_operation.length,
read.query_offset + 1, read.sequence.length,
read.cigarString(),
read.cigar_before, read.cigar_after);
}
}
}
Loading…
Cancel
Save