forked from arpcard/rgi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·83 lines (63 loc) · 3.55 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
#!/usr/bin/env bash
# run unit tests for RGI
# exit on failure of any command
set -e
cmd="COMMAND"
echo "=================================== RGI EXECUTABLE LOCATION ==================================="
which rgi
rgi -h
echo "=================================== DOWNLOAD CARD CANONICAL DATA ==================================="
# get latest card database
wget -O card_data.tar.bz2 --no-check-certificate https://card.mcmaster.ca/latest/data
mkdir -p card_data
tar xf card_data.tar.bz2 -C card_data
echo "=================================== DOWNLOAD CARD VARIANTS DATA ==================================="
# get latest card variants
wget -O prevalence-v3.0.4.tar.gz --no-check-certificate https://card.mcmaster.ca/download/6/prevalence-v3.0.4.tar.gz
mkdir -p card_variants
tar xf prevalence-v3.0.4.tar.gz -C card_variants
echo "=================================== CARD CANONICAL ANNOTATIONS ==================================="
# create fasta files with annotations from card.json
echo "$cmd python3 ./rgi card_annotation --input card_data/card.json"
python3 ./rgi card_annotation --input card_data/card.json
echo "=================================== VERSIONS ==================================="
data_version=`echo card_database_v*.fasta | sed 's/.*card_database_v\(.*\).fasta/\1/'`
echo "$cmd data_version: $data_version"
variants_version=`echo prevalence-v*.tar.gz | sed 's/.*prevalence-v\(.*\).tar.gz/\1/'`
echo "$cmd variants_version: $variants_version"
echo "=================================== CARD VARIANTS ANNOTATIONS ==================================="
# create fasta files with annotations from variants
echo "$cmd python3 ./rgi wildcard_annotation --input_directory card_variants --version '$variants_version' --card_json card_data/card.json"
python3 ./rgi wildcard_annotation --input_directory card_variants --version "$variants_version" --card_json card_data/card.json
echo "=================================== CLEAN OLD DATABASES ==================================="
# clean
echo "$cmd ./rgi clean --debug"
python3 ./rgi clean --debug
echo "=================================== LOAD DATABASES ==================================="
# load
echo "$cmd python3 ./rgi load --card_json card_data/card.json --card_annotation card_database_v${data_version}.fasta --wildcard_index card_variants/index-for-model-sequences.txt --wildcard_version '$variants_version' --wildcard_annotation wildcard_database_v${variants_version}.fasta --debug"
python3 ./rgi load --card_json card_data/card.json --card_annotation card_database_v${data_version}.fasta --wildcard_index card_variants/index-for-model-sequences.txt --wildcard_version "$variants_version" --wildcard_annotation wildcard_database_v${variants_version}.fasta --debug
echo "=================================== CHECK LOADED DATABASES ==================================="
# check database
echo "$cmd python3 ./rgi database -v --all"
python3 ./rgi database -v --all
echo "=================================== COPY DATA & INPUTS ==================================="
# for test_1.py
echo "$cmd card_data/card.json app/_data"
cp card_data/card.json app/_data
# for test_3.py
echo "$cmd card_data/card.json tests/inputs"
cp card_data/card.json tests/inputs
echo "=================================== RUN TESTS ==================================="
# run unit tests
echo "$cmd cd tests"
cd tests
echo "$cmd pytest --capture=fd -v -rxs"
pytest --capture=fd -v -rxs
pwd
rm -r ../card_*
rm ../prevalence-v*.gz
rm ../wildcard_database_v*
echo "=================================== DONE ==================================="
# exit with the exitcode thrown by pytest
exit $?