forked from acg-team/tral
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupTRAL.sh
executable file
·167 lines (125 loc) · 5.26 KB
/
setupTRAL.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
#!/usr/bin/env bash
# By execution of this script a little filesystem will be created within the INSTALLATION_PATH (default: /usr/local/bin).
# If you wish to change this path, do this within configTRAL_path.cfg
# Run this script as superuser if your INSTALLATION_PATH only can be accessed by root.
######################
# PREPARING FILESYSTEM AND INSTALLING TRAL
######################
shopt -s nocasematch # making comparisons case-insensitive
set -euo pipefail # exit on errors and undefined vars
if [[ ! "$1" =~ ^(setup|pip)$ ]]; then
echo -e "\nPlease provide as argument how you want to install TRAL with setup.py (\"setup\" or \"pip\").\n"
exit 1
fi
######################
### Prepare Filesystem
#provide paths from config file (has to be in the same directory than setupTRAL.sh)
. configTRAL_path.cfg
# create needed directories to install tral
mkdir -p "$TRAL_PATH"
mkdir -p "$TRAL_EXT_SOFTWARE" # create directory for installation of external software
# directories will be added temporarely to PATH
[[ ":$PATH:" != *"$TRAL:$PATH"* ]] && PATH="$TRAL:$PATH"
# check for pip
if ! hash "${PIP3:-pip}"; then
echo "${PIP3:-pip} is required. Set the PIP variable in configTRAL_path.cfg" >&2
exit 1
fi
######################
### Installing TRAL
if [[ $1 == "setup" ]]; then
######################
### install tral with setup.py
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit $? ; cd .. ; pwd -P )
# test if TRAL repository is already downloaded
if [ -d "$PARENT_PATH/tral" ] && [ -e "$PARENT_PATH/setup.py" ] ; then
echo -e "\nUsing TRAL source from $PARENT_PATH\n"
(cd "$PARENT_PATH" && "${PYTHON3:-python3}" setup.py install ${TRAL_SETUP_ARGS:-}) || {
echo -e "\nA problem occured while trying to install TRAL with \"${PYTHON3:-python3} setup.py install ${TRAL_SETUP_ARGS:-}\"."
exit 1
}
else
### installing with git and setup.py
# if the tral directory is not already downloaded, it has to be cloned from github
echo -e "\nPlease clone the TRAL repository from github.\n"
if [[ "${ACCEPT_ALL:-no}" = "yes" ]]; then
yn=y
else read -p "Do you want to clone the TRAL repository from github in "$TRAL_PATH"? yes(y) or no (n):" yn
fi
case $yn in
[Yy]* )
# check if git is installed
if ! hash git 2>/dev/null; then
echo "Git is required to clone the repository of TRAL. Otherwise you can download the directory manually." >&2
exit 1
fi
git clone https://github.com/acg-team/tral.git "$TRAL_PATH/tral_repository" || {
echo -e "\nA problem occured while trying to clone the TRAL repository."
exit 1
}
(cd "$TRAL_PATH/tral_repository" && "${PYTHON3:-python3}" setup.py install ${TRAL_SETUP_ARGS:-}) || {
echo -e "\nA problem occured while trying to install TRAL with \"${PYTHON3:-python3} setup.py install ${TRAL_SETUP_ARGS:-}\"."
exit 1
}
;;
[Nn]* )
echo -e "\nAbort."
exit 1
;;
esac
fi
elif [[ $1 == "pip" ]]; then
#####################
## install tral with pip
#####################
# -- TODO .tral will not automatically be added to $HOME
{
echo -e "start installation"
"${PIP:-pip}" install tral|| {
echo -e "\nA problem occured while trying to install TRAL with \"${PIP:-pip} install\"."
exit 1
}
} && {
echo -e "\n---------------------------------"
echo -e "Installing TRAL with pip successful"
echo -e "-----------------------------------\n"
}
fi
######################
### Download p-Value distribution files
if [ ! -d "$TRAL_CONF/data/pvalue" ]; then
echo -e "\nIn order to calculate the p-Value of tandem repeat scores, available p-Value distributions need to be downloaded (2.6Gb) and placed in ~/.tral/data/pvalue."
if [[ "${ACCEPT_ALL:-no}" = "yes" ]]; then
yn=y
else read -p "Would you like to do this? yes(y) or no (n):" yn
fi
case $yn in
[Yy]* )
{
if [[ ! -f "$TRAL_CONF/data/pvalue.tar.gz" ]]; then
echo "DOWNLOADING"
wget "https://acg-team.ulozezoz.myhostpoint.ch/pvalue.tar.gz" -P "$TRAL_CONF/data/"
else
echo "SKIPPING DOWNLOAD"
fi
tar -xzf "$TRAL_CONF/data/pvalue.tar.gz" -C "$TRAL_CONF/data"
rm -rf "$TRAL_CONF/data/pvalue.tar.gz"
} || {
exit 1
}
;;
[Nn]* )
echo -e "\nYou can download this file later from https://acg-team.ulozezoz.myhostpoint.ch/pvalue.tar.gz.\n"
;;
esac
else
echo -e "\nDirectory for p-Value distribution file already exists.\nWill not be updated."
fi
echo -e "\n---------------------------------"
echo -e "Installation of TRAL is completed."
echo -e "-----------------------------------\n"
######################
### Check if $TRAL_CONF was created during installation
if [ ! -d "$TRAL_CONF" ]; then
echo -e ".tral directory was not created."
fi