comparison tests/run.sh @ 18:e4d75f9efb90 draft

planemo upload commit b'4303231da9e48b2719b4429a29b72421d24310f4\n'-dirty
author nick
date Thu, 02 Feb 2017 18:44:31 -0500
parents
children
comparison
equal deleted inserted replaced
17:836fa4fe9494 18:e4d75f9efb90
1 #!/usr/bin/env bash
2 if [ x$BASH = x ] || [ ! $BASH_VERSINFO ] || [ $BASH_VERSINFO -lt 4 ]; then
3 echo "Error: Must use bash version 4+." >&2
4 exit 1
5 fi
6 # get the name of the test directory
7 dirname=$(dirname $0)
8
9 USAGE="Usage: \$ $(basename $0) [options] [test1 [test2]]"
10
11
12 function main {
13
14 do_all=true
15 verbose=true
16 # Run the requested tests
17 for arg in "$@"; do
18 # Check for options
19 #TODO: option to keep test data at end instead of removing it.
20 if [[ ${arg:0:1} == '-' ]]; then
21 case "$arg" in
22 -h)
23 echo "$USAGE" >&2
24 echo "Currently valid tests:" >&2
25 list_tests >&2
26 exit 1;;
27 -q)
28 verbose='';;
29 -v)
30 verbose=true;;
31 *)
32 echo "Unrecognized option \"$arg\"." >&2;;
33 esac
34 continue
35 fi
36 # Execute valid tests (if they're existing functions).
37 if [[ $(type -t $arg) == function ]]; then
38 do_all=''
39 if [[ $verbose ]]; then
40 $arg
41 else
42 $arg 2>/dev/null
43 fi
44 else
45 echo "Unrecognized test \"$arg\"." >&2
46 do_all=''
47 fi
48 done
49
50 # If no tests were specified in arguments, do all tests.
51 if [[ $do_all ]]; then
52 if [[ $verbose ]]; then
53 all
54 else
55 all 2>/dev/null
56 fi
57 fi
58 }
59
60 function fail {
61 echo "$@" >&2
62 exit 1
63 }
64
65 function list_tests {
66 while read declare f test; do
67 # Filter out functions that aren't tests.
68 if echo "$initial_declarations" | grep -qF 'declare -f '"$test"; then
69 continue
70 else
71 echo "$test"
72 fi
73 done < <(declare -F)
74 }
75
76 # Capture a list of all functions defined before the tests, to tell which are actual functions
77 # and which are tests.
78 initial_declarations=$(declare -F)
79
80 ########## Functional tests ##########
81
82 # Do all tests.
83 function all {
84 align
85 align_p3
86 duplex
87 duplex_qual
88 stats_diffs
89 }
90
91 function barcodes {
92 echo -e "\tmake-barcodes.awk ::: families.raw_[12].fq"
93 paste "$dirname/families.raw_1.fq" "$dirname/families.raw_2.fq" | paste - - - - \
94 | awk -f "$dirname/../make-barcodes.awk" -v TAG_LEN=12 -v INVARIANT=5 | sort \
95 | diff -s - "$dirname/families.sort.tsv"
96 }
97
98 # align_families.py
99 function align {
100 echo -e "\talign_families.py ::: families.sort.tsv:"
101 python "$dirname/../align_families.py" "$dirname/families.sort.tsv" | diff -s - "$dirname/families.msa.tsv"
102 }
103
104 # align_families.py with 3 processes
105 function align_p3 {
106 echo -e "\talign_families.py ::: families.sort.tsv:"
107 python "$dirname/../align_families.py" -p 3 "$dirname/families.sort.tsv" | diff -s - "$dirname/families.msa.tsv"
108 }
109
110 # dunovo.py defaults on toy data
111 function duplex {
112 echo -e "\tdunovo.py ::: families.msa.tsv:"
113 python "$dirname/../dunovo.py" "$dirname/families.msa.tsv" | diff -s - "$dirname/families.cons.fa"
114 python "$dirname/../dunovo.py" --incl-sscs "$dirname/families.msa.tsv" | diff -s - "$dirname/families.cons.incl-sscs.fa"
115 }
116
117 # dunovo.py quality score consideration
118 function duplex_qual {
119 echo -e "\tdunovo.py ::: qual.msa.tsv:"
120 python "$dirname/../dunovo.py" --incl-sscs -q 20 "$dirname/qual.msa.tsv" | diff -s - "$dirname/qual.cons.fa"
121 }
122
123 function duplex_gapqual {
124 echo -e "\tdunovo.py ::: gapqual.msa.tsv:"
125 python "$dirname/../dunovo.py" --incl-sscs -q 25 "$dirname/gapqual.msa.tsv" | diff -s - "$dirname/gapqual.cons.fa"
126 }
127
128 function stats_diffs {
129 echo -e "\tstats.py diffs ::: gaps.msa.tsv:"
130 python "$dirname/../stats.py" diffs "$dirname/gaps.msa.tsv" | diff -s - "$dirname/gaps-diffs.out.tsv"
131 }
132
133 main "$@"