-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
219 lines (170 loc) · 5.56 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
#!/usr/bin/env nextflow
/*
* Copyright (c) City of Hope and the authors.
*
* This file is part of 'selex-nf'.
*
* selex-nf is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* selex-nf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with selex-nf. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Main selex-nf pipeline script
*
* @authors
* Denis O'Meally <domeally.coh.org>
*/
/*
* TODO:
* fix split read channels - need to have one for pairs instead of sep L and R channels
* fix storeDir for wach process
* use labels for resource alocation
*/
log.info "selex assembly - N F ~ version 0.1"
log.info "====================================="
log.info "name : ${params.name}"
log.info "read pairs : ${params.pairs}"
log.info "MultiQC config : ${params.multiqc_config}"
log.info "output : ${params.output}"
log.info "\n"
/*
* Input parameters validation
*/
/*
* validate input files/
*/
ch_multiqc_config = file(params.multiqc_config, checkIfExists: true)
/*
* Create a channel for read files
*/
Channel
.fromFilePairs( params.pairs, size: 2)
.ifEmpty { exit 1, "Cannot find any reads matching: ${params.pairs}" }
.into { read_pairs_fastqc ; read_pairs_fastp }
/*
* STEP 1A - FastQC
*/
process fastp_raw_reads {
tag "$name"
container "quay.io/biocontainers/fastp:0.20.0--hdbcaa40_0"
cpus 8
memory 8.GB
time '2h'
publishDir "${params.output}/fastp_raw_reads", mode: 'copy'
input:
set val(name), file(reads) from read_pairs_fastp
output:
set val(name), file("*.trimmed.fastq.gz") into read_pairs_trimmed_error
set val(name), file("*.merged.fastq.gz") into read_pairs_merged
file "*.{json,html}" into fastp_raw_reads_results
script:
"""
fastp -w ${task.cpus} -i ${reads[0]} -I ${reads[1]} \
--trim_poly_x --n_base_limit 2 --low_complexity_filter --merge --correction --overlap_len_require 50 --overrepresentation_analysis \
-h ${name}.html \
-j ${name}.json \
--merged_out ${name}.merged.fastq.gz \
-o ${name}_R1.trimmed.fastq.gz \
-O ${name}_R2.trimmed.fastq.gz
"""
}
process cutadapt {
tag "$name"
container "kfdrc/cutadapt:latest"
cpus 1
memory 2.GB
time '2h'
publishDir "${params.output}/merged_trimmed_reads", mode: 'copy'
input:
set val(name), file(reads) from read_pairs_merged
output:
set val(name), file ('*.fastq.gz') into read_pairs_merged_trimmed_qc , read_pairs_merged_trimmed
file ('*.log') into cutadapt_results
script:
"""
cutadapt --discard-untrimmed -g ${params.adapter5}...${params.adapter3} -e 0.2 -m 25 -M ${params.length} -o ${name}.clipped.fastq.gz ${reads} \
> ${name}.cutadapt.log
"""
}
process fastqc_merged {
tag "$name"
container "quay.io/biocontainers/fastqc:0.11.8--1"
//module 'FastQC/0.11.8'
cpus 8
memory 2.GB
time '2h'
publishDir "${params.output}/fastqc_merged_reads", mode: 'copy',
saveAs: {filename -> filename.indexOf(".zip") > 0 ? "zips/$filename" : "$filename"}
input:
set val(name), file(reads) from read_pairs_merged_trimmed_qc //read_pairs_fastqc
output:
file ("*_fastqc.{zip,html}") into fastqc_merged_reads_results
script:
"""
fastqc -t ${task.cpus} $reads
"""
}
process fastaptamer_count {
tag "$name"
cpus 1
memory 4.GB
time '12h'
publishDir "${params.output}/fastaptamer_count", mode: 'copy'
input:
set val(name), file(reads) from read_pairs_merged_trimmed
output:
set val(name), file ("*.counts.fa") into fastaptamer_count_results
file ("*.log") into fastaptamer_count_log
file ("*.tsv") into fastaptamer_count_tsv
script:
"""
perl $workflow.projectDir/bin/fastaptamer_count -i <(zcat $reads) -o ${name}.counts.fa > ${name}.log
seqkit fx2tab ${name}.counts.fa > ${name}.counts.tsv
"""
}
process fastaptamer_cluster {
tag "$name"
cpus 1
memory 4.GB
time '12h'
publishDir "${params.output}/fastaptamer_cluster", mode: 'copy'
input:
set val(name), file(reads) from fastaptamer_count_results
output:
set val(name), file ("*.clusters.fa") into fastaptamer_cluster_results
file "*.log" into fastaptamer_cluster_log
file "*.tsv" into fastaptamer_cluster_tsv
script:
"""
perl $workflow.projectDir/bin/fastaptamer_cluster -d 2 -f 50 -i ${reads} -o ${name}.clusters.fa &> ${name}.clusters.log
seqkit fx2tab ${name}.clusters.fa > ${name}.clusters.tsv
"""
}
process multiqc {
container "ewels/multiqc:1.7"
cpus 1
memory 8.GB
time '2h'
publishDir "${params.output}/MultiQC", mode: 'copy'
input:
file (multiqc_config) from ch_multiqc_config
file ('fastqc_merged_reads/*') from fastqc_merged_reads_results.collect().ifEmpty([])
file ('cutadapt/*') from cutadapt_results.collect().ifEmpty([])
file ('fastp_raw_reads/*') from fastp_raw_reads_results.collect().ifEmpty([])
output:
file "*multiqc_report.html" into multiqc_report
file "*_data"
script:
"""
multiqc --config ${multiqc_config} .
"""
}