-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
224 lines (186 loc) · 5.37 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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
line="=".multiply(100)
ver="ont-tools:v0.0.1"
params.help = null
params.input_dir = null
params.genome_chl = null
params.genome_nuc = null
params.genes = null
params.phred_score = 7
params.output_dir = "results"
params.workflow = "concatenate"
//--------------------------------------------------------------------------------------------------------
// Validation
include { validateParameters; paramsHelp; paramsSummaryLog; fromSamplesheet } from 'plugin/nf-validation'
if (params.help) {
log.info paramsHelp("nextflow run ./main.nf ...")
exit 0
}
// Validate input parameters
validateParameters()
// Print summary of supplied parameters
log.info paramsSummaryLog(workflow)
workflow_input = params.workflow
switch (workflow_input) {
case ["concatenate"]:
include { concat_barcoded } from './modules/module_manage_files.nf'
barcodes = params.input_dir
barcodes = Channel.fromPath("${barcodes}", type:'dir', checkIfExists: true)
.map {[ it.name, it ]}
break;
case ["reads-qc", "reads-filter"]:
include { run_fastqc; run_multiqc_reads; get_stats_reads } from './modules/module_reads_qc.nf'
include { filter_reads } from './modules/module_reads_filtering.nf'
reads = params.input_dir
phred = params.phred_score
reads = Channel.fromPath("${reads}", checkIfExists: true)
.map {[ it.simpleName, it ]}
break;
case ["chloroplast-contamination"]:
include { minimap_mapping_chlo } from './modules/module_reads_mapping.nf'
include { stats_mapping ; run_multiqc_stats } from './modules/module_mapping_stats.nf'
reads = params.input_dir
genome_chl = file(params.genome_chl)
reads = Channel.fromPath("${reads}", checkIfExists: true)
.map {[ it.simpleName, it ]}
break;
case ["genome-mapping", "genome-mapping-large"]:
include { minimap_mapping; minimap_mapping_large; minimap_create_index } from './modules/module_reads_mapping.nf'
include { stats_mapping ; run_multiqc_stats } from './modules/module_mapping_stats.nf'
include { run_feature_counts } from './modules/module_reads_counts.nf'
genome = file(params.genome_nuc)
genes = file(params.genes)
reads = params.input_dir
genome = Channel.fromPath("${genome}", checkIfExists: true)
.map {[ it.simpleName, it ]}
reads = Channel.fromPath("${reads}", checkIfExists: true)
.map {[ it.simpleName, it ]}
break;
}
workflow CONCAT_BARCODES {
take:
barcodes
main:
concat_barcoded(barcodes)
}
workflow READS_QC {
take:
reads
main:
run_fastqc(reads)
run_fastqc.out.qc_html
.map { it -> it[1] }
.collect()
.set { fastqc_out }
run_multiqc_reads(fastqc_out)
reads.map { it -> it[1] }
.collect()
.set { allreads }
get_stats_reads(allreads)
}
workflow READS_FILTER {
take:
reads
phred
main:
filter_reads(reads, phred)
}
workflow CHLO_CONTAMINATION {
take:
genome_chl
reads
main:
mapped_out = minimap_mapping_chlo(genome_chl, reads)
stats_out = stats_mapping(mapped_out.minimap_align_chlo)
stats_out.stats
.map { it -> it[1] }
.collect()
.set { stats }
run_multiqc_stats(stats)
}
workflow GENOME_MAPPING {
take:
genome
genes
reads
main:
// create index and save on disk
index = minimap_create_index(genome)
// map ONT reads
mapped_out = minimap_mapping(index.
minimap_index
.collect(),
reads)
// Get counts for genes
run_feature_counts(mapped_out.minimap_align, genome, genes)
//QC and stats
stats_out = stats_mapping(mapped_out.minimap_align)
stats_out.stats
.map { it -> it[1] }
.collect()
.set { stats }
run_multiqc_stats(stats)
}
workflow GENOME_MAPPING_LARGE {
take:
genome
genes
reads
main:
// create index and save on disk
index = minimap_create_index(genome)
// map ONT reads
mapped_out = minimap_mapping_large(index.
minimap_index
.collect(),
reads)
// Get counts for genes
run_feature_counts(mapped_out.minimap_align, genome, genes)
//QC and stats
stats_out = stats_mapping(mapped_out.minimap_align)
stats_out.stats
.map { it -> it[1] }
.collect()
.set { stats }
run_multiqc_stats(stats)
}
workflow {
switchVariable = 0
if (workflow_input == "concatenate") {
switchVariable = 1;
} else if (workflow_input == "reads-qc") {
switchVariable = 2;
} else if (workflow_input == "reads-filter") {
switchVariable = 3;
} else if (workflow_input == "chloroplast-contamination") {
switchVariable = 4;
} else if (workflow_input == "genome-mapping") {
switchVariable = 5;
} else if (workflow_input == "genome-mapping-large") {
switchVariable = 6;
}
switch (switchVariable) {
case 1:
CONCAT_BARCODES(barcodes);
break;
case 2:
READS_QC(reads);
break;
case 3:
READS_FILTER(reads, phred);
break;
case 4:
CHLO_CONTAMINATION(genome_chl, reads);
break;
case 5:
GENOME_MAPPING(genome, genes, reads);
break;
case 6:
GENOME_MAPPING_LARGE(genome, genes, reads);
break;
default:
println("Please provide the correct input options")
break;
}
}