-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.nf
More file actions
109 lines (89 loc) · 3.9 KB
/
main.nf
File metadata and controls
109 lines (89 loc) · 3.9 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
// check args
if (params.input) { ch_input = file(params.input) } else { exit 1, 'No samplesheet specified!' }
if (!params.refs || !file(params.refs).exists()) { exit 1, "Invalid path specified: reference genome multifasta (--ref) " }
if (!params.kraken2_db || !file(params.kraken2_db).exists()) {exit 1, "Invalid path specified: kraken2 database (--kraken2_db)" }
if (!params.taxids || !file(params.taxids).exists()) {exit 1, "Invalid path specified: taxon ID TSV (--taxids)" }
if (params.host_kraken2_db && !file(params.host_kraken2_db).exists()) { exit 1, "unable to find kraken host db (--host_kraken2_db)"}
// Import subworkflows
include { INPUT_CHECK } from './subworkflows/input_check'
include { FASTP_MULTIQC } from './subworkflows/fastp_multiqc'
include { PROFILE_READS } from './subworkflows/profile_reads'
include { CONTIG_GEN } from './subworkflows/contig_gen'
include { CONSENSUS_ASSEMBLY } from './subworkflows/consensus_assembly'
include { REMOVE_HOST } from './subworkflows/remove_host'
// Import modules
include { KRAKEN2 } from './modules/kraken2'
include { SUBSAMPLE_FASTQ } from './modules/subsample'
include { SUMMARY } from './modules/summary'
log.info("`7MM===Yb. `7MMF' `7MF'db `7MM===Mq. db ")
log.info(" MM `Yb. `MA ,V MM `MM. ;MM: ")
log.info(" MM `Mb .gP=Ya VM: ,V `7MM MM ,M9 ,V^MM. ")
log.info(" MM MM ,M' Yb MM. M' MM MMmmdM9 ,M `MM ")
log.info(" MM ,MP 8M====== `MM A' MM MM YM. AbmmmqMA ")
log.info(" MM ,dP' YM. , :MM; MM MM `Mb. A' VML ")
log.info(".JMMmmmdP' `Mbmmd' VF .JMML..JMML. .JMM..AMA. .AMMA.\n\n")
workflow {
INPUT_CHECK (
ch_input
)
inreads = INPUT_CHECK.out.reads
if (params.subsample_raw) {
SUBSAMPLE_FASTQ(
inreads,
params.subsample_raw
)
inreads = SUBSAMPLE_FASTQ.out.reads
}
FASTP_MULTIQC (
inreads,
params.adapter_fasta,
params.save_merged,
params.skip_fastp,
params.skip_multiqc
)
ch_sample_input = FASTP_MULTIQC.out.reads
if (params.host_kraken2_db) {
REMOVE_HOST(
ch_sample_input,
file(params.host_kraken2_db)
)
ch_sample_input = REMOVE_HOST.out.reads
}
PROFILE_READS(
ch_sample_input,
file(params.kraken2_db),
file(params.taxids)
)
ch_sample_input = PROFILE_READS.out.profiled_reads
CONTIG_GEN(
ch_sample_input,
params.contig_method,
file(params.refs),
params.min_contig_length
)
CONSENSUS_ASSEMBLY(
CONTIG_GEN.out.contigs,
CONTIG_GEN.out.reads,
)
FASTP_MULTIQC.out.trim_log
.combine(
CONTIG_GEN.out.contigs,
by: 0)
.map { meta, log, tax_info, ref_info, contigs -> [ meta, tax_info, ref_info, log, contigs ] }
.set { contig_sum_ch }
// [ meta, tax_info, log, contigs, n50, consensus, init_covstats, final_covstats]
ch_summary_in = contig_sum_ch
.join(
CONTIG_GEN.out.contig_stats
.join(CONSENSUS_ASSEMBLY.out.final_consensus, by: [0, 1, 2])
.join(CONSENSUS_ASSEMBLY.out.init_covstats, by: [0, 1, 2])
.join(CONSENSUS_ASSEMBLY.out.final_covstats, by: [0, 1, 2]),
by: [0, 1, 2])
.map { meta, tax_info, ref_info, log, contigs, contig_stats, consensus, init_covstats, final_covstats ->
[ meta, tax_info, ref_info, log, contigs, contig_stats, consensus, init_covstats, final_covstats ] }
SUMMARY(
ch_summary_in
)
SUMMARY.out.summary
.collectFile(storeDir: "${params.output}", name:"${params.run_name}_summary.tsv", keepHeader: true, sort: {file -> file.name })
}