Skip to content

Commit

Permalink
Adds a test example and functional testing. Fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
pmelsted committed Nov 20, 2015
1 parent ba7a7d8 commit 752f45d
Show file tree
Hide file tree
Showing 7 changed files with 1,568 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ rp-files/
testdata/
*.o
*~
tests/chr*
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ CXXFLAGS+=-O3 -DSEQAN_ENABLE_TESTING=0 -DSEQAN_ENABLE_DEBUG=0

all: chopBAI

chopBAI: chopBAI.o
chopBAI: chopBAI.o

chopBAI.o: chopBAI.cpp bam_index_csi.h

test:
cd tests/ && ./alltests.sh

clean:
rm -f *.o chopBAI

.PHONY: test
18 changes: 18 additions & 0 deletions tests/alltests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -eo pipefail

# Test all options
for opts in "" "--linear" "--symlink" "--linear --symlink"; do
echo "Testing chopBAI with option $opts"


for chr in chrA:B:C:D chrA:B chrB; do
echo " Testing chromosome $chr"
./test.sh $chr $opts
for reg in "100" "2,000" "1-100" "1,000-10,000"; do
chrreg="${chr}:${reg}"
./test.sh $chrreg $opts
done
done
done
1,509 changes: 1,509 additions & 0 deletions tests/test.fa

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -eo pipefail

REGION=$1
#clean up directory if it exists
if [[ -d "${REGION}" ]]; then
rm -rf ./${REGION}
fi

shift 1
OPTS=$@
echo "Running command: ../chopBAI ${OPTS} test.sorted.bam ${REGION}"
../chopBAI ${OPTS} test.sorted.bam ${REGION}

if [[ -d ${REGION} ]]; then
#ok, directory exists
cd ${REGION}
if [[ ! -f test.sorted.bam ]]; then
if [[ $OPTS =~ "--symlink" || $OPTS =~ "-s" ]]; then
echo "Symlink not created!"
exit 1
else
#we'll just create it ourselves
ln -s ../test.sorted.bam
fi

samtools view test.sorted.bam ${REGION} > out.chopBAI.sam
samtools view ../test.sorted.bam ${REGION} > out.samtools.sam
diff -q out.chopBAI.sam out.samtools.sam
fi
else
echo "Directory ${REGION} was not created."
exit 1
fi
Binary file added tests/test.sorted.bam
Binary file not shown.
Binary file added tests/test.sorted.bam.bai
Binary file not shown.

0 comments on commit 752f45d

Please sign in to comment.