-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
219 lines (184 loc) · 8.12 KB
/
Copy pathMakefile
File metadata and controls
219 lines (184 loc) · 8.12 KB
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
SHELL:=/bin/bash
JAVA_VERSION=21
ARCHITECTURE=amd64
BUILD_REF_STAGE=build-ref
ENGINE=docker
UV_BIN = '$(HOME)/.local/bin/uv'
PYTHON_VERSION := 3.9
VENV_DIR := .venv
ifeq ($(ENGINE),podman)
PODMAN_PARAM=--format docker
export USE_PODMAN=true
endif
# .ONESHELL:
DEFAULT_GOAL: install
.PHONY: help clean build build-ref tests integration-tests unit-tests mypy check format \
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)"
$(UV_BIN) run mypy bin/calib_dedup/
$(UV_BIN) run mypy bin/fastp/
$(UV_BIN) run mypy bin/vidjil/
$(UV_BIN) run mypy bin/igblast/
$(UV_BIN) run mypy bin/cdr3nt_error_corrector/
check: ## >> run ruff linter
@echo ""
@echo "$(ccso)--> Running ruff check $(ccend)"
$(UV_BIN) run ruff check bin/calib_dedup/ bin/fastp/ bin/vidjil/ bin/igblast/ bin/cdr3nt_error_corrector/
format: ## >> run ruff formatter
@echo ""
@echo "$(ccso)--> Running ruff format $(ccend)"
$(UV_BIN) run ruff format bin/calib_dedup/ bin/fastp/ bin/vidjil/ bin/igblast/ bin/cdr3nt_error_corrector/
integration-tests: ## >> run tests for all workflows via pytest and pytest-workflow tool
@echo ""
@echo "$(ccso)--> Running workflow tests $(ccend)"
$(UV_BIN) run pytest tests -vv --kwdof --tag integration-tests
unit-tests: ## >> run tests for all steps via pytest tool
@echo ""
@echo "$(ccso)--> Running steps tests $(ccend)"
$(UV_BIN) run pytest bin/pyumi/unit_tests -vv
# $(UV_BIN) run pytest bin/calib_dedup/unit_tests -vv
$(UV_BIN) run pytest tests -vv --kwdof --tag unit-tests
$(UV_BIN) run pytest bin/cdr3nt_error_corrector/unit_tests -vv
tests: ##@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 \
reporter-tool reporter-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 uv.lock \
bin/igblast/igblast.reference.all_alleles.tar.gz bin/igblast/igblast.reference.major_allele.tar.gz \
bin/igblast/vidjil.germline.tar.gz bin/cdr3nt_error_corrector/olga-models.tar.gz
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:/tmp igblast-$(BUILD_REF_STAGE) -a -o /tmp/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:/tmp igblast-$(BUILD_REF_STAGE) -a -o /tmp/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)"
$(ENGINE) run --rm -v $(PWD)/bin/vidjil:/tmp vidjil-$(BUILD_REF_STAGE) -a -o /tmp/vidjil.germline.tar.gz
build-olga-models: ## >> build an archive with olga models
@echo ""
@echo "$(ccso)--> Build olga models for cdr3nt-error-corrector $(ccend)"
$(ENGINE) run --rm -v $(PWD)/bin/cdr3nt_error_corrector:/tmp cdr3nt_error_corrector-$(BUILD_REF_STAGE) -a -o /tmp/olga-models.tar.gz
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-ref-image STEP=vidjil
$(MAKE) build-vidjil-ref
$(MAKE) build-ref-image STEP=cdr3nt_error_corrector
$(MAKE) build-olga-models
dev: ##@main >> build docker images, the virtual environment and install requirements
@echo ""
@echo "$(ccso)--> Build $(ccend)"
$(MAKE) clean
$(MAKE) build-step-image STEP=downloader STAGE=image
for step in pyumi calib_dedup reporter 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-dev
# $(UV_BIN) run nf-core pipelines schema build --no-prompts
update-dev: install-uv ## >> update requirements.txt inside the virtual environment
@echo "$(ccso)--> Updating packages $(ccend)"
$(UV_BIN) venv --python $(PYTHON_VERSION)
$(UV_BIN) add -r bin/pyumi/requirements.txt
$(UV_BIN) add -r bin/cdr3nt_error_corrector/requirements.txt
update: install-uv ## >> update requirements.txt inside the virtual environment
@echo "$(ccso)--> Updating packages $(ccend)"
$(UV_BIN) venv --python $(PYTHON_VERSION)
$(UV_BIN) add "nf-core>=2.14.1" "nextflow>=24.04.2"
install-uv: ## >> Installs uv
@echo ""
@echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
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 Java
curl -fL https://download.oracle.com/java/${JAVA_VERSION}/latest/jdk-${JAVA_VERSION}_linux-x64_bin.tar.gz -o /tmp/java.tar.gz
sudo mkdir -p /usr/local/bin/java-${JAVA_VERSION}
sudo tar --strip-components=1 -xzvf /tmp/java.tar.gz -C /usr/local/bin/java-${JAVA_VERSION}
rm /tmp/java.tar.gz
echo "export JAVA_HOME=/usr/local/bin/java-${JAVA_VERSION}" | tee -a ~/.bashrc ~/.zshrc
echo 'export PATH=$$JAVA_HOME/bin:$$PATH' | tee -a ~/.bashrc ~/.zshrc
export JAVA_HOME=/usr/local/bin/java-${JAVA_VERSION}
export PATH=$$JAVA_HOME/bin:$$PATH
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) update
$(MAKE) build-ref
$(MAKE) build-step-image STEP=downloader STAGE=image
for step in pyumi calib_dedup reporter fastp vidjil igblast cdr3nt_error_corrector ; do \
$(MAKE) build-step-image STEP=$$step STAGE=image ; \
done
# 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"