-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
113 lines (94 loc) · 4.12 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
#!/usr/bin/env nextflow
/*
========================================================================================
HELP
========================================================================================
*/
def printHelp() {
log.info """
Usage:
nextflow run main.nf
Options:
--manifest Manifest containing paths to fastq files with headers ID,R1,R2. (mandatory)
--outdir Directory to store pipeline output. [default: ./results] (optional)
--skip_qc Skip metawrap qc step. [default: false] (optional)
--keep_allbins Keep allbins option for bin refinement.. [default: false] (optional)
--keep_assembly Don't cleanup assembly files. [default: false] (optional)
--keep_binning Don't cleanup binning files. [default: false] (optional)
--keep_bin_refinement Don't cleanup bin refinement files. [default: false] (optional)
--keep_reassembly Don't cleanup reassembly files. [default: false] (optional)
--keep_metawrap_qc Don't cleanup metawrap qc files. [default: false] (optional)
--skip_reassembly Skip reassembly step. [default: false] (optional)
--fastspades Use fastspades assembly option. [default: false] (optional)
--help Print this help message. (optional)
""".stripIndent()
}
if (params.help) {
printHelp()
exit 0
}
/*
========================================================================================
IMPORT MODULES/SUBWORKFLOWS
========================================================================================
*/
//
// MODULES
//
include { validate_parameters } from './modules/helper_functions.nf'
include { ASSEMBLY; BINNING; BIN_REFINEMENT; REASSEMBLE_BINS } from './modules/metawrap.nf'
include { CLEANUP_ASSEMBLY; CLEANUP_BINNING; CLEANUP_BIN_REFINEMENT; CLEANUP_REFINEMENT_REASSEMBLY;
CLEANUP_TRIMMED_FASTQ_FILES } from './modules/cleanup/cleanup.nf'
//
// SUBWORKFLOWS
//
include { METAWRAP_QC } from './subworkflows/metawrap_qc.nf'
/*
========================================================================================
VALIDATE INPUTS
========================================================================================
*/
validate_parameters()
/*
========================================================================================
RUN MAIN WORKFLOW
========================================================================================
*/
workflow {
manifest_ch = Channel.fromPath(params.manifest, checkIfExists: true)
fastq_path_ch = manifest_ch.splitCsv(header: true, sep: ',')
.map{ row -> tuple(row.ID, file(row.R1), file(row.R2)) }
if (params.skip_qc) {
ASSEMBLY(fastq_path_ch)
} else {
METAWRAP_QC(fastq_path_ch)
ASSEMBLY(METAWRAP_QC.out.filtered_reads)
}
BINNING(ASSEMBLY.out.fastq_path_ch, ASSEMBLY.out.assembly_ch)
if (params.skip_reassembly) {
BIN_REFINEMENT(BINNING.out.binning_ch, BINNING.out.fastq_path_ch)
} else {
BIN_REFINEMENT(BINNING.out.binning_ch, BINNING.out.fastq_path_ch)
REASSEMBLE_BINS(BIN_REFINEMENT.out.bin_refinement_ch, BIN_REFINEMENT.out.fastq_path_ch)
}
// cleanup
if (!params.keep_metawrap_qc && !params.skip_qc) {
if (params.skip_reassembly){
CLEANUP_TRIMMED_FASTQ_FILES(BIN_REFINEMENT.out.fastq_path_ch)
} else {
CLEANUP_TRIMMED_FASTQ_FILES(REASSEMBLE_BINS.out.fastq_path_ch)
}
}
if (!params.keep_assembly) {
CLEANUP_ASSEMBLY(BINNING.out.assembly_ch)
}
if (!params.keep_binning) {
CLEANUP_BINNING(BINNING.out.workdir, BIN_REFINEMENT.out.workdir)
}
if (!params.keep_bin_refinement && !params.keep_allbins && params.skip_reassembly) {
CLEANUP_BIN_REFINEMENT(BIN_REFINEMENT.out.workdir)
}
if (!params.keep_reassembly && !params.skip_reassembly && !params.keep_allbins) {
CLEANUP_REFINEMENT_REASSEMBLY(BIN_REFINEMENT.out.workdir, REASSEMBLE_BINS.out.workdir)
}
}