-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_software.sh
352 lines (269 loc) · 13.8 KB
/
install_software.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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
#!/bin/bash
# IMPORTANT: run this script inside the base repository directory to ensure
# software locations are properly linked.
#
# Usage: bash install_software.sh [installation_type]
#
# installation_type may be "docker", "local", "conda", "jhpce", or
# "singularity":
# docker: user plans to run BiocMAP with docker to manage software
# dependencies
# local: user wishes to install all dependencies locally (regardless
# of whether BiocMAP will be run on a cluster or with
# local resources)
# conda: required software is installed within a conda environment
# jhpce: user is setting up BiocMAP on the JHPCE cluster
# singularity: user plans to run BiocMAP with singularity to manage
# software dependencies
set -e
REPO_NAME="BiocMAP"
if [ "$(basename $(pwd))" == "$REPO_NAME" ]; then
echo "[BiocMAP] Making sure the repository is clean and ready for installation..."
#rm -r Software
rm -f test/*/*/samples.manifest
rm -f test/*/*/rules.txt
git checkout run_*_half_*.sh
git checkout nextflow.config
git checkout conf/*_half_*.config
else
echo "[BiocMAP] Please only invoke the script from directly inside the '$REPO_NAME' directory!"
exit 1
fi
if [[ "$1" == "docker" || "$1" == "singularity" ]]; then
# This is the docker image to be used for execution of R via docker/
# singularity
R_container="libddocker/bioc_kallisto:3.17"
# Point to original repo's main script to facilitate pipeline sharing
sed -i "s|ORIG_DIR=.*|ORIG_DIR=$(pwd)|" run_*_half_*.sh
# Add docker/singularity configuration to each config profile in
# 'nextflow.config'
sed -i "s|includeConfig 'conf/\(.*\)_half_\(.*\)\.config'|includeConfig 'conf/\1_half_\2.config'\n includeConfig 'conf/\1_half_$1.config'|" nextflow.config
# Remove a variable from configs that disables docker/singularity settings
sed -i "/using_containers = false/d" conf/second_half_{jhpce,local,sge,slurm}.config
BASE_DIR=$(pwd)
mkdir -p $BASE_DIR/Software/bin
cd $BASE_DIR/Software/bin
# Install nextflow (latest)
echo "[BiocMAP] Installing nextflow..."
wget -qO- https://get.nextflow.io | bash
###########################################################################
# Create the 'samples.manifest' and 'rules.txt' files for test samples
###########################################################################
if [[ "$1" == "docker" ]]; then
if [[ "$2" == "sudo" ]]; then
command="sudo docker run"
else
command="docker run"
fi
echo "[BiocMAP] Setting up test files..."
$command \
-it \
-u $(id -u):$(id -g) \
-v $BASE_DIR/scripts:/usr/local/src/scripts/ \
-v $BASE_DIR/test:/usr/local/src/test \
$R_container \
Rscript /usr/local/src/scripts/prepare_test_files.R -d $BASE_DIR
else # using singularity
echo "[BiocMAP] Pulling docker images and converting to singularity images..."
cd $BASE_DIR
# Pull images in advance, since it seems to use very large amounts of
# memory to build the '.sif' file from each docker image (we don't
# want to allocate large amounts of memory in each process just for
# this purpose)
mkdir -p docker/singularity_cache
images=$(grep 'container = ' conf/*_half_singularity.config | tr -d " |'" | cut -d '=' -f 2 | sort -u)
for image in $images; do
echo "[BiocMAP] Pulling and converting ${image}..."
image_name=$(echo $image | sed 's/[:\/]/-/g').sif
singularity pull docker/singularity_cache/$image_name docker://$image
done
echo "[BiocMAP] Setting up test files..."
singularity exec \
-B $BASE_DIR/scripts:/usr/local/src/scripts/ \
-B $BASE_DIR/test:/usr/local/src/test \
docker://$R_container \
Rscript /usr/local/src/scripts/prepare_test_files.R -d $BASE_DIR
# Set modules used correctly for JHPCE users
sed -i "/module = '.*\/.*'/d" conf/*_half_jhpce.config
sed -i "s|cache = 'lenient'|cache = 'lenient'\n module = 'singularity/3.6.0'|" conf/*_half_jhpce.config
sed -i "s|module load nextflow|module load nextflow\nmodule load singularity/3.6.0|" run_*_half_jhpce.sh
fi
echo "[BiocMAP] Done."
elif [ "$1" == "jhpce" ]; then
echo "[BiocMAP] User selected set-up at JHPCE. Installing any missing R packages..."
module load conda_R/4.3
Rscript scripts/install_r_packages.R
echo "[BiocMAP] Setting up test files..."
Rscript scripts/prepare_test_files.R -d $(pwd)
sed -i "s|ORIG_DIR=.*|ORIG_DIR=$(pwd)|" run_first_half_jhpce.sh
sed -i "s|ORIG_DIR=.*|ORIG_DIR=$(pwd)|" run_second_half_jhpce.sh
echo "[BiocMAP] Done."
elif [ "$1" == "conda" ]; then
BASE_DIR=$(pwd)
mkdir -p $BASE_DIR/Software/bin
cd $BASE_DIR/Software/bin
# Install nextflow (latest)
echo "[BiocMAP] Installing nextflow..."
wget -qO- https://get.nextflow.io | bash
cd $BASE_DIR
# Create an initial small conda environment, just containing mamba
echo "[BiocMAP] Creating a conda environment containing required software..."
source $(conda info --base)/etc/profile.d/conda.sh
conda env create -p $PWD/conda/pipeline_env -f conda/mamba.yml
conda activate $PWD/conda/pipeline_env
# Install software using mamba rather than conda
mamba install -y -c bioconda -c conda-forge r-essentials=4.3.1 r-base=4.3.1 bismark=0.23.0 fastqc=0.11.8 kallisto=0.46.1 methyldackel=0.6.0 samblaster=0.1.26 samtools=1.12 trim-galore=0.6.6
# Install Bioc R packages using mamba
mamba install -y -c bioconda -c conda-forge bioconductor-bsseq=1.36.0 bioconductor-genomicranges=1.52.0 bioconductor-hdf5array=1.28.1 bioconductor-biocparallel=1.34.2
# Install remaining non-Bioc packages
Rscript scripts/install_r_packages.R
# If an NVIDIA GPU is available (if 'nvidia-smi' works as a command), install Arioc
if nvidia-smi ; then
echo "[BiocMAP] Installing Arioc, which isn't available as a conda package..."
cd $BASE_DIR/Software/
mkdir arioc
cd arioc
wget https://github.com/RWilton/Arioc/releases/download/v1.43/Arioc.x.143.zip
unzip Arioc.x.143.zip
cd src
make clean
make AriocE
make AriocU
make AriocP
cd $BASE_DIR
cp Software/arioc/bin/* conda/pipeline_env/bin/
else
echo "[BiocMAP] Warning: skipping Arioc installation, as no NVIDIA GPU was detected."
fi
echo "[BiocMAP] Setting up test files..."
Rscript scripts/prepare_test_files.R -d $(pwd)
conda deactivate
echo "[BiocMAP] Configuring main and config files..."
# Point to original repo's main script to facilitate pipeline sharing
sed -i "s|ORIG_DIR=.*|ORIG_DIR=$(pwd)|" run_*_half_*.sh
# Add 'conda' specification to generic process scope; remove use of
# modules in JHPCE configs
sed -i "s|cache = 'lenient'|cache = 'lenient'\n conda = '$PWD/conda/pipeline_env'|" conf/*_half_*.config
sed -i "/module = '.*\/.*'/d" conf/*_half_jhpce.config
echo "[BiocMAP] Done."
elif [ "$1" == "local" ]; then
# Verify java can be executed, since this is a pre-requisite
if [ -x "$(command -v java)" ]; then
echo "[BiocMAP] Found a java runtime. Proceeding with the setup..."
# Point to original repo's main script to facilitate pipeline sharing
sed -i "s|ORIG_DIR=.*|ORIG_DIR=$(pwd)|" run_*_half_*.sh
# Add some configuration of environment variables for local runs
sed -i '5s|\(.*\)|\1\n// Add locally installed software to path-related environment variables\nrepoDir=System.getProperty("user.dir")\nenv.LD_LIBRARY_PATH="\$repoDir/Software/lib:System.getenv('"'"'LD_LIBRARY_PATH'"'"')"\nenv.PATH="\$repoDir/Software/bin:System.getenv('"'"'PATH'"'"')"\n|' conf/*_half_local.config
BASE_DIR=$(pwd)
INSTALL_DIR=$(pwd)/Software
mkdir -p $INSTALL_DIR/bin
cd $INSTALL_DIR/bin
# Install nextflow (latest)
wget -qO- https://get.nextflow.io | bash
cd $INSTALL_DIR
# Arioc (1.43) -------------------------------------------------------
# If an NVIDIA GPU is available (if 'nvidia-smi' works as a command), install Arioc
if nvidia-smi ; then
mkdir arioc
cd arioc
wget https://github.com/RWilton/Arioc/releases/download/v1.43/Arioc.x.143.zip
unzip Arioc.x.143.zip
cd src
make clean
make AriocE
make AriocU
make AriocP
cd $INSTALL_DIR
cp arioc/bin/* bin/
else
echo "[BiocMAP] Warning: skipping Arioc installation, as no NVIDIA GPU was detected."
fi
# Bismark (0.23.0) ---------------------------------------------------
wget https://github.com/FelixKrueger/Bismark/archive/0.23.0.tar.gz
tar -xzf 0.23.0.tar.gz
cp Bismark-0.23.0/bismark* bin/
cp Bismark-0.23.0/coverage2cytosine bin/
# cmake, which kallisto need to build --------------------------------
git clone https://gitlab.kitware.com/cmake/cmake.git
cd cmake
./bootstrap --prefix=$INSTALL_DIR
make
make install
cd $INSTALL_DIR
# fastqc (0.11.8) ---------------------------------------------------
wget https://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.8.zip
unzip fastqc_v0.11.8.zip
chmod -R 775 FastQC
cp FastQC/fastqc bin/
# kallisto (0.46.1) -------------------------------------------------
wget https://github.com/pachterlab/kallisto/archive/v0.46.1.tar.gz
tar -xzf v0.46.1.tar.gz
cd kallisto-0.46.1
mkdir build
cd build
$INSTALL_DIR/bin/cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ..
make
make prefix=$INSTALL_DIR install
cd $INSTALL_DIR
# MethylDackel (0.5.2) -----------------------------------------------
## Install libBigWig (0.4.6), a dependency
wget https://github.com/dpryan79/libBigWig/archive/refs/tags/0.4.6.tar.gz
tar -xzf 0.4.6.tar.gz
cd libBigWig-0.4.6
make prefix=$INSTALL_DIR install
cd $INSTALL_DIR
## Install htslib (1.12), a dependency
wget https://github.com/samtools/htslib/releases/download/1.12/htslib-1.12.tar.bz2
tar -xjf htslib-1.12.tar.bz2
cd htslib-1.12
./configure
make prefix=$INSTALL_DIR
make prefix=$INSTALL_DIR install
cd $INSTALL_DIR
## MethylDackel itself (0.5.2)
wget https://github.com/dpryan79/MethylDackel/archive/refs/tags/0.5.2.tar.gz
tar -xzf 0.5.2.tar.gz
cd MethylDackel-0.5.2
make CFLAGS="-O3 -Wall -I${INSTALL_DIR}/include " LIBS="-L${INSTALL_DIR}/lib" LIBBIGWIG="${INSTALL_DIR}/lib/libBigWig.a"
make install prefix=${INSTALL_DIR} CFLAGS="-O3 -Wall -I${INSTALL_DIR}/include " LIBS="-L${INSTALL_DIR}/lib" LIBBIGWIG="${INSTALL_DIR}/lib/libBigWig.a"
cd $INSTALL_DIR
# Install packages and set up test files
echo "[BiocMAP] Installing R packages..."
Rscript ../scripts/install_r_packages.R
echo "[BiocMAP] Setting up test files..."
Rscript ../scripts/prepare_test_files.R -d $BASE_DIR
# samblaster (v.0.1.26) ----------------------------------------------
wget https://github.com/GregoryFaust/samblaster/releases/download/v.0.1.26/samblaster-v.0.1.26.tar.gz
tar -xzf samblaster-v.0.1.26.tar.gz
cd samblaster-v.0.1.26
make
cp samblaster ../bin/
cd $INSTALL_DIR
# samtools (1.10) ---------------------------------------------------
wget https://github.com/samtools/samtools/releases/download/1.10/samtools-1.10.tar.bz2 -O samtools.tar.bz2
tar -xjf samtools.tar.bz2
cd samtools-1.10
./configure prefix=$INSTALL_DIR
make
make install
cd $INSTALL_DIR
# Trim Galore! (0.6.6) -----------------------------------------------
wget https://github.com/FelixKrueger/TrimGalore/archive/0.6.6.tar.gz
tar -xzf 0.6.6.tar.gz
cp TrimGalore-0.6.6/trim_galore bin/
# Clean up compressed files
rm $INSTALL_DIR/*.tar.gz
rm $INSTALL_DIR/*.bz2
rm $INSTALL_DIR/*.zip
# Fix any strict permissions which would not allow sharing software
# (and therefore the pipeline as a whole) with those in a group
chmod 775 -R $INSTALL_DIR
else # Java could not be found on the system
echo "[BiocMAP] A java runtime could not be found or accessed. Is it installed and on the PATH? You can install it by running 'apt install default-jre', which requires sudo/ root privileges."
echo "[BiocMAP] After installing Java, rerun this script to finish the installation procedure."
fi
else # neither "docker", "local", "conda", "jhpce", nor "singularity" were chosen
echo '[BiocMAP] Error: please specify "docker", "local", "conda", "jhpce", or "singularity" and rerun this script.'
echo '[BiocMAP] eg. bash install_software.sh "local"'
exit 1
fi