-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·129 lines (107 loc) · 3.56 KB
/
run_tests.sh
File metadata and controls
executable file
·129 lines (107 loc) · 3.56 KB
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
#!/usr/bin/env bash
declare TESTING_ENV_IS_ACTIVATE=false
declare PYTHON_TEST_ENV_NAME=''
PYTHON_TEST_ENV_NAME=$(mktemp -d $TMPDIR/contatester.XXXX)
readonly PYTHON_TEST_ENV_NAME
declare PYTHON_WHEEL_FOLDER='dist'
cleanup(){
if ${TESTING_ENV_IS_ACTIVATE};then
deactivate
fi
if [[ -d "${PYTHON_TEST_ENV_NAME}" ]]; then
rm -fr "${PYTHON_TEST_ENV_NAME}"
fi
if [[ -d "${PYTHON_WHEEL_FOLDER}" ]]; then
rm -fr "${PYTHON_WHEEL_FOLDER}"
fi
}
err_report() {
echo "Error on ${BASH_SOURCE[0]} line $1" >&2
exit 1
}
trap 'err_report $LINENO' ERR
trap cleanup INT TERM
module_load() {
# Used to load programs with module load function
if [[ -n "${IG_MODULESHOME}" ]]; then
module load "$@"
else
local dep_name=""
local dep_version=""
local is_present=false
for dependency in "$@"; do
dep_name="${dependency%/*}"
dep_version="${dependency#*/}"
if [[ "${dep_name}" == 'r' ]]; then
dep_name='R'
fi
is_present=$(command -v "${dep_name}" &> /dev/null && echo true || echo false)
if ! "${is_present}"; then
echo "ERROR: Missing tools: ${dep_name}" >&2
exit 1
#elif [[ -n "${dep_version}" ]]; then
# echo 'TODO'
fi
done
fi
return 0
}
############################# MAIN #############################
declare CONTATESTER_VERSION=0
CONTATESTER_VERSION="$(grep -Po "(?<=version = )[\d\.]+" setup.cfg)"
readonly CONTATESTER_VERSION
display_banner(){
local -i i=0
local line=''
while read line; do
((i++));
echo -e "$line"
done < banner.ansi
}
init_env(){
module_load python/3.6.5
python3 -m venv "${PYTHON_TEST_ENV_NAME}"
TESTING_ENV_IS_ACTIVATE=true
source "${PYTHON_TEST_ENV_NAME}"/bin/activate
pip3 install --upgrade pip wheel setuptools
}
install_contatester(){
local -r wheel_file=dist/contatester-"${CONTATESTER_VERSION}"-py2.py3-none-any.whl
python3 setup.py clean
if [[ ! -e "${wheel_file}" ]]; then
python3 setup.py bdist_wheel
fi
pip3 install "${wheel_file}"
}
display_banner
python3 setup.py clean
rm dist testing build -rf
echo -e '\033[31m- tmpdir : '"$PYTHON_TEST_ENV_NAME"'\033[0m'
echo -e '\033[31m- Create a python evironnment for testing scripts\033[0m'
init_env
echo -e '\033[31m- Run python tests\033[0m'
python3 setup.py test
echo -e '\033[31m- Testing install\033[0m'
install_contatester
echo -e '\033[31m- Testing scripts\033[0m'
contatester -h
echo -e '\033[34m\t- Testing calculAllelicBalance\033[0m'
calculAllelicBalance.sh -f ./data_examples/test_1.vcf.gz \
-o ./data_examples/calculAllelicBalance_output.hist \
-d ./data_examples/calculAllelicBalance_output.meandepth
echo -e '\033[34m\t- Testing contaReport\033[0m'
module_load r
contaReport.R --input ./data_examples/distrib_allele_balance.hist \
--output ./data_examples/distrib_allele_balance.conta \
--report \
--depth 30 \
--experiment WG \
--reportName \
./data_examples/distrib_allele_balance.pdf
echo -e '\033[34m\t- Testing recupConta\033[0m'
recupConta.sh -f ./data_examples/test_1.vcf.gz \
-c ./data_examples/test_1_AB_0.00_to_0.11_noLCRnoDUP.vcf.gz
echo -e '\033[34m\t- Testing checkContaminant\033[0m'
checkContaminant.sh -f ./data_examples/test_2.vcf.gz \
-c ./data_examples/test_1_AB_0.00_to_0.11_noLCRnoDUP.vcf.gz \
-s ./data_examples/test_1_comparisonSummary.txt