From: martinahansen Date: Tue, 3 Aug 2010 13:06:04 +0000 (+0000) Subject: added testing suite X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=bba949ceabb0a366245520982ad01db7c9fc62d3;p=biopieces.git added testing suite git-svn-id: http://biopieces.googlecode.com/svn/trunk@1017 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_test/in/align_seq.in b/bp_test/in/align_seq.in new file mode 100644 index 0000000..aa030ba --- /dev/null +++ b/bp_test/in/align_seq.in @@ -0,0 +1,20 @@ +SEQ: CTAGCTTCGACT +SEQ_LEN: 12 +SEQ_NAME: test1 +--- +SEQ: GAATCGACT +SEQ_LEN: 9 +SEQ_NAME: test2 +--- +SEQ: ACGAAACTAGCATC +SEQ_LEN: 14 +SEQ_NAME: test3 +--- +SEQ: AGCATCGACT +SEQ_LEN: 10 +SEQ_NAME: test4 +--- +SEQ: TAACAGGCACT +SEQ_LEN: 11 +SEQ_NAME: test5 +--- diff --git a/bp_test/in/grab.in b/bp_test/in/grab.in new file mode 100644 index 0000000..415979e --- /dev/null +++ b/bp_test/in/grab.in @@ -0,0 +1,13 @@ +SEQ_NAME: test1 +SEQ_LEN: 10 +SEQ: MDESEQATHP +--- +SEQ_NAME: test2 +SEQ_LEN: 8 +SEQ: ATCGatcg +--- +PAT_NAME: test2 +PAT: SEQ +--- +COUNT: 3 +--- diff --git a/bp_test/in/grab.in.pat b/bp_test/in/grab.in.pat new file mode 100644 index 0000000..77ca6dd --- /dev/null +++ b/bp_test/in/grab.in.pat @@ -0,0 +1,2 @@ +SEQ +COUNT diff --git a/bp_test/in/read_fasta.in b/bp_test/in/read_fasta.in new file mode 100644 index 0000000..00beff4 --- /dev/null +++ b/bp_test/in/read_fasta.in @@ -0,0 +1,4 @@ +>test1 +ATCG +>test2 +atcg diff --git a/bp_test/in/write_fasta.in b/bp_test/in/write_fasta.in new file mode 100644 index 0000000..6dcdf61 --- /dev/null +++ b/bp_test/in/write_fasta.in @@ -0,0 +1,4 @@ +SEQ: ATCGatcg +SEQ_LEN: 8 +SEQ_NAME: test +--- diff --git a/bp_test/lib/test.sh b/bp_test/lib/test.sh new file mode 100755 index 0000000..e753003 --- /dev/null +++ b/bp_test/lib/test.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env sh + +bp=`basename $0 | sed s/^test_//` +in="$BP_DIR/bp_test/in/$bp.in" +out="$BP_DIR/bp_test/out/$bp.out" +tmp="$BP_TMP/$bp.out" +log_file="$BP_TMP/test.log" + +function run +{ + local command=$1 + + echo -n "Testing $command ... " + eval $command > /dev/null 2>&1 +} + + +function assert_no_diff +{ + local src=$1 + local dst=$2 + + local diff=`diff -q $src $dst` + + if [ "$diff" != "" ]; then + echo_red "FAIL" + echo "FAIL" >> $log_file + else + echo_green "OK" + echo "OK" >> $log_file + fi +} + + +function echo_green +{ + local msg=$1 + + echo -e "\033[32;38m$msg\033[0m" +} + +function echo_red +{ + local msg=$1 + + echo -e "\033[31;38m$msg\033[0m" +} diff --git a/bp_test/out/align_seq.out.1 b/bp_test/out/align_seq.out.1 new file mode 100644 index 0000000..e161ba7 --- /dev/null +++ b/bp_test/out/align_seq.out.1 @@ -0,0 +1,20 @@ +SEQ: ---TAACAGGCACT +SEQ_LEN: 14 +SEQ_NAME: test5 +--- +SEQ: -----GAATCGACT +SEQ_LEN: 14 +SEQ_NAME: test2 +--- +SEQ: --CTAGCTTCGACT +SEQ_LEN: 14 +SEQ_NAME: test1 +--- +SEQ: ACGAAACTAGCATC +SEQ_LEN: 14 +SEQ_NAME: test3 +--- +SEQ: ----AGCATCGACT +SEQ_LEN: 14 +SEQ_NAME: test4 +--- diff --git a/bp_test/out/grab.out.1 b/bp_test/out/grab.out.1 new file mode 100644 index 0000000..5ffd399 --- /dev/null +++ b/bp_test/out/grab.out.1 @@ -0,0 +1,11 @@ +SEQ: MDESEQATHP +SEQ_LEN: 10 +SEQ_NAME: test1 +--- +SEQ: ATCGatcg +SEQ_LEN: 8 +SEQ_NAME: test2 +--- +PAT: SEQ +PAT_NAME: test2 +--- diff --git a/bp_test/out/grab.out.10 b/bp_test/out/grab.out.10 new file mode 100644 index 0000000..e117dbf --- /dev/null +++ b/bp_test/out/grab.out.10 @@ -0,0 +1,4 @@ +SEQ: ATCGatcg +SEQ_LEN: 8 +SEQ_NAME: test2 +--- diff --git a/bp_test/out/grab.out.2 b/bp_test/out/grab.out.2 new file mode 100644 index 0000000..faac8b6 --- /dev/null +++ b/bp_test/out/grab.out.2 @@ -0,0 +1,13 @@ +SEQ: MDESEQATHP +SEQ_LEN: 10 +SEQ_NAME: test1 +--- +SEQ: ATCGatcg +SEQ_LEN: 8 +SEQ_NAME: test2 +--- +PAT: SEQ +PAT_NAME: test2 +--- +COUNT: 3 +--- diff --git a/bp_test/out/grab.out.3 b/bp_test/out/grab.out.3 new file mode 100644 index 0000000..faac8b6 --- /dev/null +++ b/bp_test/out/grab.out.3 @@ -0,0 +1,13 @@ +SEQ: MDESEQATHP +SEQ_LEN: 10 +SEQ_NAME: test1 +--- +SEQ: ATCGatcg +SEQ_LEN: 8 +SEQ_NAME: test2 +--- +PAT: SEQ +PAT_NAME: test2 +--- +COUNT: 3 +--- diff --git a/bp_test/out/grab.out.4 b/bp_test/out/grab.out.4 new file mode 100644 index 0000000..900f5c4 --- /dev/null +++ b/bp_test/out/grab.out.4 @@ -0,0 +1,2 @@ +COUNT: 3 +--- diff --git a/bp_test/out/grab.out.5 b/bp_test/out/grab.out.5 new file mode 100644 index 0000000..67046b9 --- /dev/null +++ b/bp_test/out/grab.out.5 @@ -0,0 +1,8 @@ +SEQ: MDESEQATHP +SEQ_LEN: 10 +SEQ_NAME: test1 +--- +SEQ: ATCGatcg +SEQ_LEN: 8 +SEQ_NAME: test2 +--- diff --git a/bp_test/out/grab.out.6 b/bp_test/out/grab.out.6 new file mode 100644 index 0000000..5bc1520 --- /dev/null +++ b/bp_test/out/grab.out.6 @@ -0,0 +1,7 @@ +SEQ: MDESEQATHP +SEQ_LEN: 10 +SEQ_NAME: test1 +--- +PAT: SEQ +PAT_NAME: test2 +--- diff --git a/bp_test/out/grab.out.7 b/bp_test/out/grab.out.7 new file mode 100644 index 0000000..c60949d --- /dev/null +++ b/bp_test/out/grab.out.7 @@ -0,0 +1,3 @@ +PAT: SEQ +PAT_NAME: test2 +--- diff --git a/bp_test/out/grab.out.8 b/bp_test/out/grab.out.8 new file mode 100644 index 0000000..e117dbf --- /dev/null +++ b/bp_test/out/grab.out.8 @@ -0,0 +1,4 @@ +SEQ: ATCGatcg +SEQ_LEN: 8 +SEQ_NAME: test2 +--- diff --git a/bp_test/out/grab.out.9 b/bp_test/out/grab.out.9 new file mode 100644 index 0000000..67046b9 --- /dev/null +++ b/bp_test/out/grab.out.9 @@ -0,0 +1,8 @@ +SEQ: MDESEQATHP +SEQ_LEN: 10 +SEQ_NAME: test1 +--- +SEQ: ATCGatcg +SEQ_LEN: 8 +SEQ_NAME: test2 +--- diff --git a/bp_test/out/read_fasta.out.1 b/bp_test/out/read_fasta.out.1 new file mode 100644 index 0000000..845ac01 --- /dev/null +++ b/bp_test/out/read_fasta.out.1 @@ -0,0 +1,8 @@ +SEQ: ATCG +SEQ_LEN: 4 +SEQ_NAME: test1 +--- +SEQ: atcg +SEQ_LEN: 4 +SEQ_NAME: test2 +--- diff --git a/bp_test/out/read_fasta.out.2 b/bp_test/out/read_fasta.out.2 new file mode 100644 index 0000000..79b3251 --- /dev/null +++ b/bp_test/out/read_fasta.out.2 @@ -0,0 +1,4 @@ +SEQ: ATCG +SEQ_LEN: 4 +SEQ_NAME: test1 +--- diff --git a/bp_test/out/write_fasta.out.1 b/bp_test/out/write_fasta.out.1 new file mode 100644 index 0000000..0c4b8a8 --- /dev/null +++ b/bp_test/out/write_fasta.out.1 @@ -0,0 +1,2 @@ +>test +ATCGatcg diff --git a/bp_test/out/write_fasta.out.2 b/bp_test/out/write_fasta.out.2 new file mode 100644 index 0000000..526b10c --- /dev/null +++ b/bp_test/out/write_fasta.out.2 @@ -0,0 +1,3 @@ +>test +ATCG +atcg diff --git a/bp_test/test/test_align_seq b/bp_test/test/test_align_seq new file mode 100755 index 0000000..669747d --- /dev/null +++ b/bp_test/test/test_align_seq @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +source "lib/test.sh" + +run "$bp -I $in -O $tmp.1" +assert_no_diff $tmp.1 $out.1 +rm $tmp.1 diff --git a/bp_test/test/test_grab b/bp_test/test/test_grab new file mode 100755 index 0000000..bda9e3e --- /dev/null +++ b/bp_test/test/test_grab @@ -0,0 +1,43 @@ +#!/usr/bin/env sh + +source "lib/test.sh" + +run "$bp -I $in -p SEQ -O $tmp.1" +assert_no_diff $tmp.1 $out.1 +rm $tmp.1 + +run "$bp -I $in -p SEQ,COUNT -O $tmp.2" +assert_no_diff $tmp.2 $out.2 +rm $tmp.2 + +run "$bp -I $in -P $in.pat -O $tmp.3" +assert_no_diff $tmp.3 $out.3 +rm $tmp.3 + +run "$bp -I $in -p SEQ -i -O $tmp.4" +assert_no_diff $tmp.4 $out.4 +rm $tmp.4 + +run "$bp -I $in -p SEQ -K -O $tmp.5" +assert_no_diff $tmp.5 $out.5 +rm $tmp.5 + +run "$bp -I $in -p SEQ -V -O $tmp.6" +assert_no_diff $tmp.6 $out.6 +rm $tmp.6 + +run "$bp -I $in -p SEQ -k PAT -O $tmp.7" +assert_no_diff $tmp.7 $out.7 +rm $tmp.7 + +run "$bp -I $in -r a -k SEQ -O $tmp.8" +assert_no_diff $tmp.8 $out.8 +rm $tmp.8 + +run "$bp -I $in -r a -k SEQ -c -O $tmp.9" +assert_no_diff $tmp.9 $out.9 +rm $tmp.9 + +run "$bp -I $in -e 'SEQ_LEN<10' -O $tmp.10" +assert_no_diff $tmp.10 $out.10 +rm $tmp.10 diff --git a/bp_test/test/test_read_fasta b/bp_test/test/test_read_fasta new file mode 100755 index 0000000..aee8d00 --- /dev/null +++ b/bp_test/test/test_read_fasta @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +source "lib/test.sh" + +run "$bp -i $in -O $tmp.1" +assert_no_diff $tmp.1 $out.1 +rm $tmp.1 + +run "$bp -i $in -n 1 -O $tmp.2" +assert_no_diff $tmp.2 $out.2 +rm $tmp.2 diff --git a/bp_test/test/test_write_fasta b/bp_test/test/test_write_fasta new file mode 100755 index 0000000..4597200 --- /dev/null +++ b/bp_test/test/test_write_fasta @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +source "lib/test.sh" + +run "write_fasta -I $in -o $tmp.1 -x" +assert_no_diff $tmp.1 $out.1 +rm $tmp.1 + +run "write_fasta -I $in -w 4 -o $tmp.2 -x" +assert_no_diff $tmp.2 $out.2 +rm $tmp.2 diff --git a/bp_test/test_all b/bp_test/test_all new file mode 100755 index 0000000..061bec3 --- /dev/null +++ b/bp_test/test_all @@ -0,0 +1,29 @@ +#!/usr/bin/env sh + +source "lib/test.sh" + +rm $log_file + +count=0 +time0=`date +%s` + +for i in `ls "$BP_DIR/bp_test/test/"`; do + "$BP_DIR/bp_test/test/$i" + count=$[ $count + 1 ] +done + +time1=`date +%s` +time=$[ $time1 - $time0 ] + +test_count=`cat $log_file | wc -l | sed "s/ //g"` +test_ok=`grep -c "OK" $log_file` + +test_fail=$[ $test_count - $test_ok ] + +report="Biopieces tested: $count Tests run: $test_count OK: $test_ok FAIL: $test_fail Time: $time secs" + +if [ $test_fail = 0 ]; then + echo_green "$report" +else + echo_red "$report" +fi