-
Notifications
You must be signed in to change notification settings - Fork 9
/
install
executable file
·228 lines (189 loc) · 6.28 KB
/
install
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
#
# Install dependencies
#
function install_iedb() {
echo
echo "checking IEDB dependency"
# From IEDB/mhc_i/README: tcsh and gawk are required
which tcsh
if [[ "$?" -ne 0 ]]; then
echo "IEDB requires tcsh to be installed" >&2
return 1
fi
which gawk
if [[ "$?" -ne 0 ]]; then
echo "IEDB requires gawk to be installed" >&2
return 1
fi
cd "${SCRIPT_DIR}/IEDB" || return 1
if [[ ! -d mhc_i ]]
then
tar -xvf IEDB_MHC_I-2.15.5.tar.gz || return 1
fi
cd mhc_i || return 1
# The IEDB ./configure script unpacks .tar files which can take a long time.
# Create a .done file to indicate that ./configure has already been run.
# Only run ./configure if there's no .done file
local DONE_FILE='configure.done'
if [[ ! -f "${DONE_FILE}" ]]; then
# Need to activate Python 2 environment so that '/usr/bin/env python' used in
# ./configure finds python 2. Otherwise there is a syntax error.
conda activate "${CONDA_ENV_PREFIX_2}" || return 1
./configure || return 1
conda deactivate || return 1
touch "${DONE_FILE}" || return 1
fi
}
function install_ms_gf() {
echo
echo "checking MS GF+ dependency"
cd "${SCRIPT_DIR}" || return 1
if [[ ! -d ms_gf_plus ]]
then
mkdir ms_gf_plus || return 1
fi
cd ms_gf_plus || return 1
if [[ ! -f MSGFPlus_v20190703.zip ]]
then
local MSGF_URI="https://github.com/MSGFPlus/msgfplus/releases/download/v2019.07.03/MSGFPlus_v20190703.zip"
curl -L "${MSGF_URI}" -o MSGFPlus_v20190703.zip || return 1
fi
if [[ ! -f README.md ]]
then
unzip MSGFPlus_v20190703.zip || return 1
fi
}
function install_python_packages() {
local INSTALL_OPTIONAL="$1"
echo
echo "checking python dependencies"
cd "${SCRIPT_DIR}" || return 1
# rmats is an optional dependency.
# Record the path if it is installed.
local RMATS_PATH=''
# Python 2
conda activate "${CONDA_ENV_PREFIX_2}" || return 1
if [[ "${INSTALL_OPTIONAL}" -ne 0 ]]; then
conda install -c conda-forge -c bioconda --file conda_requirements_py2.txt \
--file conda_requirements_py2_optional.txt || return 1
# Find the rmats path needed to pass as --rMATS-path to IRIS
RMATS_PATH="$(which rmats.py)"
if [[ "$?" -ne 0 ]]; then
echo "could not find path to rmats.py" >&2
exit 1
fi
else
conda install -c conda-forge -c bioconda --file conda_requirements_py2.txt || return 1
fi
# rmats_path will be '' if optional dependencies were not installed
echo "rmats_path: '${RMATS_PATH}'" \
>> "${SCRIPT_DIR}/snakemake_config.yaml" || return 1
conda deactivate || return 1
if [[ "${INSTALL_OPTIONAL}" -ne 0 ]]; then
# samtools has dependency conflicts with the other packages in the
# Python 2 conda environment after:
# https://github.com/bioconda/bioconda-recipes/pull/40629
# A workaround is to install to a new conda environment and create a symlink.
conda activate "${CONDA_ENV_PREFIX_SAMTOOLS}" || return 1
conda install -c conda-forge -c bioconda samtools=1.9 || return 1
local SAMTOOLS_PATH="$(which samtools)" || return 1
conda deactivate || return 1
ln -s "${SAMTOOLS_PATH}" "${CONDA_ENV_PREFIX_2}/bin/samtools" || return 1
# Another option is to build from source
# conda activate "${CONDA_ENV_PREFIX_2}" || return 1
# mkdir samtools || return 1
# cd samtools || return 1
# local SAMTOOLS_URL='https://github.com/samtools/samtools/releases/download/1.9/samtools-1.9.tar.bz2'
# curl -L "${SAMTOOLS_URL}" -O || return 1
# tar -xvf samtools-1.9.tar.bz2 || return 1
# cd samtools-1.9 || return 1
# ./configure --without-curses || return 1
# make || return 1
# make prefix="${CONDA_ENV_PREFIX_2}" install || return 1
# cd "${SCRIPT_DIR}" || return 1
# conda deactivate || return 1
fi
# Python 3
conda activate "${CONDA_ENV_PREFIX_3}" || return 1
conda install -c conda-forge -c bioconda --file conda_requirements_py3.txt || return 1
conda deactivate || return 1
}
function check_iris_data() {
echo
echo "checking IRIS data dependency"
cd "${SCRIPT_DIR}" || return 1
if [[ ! -d IRIS_data ]]
then
echo "Need to download IRIS_data/" >&2
fi
}
function install_iris_package() {
echo
echo "installing IRIS"
cd "${SCRIPT_DIR}" || return 1
conda activate "${CONDA_ENV_PREFIX_2}" || return 1
python setup.py install || return 1
conda deactivate || return 1
}
function ensure_conda_envs() {
echo
echo "checking conda"
conda create --prefix "${CONDA_ENV_PREFIX_2}" || return 1
conda create --prefix "${CONDA_ENV_PREFIX_3}" || return 1
conda create --prefix "${CONDA_ENV_PREFIX_SAMTOOLS}" || return 1
}
function install_optional() {
install_ms_gf
if [[ "$?" -ne 0 ]]; then
echo "Error installing optional dependency: ms gf" >&2
fi
}
function install() {
local INSTALL_OPTIONAL="$1"
ensure_conda_envs || return 1
install_python_packages "${INSTALL_OPTIONAL}" || return 1
install_iedb || return 1
if [[ "${INSTALL_OPTIONAL}" -ne 0 ]]; then
install_optional || return 1
fi
install_iris_package || return 1
check_iris_data || return 1
echo "conda_wrapper: '${SCRIPT_DIR}/conda_wrapper'" \
>> "${SCRIPT_DIR}/snakemake_config.yaml" || return 1
echo "conda_env_2: '${SCRIPT_DIR}/conda_env_2'" \
>> "${SCRIPT_DIR}/snakemake_config.yaml" || return 1
echo "conda_env_3: '${SCRIPT_DIR}/conda_env_3'" \
>> "${SCRIPT_DIR}/snakemake_config.yaml" || return 1
echo "iris_data: '${SCRIPT_DIR}/IRIS_data'" \
>> "${SCRIPT_DIR}/snakemake_config.yaml" || return 1
echo "iedb_path: '${SCRIPT_DIR}/IEDB/mhc_i/src'" \
>> "${SCRIPT_DIR}/snakemake_config.yaml" || return 1
}
function display_usage() {
echo "usage:"
echo " ./install {core|all}"
echo ""
echo "./install core: installs only the required dependencies for the major IRIS modules"
echo ""
echo "./install all: installs all dependencies"
}
function main() {
local INSTALL_OPTIONAL
if [[ "$#" -ne 1 ]]; then
echo "exactly one argument required" >&2
display_usage
return 1
elif [[ "$1" = 'core' ]]; then
INSTALL_OPTIONAL=0
elif [[ "$1" = 'all' ]]; then
INSTALL_OPTIONAL=1
else
echo "unrecognized argument: $1" >&2
display_usage
return 1
fi
source set_env_vars.sh || return 1
install "${INSTALL_OPTIONAL}" || return 1
}
main "$@"