forked from bactopia/bactopia
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnextflow.config
194 lines (176 loc) · 6.62 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
// main script name
manifest {
author = 'Robert A. Petit III'
name = 'bactopia'
homePage = 'https://github.com/bactopia/bactopia'
description = 'An extensive workflow for processing Illumina sequencing of bacterial genomes.'
mainScript = 'main.nf'
version = '3.0.1'
nextflowVersion = '>=21.10'
}
// Includes
bactopia_cache = System.getenv("BACTOPIA_CACHEDIR") ? "${BACTOPIA_CACHEDIR}" : "${HOME}/.bactopia"
includeConfig "conf/params.config"
includeConfig "conf/workflows.config"
if (params.workflows.containsKey(params.wf)) {
if (params.workflows[params.wf].containsKey("is_workflow")) {
// Running as main workflow (e.g. bactopia/staphopia)
includeConfig "conf/params/bactopia.config"
params.workflows[params.wf]['includes'].each { it ->
if (params.workflows[it].containsKey("modules")) {
// Subworkflow which includes multiple modules
params.workflows[it]['modules'].each { module ->
includeConfig "${params.workflows[module].path}/params.config"
}
} else {
// Module
includeConfig "${params.workflows[it].path}/params.config"
}
}
if (params.containsKey("ask_merlin")) {
if (params.ask_merlin) {
params.workflows['merlin']['modules'].each { module ->
includeConfig "${params.workflows[module].path}/params.config"
}
}
}
if (params.wf == "bactopia" || params.wf == "staphopia") {
if (params.use_bakta) {
params.workflows['bakta']['modules'].each { module ->
includeConfig "${params.workflows[module].path}/params.config"
}
} else {
includeConfig "${params.workflows['prokka'].path}/params.config"
}
}
if (params.wf == "cleanyerreads") {
includeConfig "conf/params/clean-yer-reads.config"
} else if (params.wf == "teton") {
includeConfig "conf/params/teton.config"
}
} else {
// Running as bactopia tool
includeConfig "conf/params/bactopia-tools.config"
if (params.workflows[params.wf].containsKey("use_local")) {
includeConfig "conf/params/local/${params.workflows[params.wf].use_local}.config"
}
if (params.workflows[params.wf].containsKey("modules")) {
// Subworkflow which includes multiple modules
params.workflows[params.wf]['modules'].each { module ->
includeConfig "${params.workflows[module].path}/params.config"
}
}
if (params.workflows[params.wf].containsKey("path")) {
// Module
includeConfig "${params.workflows[params.wf].path}/params.config"
}
}
} else {
// Include main bactopia params
includeConfig "conf/params/bactopia.config"
}
if (params.is_ci) {
includeConfig "conf/tests.config"
}
includeConfig "conf/outputs.config"
// Set up containers
singularity_cache = System.getenv("NXF_SINGULARITY_CACHEDIR") ? "${NXF_SINGULARITY_CACHEDIR}" : "${params.singularity_cache_dir}"
run_timestamp = new java.util.Date().format('yyyyMMdd-HHmmss')
rundir = params.is_ci ? "${params.run_name}" : "${params.run_name}-${run_timestamp}"
// Load nf-core custom profiles from different Institutions
try {
includeConfig "${params.custom_config_base}/nfcore_custom.config"
} catch (Exception e) {
System.err.println("WARNING: Could not load nf-core/config profiles: ${params.custom_config_base}/nfcore_custom.config")
}
// NOTE: The following section will only be needed if a bactopia specific profile is added to nf-core/configs
// Load Bactopia custom profiles from different institutions.
//try {
// includeConfig "${params.custom_config_base}/pipeline/bactopia.config"
//} catch (Exception e) {
// System.err.println("WARNING: Could not load nf-core/config/bactopia profiles: ${params.custom_config_base}/pipeline/bactopia.config")
//}
includeConfig "conf/profiles.config"
if (params.nfconfig) {
includeConfig check_path(params.nfconfig)
}
if (!params.help || !params.help || !params.list_wfs) {
infodir = "${params.outdir}/bactopia-runs/${rundir}/nf-reports"
// Reporting configuration
timeline {
enabled = true
overwrite = true
file = "${infodir}/${params.wf}-timeline.html"
}
report {
enabled = true
overwrite = true
file = "${infodir}/${params.wf}-report.html"
}
trace {
enabled = true
overwrite = true
file = "${infodir}/${params.wf}-trace.txt"
fields = 'task_id,hash,native_id,process,tag,name,status,exit,module,container,cpus,time,disk,memory,attempt,start,complete,duration,realtime,queue,%cpu,%mem,rss,vmem'
}
dag {
enabled = true
overwrite = true
file = "${infodir}/${params.wf}-dag.svg"
}
}
// Function to ensure that resource requirements don't go beyond a maximum limit
// Source: https://github.com/nf-core/rnaseq/blob/master/nextflow.config
def check_max(obj, max, type) {
if (type == 'memory') {
try {
if (obj > max)
return max
else
return obj
} catch (all) {
println "ERROR - Max memory '${params.max_memory} GB' is not valid! Using default value: $obj"
return obj
}
} else if (type == 'time') {
try {
max_time = (params.max_time).m
if (obj > max)
return max
else
return obj
} catch (all) {
println "ERROR - Max time '${params.max_time} minutes' is not valid! Using default value: $obj"
return obj
}
} else if (type == 'cpus') {
try {
if (obj == 'request') {
return max
} else {
//return Math.min(obj, max) <- Error found
return 2
}
} catch (all) {
println "ERROR - Max cpus '${Math.min(obj, max)}' is not valid! Using default value: ${max}"
return obj
}
}
}
def check_path(file_path) {
// Try relative first
launchDir = System.properties['user.dir']
relative_path = "${launchDir}/${file_path}"
File file_obj = new File(relative_path)
if (file_obj.exists()) {
return relative_path
} else {
// Try as absolute path
file_obj = new File(file_path)
if (file_obj.exists()) {
return file_path
} else {
println "ERROR - Unable to locate '${params.nfconfig}' please check it exists"
}
}
}