-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·221 lines (201 loc) · 6.3 KB
/
test.sh
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
# set bash mode to strict
set -euo pipefail
IFS=$'\n\t'
CWD=$(pwd)
DIR=$(cd "$(dirname "$0")"; pwd)
#conda env
conda env create --name covsonar_ci --file $DIR/sonar.env.yml
source $(conda info --root)/etc/profile.d/conda.sh
set +u
conda activate covsonar_ci
set -u
#doctest
cd $DIR/lib
./sonardb.py
cd "$CWD"
#end-to-end test
db=$(mktemp /tmp/sonar.XXXXXX)
exec 3>"$db"
rm "$db"
: ...
echo foo >&3
out=$(mktemp /tmp/sonar.XXXXXX)
exec 3>"$out"
rm "$out"
: ...
echo foo >&3
$DIR/sonar.py add --db "$db" -f "$DIR/test/test.fasta"
$DIR/sonar.py update --db "$db" --pangolin "$DIR/test/test_pangolin.csv"
$DIR/sonar.py update --db "$db" --tsv "$DIR/test/test.tsv.gz" --fields accession=accessions zip=regions date=dates gisaid=gisaid ena=ena lab=lab source=source collection=collection technology=technology platform=platform chemistry=chemistry material=material ct=ct software=software version=software_version
$DIR/sonar.py optimize --db "$db"
$DIR/sonar.py match --db "$db" | (sed -u 1q; sort) > "$out"
if diff -q $DIR/test/expected.csv "$out"; then
echo 'match 1 as expected'
else
echo 'match 1 not as expected'
diff $DIR/test/expected.csv "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py match --date 2021-01-01:2021-01-31 -i C241T --db "$db" > "$out"
if diff -q $DIR/test/expected2.csv "$out"; then
echo 'match 2 as expected'
else
echo 'match 2 not as expected'
diff $DIR/test/expected2.csv "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py match -i G1820A --db "$db" > "$out"
if diff -q $DIR/test/expected2.csv "$out"; then
echo 'match 3 as expected'
else
echo 'match 3 not as expected'
diff $DIR/test/expected2.csv "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py match -e C1348T -i G1820A --db "$db" > "$out"
if diff -q $DIR/test/expected2.csv "$out"; then
echo 'match 4 as expected'
else
echo 'match 4 not as expected'
diff $DIR/test/expected2.csv "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py match --acc test2 --db "$db" > "$out"
if diff -q $DIR/test/expected2.csv "$out"; then
echo 'match 5 as expected'
else
echo 'match 5 not as expected'
diff $DIR/test/expected2.csv "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py match --zip 0177 --db "$db" > "$out"
if diff -q $DIR/test/expected2.csv "$out"; then
echo 'match 6 as expected'
else
echo 'match 6 not as expected'
diff $DIR/test/expected2.csv "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py match --acc '^NC_045512.2' --lineage '^B.1.1.297' --db "$db" > "$out"
if diff -q $DIR/test/expected2.csv "$out"; then
echo 'match 7 as expected'
else
echo 'match 7 not as expected'
diff $DIR/test/expected2.csv "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
n=$($DIR/sonar.py match --count --lab l3 --source sentinel --db "$db")
if [ "$n" -eq 0 ]; then
echo 'match 8 as expected'
else
echo "match 8 not as expected (expected 0 got $n)"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
echo "updating database ..."
$DIR/sonar.py add --db "$db" -f "$DIR/test/test2.fasta.xz" --quiet
$DIR/sonar.py update --db "$db" --tsv "$DIR/test/test.tsv.gz" --fields accession=accessions zip=regions date=dates gisaid=gisaid ena=ena lab=lab source=source collection=collection technology=technology platform=platform chemistry=chemistry material=material ct=ct software=software version=software_version
n=$($DIR/sonar.py match --count --lab l3 --source sentinel --db "$db")
if [ "$n" -eq 1 ]; then
echo 'match 9 as expected'
else
echo "match 9 not as expected (expected 1 got $n)"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
n=$($DIR/sonar.py match --count --collection random --technology Illumina --db "$db")
if [ "$n" -eq 2 ]; then
echo 'match 10 as expected'
else
echo "match 10 not as expected (expected 2 got $n)"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
n=$($DIR/sonar.py match --count --zip 033 --lab l3 --source sentinel --collection RANDOM --technology illumina --platform nextseq --chemistry flex cleanplex --material swap --min_ct 30 --max_ct 34 --software covpipe --version 3.0.5 --db "$db")
if [ "$n" -eq 1 ]; then
echo 'match 11 as expected'
else
echo "match 11 not as expected (expected 1 got $n)"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
n=$($DIR/sonar.py match --count --min_ct 10 --max_ct 30 --db "$db")
if [ "$n" -eq 2 ]; then
echo 'match 12 as expected'
else
echo "match 12 not as expected (expected 2 got $n)"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
n=$($DIR/sonar.py match --count --no_frameshifts --db "$db")
if [ "$n" -eq 3 ]; then
echo 'match 13 as expected'
else
echo "match 13 not as expected (expected 3 got $n)"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py match --only_frameshifts --db "$db" --ambig > "$out"
if diff -q $DIR/test/expected3.csv "$out"; then
echo 'match 14 as expected'
else
echo 'match 14 not as expected'
diff $DIR/test/expected3.csv "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py restore --db "$db" --acc test3 > "$out"
if diff -q $DIR/test/test2.fasta "$out"; then
echo 'match 15 as expected'
else
echo 'match 15 not as expected'
diff $DIR/test/test2.fasta "$out"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py add --db "$db" -f "$DIR/test/test2.fasta.xz" --source TEST --noprogress
n=$($DIR/sonar.py match --count --source TEST --db "$db")
if [ "$n" -eq 1 ]; then
echo 'match 16 as expected'
else
echo "match 16 not as expected (expected 1 got $n)"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
$DIR/sonar.py remove --db "$db" --acc "test3"
n=$($DIR/sonar.py match --count --source TEST --db "$db")
if [ "$n" -eq 0 ]; then
echo 'match 17 as expected'
else
echo "match 17 not as expected (expected 1 got $n)"
conda deactivate
conda env remove -y --name covsonar_ci
exit 1
fi
#cleaning
conda deactivate
conda env remove -y --name covsonar_ci