-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathconfigure.sh
executable file
·100 lines (89 loc) · 2.92 KB
/
configure.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
#!/usr/bin/env bash
# exit_status=0
my_dir="${0%/*}"
OVERRIDE=false
BUILD_BED2GTF=false
CLEANUP=false
### Parsing arguments ###
for arg in "$@"
do
case $arg in
--override)
OVERRIDE=true
echo "Overriding existing CESAR installation and models"
;;
--bed2gtf)
BUILD_BED2GTF=true
echo "Building bed2gtf"
;;
--cleanup)
CLEANUP=true
echo "Cleanup activated"
;;
esac
done
### Cleanup scenario ###
### Cleanup ###
if $CLEANUP; then
printf "Cleaning up...\n"
rm -f "${my_dir}"/modules/*.so
rm -f "${my_dir}"/modules/chain_score_filter
rm -f "${my_dir}"/modules/chain_filter_by_id
rm -rf ./CESAR2.0
rm -f ./models/*.dat
echo "Cleanup completed"
fi
### C modules ###
# Check machine architecture and set appropriate flags
printf "Compiling C code...\n"
if [ "$(uname -m)" = "arm64" ]; then
CFLAGS="-Wall -Wextra -O2 -g -std=c99 -arch arm64" # adjust flags for M1 if necessary
else
CFLAGS="-Wall -Wextra -O2 -g -std=c99" # original flags for x86
fi
gcc $CFLAGS -o "${my_dir}"/modules/chain_score_filter "${my_dir}"/modules/chain_score_filter.c
gcc $CFLAGS -o "${my_dir}"/modules/chain_filter_by_id "${my_dir}"/modules/chain_filter_by_id.c
gcc $CFLAGS -fPIC -shared -o "${my_dir}"/modules/chain_coords_converter_slib.so "${my_dir}"/modules/chain_coords_converter_slib.c
gcc $CFLAGS -fPIC -shared -o "${my_dir}"/modules/extract_subchain_slib.so "${my_dir}"/modules/extract_subchain_slib.c
gcc $CFLAGS -fPIC -shared -o "${my_dir}"/modules/chain_bst_lib.so "${my_dir}"/modules/chain_bst_lib.c
### XGBoost models ###
if ! $OVERRIDE && { [[ -f "./models/se_model.dat" ]] || [[ -f "./models/me_model.dat" ]]; }
then
printf "Model found\n";
else
printf "XGBoost model not found\nTraining...\n"
eval "python3 train_model.py"
printf "Model created\n"
fi
### CESAR2.0 ###
if ! $OVERRIDE && [[ -f "./CESAR2.0/cesar" ]]
then
printf "CESAR installation found\n"
else
if [ -d ".git" ]
then
printf "Git repo detected, cloning CESAR using git submodule...\n"
git submodule init CESAR2.0
git submodule update CESAR2.0
cd CESAR2.0 && make
else
printf "No git repo detected, downloading CESAR using wget...\n"
wget -q https://github.com/kirilenkobm/CESAR2.0/archive/refs/tags/toga_submodule_1.zip
unzip -q toga_submodule_1.zip -d .
mv CESAR2.0-toga_submodule_1 CESAR2.0
cd CESAR2.0 && make
fi
printf "Don't worry about '*** are the same file' message if you see it\n"
fi
### Bed2Gtf ###
if $BUILD_BED2GTF; then
if ! $OVERRIDE && [[ -f "./bed2gtf/some_check_file" ]]
then
printf "bed2gtf installation found\n"
else
printf "bed2gtf installation not found, cloning and building\n"
git submodule init bed2gtf
git submodule update bed2gtf
# ACTUAL BUILD COMMAND HERE
fi
fi