-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
183 lines (145 loc) · 9.09 KB
/
Copy pathmain.nf
File metadata and controls
183 lines (145 loc) · 9.09 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
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
/*
========================================================================================
H U G T i P - H I V - 1 . n f
========================================================================================
A Nextflow pipeline for analysis of NGS-based HIV Drug resitance data
based on the QuasiFlow workflow
----------------------------------------------------------------------------------------
*/
/*
IMPORT MODULES
*/
include { runTrimFiltReads } from './modules/runTrimFiltReads.nf'
include { runfastQC } from './modules/runfastQC.nf'
include { getReadStats } from './modules/getReadStats.nf'
include { runMultiQC } from './modules/runMultiQC.nf'
include { runHydra } from './modules/runHydra.nf'
include { runSierralocal } from './modules/runSierralocal.nf'
include { renderReport } from './modules/renderReport.nf'
include { getVersions } from './modules/getVersions.nf'
//include { runJoinStats } from './modules/joinStats.nf'
/*
······································································································
REQUIRED ARGUMENTS
······································································································
*/
def helpMessage() {
log.info"""
============================================================
HUGTiP-HIV-1.nf ~ version ${params.version}
============================================================
Usage:
The typical command for running the pipeline is as follows:
nextflow run HUGTiP-HIV-1.nf/main.nf --samplesheet <samplesheet> --runID <name of run>
Mandatory arguments:
--name [chr] Name of the run.
--samplesheet [chr] Path to input data samplesheet (must be a csv with 4 columns: sampleID,forward,reverse,type)
sampleID - name of sample
forward/reverse - complete paths to the read files
type - sample or control.
HyDRA arguments (optional):
--mutation_db [chr] Path to mutational database.
--reporting_threshold [num] Minimum mutation frequency percent to report (default: 1).
--consensus_pct [num] Minimum percentage a base needs to be incorporated into the consensus sequence (default: 20).
--min_read_qual [num] Minimum quality for a position in a read to be masked (default: 30).
--length_cutoff [num] Reads which fall short of the specified length will be filtered out (default: 50).
--score_cutoff [num] Reads that have a median or mean quality score (depending on the score type specified) less than the score cutoff value will be filtered out (default: 30).
--min_variant_qual [num] Minimum quality for variant to be considered later on in the pipeline (default: 30).
--min_dp [num] Minimum required read depth for variant to be considered later on in the pipeline (default: 100).
--min_ac [num] The minimum required allele count for variant to be considered later on in the pipeline (default: 5).
--min_freq [num] The minimum required frequency for mutation to be considered in drug resistance report (default: 0.2).
Sierralocal arguments (optional):
--xml Path to HIVdb ASI2 XML.
--apobec-tsv Path to tab-delimited (tsv) HIVdb APOBEC DRM file.
--comments-tsv Path to tab-delimited (tsv) HIVdb comments file.
""".stripIndent()
}
/*
······································································································
WORKFLOW: main
······································································································
*/
workflow {
def color_purple = '\u001B[35m'
def color_green = '\u001B[32m'
def color_red = '\u001B[31m'
def color_reset = '\u001B[0m'
def color_cyan = '\u001B[36m'
// Create channel from sample sheet
if (params.samplesheet == null) {
error "Please provide a samplesheet CSV file with --samplesheet (csv)"
}
// Create channel from sample sheet
if (params.runID == null) {
error "Please provide a runID file with --runID (chr)"
}
if (params.outdir == null) {
error "Please provide a runID file with --name (chr)"
}
if (params.workDir == null) {
error "Please provide a runID file with --name (chr)"
}
/*
······································································································
CREATION OF CHANNELS
The section creates the samples_ch and the controls_ch from the samplesheet. First the
sample sheet is imported and split by the 'type' column into sample or control, and these
two sets of samples are directed into seperate workflows.
······································································································
*/
Channel.fromPath(params.samplesheet)
.splitCsv(header: true, sep: ',')
.map { row ->
def requiredColumns = ['sampleID', 'forward', 'reverse', 'type']
def missingColumns = requiredColumns.findAll { !row.containsKey(it) }
if (missingColumns) {
error "Missing required column(s) in samplesheet: ${missingColumns.join(', ')}"
}
tuple(row.sampleID.trim(),
file(row.forward.trim(), checkIfExists: true),
file(row.reverse.trim(), checkIfExists: true),
row.type.trim()
)
}
.branch {
sample: it[3] == 'sample'
control: it[3] == 'control'
}
.set { branched_samples_by_type }
samples_ch = branched_samples_by_type.sample
controls_ch = branched_samples_by_type.control
/*
······································································································
MAIN WORKFLOW
······································································································
*/
// Produce version control files
getVersions( params.runID )
// Run TimGalore on the reads
runTrimFiltReads( params.runID, samples_ch )
// Run FastQC
//runfastQC( params.runID, runTrimFiltReads.out.trimmed_reads_ch )
// Collect all the samples for running MultiQC
// multiqc_zips = runfastQC.out.fastqc_zips.collect()
// multiqc_htmls = runfastQC.out.fastqc_htmls.collect()
getReadStats( params.runID,
runTrimFiltReads.out.trimmed_reads_ch )
// Run MultiQC
//runMultiQC( params.runID, multiqc_zips, multiqc_htmls )
// Run Hydra on the reads
runHydra( params.runID, runTrimFiltReads.out.trimmed_reads_ch )
// Run SierraLocal on the reads
runSierralocal( params.runID, runHydra.out.cns_sequence )
// Merge the channels for the final_report_ch
merged_reports_ch = getReadStats.out.report_ch
.join(runHydra.out.report_ch)
.join(runSierralocal.out.report_ch)
//runJoinStats( params.runID,
// merged_reports_ch )
// Render the HTML output
renderReport( params.runID,
getVersions.out.versions,
merged_reports_ch )
}