forked from epiliper/REVICA-STRM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
148 lines (125 loc) · 6.39 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
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
#!/usr/bin/env nextflow
/*
========================================================================================
REVICA
========================================================================================
Github Repo:
https://github.com/asereewit/revica
Author:
Jaydee Sereewit <aseree@uw.edu>
Alex L Greninger <agrening@uw.edu>
UW Medicine | Virology
Department of Laboratory Medicine and Pathology
University of Washington
LICENSE: GNU
----------------------------------------------------------------------------------------
*/
// if INPUT not set
if (params.input) { ch_input = file(params.input) } else { exit 1, 'Input samplesheet not specified!' }
// if db not set
if (!params.db) { exit 1, "Reference database not specified!"}
//
// SUBWORKFLOWS
//
include { INPUT_CHECK } from './subworkflows/input_check'
include { REFERENCE_PREP } from './subworkflows/reference_prep'
include { CONSENSUS_ASSEMBLY } from './subworkflows/consensus_assembly'
include { FINALIZE_OUTPUT } from './modules/finalize_output'
//
// MODULES
//
include { SEQTK_SAMPLE } from './modules/seqtk_sample'
include { SUMMARY } from './modules/summary'
include { KRAKEN2 } from './modules/kraken2'
include { FASTQ_TRIM_FASTP_MULTIQC } from './subworkflows/fastq_trim_fastp_multiqc.nf'
include { DELETE_TEMP_FILES } from './modules/delete_temp_files'
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
/* */
/* RUN THE WORKFLOW */
/* */
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
log.info " "
log.info " ██████╗ ███████╗██╗ ██╗██╗ ██████╗ █████╗ ███████╗████████╗██████╗ ███╗ ███╗ "
log.info " ██╔══██╗██╔════╝██║ ██║██║██╔════╝██╔══██╗ ██╔════╝╚══██╔══╝██╔══██╗████╗ ████║ "
log.info " ██████╔╝█████╗ ██║ ██║██║██║ ███████║█████╗███████╗ ██║ ██████╔╝██╔████╔██║ "
log.info " ██╔══██╗██╔══╝ ╚██╗ ██╔╝██║██║ ██╔══██║╚════╝╚════██║ ██║ ██╔══██╗██║╚██╔╝██║ "
log.info " ██║ ██║███████╗ ╚████╔╝ ██║╚██████╗██║ ██║ ███████║ ██║ ██║ ██║██║ ╚═╝ ██║ "
log.info " ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ "
log.info " "
workflow {
INPUT_CHECK (
ch_input
)
FASTQ_TRIM_FASTP_MULTIQC (
INPUT_CHECK.out.reads,
params.adapter_fasta,
params.save_trimmed_fail,
params.save_merged,
params.skip_fastp,
params.skip_fastqc
)
ch_sample_input = FASTQ_TRIM_FASTP_MULTIQC.out.reads
if (params.run_kraken2) {
KRAKEN2 (
FASTQ_TRIM_FASTP_MULTIQC.out.reads,
file(params.kraken2_db),
params.kraken2_variants_host_filter || params.kraken2_assembly_host_filter,
params.kraken2_variants_host_filter || params.kraken2_assembly_host_filter
)
if (params.kraken2_variants_host_filter) {
ch_sample_input = KRAKEN2.out.unclassified_reads_fastq
}
}
if (params.sample) {
SEQTK_SAMPLE (
ch_sample_input,
params.sample
)
ch_ref_prep_input = SEQTK_SAMPLE.out.reads
} else {
ch_ref_prep_input = ch_sample_input
}
if (!params.skip_consensus) {
REFERENCE_PREP (
ch_ref_prep_input,
file(params.db)
)
CONSENSUS_ASSEMBLY (
REFERENCE_PREP.out.reads,
REFERENCE_PREP.out.ref,
)
FASTQ_TRIM_FASTP_MULTIQC.out.trim_log
.combine(CONSENSUS_ASSEMBLY.out.final_consensus
.join(CONSENSUS_ASSEMBLY.out.bam, by: [0,1]), by: 0)
.map { meta, trim_log, ref_info, consensus, bam, bai -> [ meta, ref_info, trim_log, consensus, bam, bai ] }
.set { ch_summary_in }
SUMMARY (
ch_summary_in
)
SUMMARY.out.summary
.collectFile(storeDir: "${params.output}", name:"${params.run_name}_summary.tsv", keepHeader: true, sort: true)
SUMMARY.out.ready_to_concat
.collect()
.map { it -> true }
.set { all_summaries_done }
FINALIZE_OUTPUT(
CONSENSUS_ASSEMBLY.out.final_consensus.map { meta, ref_info, ref -> [ ref ] }.collect(),
CONSENSUS_ASSEMBLY.out.initial_consensus.map { meta, ref_info, ref -> [ ref ] }.collect(),
CONSENSUS_ASSEMBLY.out.bam.map { meta, ref_info, bam, bai -> [ bam ] }.collect(),
// .map { meta, final_ref_info, final_ref, init_ref_info, init_ref, bam , bai -> [ meta, final_ref, init_ref, bam ] }
ch_input,
// file("${params.output}").toAbsolutePath().toString(),
// file("${params.input}").toAbsolutePath().toString(),
all_summaries_done,
params.concat_flu
)
if (!params.save_temp_files) {
DELETE_TEMP_FILES(
FINALIZE_OUTPUT.out.done,
file("${params.output}").toAbsolutePath()
)
}
}
}