-
Notifications
You must be signed in to change notification settings - Fork 78
/
test.sh
executable file
·106 lines (84 loc) · 4.17 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
#!/usr/bin/env bash
# run unit tests for RGI
# exit on failure of any command
set -e
cmd="COMMAND"
echo "=================================== CHECK DEPENDENCIES VERSIONS ==================================="
blastp -version
bowtie2 --version
diamond --version
samtools --version
bamtools --version
bedtools --version
# bwa
jellyfish --version
kma -v
echo "=================================== RGI EXECUTABLE LOCATION ==================================="
which rgi
rgi -h
# echo "=================================== RGI AUTO LOAD ==================================="
# rgi auto_load --clean
echo "=================================== DOWNLOAD CARD CANONICAL DATA ==================================="
# get latest card database
wget --quiet -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 --quiet -O prevalence-v4.0.0.tar.bz2 --no-check-certificate https://card.mcmaster.ca/download/6/prevalence-v4.0.0.tar.bz2
mkdir -p card_variants
tar xf prevalence-v4.0.0.tar.bz2 -C card_variants
gunzip card_variants/*.gz
echo "=================================== CARD CANONICAL ANNOTATIONS ==================================="
# create fasta files with annotations from card.json
echo "$cmd rgi card_annotation --input card_data/card.json"
python3 ./rgi card_annotation --input card_data/card.json
echo "=================================== VERSIONS ==================================="
# remove file with '_all.fasta'
rm card_database_v*_all.fasta
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.bz2 | sed 's/.*prevalence-v\(.*\).tar.bz2/\1/'`
echo "$cmd variants_version: $variants_version"
echo "=================================== CARD VARIANTS ANNOTATIONS ==================================="
# create fasta files with annotations from variants
echo "$cmd 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 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 rgi database -v --all"
python3 ./rgi database -v --all
echo "=================================== COPY DATA & INPUTS ==================================="
# for test_1.py
echo "$cmd cp card_data/card.json app/_data"
cp card_data/card.json app/_data
# for test_3.py
echo "$cmd cp card_data/card.json tests/inputs"
cp card_data/card.json tests/inputs
echo "=================================== CLEAN ==================================="
# clean up files
rm -r card_*
rm wildcard_database_v*
rm prevalence-v*
echo "=================================== RUN TESTS ==================================="
# run unit tests
# echo "$cmd cd tests"
pushd tests
# cd tests
echo `pwd`
tree -L 2
# echo "$cmd pytest --capture=fd -v -rxs"
#pytest test_1.py -v -rxs --color=auto --durations=0 -k "protein"
pytest --capture=fd -v -rxs
popd
echo "=================================== DONE ==================================="
# exit with the exitcode thrown by pytest
exit $?