forked from nf-core/viralrecon
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.nf
More file actions
215 lines (187 loc) · 8.54 KB
/
main.nf
File metadata and controls
215 lines (187 loc) · 8.54 KB
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
205
206
207
208
209
210
211
212
213
214
215
#!/usr/bin/env nextflow
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nf-core/viralrecon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Github : https://github.com/nf-core/viralrecon
Website: https://nf-co.re/viralrecon
Slack : https://nfcore.slack.com/channels/viralrecon
----------------------------------------------------------------------------------------
*/
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GENOME PARAMETER VALUES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
def primer_set = ''
def primer_set_version = 0
// Make sure platform is defined
if( !params.platform ) {
error "Parameter --platform is required (illumina / nanopore). Please specify."
}
// Check that platform value is valid
def valid_platforms = ["illumina","nanopore"]
if( !(params.platform in valid_platforms) ) {
error "Invalid value for --platform: '${params.platform}'. Allowed values: ${valid_platforms.join(', ')}"
}
if (params.platform == 'illumina' && params.protocol == 'amplicon') {
primer_set = params.primer_set
primer_set_version = params.primer_set_version
} else if (params.platform == 'nanopore') {
primer_set = params.primer_set
primer_set_version = params.primer_set_version
params.artic_scheme = getGenomeAttribute('scheme', primer_set, primer_set_version)
}
def artic_scheme = params.platform == 'nanopore' ? params.artic_scheme : null
params.fasta = getGenomeAttribute('fasta')
params.gff = getGenomeAttribute('gff')
params.bowtie2_index = getGenomeAttribute('bowtie2')
params.primer_bed = getGenomeAttribute('primer_bed', primer_set, primer_set_version)
params.nextclade_dataset = getGenomeAttribute('nextclade_dataset_v3pl')
params.nextclade_dataset_name = getGenomeAttribute('nextclade_dataset_name')
params.nextclade_dataset_tag = getGenomeAttribute('nextclade_dataset_tag_v3pl')
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT FUNCTIONS / MODULES / SUBWORKFLOWS / WORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
include { VIRALRECON } from './workflows/viralrecon'
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_viralrecon_pipeline'
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_viralrecon_pipeline'
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NAMED WORKFLOWS FOR PIPELINE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
//
// WORKFLOW: Run main nf-core/viralrecon analysis pipeline depending on type of input
//
workflow NFCORE_VIRALRECON {
take:
samplesheet // channel: samplesheet read in from --input
main:
//
// WORKFLOW: Run pipeline
//
multiqc_report = Channel.empty()
VIRALRECON (
samplesheet,
params.fasta,
params.gff,
params.primer_bed,
params.bowtie2_index,
params.nextclade_dataset,
params.nextclade_dataset_name,
params.nextclade_dataset_tag,
artic_scheme
)
multiqc_report = VIRALRECON.out.multiqc_report
emit:
multiqc_report // channel: /path/to/multiqc_report.html
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
//
// WORKFLOW: Execute a single named workflow for the pipeline
// See: https://github.com/nf-core/rnaseq/issues/619
//
workflow {
main:
//
// SUBWORKFLOW: Run initialisation tasks
//
PIPELINE_INITIALISATION (
params.version,
params.validate_params,
params.monochrome_logs,
args,
params.outdir,
params.input,
params.help,
params.help_full,
params.show_hidden
)
//
// WORKFLOW: Run main workflow
//
NFCORE_VIRALRECON (
PIPELINE_INITIALISATION.out.samplesheet
)
//
// SUBWORKFLOW: Run completion tasks
//
PIPELINE_COMPLETION (
params.email,
params.email_on_fail,
params.plaintext_email,
params.outdir,
params.monochrome_logs,
params.hook_url,
NFCORE_VIRALRECON.out.multiqc_report
)
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FUNCTIONS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
def getGenomeAttribute(attribute, primer_set='', primer_set_version=0) {
def val = ''
def support_link = " The default genome config used by the pipeline can be found here:\n" +
" - https://github.com/nf-core/configs/blob/master/conf/pipeline/viralrecon/genomes.config\n\n" +
" If you would still like to blame us please come and find us on nf-core Slack:\n" +
" - https://nf-co.re/viralrecon#contributions-and-support\n" +
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
if (params.genomes && params.genome && params.genomes.containsKey(params.genome)) {
def genome_map = params.genomes[ params.genome ]
if (primer_set) {
if (genome_map.containsKey('primer_sets')) {
genome_map = genome_map[ 'primer_sets' ]
if (genome_map.containsKey(primer_set)) {
genome_map = genome_map[ primer_set ]
primer_set_version = primer_set_version.toString()
if (genome_map.containsKey(primer_set_version)) {
genome_map = genome_map[ primer_set_version ]
} else {
Nextflow.error("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" --primer_set_version '${primer_set_version}' not found!\n\n" +
" Currently, the available primer set version keys are: ${genome_map.keySet().join(", ")}\n\n" +
" Please check:\n" +
" - The value provided to --primer_set_version (currently '${primer_set_version}')\n" +
" - The value provided to --primer_set (currently '${primer_set}')\n" +
" - The value provided to --genome (currently '${params.genome}')\n" +
" - Any custom config files provided to the pipeline.\n\n" + support_link)
}
} else {
Nextflow.error("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" --primer_set '${primer_set}' not found!\n\n" +
" Currently, the available primer set keys are: ${genome_map.keySet().join(", ")}\n\n" +
" Please check:\n" +
" - The value provided to --primer_set (currently '${primer_set}')\n" +
" - The value provided to --genome (currently '${params.genome}')\n" +
" - Any custom config files provided to the pipeline.\n\n" + support_link)
}
} else {
Nextflow.error("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
" Genome '${params.genome}' does not contain any primer sets!\n\n" +
" Please check:\n" +
" - The value provided to --genome (currently '${params.genome}')\n" +
" - Any custom config files provided to the pipeline.\n\n" + support_link)
}
}
if (genome_map.containsKey(attribute)) {
val = genome_map[ attribute ]
} else if (params.genomes[ params.genome ].containsKey(attribute)) {
val = params.genomes[ params.genome ][ attribute ]
}
}
return val
}
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/