|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +function unpack_test_data() { |
| 4 | + t=test_data.tar.gz |
| 5 | + if [ ! -f $t ]; then |
| 6 | + echo "Error: file $t not found!" |
| 7 | + exit 1 |
| 8 | + fi |
| 9 | + echo "..unpacking test data.." |
| 10 | + echo |
| 11 | + tar -xzf $t |
| 12 | + if [ ! -f test_data/human-chr19_P.gff ]; then |
| 13 | + echo "Error: invalid test data archive?" |
| 14 | + exit 1 |
| 15 | + fi |
| 16 | +} |
| 17 | + |
| 18 | +if [ ! -f test_data/human-chr19_P.gff ]; then |
| 19 | + if [ -f test_data.tar.gz ]; then |
| 20 | + #extract the tarball and rename the directory |
| 21 | + unpack_test_data |
| 22 | + else |
| 23 | + echo "..Downloading test data.." |
| 24 | + #use curl to fetch the tarball from a specific github release or branch |
| 25 | + curl -sLJO https://github.com/mpertea/stringtie2/raw/test_data/test_data.tar.gz |
| 26 | + unpack_test_data |
| 27 | + fi |
| 28 | +fi |
| 29 | +cd test_data |
| 30 | +# array element format: |
| 31 | +# |
| 32 | +arrins=("short_reads" "short_reads_and_superreads" "long_reads" "long_reads") |
| 33 | +arrparms=("" "" "-L" "-L -G human-chr19_P.gff") |
| 34 | +arrout=("short_reads" "short_reads_and_superreads" "long_reads" "long_reads_guided") |
| 35 | +arrmsg=("Short reads" "Short reads and super-reads" \ |
| 36 | + "Long reads" "Long reads with annotation guides") |
| 37 | +for i in ${!arrmsg[@]}; do |
| 38 | + fout="${arrout[$i]}.out.gtf" |
| 39 | + /bin/rm -f $fout |
| 40 | + fcmp="${arrout[$i]}.out_expected.gtf" |
| 41 | + if [ ! -f $fcmp ]; then |
| 42 | + echo "Error: file $fcmp does not exist! Re-download test data." |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + echo "Test ${i}: ${arrmsg[$i]}" |
| 46 | + fin=${arrins[$i]}.bam |
| 47 | + ../stringtie ${arrparms[$i]} -o $fout $fin |
| 48 | + if [ ! -f $fout ]; then |
| 49 | + echo "Error: file $fout not created! Failed running stringtie on $fin" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | + if diff -q -I '^#' $fout $fcmp &>/dev/null; then |
| 53 | + echo " OK." |
| 54 | + else |
| 55 | + echo "Error: test failed, output $fout different than expected ($fcmp)!" |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | +done |
0 commit comments