1 # from http://tldp.org/LDP/abs/html/debugging.html#ASSERT
3 assert
() # If condition false,
5 #+ with appropriate error message.
10 if [ -z "$2" ] # Not enough parameters passed
11 then #+ to assert() function.
12 return $E_PARAM_ERR # No damage done.
19 echo "Assertion failed: \"$1\""
20 echo "File \"$0\", line $lineno" # Give name of file and line number.
24 # and continue executing the script.
27 [TEST]: '$1' PASSED at line:$lineno
32 rm -f ref.bwameth
* bwa-meth.bam
34 python ..
/bwameth.py index ref.fa
36 ##########################
38 ##########################
40 python ..
/bwameth.py
--read-group $
'@RG\tID:asdf\tSM:asdf' --reference ref.fa t_R1.fastq.gz t_R2.fastq.gz | samtools view
-b - > bwa-meth.bam
42 n
=`samtools view -H bwa-meth.bam | grep "@RG" | grep -cw "ID:asdf"`
43 assert
"$n -eq 1" $LINENO
44 a
=`samtools view bwa-meth.bam | grep -c RG:Z:asdf`
45 b
=`samtools view bwa-meth.bam | wc -l`
46 assert
"$a -eq $b" $LINENO
50 ##########################
51 # test normal alignment
52 ##########################
53 python ..
/bwameth.py
--reference ref.fa t_R1.fastq.gz t_R2.fastq.gz \
54 | samtools view
-b - > bwa-meth.bam
55 assert
" -e bwa-meth.bam " $LINENO
57 ##########################
58 # test multiple fastq sets
59 ##########################
60 # NOTE: here we repeat the same fastq, but you'd want diff ones from same sample
62 python ..
/bwameth.py
--reference ref.fa t_R1.fastq.gz
,t_R1.fastq.gz t_R2.fastq.gz
,t_R2.fastq.gz \
63 | samtools view
-b - > bwa-meth.bam
64 assert
" -e bwa-meth.bam " $LINENO
66 ##########################
68 ##########################
70 python ..
/bwameth.py
--reference ref.fa t_R1.fastq.gz \
71 | samtools view
-b - > bwa-meth.bam
73 assert
" -e bwa-meth.bam " $LINENO
74 count
=`samtools view -cf2 bwa-meth.bam`
75 assert
"$count -eq 0" $LINENO
76 count
=`samtools view -cF4 bwa-meth.bam`
77 assert
"$count -gt 1000" $LINENO
80 ##############################
81 # test single end, many fastqs
82 ##############################
84 python ..
/bwameth.py
--reference ref.fa t_R1.fastq.gz
,t_R1.fastq.gz \
85 | samtools view
-b - > bwa-meth.bam
86 assert
" -e bwa-meth.bam " $LINENO
87 count2
=`samtools view -cf2 bwa-meth.bam`
88 assert
"$count2 -eq 0" $LINENO
89 count2
=`samtools view -cF4 bwa-meth.bam`
90 assert
"$count2 -gt $count" $LINENO
93 echo "Success: ALL Tests PASS"