-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.nf
98 lines (81 loc) · 2.63 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
/*
* An assembly pipeline in Nextflow DSL2
* -----------------------------------------
import java.nio.file.*
== V6 ==
Added MLST support
and optional assembler (Unicycler)
*/
/*
* Input parameters
*/
include { validateParameters; paramsHelp; paramsSummaryLog; fromSamplesheet } from 'plugin/nf-validation'
include { make_input } from './lib/utils'
/*
Import processes from external files
It is common to name processes with UPPERCASE strings, to make
the program more readable (this is of course not mandatory)
*/
include { FASTP; SUBSAMPLE; MULTIQC; QUAST } from './modules/qc'
include { SHOVILL; UNICYCLER } from './modules/assembly'
include { ABRICATE; ABRICATE_SUMMARY } from './modules/annotation'
include { MLST; MLST_SUMMARY } from './modules/annotation'
include { PROKKA } from './modules/annotation'
/*
* DSL2 allows to reuse channels
*/
// reads = Channel
// .fromFilePairs(params.reads, checkIfExists: true)
reads = make_input(params.reads)
reads.view()
// Print help message, supply typical command line usage for the pipeline
if (params.help) {
log.info paramsHelp("nextflow quadram-institute-bioscience/nextflow-example --input input_file.csv")
exit 0
}
// Validate input parameters
validateParameters()
// Print summary of supplied parameters
log.info paramsSummaryLog(workflow)
workflow {
ch_multiqc = Channel.empty()
if (!params.skip_subsample) {
SUBSAMPLE( reads )
ch_fastp = SUBSAMPLE.out
} else {
ch_fastp = reads
}
if (!params.skip_qc) {
FASTP( ch_fastp )
ch_fastp_reads = FASTP.out.reads
ch_multiqc = ch_multiqc.mix(FASTP.out.json).ifEmpty([])
} else {
ch_fastp_reads = ch_fastp
}
if (params.unicycler) {
CONTIGS = UNICYCLER( ch_fastp_reads )
} else {
CONTIGS = SHOVILL( ch_fastp_reads )
}
// AMR
if (!params.skip_amr) {
ABRICATE( CONTIGS )
ABRICATE_SUMMARY( ABRICATE.out.map{it -> it[1]}.collect() )
ch_multiqc = ch_multiqc.mix( ABRICATE_SUMMARY.out.multiqc ).ifEmpty([])
}
// Annotation
if (!params.skip_prokka) {
PROKKA( CONTIGS )
ch_multiqc = ch_multiqc.mix( PROKKA.out ).ifEmpty([])
}
// QUAST requires all the contigs to be in the same directory
QUAST( CONTIGS.map{it -> it[1]}.collect() )
ch_multiqc = ch_multiqc.mix( QUAST.out ).ifEmpty([])
if (!params.skip_mlst) {
MLST( CONTIGS.map{it -> it[1]}.collect() )
MLST_SUMMARY( MLST.out.tab )
ch_multiqc = ch_multiqc.mix( MLST_SUMMARY.out ).ifEmpty([])
}
// Collect all the relevant file for MultiQC
MULTIQC( ch_multiqc.collect() )
}