-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
231 lines (197 loc) · 8.39 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
SHELL:=/bin/bash
PYTHON_VERSION=3.9.19
PYTHON_SYS=python3.9
VIRTUAL_ENV=env
PYTHON_ENV=${VIRTUAL_ENV}/bin/python3
JAVA_VERSION=21
ARCHITECTURE=amd64
BUILD_REF_STAGE=build-ref
ENGINE=docker
ifeq ($(ENGINE),podman)
PODMAN_PARAM=--format docker
export USE_PODMAN=true
endif
# .ONESHELL:
DEFAULT_GOAL: install
.PHONY: help clean build build-ref integration-tests unit-tests mypy check format \
install-nextflow install-python install-docker install-java install-podman
# Colors for echos
ccend = $(shell tput sgr0)
ccbold = $(shell tput bold)
ccgreen = $(shell tput setaf 2)
ccso = $(shell tput smso)
mypy: venv ## >> run mypy type checker
@echo ""
@echo "$(ccso)--> Running mypy $(ccend)"
$(PYTHON_ENV) -m mypy bin/calib_dedup/
$(PYTHON_ENV) -m mypy bin/fastp/
$(PYTHON_ENV) -m mypy bin/vidjil/
$(PYTHON_ENV) -m mypy bin/igblast/
$(PYTHON_ENV) -m mypy bin/cdr3nt_error_corrector/
check: venv ## >> run ruff linter
@echo ""
@echo "$(ccso)--> Running ruff check $(ccend)"
$(PYTHON_ENV) -m ruff check bin/calib_dedup/ bin/fastp/ bin/vidjil/ bin/igblast/ bin/cdr3nt_error_corrector/
format: venv ## >> run ruff formatter
@echo ""
@echo "$(ccso)--> Running ruff format $(ccend)"
$(PYTHON_ENV) -m ruff format bin/calib_dedup/ bin/fastp/ bin/vidjil/ bin/igblast/ bin/cdr3nt_error_corrector/
integration-tests: venv ## >> run tests for all workflows via pytest and pytest-workflow tool
@echo ""
@echo "$(ccso)--> Running workflow tests $(ccend)"
$(PYTHON_ENV) -m pytest tests -vv --kwdof --tag integration-tests
unit-tests: venv ## >> run tests for all steps via pytest tool
@echo ""
@echo "$(ccso)--> Running steps tests $(ccend)"
$(PYTHON_ENV) -m pytest bin/pyumi/unit_tests -vv
# $(PYTHON_ENV) -m pytest bin/calib_dedup/unit_tests -vv
$(PYTHON_ENV) -m pytest tests -vv --kwdof --tag unit-tests
$(PYTHON_ENV) -m pytest bin/cdr3nt_error_corrector/unit_tests -vv
tests: venv ##@main >> run integration and unit tests
@echo ""
@echo "$(ccso)--> Running integration and unit tests $(ccend)"
$(MAKE) unit-tests
$(MAKE) integration-tests
clean: ## >> remove docker images, python environment and nextflow build files
@echo ""
@echo "$(ccso)--> Removing temporary files and images $(ccend)"
$(ENGINE) rmi -f downloader-image \
pyumi-tool pyumi-image \
calib_dedup-tool calib_dedup-image \
fastp-tool fastp-image \
vidjil-tool vidjil-image \
igblast-tool igblast-image \
cdr3nt_error_corrector-tool cdr3nt_error_corrector-image
rm -rf $(VIRTUAL_ENV) \
.nextflow.log* work .nextflow nextflow
build-ref-image:
@echo ""
@echo "$(ccso)--> Build images of reference generators $(ccend)"
$(ENGINE) build --target build-ref -t $(STEP)-$(BUILD_REF_STAGE) $(PODMAN_PARAM) bin/$(STEP)/
build-igblast-ref-major: ## >> build an archive with igblast vdj reference with only major allele (*01)
@echo ""
@echo "$(ccso)--> Build a vdj reference with all alleles (*01) for igblast $(ccend)"
$(ENGINE) run --rm -v $(pwd)/bin/igblast:/work igblast-$(BUILD_REF_STAGE) -o /work/igblast.reference.major_allele.tar.gz
build-igblast-ref-all: ## >> build an archive with igblast vdj reference with all alleles
@echo ""
@echo "$(ccso)--> Build a vdj reference with all alleles (*01, *02, etc.) for igblast $(ccend)"
$(ENGINE) run --rm -v $(pwd)/bin/igblast:/work igblast-$(BUILD_REF_STAGE) -a -o /work/igblast.reference.all_alleles.tar.gz
build-vidjil-ref: ## >> build an archive with vidjil reference
@echo ""
@echo "$(ccso)--> Build a vdj reference for vidjil $(ccend)"
bash bin/vidjil/build_ref.sh
mv /tmp/vidjil.germline.tar.gz bin/vidjil/
build-olga-models: ## >> build an archive with olga models
@echo ""
@echo "$(ccso)--> Build olga models for cdr3nt-error-corrector $(ccend)"
bash bin/cdr3nt_error_corrector/build_ref.sh
mv /tmp/olga-models.tar.gz bin/cdr3nt_error_corrector/
build-ref: ##@main >> build all references
@echo ""
@echo "$(ccso)--> Build all references $(ccend)"
$(MAKE) build-ref-image STEP=igblast
$(MAKE) build-igblast-ref-major
$(MAKE) build-igblast-ref-all
$(MAKE) build-vidjil-ref
$(MAKE) build-olga-models
build: ##@main >> build docker images, the virtual environment and install requirements
@echo ""
@echo "$(ccso)--> Build $(ccend)"
$(MAKE) clean
$(MAKE) install-nextflow
$(MAKE) build-step-image STEP=downloader STAGE=image
for step in pyumi calib_dedup fastp vidjil igblast cdr3nt_error_corrector ; do \
$(MAKE) build-step-image STEP=$$step STAGE=image ; \
$(MAKE) build-step-image STEP=$$step STAGE=tool ; \
done
$(MAKE) update
nf-core schema build --no-prompts
chmod +x pyigmap
venv: $(VIRTUAL_ENV)
$(VIRTUAL_ENV): ## >> setup the virtual environment
@echo "$(ccso)--> Install and setup virtualenv $(ccend)"
$(PYTHON_SYS) -m pip install --upgrade pip
$(PYTHON_SYS) -m pip install virtualenv
virtualenv $(VIRTUAL_ENV)
update: venv ## >> update requirements.txt inside the virtual environment
@echo "$(ccso)--> Updating packages $(ccend)"
$(PYTHON_ENV) -m pip install -r bin/pyumi/requirements.txt
$(PYTHON_ENV) -m pip install -r bin/cdr3nt_error_corrector/requirements.txt
$(PYTHON_ENV) -m pip install pytest==8.1.1 pytest-workflow==2.1.0 ruff==0.4.2 mypy==1.10.0 nf-core==2.14.1
install-python: ## >> install a python
curl -fL http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz > /tmp/python.tgz
mkdir -p /tmp/python
tar xzvf /tmp/python.tgz --one-top-level=/tmp/python --strip-component 1
cd /tmp/python && \
./configure --enable-optimizations && \
make -j 8 && sudo make altinstall
sudo apt install ${PYTHON_SYS}-distutils
sudo rm -rf /tmp/python.tgz /tmp/python
install-docker: ## >> install a docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=${ARCHITECTURE}] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable"
sudo apt-get update
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
install-podman: ## >> install a Podman
sudo apt-get update
sudo apt-get -y install podman
install-java: ## >> install a java
curl -fL https://download.oracle.com/java/${JAVA_VERSION}/latest/jdk-${JAVA_VERSION}_linux-x64_bin.tar.gz > /tmp/java.tar.gz
mkdir -p /tmp/java-${JAVA_VERSION}
tar xzvf /tmp/java.tar.gz --one-top-level=/tmp/java-${JAVA_VERSION} --strip-component 1
sudo mv /tmp/java-${JAVA_VERSION} /usr/local/bin/
@echo "export JAVA_HOME=/usr/local/bin/java-${JAVA_VERSION}" >> ~/.bashrc
@echo 'export PATH=$$JAVA_HOME/bin:$$PATH' >> ~/.bashrc
export JAVA_HOME=/usr/local/bin/java-${JAVA_VERSION}
export PATH=$$JAVA_HOME/bin:$$PATH
@java -version
rm /tmp/java.tar.gz
install-nextflow: ## >> install a NextFlow
@java --version
curl -s https://get.nextflow.io | bash
install-gh:
curl -sS https://webi.sh/gh | sh
install-cliff: ## >> Install git-cliff tool
@echo ""
@echo "$(ccso)--> Installing git-cliff tool $(ccend)"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
$$HOME/.cargo/bin/cargo install --version 2.6.1 git-cliff
changelog: install-cliff ## >> Update CHANGELOG.md
@echo ""
@echo "$(ccso)--> Updating CHANGELOG.md $(ccend)"
git-cliff --tag $(TAG) --bump -o CHANGELOG.md
git add CHANGELOG.md && git commit -m "chore(release): prepare for $(TAG)"
git show
release: install-gh changelog
git tag $(TAG) && git push origin $(TAG)
git push
git cliff --strip all --latest | gh release create $(TAG) --notes-file -
build-step-image:
@$(ENGINE) version
$(ENGINE) build --target $(STAGE) -t $(STEP)-$(STAGE) $(PODMAN_PARAM) bin/$(STEP)
install: ## Install and check dependencies
$(MAKE) install-nextflow
$(MAKE) build-ref
$(MAKE) build-step-image STEP=downloader STAGE=image
for step in pyumi calib_dedup fastp vidjil igblast cdr3nt_error_corrector ; do \
$(MAKE) build-step-image STEP=$$step STAGE=image ; \
done
chmod +x pyigmap
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-\$\(]+)\s*:.*\#\#(?:@([a-zA-Z\-\)]+))?\s(.*)$$/ }; \
print "usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }
help: ##@other >> Show this help.
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
@echo ""
@echo "Note: to activate the environment in your local shell type:"
@echo " $$ source $(VIRTUAL_ENV)/bin/activate"