-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnextflow.config
165 lines (156 loc) · 5.29 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
// CONFIGURATION FILE
manifest {
author = 'H3ABioNet'
description = 'H3ABioNet Variant Calling Workflow'
mainScript = 'main.nf'
}
// 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
}
}
}
// GET THE PATHS FOR THE INPUT, OUTPUT AND DATA - BIND THEM TO THE SINGULARITY IMAGE! FAILSAFE IN CASE DATA RESIDES SOMEWHERE ELSE!!
def checkBindPaths() {
if(params.data == null || params.out == null || params.resources == null){
bind_paths = ''
}else{
bind_paths = [params.data, params.out, params.resources].collect { it -> "-B ${it}"}.join(" ").toString()
}
return bind_paths
}
// PROCESS SETTINGS
process {
// ALL PROCESSES
stageInMode = 'symlink'
stageOutMode = 'rsync'
scratch = 'false'
// RESOURCES
cpus = { check_max( 1 * task.attempt, 'cpus' ) }
memory = { check_max( 1.GB * task.attempt, 'memory' ) }
time = { check_max( 2.h * task.attempt, 'time' ) }
// PROCESS CONTAINERS AND RESOURCES
withLabel:fastqc {
container = "$baseDir/containers/h3avarcall_fastqc.sif"
}
withLabel:trimmomatic{
container = "$baseDir/containers/h3avarcall_trimmomatic.sif"
cpus = { check_max( 4 * task.attempt, 'cpus' ) }
memory = { check_max( 4.GB * task.attempt, 'memory' ) }
}
withLabel:bwa {
container = "$baseDir/containers/h3avarcall_bwa.sif"
cpus = { check_max( 4 * task.attempt, 'cpus' ) }
memory = { check_max( 8.GB * task.attempt, 'memory' ) }
}
withLabel:gatk {
container = "$baseDir/containers/h3avarcall_gatk.sif"
cpus = { check_max( 1 * task.attempt, 'cpus' ) }
memory = { check_max( 1.GB * task.attempt, 'memory' ) }
}
withLabel:multiqc {
container = "$baseDir/containers/h3avarcall_multiqc.simg"
}
withName:run_MarkDuplicates {
memory = { check_max( 4.GB * task.attempt, 'memory' ) }
}
withName: 'run_HaplotypeCaller|run_CombineGVCF' {
cpus = { check_max( 4 * task.attempt, 'cpus' ) }
memory = { check_max( 8.GB * task.attempt, 'memory' ) }
}
}
// SINGULARITY SETTINGS
def singularityOptions() {
singularity {
enabled = true
cacheDir = "$baseDir/containers"
runOptions = "$bind_paths" + " --cleanenv"
autoMounts = true
}
}
// INPUT PARAMETERS
def checkOutPath() {
if(params.out == null) {
out_path = "$baseDir/workflow_results"
} else{
out_path = params.out
}
}
// WORKFLOW TRACING
def workflowTracing() {
if(params.mode == null || params.help || params.mode in [ 'do.GetContainers', 'do.GenomeIndexing', 'do.MultiQC']) {}
else if( params.mode in ['do.QC', 'do.ReadTrimming', 'do.ReadAlignment', 'do.VariantCalling', 'do.VariantFiltering' ]) {
if(params.mode == 'do.QC') {
trace_dir = "${out_path}/1_QC"
} else if(params.mode == 'do.ReadTrimming') {
trace_dir = "${out_path}/2_Read_Trimming"
} else if(params.mode == 'do.ReadAlignment') {
trace_dir = "${out_path}/3_Read_Alignment"
} else if(params.mode == 'do.VariantCalling') {
trace_dir = "${out_path}/4_Variant_Calling"
} else if(params.mode == 'do.VariantFiltering') {
trace_dir = "${out_path}/5_Variant_Filtering"
} else {}
trace {
enabled = true
file = "${trace_dir}/workflow_report/h3avarcall_trace.txt"
}
timeline {
enabled = true
file = "${trace_dir}/workflow_report/h3avarcall_timeline.html"
}
report {
enabled = true
file = "${trace_dir}/workflow_report/h3avarcall_report.html"
}
dag {
enabled = true
file = "${trace_dir}/workflow_report/h3avarcall_workflow.dot"
}
} else {}
}
// PIPELINE PROFILES
profiles {
local {
executor = 'local'
includeConfig "$baseDir/main.config"
checkOutPath()
checkBindPaths()
singularityOptions()
workflowTracing()
}
slurm {
executor = 'slurm'
queue = 'batch'
includeConfig "$baseDir/main.config"
checkOutPath()
checkBindPaths()
singularityOptions()
workflowTracing()
}
}