forked from mskcc/pluto-cwl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
285 lines (230 loc) · 8.75 KB
/
Makefile
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
export SHELL:=/bin/bash
.ONESHELL:
# enforce some stricter shell options to
OLDSHELLOPTS:=$(SHELLOPTS)
export SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit
UNAME:=$(shell uname)
# .sh file to source for each recipe
ENVSH:=env.juno.sh
define help
This is the Makefile for helix filters CWL
Development Guide
-----------------
Create a new .cwl file in the cwl/ dir, and a corresponding test script in the tests/ dir
Pull copies of the Singularity containers locally:
```
# pulls the latest tagged container
make singularity-pull
# pulls the latest master branch container
make singularity-pull-dev
```
Run the individual test case & cwl you are developing directly
```
# load the environment for running pluto-cwl
make bash
# run your test script
python3 tests/test_tmb_cwl.py
```
Note that `unittest.main()` needs to be included in your test script to run it directly from CLI
When you are done working on your updates, run the full test suite with:
```
# serial test runner
make test
# or
# run tests in parallel
make test3 -j 8
```
To do a version bump of all CWL files to a new version of the helix_filters container, use:
```
make update-container-tags
# example
make update-container-tags OLD_TAG='20.11.2' NEW_TAG='21.01.0'
```
NOTE: these may be deprecated;
Run the workflow against the demo dataset with:
```
make run
```
Run the Facets Suite workflow against the demo dataset with
```
make facets
```
endef
export help
help:
@printf "$$help"
.PHONY : help
# ~~~~~ Install Dependencies ~~~~~~ #
# This is only needed if you are not running on Juno/Silo server, or want to use Toil
# NOTE: see env.sh for PATH and PYTHONHOME, PYTHONPATH modifications for this to work correctly
ifeq ($(UNAME), Darwin)
CONDASH:=Miniconda3-4.7.12.1-MacOSX-x86_64.sh
endif
ifeq ($(UNAME), Linux)
CONDASH:=Miniconda3-4.7.12.1-Linux-x86_64.sh
endif
CONDAURL:=https://repo.anaconda.com/miniconda/$(CONDASH)
conda: SHELLOPTS=$(OLDSHELLOPTS)
conda:
@echo ">>> Setting up conda..."
@wget "$(CONDAURL)" && \
bash "$(CONDASH)" -b -p conda && \
rm -f "$(CONDASH)"
install: SHELLOPTS=$(OLDSHELLOPTS)
install: conda
. "$(ENVSH)" conda
conda install -y conda-forge::jq=1.5
pip install -r requirements.txt
$(MAKE) init
init: SHELLOPTS=$(OLDSHELLOPTS)
init:
git submodule init
git submodule update
# ~~~~~ Container ~~~~~ #
# pull the Docker container and convert it to Singularity container image file
export SINGULARITY_CACHEDIR:=/juno/work/ci/pluto-cwl-test/cache
# GIT_TAG:=$(shell git describe --tags --abbrev=0)
HF_CONTAINER:=mskcc/helix_filters_01
HF_TAG:=21.3.4
DOCKER_TAG:=$(HF_CONTAINER):$(HF_TAG)
DOCKER_DEV_TAG:=$(HF_CONTAINER):latest
# NOTE: you cannot use a filename with a ':' as a Makefile target
SINGULARITY_SIF:=mskcc_helix_filters_01:$(HF_TAG).sif
SINGULARITY_DEV_SIF:=mskcc_helix_filters_01:latest.sif
singularity-pull:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(SINGULARITY_SIF)" docker://$(DOCKER_TAG)
singularity-pull-dev:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(SINGULARITY_DEV_SIF)" docker://$(DOCKER_DEV_TAG)
# unset SINGULARITY_CACHEDIR && \
# module load singularity/3.3.0 && \
# shell into the Singularity container to check that it looks right
singularity-shell:
- . "$(ENVSH)" singularity && \
singularity shell "$(SINGULARITY_SIF)"
# mskcc/roslin-variant-facets:1.6.3
# mskcc/helix_filters_01:facets-1.6.3
FACETS_DOCKERTAG:=mskcc/helix_filters_01:facets-1.6.3
FACETS_SIF:=mskcc_helix_filters_01:facets-1.6.3.sif
singularity-pull-facets:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(FACETS_SIF)" docker://$(FACETS_DOCKERTAG)
FACETS_SUITE_DOCKERTAG:=mskcc/helix_filters_01:facets-suite-2.0.6
FACETS_SUITE_SIF:=helix_filters_01_facets-suite-2.0.6.sif
singularity-pull-facets-suite:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(FACETS_SUITE_SIF)" docker://$(FACETS_SUITE_DOCKERTAG)
# docker://cmopipeline/getbasecountsmultisample:1.2.2
FILLOUT_DOCKERTAG:=mskcc/helix_filters_01:getbasecountsmultisample-1.2.2
FILLOUT_SIF:=helix_filters_01_getbasecountsmultisample-1.2.2.sif
singularity-pull-fillout:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(FILLOUT_SIF)" docker://$(FILLOUT_DOCKERTAG)
MSI_DOCKERTAG:=mskcc/msisensor:0.2
MSI_SIF:=mskcc_msisensor:0.2.sif
singularity-pull-msi:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(MSI_SIF)" docker://$(MSI_DOCKERTAG)
IGV_REPORTS_DOCKERTAG:=$(HF_CONTAINER):igv-reports-1.0.1
IGV_REPORTS_SIF:=mskcc_helix_filters_01:igv-reports-1.0.1.sif
singularity-pull-igv-reports:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(IGV_REPORTS_SIF)" docker://$(IGV_REPORTS_DOCKERTAG)
# mskcc/roslin-variant-cmo-utils:1.9.15
# mskcc_roslin-variant-cmo-utils:1.9.15.sif
CMOUTILS_DOCKERTAG:=mskcc/roslin-variant-cmo-utils:1.9.15
CMOUTILS_SIF:=mskcc_roslin-variant-cmo-utils:1.9.15.sif
singularity-pull-cmoutils:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(CMOUTILS_SIF)" docker://$(CMOUTILS_DOCKERTAG)
R_DOCKERTAG:=mskcc/helix_filters_01:R-3.5.1
R_SIF:=mskcc_helix_filters_01:R-3.5.1.sif
singularity-pull-r:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(R_SIF)" docker://$(R_DOCKERTAG)
REPORT_DOCKERTAG:=mskcc/helix_filters_01:reporting
REPORT_SIF:=mskcc_helix_filters_01:reporting.sif
singularity-pull-report:
. "$(ENVSH)" singularity && \
singularity pull --force --name "$(REPORT_SIF)" docker://$(REPORT_DOCKERTAG)
# Need this container for the VEP cache dir; its too large to pass as CWL workflow inputs
# https://hub.docker.com/r/mskcc/roslin-variant-vcf2maf/tags?page=1&ordering=last_updated
# if there is a local copy of the file then copy it here
VEP_SIF:=roslin-variant-vcf2maf_1.6.17.sif
VEP_SIF_LOCAL:=/juno/work/ci/singularity_images/roslin-variant-vcf2maf_1.6.17.sif
VEP_DOCKERTAG:=mskcc/roslin-variant-vcf2maf:1.6.17
singularity-pull-vep:
if [ ! -e "$(VEP_SIF)" ]; then
if [ -e "$(VEP_SIF_LOCAL)" ]; then
ln -s "$(VEP_SIF_LOCAL)" "$(VEP_SIF)"
else
. "$(ENVSH)" singularity && singularity pull --force --name "$(VEP_SIF)" docker://$(VEP_DOCKERTAG)
fi
fi
# rsync -vrthP "$(VEP_SIF_LOCAL)" "$(VEP_SIF)"
singularity-pull-all: singularity-pull singularity-pull-dev singularity-pull-facets-suite singularity-pull-facets singularity-pull-fillout singularity-pull-igv-reports singularity-pull-cmoutils singularity-pull-msi singularity-pull-vep singularity-pull-r
# change the Docker tag for all the CWL files from the old pattern to the new pattern
OLD_TAG:=
NEW_TAG:=
UPDATE_CONTAINER:=$(HF_CONTAINER)
update-container-tags:
[ -z "$(OLD_TAG)" ] && echo "ERROR: OLD_TAG value missing" && exit 1 || :
[ -z "$(NEW_TAG)" ] && echo "ERROR: NEW_TAG value missing" && exit 1 || :
for i in $$(find cwl -type f -exec grep -l 'dockerPull: $(UPDATE_CONTAINER)' {} \;); do \
perl -i -pe 's/$(OLD_TAG)/$(NEW_TAG)/g' $$i ; \
done
# ~~~~~ Debug & Development ~~~~~ #
# Run the test suite
# NOTE: run with `$ LARGE_TESTS=True python3 tests/... ` to enable large test cases
export FIXTURES_DIR:=/juno/work/ci/helix_filters_01/fixtures
# TODO: figure out why this is missing some tests
test2:
. "$(ENVSH)" test && \
if [ ! -e "$(SINGULARITY_SIF)" ]; then $(MAKE) singularity-pull; fi && \
python3 test.py
# TODO: figure out if we can run the tests in parallel or otherwise make it faster
# for some reason the test recipe is not running all tests....
test:
. "$(ENVSH)" test && \
if [ ! -e "$(SINGULARITY_SIF)" ]; then $(MAKE) singularity-pull; fi && \
for i in tests/test_*.py; do echo $$i; python3 $$i; done
# run tests in parallel;
# $ make test3 -j 4
TESTS:=$(shell ls tests/test_*.py)
$(TESTS):
. "$(ENVSH)" test && echo $@; python3 $@
.PHONY:$(TESTS)
test3:$(TESTS)
# interactive session with environment populated
bash: ENV=shell
bash:
. "$(ENVSH)" "$(ENV)" && bash
clean:
rm -rf cache tmp
clean-all: clean
rm -rf output portal analysis mutation_maf_files.txt facets_hisens_seg_files.txt facets_hisens_cncf_files.txt mutation_svs_txt_files.txt mutation_svs_maf_files.txt
# Example args for running with Toil
run-toil: OUTPUTDIR=$(CURDIR)/toil_output
run-toil: LOGFILE=$(OUTPUTDIR)/toil.log
run-toil: JOBSTORE=$(OUTPUTDIR)/job-store
run-toil: WORKDIR=$(OUTPUTDIR)/work
run-toil: ENV=toil
run-toil:
. $(ENVSH) $(ENV)
unset SINGULARITY_CACHEDIR
mkdir -p "$(OUTPUTDIR)"
mkdir -p "$(WORKDIR)"
[ -e "$(JOBSTORE)" ] && rm -rf "$(JOBSTORE)" || :
( toil-cwl-runner \
--logFile "$(LOGFILE)" \
--outdir "$(OUTPUTDIR)" \
--workDir "$(WORKDIR)" \
--jobStore "$(JOBSTORE)" \
--singularity \
--batchSystem lsf --disableCaching True \
--disable-user-provenance --disable-host-provenance \
--preserve-entire-environment \
cwl/example_workflow.cwl cwl/example_input.json ) > toil.stdout.txt
# --preserve-environment PATH TMPDIR TOIL_LSF_ARGS SINGULARITY_CACHEDIR SINGULARITY_TMPDIR SINGULARITY_PULLDIR PWD \
# --maxLocalJobs 500 \