-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.nf
190 lines (152 loc) · 4.96 KB
/
main.nf
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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
import org.yaml.snakeyaml.Yaml
/*
* Generic multiplatform genome assembly pipeline (MpGAP)
*/
/*
* Include functions
*/
include { helpMessage } from './nf_functions/help.nf'
include { logMessage } from './nf_functions/logMessages.nf'
/*
* Help message
*/
params.help = false
if (params.help) {
helpMessage()
exit 0
}
/*
Download configuration file, if necessary.
*/
params.get_config = false
if (params.get_config) {
new File("MPGAP.config").write(new URL ("https://github.com/fmalmeida/mpgap/raw/master/nextflow.config").getText())
println ""
println "MPGAP.config file saved in working directory"
println "After configuration, run:"
println "nextflow run fmalmeida/mpgap -c ./MPGAP.config"
println "Nice code!\n"
exit 0
}
/*
Download samplesheet, if necessary.
*/
params.get_samplesheet = false
if (params.get_samplesheet) {
new File("MPGAP_samplesheet.yml").write(new URL ("https://github.com/fmalmeida/mpgap/raw/master/example_samplesheet.yml").getText())
println ""
println "Samplesheet (MPGAP_samplesheet.yml) file saved in working directory"
println "Nice code!\n"
exit 0
}
/*
* Load general parameters and establish defaults
*/
// General
params.output = 'output'
params.threads = 3
params.input = ''
// Assemblers?
params.skip_flye = false
params.skip_spades = false
params.skip_shovill = false
params.skip_canu = false
params.skip_unicycler = false
params.skip_haslr = false
params.skip_raven = false
params.skip_wtdbg2 = false
params.skip_shasta = false
// shasta default configuration
params.shasta_config = 'Nanopore-Oct2021'
// medaka model default configuration
params.medaka_model = 'r941_min_high_g360'
// genome size for canu and wtdbg2 and haslr
params.genome_size = ''
// Additional parameters for assemblers and quast
params.quast_additional_parameters = ''
params.canu_additional_parameters = ''
params.unicycler_additional_parameters = ''
params.flye_additional_parameters = ''
params.spades_additional_parameters = ''
params.shovill_additional_parameters = ''
params.haslr_additional_parameters = ''
params.raven_additional_parameters = ''
params.wtdbg2_additional_parameters = ''
params.shasta_additional_parameters = ''
// Long reads
params.corrected_long_reads = false
params.nanopolish_max_haplotypes = 1000
// Hybrid strategies default configuration
params.hybrid_strategy = 1
params.pilon_memory_limit = 50
/*
* Define log message
*/
logMessage()
/*
* Define custom workflows
*/
// misc
include { parse_samplesheet } from './workflows/parse_samples.nf'
include { ASSEMBLY_QC } from './workflows/assembly_qc.nf'
// Short reads only
include { SHORTREADS_ONLY } from './workflows/short-reads-only.nf'
// Long reads only
include { LONGREADS_ONLY } from './workflows/long-reads-only.nf'
// Hybrid
include { HYBRID } from './workflows/hybrid.nf'
/*
* DEFINE (RUN) MAIN WORKFLOW
*/
workflow {
// Message to user
println("""
Launching defined workflows!
By default, all workflows will appear in the console "log" message.
However, the processes of each workflow will be launched based on the inputs received.
You can see that processes that were not launched have an empty [- ].
""")
// with samplesheet?
if (params.input) {
// Load YAML
samplesheet_yaml = file(params.input)
parameter_yaml = samplesheet_yaml.readLines().join("\n")
new Yaml().load(parameter_yaml).each { k, v -> params[k] = v }
// Copy YAML samplesheet to output directory so user has a copy of it
file(params.output).mkdir()
samplesheet_yaml.copyTo(params.output + "/" + "${samplesheet_yaml.getName()}")
// Parse YAML file
parse_samplesheet(params.samplesheet)
// short reads only samples
SHORTREADS_ONLY(parse_samplesheet.out[0])
// long reads only samples
LONGREADS_ONLY(parse_samplesheet.out[1])
// hybrid samples
HYBRID(parse_samplesheet.out[2])
// QC
ASSEMBLY_QC(SHORTREADS_ONLY.out.mix(LONGREADS_ONLY.out, HYBRID.out))
} else {
// Message to user
println("""
ERROR!
A major error has occurred!
==> A samplesheet has not been provided. Please, provide a samplesheet to run the analysis. Online documentation is available at: https://mpgap.readthedocs.io/en/latest/
Please, read the docs.
Cheers.
""")
}
}
/*
* Completition message
*/
workflow.onComplete {
println "Pipeline completed at: $workflow.complete"
println "Execution status: ${ workflow.success ? 'OK' : 'failed' }"
println "Execution duration: $workflow.duration"
println ""
println "${ workflow.success ? 'I wish you nice results!' : 'Do not give up, we can fix it!' }"
println "${ workflow.success ? 'Thank you for using fmalmeida/mpgap pipeline!' : '' }"
println ""
}