-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (89 loc) · 4.1 KB
/
Copy pathMakefile
File metadata and controls
109 lines (89 loc) · 4.1 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
# ----------------------------------------------------------------------
# Project handling
# ----------------------------------------------------------------------
# Default project (used if no .project file exists)
DEFAULT_PROJECT ?= example
# .project file – contains the name of the active project
PROJECT_FILE := .project
# Resolve the active project:
# 1️⃣ If the file exists, read its contents.
# 2️⃣ Otherwise fall back to DEFAULT_PROJECT.
PROJECT := $(or $(shell cat $(PROJECT_FILE) 2>/dev/null),$(DEFAULT_PROJECT))
# Full config‑file path derived from the project name
CONFIGFILE := config/config.$(PROJECT).yaml
# ----------------------------------------------------------------------
# Common Snakemake command parts
# ----------------------------------------------------------------------
CONDA_ENV_DIR=$(shell dirname ${CONDA_EXE})
HN=$(shell hostname | sed "s/[0-9]//g")
ifeq ($(HN),$(filter $(HN),cnode gnode hnode))
CONDA_ENV_NAME=/exchange/healthds/software/envs/snakemake
else
CONDA_ENV_NAME=snakemake
endif
# Targets list (unchanged)
TARGETS=dependencies dag run unlock
# ----------------------------------------------------------------------
# Top level
# ----------------------------------------------------------------------
all:
@echo "Try one of: ${TARGETS}"
@echo "Current project: $(PROJECT) (config → $(CONFIGFILE))"
# ----------------------------------------------------------------------
# DAG
# ----------------------------------------------------------------------
dag:
source $(CONDA_ENV_DIR)/activate $(CONDA_ENV_NAME) && \
snakemake --configfile "$(CONFIGFILE)" --dag | dot -Tsvg > dag.svg
# ----------------------------------------------------------------------
# Environment
# ----------------------------------------------------------------------
dependencies:
mamba env update -n snakemake --file environment.yml
dev-dependencies: dependencies
mamba env update -n snakemake --file environment_dev.yml
# ----------------------------------------------------------------------
# Dry‑run
# ----------------------------------------------------------------------
dry-run:
source $(CONDA_ENV_DIR)/activate $(CONDA_ENV_NAME) && \
snakemake --configfile "$(CONFIGFILE)" --sdm conda --dry-run --profile slurm --snakefile workflow/Snakefile
# ----------------------------------------------------------------------
# Run
# ----------------------------------------------------------------------
pre-commit:
if [ ! -f .git/hooks/pre-commit ]; then pre-commit install; fi
pre-commit run --all-files
local-run:
source $(CONDA_ENV_DIR)/activate $(CONDA_ENV_NAME) && \
snakemake --configfile "$(CONFIGFILE)" --printshellcmds --sdm conda --sdm apptainer --cores 4 --snakefile workflow/Snakefile
run:
source $(CONDA_ENV_DIR)/activate $(CONDA_ENV_NAME) && \
snakemake --configfile "$(CONFIGFILE)" --profile slurm --snakefile workflow/Snakefile
rerun:
source $(CONDA_ENV_DIR)/activate $(CONDA_ENV_NAME) && \
snakemake --configfile "$(CONFIGFILE)" --profile slurm --snakefile workflow/Snakefile --rerun-incomplete --rerun-trigger mtime
unlock:
source $(CONDA_ENV_DIR)/activate $(CONDA_ENV_NAME) && \
snakemake --configfile "$(CONFIGFILE)" --unlock
dockerfile_:
source $(CONDA_ENV_DIR)/activate $(CONDA_ENV_NAME) && \
snakemake --configfile "$(CONFIGFILE)" --containerize --snakefile workflow/Snakefile > Dockerfile
# ----------------------------------------------------------------------
# Project helpers – create/override the .project file
# ----------------------------------------------------------------------
project-metaanalysis:
@echo "metaanalysis" > $(PROJECT_FILE)
@echo "✅ Project set to 'metaanalysis' "
project-believe:
@echo "believe" > $(PROJECT_FILE)
@echo "✅ Project set to 'believe' "
project-%:
@echo "$*" > $(PROJECT_FILE)
@echo "✅ Project set to '$*' "
# ----------------------------------------------------------------------
# Clean up helper (optional)
# ----------------------------------------------------------------------
clean-project:
@rm -f $(PROJECT_FILE)
@echo "🗑️ Removed $(PROJECT_FILE); next run will fall back to DEFAULT_PROJECT='$(DEFAULT_PROJECT)'"