-
Notifications
You must be signed in to change notification settings - Fork 7
/
nextflow.config
204 lines (187 loc) · 5.7 KB
/
nextflow.config
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
// Configuration File
manifest {
author = 'Phelelani Mpangase'
homePage = 'https://github.com/phelelani/nf-rnaSeqMetagen'
description = 'rnaSeqMetagen pipeline'
mainScript = 'main.nf'
version = '0.2'
}
// CHECK INPUTS AND OUTPUTS:
params {
data = null
out = null
db = null
genome = null
genes = null
help = null
mode = null
// RESOURCES
max_memory = 200.GB
max_cpus = 24
max_time = 24.h
}
// FUNCTION TO ENSURE THAT RESOURCE REQUIREMENTS DON'T GO BEYOND A MAXIMUM LIMIT
def check_max(obj, type) {
if(type == 'memory'){
try {
if(obj.compareTo(params.max_memory as nextflow.util.MemoryUnit) == 1)
return params.max_memory as nextflow.util.MemoryUnit
else
return obj
} catch (all) {
println " ### ERROR ### Max memory '${params.max_memory}' is not valid! Using default value: $obj"
return obj
}
} else if(type == 'time'){
try {
if(obj.compareTo(params.max_time as nextflow.util.Duration) == 1)
return params.max_time as nextflow.util.Duration
else
return obj
} catch (all) {
println " ### ERROR ### Max time '${params.max_time}' is not valid! Using default value: $obj"
return obj
}
} else if(type == 'cpus'){
try {
return Math.min( obj, params.max_cpus as int )
} catch (all) {
println " ### ERROR ### Max cpus '${params.max_cpus}' is not valid! Using default value: $obj"
return obj
}
}
}
// CHECK INPUT AND OUTPUT PATHS
def checkPaths() {
def bind_dirs = []
// CHECK DATA INPUT DIR
if(params.data == null) {
// DO NOTHING!
} else{
data_dir = new File("${params.data}")
bind_dirs.add("${data_dir}")
}
// CHECK DATA OUTPUT DIR
if(params.out == null) {
out_dir = new File("$PWD/results_nf-rnaSeqMetagen")
} else{
out_dir = new File("${params.out}")
bind_dirs.add("${out_dir}")
}
// CHECK KRAKEN2_DB
if(params.db == null) {
// DO NOTHING!
} else{
db = new File("${params.db}")
bind_dirs.add(db)
}
// CHECK GENOME
if(params.genome == null) {
// DO NOTHING!
} else{
genome_dir = new File("${params.genome}").getParent()
bind_dirs.add("${genome_dir}")
}
// CHECK GENES
if(params.genes == null) {
// DO NOTHING!
} else{
genes_dir = new File("${params.genes}").getParent()
bind_dirs.add("${genes_dir}")
}
// BIND GENOME AND GENES DIR
if (bind_dirs.isEmpty()) {
dirs = " "
} else {
dirs = bind_dirs.unique().collect { it -> "-B ${it}"}.join(" ").toString()
}
return [ "${dirs}", out_dir ]
}
// SINGULARITY OPTIONS
def singularityOptions() {
singularity {
enabled = true
cacheDir = "$HOME/.singularity/cache"
runOptions = "$dirs" + " --cleanenv"
autoMounts = true
}
}
// PIPELINE TRACING, VISUALIZATION AND HELP
def pipelineHelp() {
if(params.help || params.mode == null) {
} else if(params.mode == 'run.FilterClassify') {
trace {
enabled = true
file = "${out_dir}/workflow-tracing/nf-rnaSeqMetagen_trace.txt"
}
timeline {
enabled = true
file = "${out_dir}/workflow-tracing/nf-rnaSeqMetagen_timeline.html"
}
report {
enabled = true
file = "${out_dir}/workflow-tracing/nf-rnaSeqMetagen_report.html"
}
dag {
enabled = true
file = "${out_dir}/workflow-tracing/nf-rnaSeqMetagen_flow.dot"
}
} else{}
}
// ALL PROCESSESS SETTINGS
process {
// ALL PROCESSES
cache = true
stageInMode = 'symlink'
stageOutMode = 'rsync'
// SPECIAL RESOURCE REQUIREMENTS
withLabel: 'mini' {
cpus = 1 //{ check_max( 1 * task.attempt, 'cpus' ) }
memory = 4.GB //{ check_max( 4.GB * task.attempt, 'memory' ) }
time = { check_max( 12.h * task.attempt, 'time' ) }
}
withLabel: 'midi' {
cpus = 6 //{ check_max( 8 * task.attempt, 'cpus' ) }
memory = 24.GB //{ check_max( 24.GB * task.attempt, 'memory' ) }
time = { check_max( 24.h * task.attempt, 'time' ) }
}
withLabel: 'maxi' {
cpus = 12 //{ check_max( 16 * task.attempt, 'cpus' ) }
memory = 56.GB //{ check_max( 56.GB * task.attempt, 'memory' ) }
time = { check_max( 48.h * task.attempt, 'time' ) }
}
// CONTAINERS
withName:'run_GenerateSTARIndex|run_STAR' {
container = 'file:///$HOME/.singularity/cache/nf-rnaseqmetagen_star.sif'
}
withName:'run_TrinityAssemble' {
container = 'file:///$HOME/.singularity/cache/nf-rnaseqmetagen_trinity.sif'
cpus = 20
memory = 150.GB
}
withName:'run_GenerateKrakenDB|run_UpdateTaxonomy|run_KrakenClassifyReads|run_KrakenClassifyFasta|run_KronaReport' {
container = 'file:///$HOME/.singularity/cache/nf-rnaseqmetagen_kraken2.sif'
}
withName:'run_CollectTaxSeqs|run_CopyUpsetDir|run_PrepareMatrixData|run_CreateMatrix' {
container = 'file:///$HOME/.singularity/cache/nf-rnaseqmetagen_upset.sif'
}
withName:'run_MultiQC' {
container = 'file:///$HOME/.singularity/cache/nf-rnaseqmetagen_multiqc.sif'
}
}
// PROFILES AND PROCESS OPTIONS
profiles {
standard {
executor = 'local'
checkPaths()
singularityOptions()
pipelineHelp()
}
slurm {
executor = 'slurm'
queue = 'batch'
checkPaths()
singularityOptions()
pipelineHelp()
}
}