-
Notifications
You must be signed in to change notification settings - Fork 29
/
cistopic_singularity.def
223 lines (175 loc) · 6.59 KB
/
cistopic_singularity.def
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
Bootstrap: scratch
%setup
alpine_lastest_stable_base_url='http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64'
# Get url of last stable version of alpine minirootfs:
# - Parse YAML file with info about lastest releases.
# - Get url of the first "Mini root filesystem" section.
alpine_minirootfs_url=$(
curl "${alpine_lastest_stable_base_url}/latest-releases.yaml" \
| awk \
-F ': ' \
-v "alpine_lastest_stable_base_url=${alpine_lastest_stable_base_url}" '
{
if ( $1 ~ " title" ) {
if ($2 == "\"Mini root filesystem\"" ) {
mini_root_filesystem_section = 1;
} else {
mini_root_filesystem_section = 0;
}
} else if ( mini_root_filesystem_section == 1 && $1 == " file") {
# Print full url to Alpine minirootfs.
printf("%s/%s", alpine_lastest_stable_base_url, $2);
mini_root_filesystem_file_found = 1;
exit 0;
}
}
END {
if ( mini_root_filesystem_file_found != 1 ) {
# Unable to find minirootfs url.
printf("%s", "error");
}
}
'
)
if [ "${alpine_minirootfs_url}" = "error" ] ; then
printf 'Error: Unable to find last stable version of alpine minirootfs url.';
exit 1;
fi
# Download and extract alpine minirootfs.
curl ${alpine_minirootfs_url} \
| tar xz -C "${SINGULARITY_ROOTFS}" --exclude=./dev --exclude=./etc/hosts
%post
export LANG=en_US.UTF-8
# Use a custom TMP dir for manually downloadeded packages.
export TMPDIR=$(mktemp -t -d cistopic_singularity_XXXXXX);
# Update package list.
apk update
# Upgrade installed packages.
apk upgrade
# Install needed packages to download, compile and run R packages.
apk add \
build-base expat expat-dev libxml2 libxml2-dev \
autoconf automake libtool curl R R-dev R-doc git
# Function to install a CRAN package.
install_CRAN_package () {
local CRAN_package="${1}"
printf 'if (!require("%s", character.only=TRUE, quietly=TRUE)) {\n install.packages(c("%s"), repo=c(CRAN = "https://cloud.r-project.org"));\n}\nq();\n' \
"${CRAN_package}" \
"${CRAN_package}" \
| R --vanilla --quiet
}
# Function to Install a Bioconductor packages.
install_Bioconductor_package () {
local bioconductor_package="${1}"
printf 'if (!require("%s", character.only=TRUE, quietly=TRUE)) {\n require(BiocManager);\n BiocManager::install(c("%s"));\n}\nq();\n' \
"${bioconductor_package}" \
"${bioconductor_package}" \
| R --vanilla --quiet
}
## Install httpuv manually as installing it directly from R does not work.
httpuv_version='1.4.5.1'
httpuv_CRAN_packages='
Rcpp
promises
later
BH
'
# Install list of CRAN packages needed to install httpuv.
for CRAN_package in ${httpuv_CRAN_packages} ; do
printf '\nInstalling CRAN package: "%s"\n\n' "${CRAN_package}"
install_CRAN_package "${CRAN_package}"
done
# Download httpuv tarball.
curl \
-o "${TMPDIR}/httpuv_${httpuv_version}.tar.gz" \
"https://cloud.r-project.org/src/contrib/httpuv_${httpuv_version}.tar.gz"
# Extract httpuv tarball.
tar xz -C ${TMPDIR} -f "${TMPDIR}/httpuv_${httpuv_version}.tar.gz"
# Regenerate automake config files for libuv.
cd ${TMPDIR}/httpuv/src/libuv/ && aclocal && autoconf && automake && cd -
# Install httpuv.
R CMD INSTALL ${TMPDIR}/httpuv
# Remove downloaded and extracted httpuv related files.
rm -r ${TMPDIR}/httpuv "${TMPDIR}/httpuv_${httpuv_version}.tar.gz"
## Install udunits2 manually as it is not in the apk package manager.
udunits2_version='2.2.26'
# Download udunits2 tarball.
curl \
-o "${TMPDIR}/udunits-${udunits2_version}.tar.gz" \
"ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-${udunits2_version}.tar.gz"
# Extract udunits2 tarball.
tar xz -C ${TMPDIR} -f "${TMPDIR}/udunits-${udunits2_version}.tar.gz"
# Configure and install udunits2.
cd ${TMPDIR}/udunits-${udunits2_version} && ./configure && make && make install && cd -
# Remove downloaded and extracted udunits2 related files.
rm -r "${TMPDIR}/udunits-${udunits2_version}" "${TMPDIR}/udunits-${udunits2_version}.tar.gz"
## Install R dependencies for cisTopic.
# List of CRAN packages.
CRAN_packages='
BiocManager
data.table
doSNOW
DT
fastcluster
feather
fitdistrplus
ggplot2
knitr
lda
Matrix
plotly
plyr
rmarkdown
Rtsne
R.utils
scatterplot3d
tibble
umap
'
# List of Bioconductor packages.
bioconductor_packages='
BiocGenerics
BiocStyle
GenomicRanges
ChIPseeker
ComplexHeatmap
destiny
GSEABase
Rsubread
rGREAT
rtracklayer
S4Vectors
SummarizedExperiment
AUCell
RcisTarget
'
# Install list of CRAN packages.
for CRAN_package in ${CRAN_packages} ; do
printf '\nInstalling CRAN package: "%s"\n\n' "${CRAN_package}"
install_CRAN_package "${CRAN_package}"
done
# Install list of BioConductor packages.
for bioconductor_package in ${bioconductor_packages} ; do
printf '\nInstalling Bioconductor package: "%s"\n\n' "${bioconductor_package}"
install_Bioconductor_package "${bioconductor_package}"
done
## cisTopic installation.
# Clone cisTopic git repository.
git clone --depth 1 https://github.com/aertslab/cisTopic ${TMPDIR}/cisTopic-git
# Install cisTopic.
R CMD INSTALL ${TMPDIR}/cisTopic-git
# Remove cisTopic git repository.
rm -rf ${TMPDIR}/cisTopic-git
# Remove build dependencies.
apk del build-base expat-dev libxml2-dev autoconf automake libtool R-dev R-doc git
%runscript
R "${@}"
%labels
Maintainer Gert Hulselmans
Package cisTopic
Version v0.2.0
URL https://github.com/aertslab/cisTopic
%environment
export R_MAX_NUM_DLLS=500
%help
For help see: https://rawcdn.githack.com/aertslab/cisTopic/f6091ff94c79dfc927ae8eddf201d10a3f092923/vignettes/CompleteAnalysis.html