-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathmain.nf
More file actions
executable file
·580 lines (511 loc) · 28 KB
/
main.nf
File metadata and controls
executable file
·580 lines (511 loc) · 28 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
#!/usr/bin/env nextflow
/*
========================================================================================
CDCgov/phoenix
========================================================================================
Github : https://github.com/CDCgov/phoenix
Slack : https://staph-b-dev.slack.com/channels/phoenix-dev
----------------------------------------------------------------------------------------
*/
nextflow.enable.dsl = 2
// ANSI escape code for orange (bright yellow)
def orange = '\033[38;5;208m'
def red = '\033[1;31m' // Bright red
def reset = '\033[0m'
/*
========================================================================================
VALIDATE & PRINT PARAMETER SUMMARY
========================================================================================
*/
WorkflowMain.initialise(workflow, params, log)
//Check coverage is above its threshold
if (params.coverage.toInteger() < 30) { exit 1, 'The minimum coverage allowed for QA/QC purposes is 30 and is the default. Please choose a value >=30.' }
// Check for incorrect --output parameter
params.output = "" /// Initialise param so no warning is printed
if (params.output) { exit 1, "ERROR: Unknown parameter '--output'. Did you mean '--outdir'?" }
//comment out in v2.3.0 to run --centar
//if (params.centar == true) { exit 1, "Sorry, --centar available yet as it's validation isn't complete. It will be released with a newer version of phx in the future." }
// Access workflow metadata
if (params.pipeline != null) { exit 1, "--pipeline is not a parameter for phoenix, please use --mode." }
/*
========================================================================================
NAMED WORKFLOW FOR PIPELINE
========================================================================================
*/
include { PHOENIX_EXTERNAL } from './workflows/phoenix'
include { PHOENIX_EXQC } from './workflows/cdc_phoenix'
include { SCAFFOLDS_EXTERNAL } from './workflows/scaffolds'
include { SCAFFOLDS_EXQC } from './workflows/cdc_scaffolds'
include { SRA_PREP } from './workflows/sra_prep'
include { CLIA_INTERNAL } from './workflows/clia'
include { UPDATE_PHOENIX_WF } from './workflows/update_phoenix'
include { RUN_CENTAR } from './workflows/centar'
include { COMBINE_GRIPHINS_WF } from './workflows/combine_griphins'
//
// WORKFLOW: Run main cdcgov/phoenix analysis pipeline
//
workflow PHOENIX {
//Check path of kraken2db
if (params.kraken2db == null) { exit 1, 'Input path to kraken2db not specified! Use --kraken2db to tell PHoeNIx where to find the database.' }
// Validate input parameters
// Check input path parameters to see if they exist
def checkPathParamList = [ params.input, params.multiqc_config, params.kraken2db] //removed , params.fasta to stop issue w/connecting to aws and igenomes not used
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
// Check mandatory parameters
//input on command line
if (params.input) { ch_input = file(params.input) } else { exit 1, 'For --mode PHOENIX: Input samplesheet not specified!' }
if (params.input_sra != null ) { exit 1, 'For --mode PHOENIX: Input samplesheet not specified! --input_sra is for --mode SRA, did you mean to run that mode?' }
ch_versions = Channel.empty() // Used to collect the software versions
main:
PHOENIX_EXTERNAL ( ch_input, ch_versions, true, params.centar )
emit:
scaffolds = PHOENIX_EXTERNAL.out.scaffolds
trimmed_reads = PHOENIX_EXTERNAL.out.trimmed_reads
mlst = PHOENIX_EXTERNAL.out.mlst
amrfinder_output = PHOENIX_EXTERNAL.out.amrfinder_output
gamma_ar = PHOENIX_EXTERNAL.out.gamma_ar
phx_summary = PHOENIX_EXTERNAL.out.phx_summary
//output for phylophoenix
griphin_tsv = PHOENIX_EXTERNAL.out.griphin_tsv
griphin_excel = PHOENIX_EXTERNAL.out.griphin_excel
dir_samplesheet = PHOENIX_EXTERNAL.out.dir_samplesheet
//output for ncbi upload
ncbi_sra_sheet = params.create_ncbi_sheet ? PHOENIX_EXTERNAL.out.ncbi_sra_sheet : null
ncbi_biosample_sheet = params.create_ncbi_sheet ? PHOENIX_EXTERNAL.out.ncbi_biosample_sheet : null
}
//
// WORKFLOW: Run internal version of cdcgov/phoenix analysis pipeline that includes BUSCO, SRST2 and KRAKEN_ASMBLED
//
workflow CDC_PHOENIX {
//Check path of kraken2db
if (params.kraken2db == null) { exit 1, 'Input path to kraken2db not specified! Use --kraken2db to tell PHoeNIx where to find the database.' }
// Validate input parameters
// Check input path parameters to see if they exist
def checkPathParamList = [ params.input, params.multiqc_config, params.kraken2db]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
// Check mandatory parameters
//input on command line
if (params.input) { ch_input = file(params.input) } else { exit 1, 'For --mode CDC_PHOENIX: Input samplesheet not specified!' }
if (params.input_sra != null ) { exit 1, 'For --mode CDC_PHOENIX: Input samplesheet not specified! --input_sra is for --mode CDC_SRA, did you mean to run that mode?' }
ch_versions = Channel.empty() // Used to collect the software versions
main:
PHOENIX_EXQC ( ch_input, ch_versions, true, params.centar )
emit:
scaffolds = PHOENIX_EXQC.out.scaffolds
trimmed_reads = PHOENIX_EXQC.out.trimmed_reads
mlst = PHOENIX_EXQC.out.mlst
amrfinder_output = PHOENIX_EXQC.out.amrfinder_output
gamma_ar = PHOENIX_EXQC.out.gamma_ar
phx_summary = PHOENIX_EXQC.out.phx_summary
//output for phylophoenix
griphin_tsv = PHOENIX_EXQC.out.griphin_tsv
griphin_excel = PHOENIX_EXQC.out.griphin_excel
dir_samplesheet = PHOENIX_EXQC.out.dir_samplesheet
//output for ncbi upload
ncbi_sra_sheet = params.create_ncbi_sheet ? PHOENIX_EXQC.out.ncbi_sra_sheet : null
ncbi_biosample_sheet = params.create_ncbi_sheet ? PHOENIX_EXQC.out.ncbi_biosample_sheet : null
}
/*
========================================================================================
RUN SRA WORKFLOWS
========================================================================================
*/
//
// WORKFLOW: Run internal version of phx based on sample SRA names, these will be pulled from NCBI for you.
//
workflow SRA {
//Check path of kraken2db
if (params.kraken2db == null) { exit 1, 'Input path to kraken2db not specified! Use --kraken2db to tell PHoeNIx where to find the database.' }
// Validate input parameters
// Check input path parameters to see if they exist
def checkPathParamList = [ params.input_sra, params.multiqc_config, params.kraken2db ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
// Checking that --create_ncbi_sheet wasn't passed
if (params.create_ncbi_sheet) { exit 1, '--create_ncbi_sheet is not a valid argument for --mode SRA.' }
if (params.input != null) { exit 1, '--input is for --mode PHOENIX, did you mean to run that mode? Use --input_sra for --mode SRA' }
// Check mandatory parameters
//input on command line
if (params.input_sra) {
//create channel input
ch_input = file(params.input_sra)
//Check that SRR numbers are passed not SRX
if (ch_input) {
// Read the contents of the file
def sraNumbers = ch_input.text.readLines()
// Check each line in the file
for (sraNumber in sraNumbers) {
// Check if it starts with "SRR"
if (!sraNumber.startsWith("SRR") & !sraNumber.startsWith("ERR")) {
exit 1, "Invalid value in ${params.input_sra}. Only SRR numbers are allowed for --mode SRA, but found: $sraNumber"
}
}
}
} else { exit 1, 'For --mode SRA: Input samplesheet not specified! Make sure to use --input_sra NOT --input' }
main:
// pull data and create samplesheet for it.
SRA_PREP ( ch_input )
// pass samplesheet to PHOENIX
PHOENIX_EXTERNAL ( SRA_PREP.out.samplesheet, SRA_PREP.out.versions, false, params.centar )
emit:
scaffolds = PHOENIX_EXTERNAL.out.scaffolds
trimmed_reads = PHOENIX_EXTERNAL.out.trimmed_reads
mlst = PHOENIX_EXTERNAL.out.mlst
amrfinder_output = PHOENIX_EXTERNAL.out.amrfinder_output
gamma_ar = PHOENIX_EXTERNAL.out.gamma_ar
phx_summary = PHOENIX_EXTERNAL.out.phx_summary
//output for phylophoenix
griphin_tsv = PHOENIX_EXTERNAL.out.griphin_tsv
griphin_excel = PHOENIX_EXTERNAL.out.griphin_excel
dir_samplesheet = PHOENIX_EXTERNAL.out.dir_samplesheet
}
//
// WORKFLOW: Run cdc version of phx based on sample SRA names, the fastq will be pulled from NCBI for you.
//
workflow CDC_SRA {
//Check path of kraken2db
if (params.kraken2db == null) { exit 1, 'Input path to kraken2db not specified! Use --kraken2db to tell PHoeNIx where to find the database.' }
// Validate input parameters
// Check input path parameters to see if they exist
def checkPathParamList = [ params.input_sra, params.multiqc_config, params.kraken2db]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
// Checking that --create_ncbi_sheet wasn't passed
if (params.create_ncbi_sheet) { exit 1, '--create_ncbi_sheet is not a valid argument for --mode CDC_SRA.' }
if (params.input != null) { exit 1, '--input is for --mode CDC_PHOENIX, did you mean to run that mode? Use --input_sra for --mode CDC_SRA' }
// Check mandatory parameters
//input on command line
if (params.input_sra) {
//create channel input
ch_input = file(params.input_sra)
//Check that SRR numbers are passed not SRX
if (ch_input) {
// Read the contents of the file
def sraNumbers = ch_input.text.readLines()
// Check each line in the file
for (sraNumber in sraNumbers) {
// Check if it starts with "SRR"
if (!sraNumber.startsWith("SRR") & !sraNumber.startsWith("ERR")) {
exit 1, "Invalid value in ${params.input_sra}. Only SRR numbers are allowed for --mode CDC_SRA, but found: $sraNumber"
}
}
}
} else { exit 1, 'For --mode CDC_SRA: Input samplesheet not specified! Make sure to use --input_sra NOT --input' }
main:
// pull data and create samplesheet for it.
SRA_PREP ( ch_input )
// pass samplesheet to PHOENIX
PHOENIX_EXQC ( SRA_PREP.out.samplesheet, SRA_PREP.out.versions, false, params.centar )
emit:
scaffolds = PHOENIX_EXQC.out.scaffolds
trimmed_reads = PHOENIX_EXQC.out.trimmed_reads
mlst = PHOENIX_EXQC.out.mlst
amrfinder_output = PHOENIX_EXQC.out.amrfinder_output
gamma_ar = PHOENIX_EXQC.out.gamma_ar
phx_summary = PHOENIX_EXQC.out.phx_summary
//output for phylophoenix
griphin_tsv = PHOENIX_EXQC.out.griphin_tsv
griphin_excel = PHOENIX_EXQC.out.griphin_excel
dir_samplesheet = PHOENIX_EXQC.out.dir_samplesheet
}
/*
========================================================================================
RUN SCAFFOLD WORKFLOWS
========================================================================================
*/
//
// WORKFLOW: Entry point to analyze scaffold file(s) and run everything after Spades
//
workflow SCAFFOLDS {
//Check path of kraken2db
if (params.kraken2db == null) { exit 1, 'Input path to kraken2db not specified! Use --kraken2db to tell PHoeNIx where to find the database.' }
// Checking that --create_ncbi_sheet wasn't passed
if (params.create_ncbi_sheet) { exit 1, '--create_ncbi_sheet is not a valid argument for --mode SCAFFOLDS.' }
// Validate input parameters
// Check input path parameters to see if they exist
if (params.input != null ) { // if a samplesheet is passed
if (params.indir != null ) { //if samplesheet is passed and an input directory exit
exit 1, 'For --mode SCAFFOLDS: You need EITHER an input samplesheet or a directory! Just pick one.'
} else { // if only samplesheet is passed check to make sure input is an actual file
def checkPathParamList = [ params.input, params.multiqc_config, params.kraken2db ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
ch_input_indir = null //keep input directory null if not passed
// get full path for input and make channel
if (params.input) { ch_input = file(params.input) }
}
} else {
if (params.indir != null ) { // if no samplesheet is passed, but an input directory is given
ch_input = null //keep samplesheet input null if not passed
def checkPathParamList = [ params.indir, params.multiqc_config, params.kraken2db ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
ch_input_indir = Channel.fromPath(params.indir, relative: true)
} else { // if no samplesheet is passed and no input directory is given
exit 1, 'For --mode SCAFFOLDS: You need EITHER an input samplesheet or a directory!'
}
}
main:
SCAFFOLDS_EXTERNAL ( ch_input, ch_input_indir, params.centar )
emit:
scaffolds = SCAFFOLDS_EXTERNAL.out.scaffolds
mlst = SCAFFOLDS_EXTERNAL.out.mlst
amrfinder_output = SCAFFOLDS_EXTERNAL.out.amrfinder_output
gamma_ar = SCAFFOLDS_EXTERNAL.out.gamma_ar
phx_summary = SCAFFOLDS_EXTERNAL.out.phx_summary
}
//
// WORKFLOW: Entry point to analyze scaffold file(s) and run everything after Spades
//
workflow CDC_SCAFFOLDS {
//Check path of kraken2db
if (params.kraken2db == null) { exit 1, 'Input path to kraken2db not specified! Use --kraken2db to tell PHoeNIx where to find the database.' }
// Checking that --create_ncbi_sheet wasn't passed
if (params.create_ncbi_sheet) { exit 1, '--create_ncbi_sheet is not a valid argument for --mode CDC_SCAFFOLDS.' }
// Validate input parameters
// Check input path parameters to see if they exist
if (params.input != null ) { // if a samplesheet is passed
// allow input to be relative
//input_samplesheet_path = Channel.fromPath(params.input, relative: true)
if (params.indir != null ) { //if samplesheet is passed and an input directory exit
exit 1, 'For --mode CDC_SCAFFOLDS: You need EITHER an input samplesheet or a directory! Just pick one.'
} else { // if only samplesheet is passed check to make sure input is an actual file
def checkPathParamList = [ params.input, params.multiqc_config, params.kraken2db ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
ch_input_indir = null //keep input directory null if not passed
// get full path for input and make channel
if (params.input) { ch_input = file(params.input) }
}
} else {
if (params.indir != null ) { // if no samplesheet is passed, but an input directory is given
ch_input = null //keep samplesheet input null if not passed
def checkPathParamList = [ params.indir, params.multiqc_config, params.kraken2db ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
ch_input_indir = Channel.fromPath(params.indir, relative: true)
} else { // if no samplesheet is passed and no input directory is given
exit 1, 'For --mode CDC_SCAFFOLDS: You need EITHER an input samplesheet or a directory!'
}
}
main:
SCAFFOLDS_EXQC ( ch_input, ch_input_indir, params.centar )
emit:
scaffolds = SCAFFOLDS_EXQC.out.scaffolds
mlst = SCAFFOLDS_EXQC.out.mlst
amrfinder_output = SCAFFOLDS_EXQC.out.amrfinder_output
gamma_ar = SCAFFOLDS_EXQC.out.gamma_ar
phx_summary = SCAFFOLDS_EXQC.out.phx_summary
}
//
// WORKFLOW: Entry point for CLIA analysis
//
workflow CLIA {
//Check path of kraken2db
if (params.kraken2db == null) { exit 1, 'Input path to kraken2db not specified! Use --kraken2db to tell PHoeNIx where to find the database.' }
// Checking that --create_ncbi_sheet wasn't passed
if (params.create_ncbi_sheet) { exit 1, '--create_ncbi_sheet is not a valid argument for --mode CLIA.' }
//Check that SRR numbers are passed no SRX
if (params.create_ncbi_sheet) {
// Read the contents of the file
def sraNumbers = file(params.create_ncbi_sheet).text.readLines()
// Check each line in the file
for (sraNumber in sraNumbers) {
// Check if it starts with "SRR"
if (!sraNumber.startsWith("SRR")) {
exit 1, "Invalid value in ${params.create_ncbi_sheet}. Only SRR numbers are allowed, but found: $sraNumber"
}
}
}
// Validate input parameters
// Check input path parameters to see if they exist
def checkPathParamList = [ params.input, params.multiqc_config, params.kraken2db]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
// Check mandatory parameters
//input on command line
if (params.input) { ch_input = file(params.input) } else { exit 1, 'For --mode CLIA: Input samplesheet not specified!' }
ch_versions = Channel.empty() // Used to collect the software versions
// ; means do nothing as that is correct
if (params.busco_db_path != null) { ; } else { exit 1, 'For --mode CLIA, BUSCO online mode is not allowed, please pass a path to --busco_db_path!' }
main:
CLIA_INTERNAL ( ch_input, ch_versions )
}
/*
========================================================================================
RUN PHX Utilities WORKFLOWS
========================================================================================
*/
//
// WORKFLOW: Entry point for updating phoenix mlst and ar output
//
workflow UPDATE_PHOENIX {
//Regardless of what is passed outdir needs to be the same as the input dir
//if you don't pass outdir then the indir
//if (params.outdir == "${launchDir}/phx_output" ) { params.outdir = params.indir } else { println("You didn't specify an outdir so phx assumes its the same as the indir.") }
// check config file
if (!workflow.configFiles) {
error "The -c parameter (configuration file) is missing. If you don't pass this then the default databases for this version of phoenix will be used."
}
// Check mandatory parameters
ch_versions = Channel.empty() // Used to collect the software versions
// Check input path parameters to see if they exist
if (params.input != null ) { // if a samplesheet is passed
//input_samplesheet_path = Channel.fromPath(params.input, relative: true)
if (params.indir != null ) { //if samplesheet is passed and an input directory exit
exit 1, 'For --mode UPDATE_CDC_PHOENIX: You need EITHER an input samplesheet or a directory! Just pick one.'
} else { // if only samplesheet is passed check to make sure input is an actual file
def checkPathParamList = [ params.input, params.multiqc_config ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
ch_input_indir = null //keep input directory null if not passed
// get full path for input and make channel
if (params.input) { ch_input = file(params.input) }
}
} else {
if (params.indir != null ) { // if no samplesheet is passed, but an input directory is given
ch_input = null //keep samplesheet input null if not passed
def checkPathParamList = [ params.indir, params.multiqc_config ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
ch_input_indir = Channel.fromPath(params.indir, relative: true, type: 'dir')
} else { // if no samplesheet is passed and no input directory is given
exit 1, 'For --mode UPDATE_CDC_PHOENIX: You need EITHER an input samplesheet or a directory!'
}
}
main:
UPDATE_PHOENIX_WF ( ch_input, ch_input_indir, ch_versions )
emit:
mlst = UPDATE_PHOENIX_WF.out.mlst
amrfinder_output = UPDATE_PHOENIX_WF.out.amrfinder_output
gamma_ar = UPDATE_PHOENIX_WF.out.gamma_ar
phx_summary = UPDATE_PHOENIX_WF.out.phx_summary
//output for phylophoenix
griphin_tsv = UPDATE_PHOENIX_WF.out.griphin_tsv
griphin_excel = UPDATE_PHOENIX_WF.out.griphin_excel
}
//
// WORKFLOW: Entry point for combining multiple griphin files
//
workflow COMBINE_GRIPHINS {
// Check mandatory parameters
ch_versions = Channel.empty() // Used to collect the software versions
// Check input path parameters to see if they exist
if (params.input != null ) { // if a samplesheet is passed
//input_samplesheet_path = Channel.fromPath(params.input, relative: true)
if (params.indir != null ) { //if samplesheet is passed and an input directory exit
exit 1, 'For --mode COMBINE_GRIPHINS: --indir is not a valid parameter, please pass a samplesheet and with --input.'
} else { // if only samplesheet is passed check to make sure input is an actual file
def checkPathParamList = [ params.input, params.multiqc_config ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
// get full path for input and make channel
if (params.input) { ch_input = file(params.input) }
//check outdir
if (params.outdir == "${launchDir}/phx_output" ) {
println("${orange}Warning: No outdir was passed, combined griphin file will be saved to the default ${launchDir}/phx_output.${reset}")
} else {
// Allow outdir to be relative
outdir = Channel.fromPath(params.outdir, relative: true)
}
}
} else {
exit 1, 'For --mode COMBINE_GRIPHINS: --indir is not a valid parameter, please pass a samplesheet and with --input.'
}
//no griphins to start - they should be in the input samplesheet
//input_griphins_ch = null
//input_griphins_tsv_ch = null
main:
COMBINE_GRIPHINS_WF ( ch_input, ch_versions )
}
/*
========================================================================================
RUN Species specific WORKFLOWS - waiting for completed validation to be released with v2.3.0
========================================================================================
*/
//
// WORKFLOW: Entry point for running C. diff specific pipeline as standalone
//
workflow CENTAR {
// Check mandatory parameters
ch_versions = Channel.empty() // Used to collect the software versions
// Check input path parameters to see if they exist
if (params.input != null ) { // if a samplesheet is passed
if (params.indir != null ) { //if samplesheet is passed and an input directory exit
exit 1, 'For --mode RUN_CENTAR: You need EITHER an input samplesheet or a directory! Just pick one.'
} else { // if only samplesheet is passed check to make sure input is an actual file
def checkPathParamList = [ params.input, params.multiqc_config ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
ch_input_indir = null //keep input directory null if not passed
// get full path for input and make channel
if (params.input) { ch_input = file(params.input) }
// Allow outdir to be relative !!!! Does this need to be changed if outdir is empty??
outdir = Channel.fromPath(params.outdir, relative: true)
//griph_out = Channel.fromPath(params.griphin_out, relative: true)
}
} else {
if (params.indir != null ) { // if no samplesheet is passed, but an input directory is given
ch_input = null //keep samplesheet input null if not passed
def checkPathParamList = [ params.indir, params.multiqc_config ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
//make sure a directory is passed
if (new File(params.indir).isDirectory()){
ch_input_indir = Channel.fromPath(params.indir, relative: true)
} else {
exit 1, 'You passed a file with --indir and a directory is required. Or use --input'
}
if (params.outdir == "${launchDir}/phx_output" ) {
outdir = params.indir
println("${orange}Warning: No outdir was passed, so CENTAR files will be saved to the indir ${outdir}.${reset}")
} else {
// Allow outdir to be relative
outdir = Channel.fromPath(params.outdir, relative: true)
//griph_out = Channel.fromPath(params.griphin_out, relative: true)
}
} else { // if no samplesheet is passed and no input directory is given
exit 1, 'For --mode CENTAR: You need EITHER an input samplesheet or a directory!'
}
}
//make sure outdir and griphin_out aren't passed at the same time
if (params.griphin_out != "${launchDir}" && params.outdir != "${launchDir}/phx_output"){
exit 1, "When using --outdir with CENTAR you can't use --griphin_out as --outdir directs all CENTAR and GRiPHin summary files to outdir. Please rerun with only one of these parameters."
}
// check if the wgmlst_container was passed
if (params.wgmlst_container == null) { println("${orange}Warning: No path was passed for --wgmlst_container so ribotyping will not be reported.${reset}") }
main:
RUN_CENTAR ( ch_input, ch_input_indir, ch_versions, outdir )
emit:
//output for phylophoenix
griphins_excel = RUN_CENTAR.out.griphins_excel
}
/*
========================================================================================
Setting up profiles
========================================================================================
*/
//
// WORKFLOW: Execute a single named workflow for the pipeline
//
workflow {
if(params.mode_upper == "PHOENIX") {
PHOENIX()
} else if(params.mode_upper == "CDC_PHOENIX") {
CDC_PHOENIX()
} else if(params.mode_upper == "SRA") {
SRA()
} else if(params.mode_upper == "CDC_SRA") {
CDC_SRA()
} else if(params.mode_upper == "SCAFFOLDS") {
SCAFFOLDS()
} else if(params.mode_upper == "CDC_SCAFFOLDS") {
CDC_SCAFFOLDS()
} else if(params.mode_upper == "UPDATE_PHOENIX") {
UPDATE_PHOENIX()
} else if(params.mode_upper == "CLIA") {
CLIA()
println("${red}WARNING: While this pipeline is undergoing CLIA validation at CDC, other users MUST conduct their own validation of this workflow and obtain explicit approval from THEIR CLIA director before considering it CLIA certified. Using this pipeline and reporting it's results to the patient, their care provider, or placed in the patient's medical record without proper validation may violate regulatory requirements.${reset}")
} else if(params.mode_upper == "COMBINE_GRIPHINS") {
COMBINE_GRIPHINS()
} else if(params.mode_upper == "CENTAR") {
CENTAR()
// comment out to run CENTAR
//exit 1, "Sorry, --mode CENTAR hasn't completed its validation yet and will be released in another version of PHoeNIx!"
} else {
exit 1, 'Please select a pipeline to run either: PHOENIX, CDC_PHOENIX, SCAFFOLDS, CDC_SCAFFOLDS, SRA, CDC_SRA, UPDATE_PHOENIX and COMBINE_GRIPHINS'
}
}
/*
========================================================================================
THE END
========================================================================================
*/