forked from stevekm/nf-bio-basic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
155 lines (121 loc) · 4.68 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
SHELL:=/bin/bash
UNAME:=$(shell uname)
none:
# ~~~~~ SETUP PIPELINE ~~~~~ #
./nextflow:
curl -fsSL get.nextflow.io | bash
install: ./nextflow
update: ./nextflow
./nextflow self-update
# ~~~~~ SETUP CONDA ~~~~~ #
ifeq ($(UNAME), Darwin)
CONDASH:=Miniconda3-4.5.4-MacOSX-x86_64.sh
endif
ifeq ($(UNAME), Linux)
CONDASH:=Miniconda3-4.5.4-Linux-x86_64.sh
endif
# CONDASH:=Miniconda3-4.5.4-Linux-ppc64le.sh
CONDAURL:=https://repo.continuum.io/miniconda/$(CONDASH)
CONDADIR:=$(shell python -c 'import os; print(os.path.realpath("conda"))')
CONDA_ACTIVATE:=$(CONDADIR)/bin/activate
conda:
wget "$(CONDAURL)" && \
bash "$(CONDASH)" -b -p conda && \
rm -f "$(CONDASH)" && \
unset PYTHONHOME; unset PYTHONPATH && \
source "$(CONDA_ACTIVATE)" && \
conda config --add channels defaults && \
conda config --add channels bioconda
# NOTE: methods of getting local conda into PATH;
# unset PYTHONHOME; unset PYTHONPATH; export PATH=$(CONDADIR)/bin:$$PATH; \
# unset PYTHONHOME; unset PYTHONPATH; source "$(CONDA_ACTIVATE)" && \
TIMESTAMP=$(shell date +%s)
clean-conda:
[ -d conda ] && mv conda ".conda.old.${TIMESTAMP}" && rm -rf ".conda.old.${TIMESTAMP}" &
# ~~~~~ SETUP DOCKER ~~~~~ #
check-Docker:
docker --version > /dev/null 2>&1 || { echo "ERROR: 'docker' not found, is it running?" && exit 1 ; }
docker: check-Docker
docker build -t stevekm/nf-bio-basic .
docker-test: docker
docker run --rm -ti stevekm/nf-bio-basic bash
# ~~~~~ CREATE SINGULARITY IMAGE ON MAC USING VAGRANT ~~~~~ #
# # Requires Vagrant install:
# brew cask install virtualbox
# brew cask install vagrant # https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.dmg
# brew cask install vagrant-manager
# #
# set up directories and files for Vagrant
vagrant-installed:
type vagrant >/dev/null 2>&1 || { echo >&2 "Vagrant required but not found. Aborting."; exit 1; }
# singularity-vm:
# mkdir -p singularity-vm
#
# singularity-vm/Vagrantfile: singularity-vm
# if [ ! -f singularity-vm/Vagrantfile ]; then \
# cd singularity-vm && \
# vagrant init singularityware/singularity-2.4 && \
# sed -i '' 's| # config.vm.synced_folder "../data", "/vagrant_data"| config.vm.synced_folder "image", "/image"|' Vagrantfile ; \
# fi
#
# singularity-vm/image: singularity-vm
# mkdir -p singularity-vm/image
singularity-vm/image/Singularity:
/bin/cp -v Singularity singularity-vm/image/Singularity
# Create the Singularity container file
singularity-vm/image/nf-bio-basic.simg: singularity-vm/image/Singularity
cd singularity-vm && \
vagrant up && \
vagrant ssh -c 'cd /image && sudo singularity build nf-bio-basic.simg Singularity'
singularity-container: singularity-vm/image/nf-bio-basic.simg
singularity-vm/image/multiqc.txt: singularity-vm/image/nf-bio-basic.simg
cd singularity-vm && \
vagrant up && \
vagrant ssh -c 'cd /image && singularity exec nf-bio-basic.simg multiqc --version > multiqc.txt'
singularity-test: singularity-vm/image/multiqc.txt
cat singularity-vm/image/multiqc.txt
# ~~~~~ RUN PIPELINE ~~~~~ #
# $ make run EP='-profile sge -resume'
# default run use Docker, executes locally
run: install
./nextflow run main.nf $(EP)
run-conda: install conda
if [ "$$( module > /dev/null 2>&1; echo $$?)" -eq 0 ]; then module unload python ; fi ; \
unset PYTHONHOME; unset PYTHONPATH; source "$(CONDA_ACTIVATE)" && \
./nextflow run main.nf -profile conda $(EP)
# conda needs to be in PATH for parent Nextflow process !!
run-conda-slurm: install conda
if [ "$$( module > /dev/null 2>&1; echo $$?)" -eq 0 ]; then module unload python ; fi ; \
unset PYTHONHOME; unset PYTHONPATH; source "$(CONDA_ACTIVATE)" && \
./nextflow run main.nf -profile slurmConda $(EP)
run-conda-sge: install conda
if [ "$$( module > /dev/null 2>&1; echo $$?)" -eq 0 ]; then module unload python ; fi ; \
unset PYTHONHOME; unset PYTHONPATH; source "$(CONDA_ACTIVATE)" && \
./nextflow run main.nf -profile sgeConda $(EP)
SINGULARITYIMG:=singularity-vm/image/nf-bio-basic.simg
run-singularity-slurm: install
./nextflow run main.nf -profile singularity,slurm $(EP)
run-singularity: install
./nextflow run main.nf -profile singularity $(EP)
# ~~~~~ CLEANUP ~~~~~ #
clean-traces:
rm -f trace*.txt.*
clean-logs:
rm -f .nextflow.log.*
clean-reports:
rm -f *.html.*
clean-flowcharts:
rm -f *.dot.*
clean-output:
[ -d output ] && mv output oldoutput && rm -rf oldoutput &
clean-work:
[ -d work ] && mv work oldwork && rm -rf oldwork &
# deletes files from previous runs of the pipeline, keeps current results
clean: clean-logs clean-traces clean-reports clean-flowcharts
# deletes all pipeline output
clean-all: clean clean-output clean-work
[ -d .nextflow ] && mv .nextflow .nextflowold && rm -rf .nextflowold &
rm -f .nextflow.log
rm -f *.png
rm -f trace*.txt*
rm -f *.html*