-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
114 lines (83 loc) · 2.98 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
.PHONY: all help clean cleanall cleanallall test reports format edit conda viewconf
SHELL=/usr/bin/env bash -eo pipefail
.SECONDARY:
.SUFFIXES:
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!! WARNING: !! TOPDIR changes automatically to .. when run from .test/ !!
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#TOPDIR = .
TOPDIR = $(shell if [ -d ".test" ]; then echo . ; else echo .. ; fi)
# test if this is run from the .test/ directory
ifeq ($(strip $(TOPDIR)),..)
SNAKEMAKE_PARAM_DIR = --snakefile ../workflow/Snakefile --show-failed-logs
else
SNAKEMAKE_PARAM_DIR =
endif
CONDA_DIR = $(shell grep "^conda_dir:" config.yaml | awk '{print $$2}')
ifeq ($(CONDA_DIR),)
$(error 'conda_dir' not found in the configuration)
endif
USE_CONDA = $(shell grep "^use_conda:" config.yaml | awk '{print $$2}')
ifeq ($(USE_CONDA),)
$(error 'use_conda' not found in the configuration)
endif
CONDA_DIR_ADJ = $(TOPDIR)/$(CONDA_DIR)
ifeq ($(strip $(USE_CONDA)),True)
CONDA_PARAMS = --software-deployment-method conda --conda-prefix="$(CONDA_DIR_ADJ)"
endif
######################
## General commands ##
######################
all: ## Run everything
snakemake --cores all $(CONDA_PARAMS) -p --rerun-incomplete $(SNAKEMAKE_PARAM_DIR) --keep-going --retries 1
help: ## Print help messages
@printf "$$(grep -hE '^\S*(:.*)?##' $(MAKEFILE_LIST) \
| sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\e[36m\1\\e[0m:\2/' -e 's/^\([^#]\)/ \1/g'\
| column -c2 -t -s : )\n"
conda: ## Create the conda environments
snakemake -p --cores all -d .test $(CONDA_PARAMS) --conda-create-envs-only
clean: ## Clean all output archives and intermediate files
rm -fvr output/* intermediate/*
@if [ -d ".test" ]; then \
$(MAKE) -C .test clean; \
fi
cleanall: clean ## Clean everything but Conda, Snakemake, and input files
rm -fvr intermediate/*
@if [ -d ".test" ]; then \
$(MAKE) -C .test cleanall; \
fi
cleanallall: cleanall ## Clean completely everything
rm -fvr {input,$(CONDA_DIR)}/*
rm -fr .snakemake/
@if [ -d ".test" ]; then \
$(MAKE) -C .test cleanallall; \
fi
###############
## Reporting ##
###############
viewconf: ## View configuration without comments
@cat config.yaml \
| perl -pe 's/ *#.*//g' \
| grep --color='auto' -E '.*\:'
@#| grep -Ev ^$$
reports: ## Create html report
snakemake --cores all $(CONDA_PARAMS) -p --rerun-incomplete $(SNAKEMAKE_PARAM_DIR) --report report.html
@if [ -d ".test" ]; then \
$(MAKE) -C .test reports; \
fi
####################
## For developers ##
####################
test: ## Run the workflow on test data
#snakemake -d .test --cores $(CONDA_PARAMS) -p --show-failed-logs --rerun-incomplete
@if [ -d ".test" ]; then \
$(MAKE) -C .test; \
fi
format: ## Reformat all source code
snakefmt workflow
yapf -i --recursive workflow
checkformat: ## Check source code format
snakefmt --check workflow
yapf --diff --recursive workflow
edit:
nvim -p workflow/Snakefile workflow/rules/*.smk