File: maintests.sh

package info (click to toggle)
lambda-align2 2.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 976 kB
  • sloc: cpp: 6,980; sh: 118; makefile: 42
file content (93 lines) | stat: -rwxr-xr-x 2,545 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh

set -xe

errorout()
{
    echo $1 #> /dev/stderr
    [ "$MYTMP" = "" ] || rm -r "${MYTMP}"
    exit 1
}

[ $# -ne 6 ] && exit 1

SRCDIR=$1
BINDIR=$2
PROG=$3
DI=$4
MODE=$5
EXTENSION=$6

# check existence of commands
which openssl gunzip mktemp diff cat zcat zgrep > /dev/null
[ $? -eq 0 ] || errorout "Not all required programs found. Needs: openssl gunzip mktemp diff cat zcat zgrep"

SALPH=prot      # actual subject alph
QALPHIN=prot    # query input file alph
SALPHIN=prot    # subject input file alph
INDEXER=mkindexp
SEARCHER=searchp
case "$PROG" in "blastn")
    INDEXER=mkindexn
    SEARCHER=searchn
    QALPHIN=nucl
    SALPH=nucl
    SALPHIN=nucl
    ;;
"blastp")
    ;;
"blastx")
    QALPHIN=nucl
    ;;
"tblastn")
    INDEXER=mkindexn
    SALPH=trans
    SALPHIN=nucl
    ;;
"tblastx")
    INDEXER=mkindexn
    SALPH=trans
    QALPHIN=nucl
    SALPHIN=nucl
    ;;
esac

MYTMP="$(mktemp -q -d -t "$(basename "$0").XXXXXX" 2>/dev/null || mktemp -q -d)"
[ $? -eq 0 ] || errorout "Could not create tmp"

cd "$MYTMP"
[ $? -eq 0 ] || errorout "Could not cd to tmp"

gunzip < "${SRCDIR}/tests/db_${SALPHIN}.fasta.gz" > db.fasta
[ $? -eq 0 ] || errorout "Could not unzip database file"

${BINDIR}/bin/lambda2 ${INDEXER} -d db.fasta -i ${DI}.lambda
[ $? -eq 0 ] || errorout "Could not run the indexer"

openssl md5 $(find * -type f | sort) > db_${SALPH}_${DI}.md5sums
[ $? -eq 0 ] || errorout "Could not run md5 or md5sums"
#openssl md5 $(find * -type f | sort | grep -v md5sums) > ${SRCDIR}/tests/db_${SALPH}_${DI}.md5sums
#gzip -f ${SRCDIR}/tests/db_${SALPH}_${DI}.md5sums

gunzip < "${SRCDIR}/tests/db_${SALPH}_${DI}.md5sums.gz" > db_${SALPH}_${DI}.md5sums.orig
[ $? -eq 0 ] || errorout "Could not unzip tests/db_${SALPH}_${DI}.md5sums.gz"

#[ "$(cat db_${SALPH}_${DI}.md5sums)" = "$(cat db_${SALPH}_${DI}.md5sums.orig)" ] || errorout "$(diff -u db_${SALPH}_${DI}.md5sums db_${SALPH}_${DI}.md5sums.orig)"

## INDEXER tests end here
if [ "$MODE" = "MKINDEX" ]; then
    rm -r "${MYTMP}"
    exit 0
fi

gunzip < "${SRCDIR}/tests/queries_${QALPHIN}.fasta.gz" > queries.fasta
[ $? -eq 0 ] || errorout "Could not unzip queries.fasta"

${BINDIR}/bin/lambda2 ${SEARCHER} -i ${DI}.lambda -q queries.fasta -t 1 --version-to-outputfile off \
-o output_${PROG}_${DI}.${EXTENSION}
[ $? -eq 0 ] || errorout "Search failed."

[ "$(openssl md5 output_${PROG}_${DI}.${EXTENSION})" = \
"$(zgrep "(output_${PROG}_${DI}.${EXTENSION})" "${SRCDIR}/tests/search_test_outfile.md5sums.gz")" ] || errorout "MD5 mismatch of output file"

rm -r "${MYTMP}"