-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathQC.wdl
171 lines (155 loc) · 8.11 KB
/
QC.wdl
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
version 1.0
# Copyright (c) 2018 Leiden University Medical Center
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import "tasks/cutadapt.wdl" as cutadapt
import "tasks/fastqc.wdl" as fastqc
workflow QC {
input {
File read1
File? read2
String outputDir = "."
# A readgroupName so cutadapt creates a unique report name.
# This is useful if all the QC files are dumped in one folder.
String readgroupName = sub(basename(read1),"(\.fq)?(\.fastq)?(\.gz)?", "")
# Only run cutadapt if it makes sense.
Boolean runAdapterClipping = defined(adapterForward) || defined(adapterReverse) || length(select_first([contaminations, []])) > 0
Boolean extractFastqcZip = false
String? adapterForward
String? adapterReverse
Array[String]+? contaminations
Map[String, String] dockerImages = {
"fastqc": "quay.io/biocontainers/fastqc:0.12.1--hdfd78af_0",
"cutadapt": "quay.io/biocontainers/cutadapt:4.4--py310h1425a21_0"
}
}
meta {
allowNestedInputs: true
}
# If read2 is defined but a reverse adapter is not given we set it empty.
# If read2 is defined and a reverse adapter is given we use that.
# If read2 is not defined we set it empty.
Array[String] adapterReverseDefault = if defined(read2) then select_all([adapterReverse]) else []
call fastqc.Fastqc as FastqcRead1 {
input:
seqFile = read1,
outdirPath = outputDir + "/",
extract = extractFastqcZip,
dockerImage = dockerImages["fastqc"]
}
if (defined(read2)) {
call fastqc.Fastqc as FastqcRead2 {
input:
seqFile = select_first([read2]),
outdirPath = outputDir + "/",
extract = extractFastqcZip,
dockerImage = dockerImages["fastqc"]
}
String read2outputPath = outputDir + "/cutadapt_" + basename(select_first([read2]))
}
if (runAdapterClipping) {
call cutadapt.Cutadapt as Cutadapt {
input:
read1 = read1,
read2 = read2,
read1output = outputDir + "/cutadapt_" + basename(read1),
read2output = read2outputPath,
adapter = select_all([adapterForward]),
anywhere = select_first([contaminations, []]),
adapterRead2 = adapterReverseDefault,
anywhereRead2 = if defined(read2)
then select_first([contaminations, []])
else [],
reportPath = outputDir + "/" + readgroupName + "_cutadapt_report.txt",
dockerImage = dockerImages["cutadapt"]
}
call fastqc.Fastqc as FastqcRead1After {
input:
seqFile = Cutadapt.cutRead1,
outdirPath = outputDir + "/",
extract = extractFastqcZip,
dockerImage = dockerImages["fastqc"]
}
if (defined(read2)) {
call fastqc.Fastqc as FastqcRead2After {
input:
seqFile = select_first([Cutadapt.cutRead2]),
outdirPath = outputDir + "/",
extract = extractFastqcZip,
dockerImage = dockerImages["fastqc"]
}
}
}
output {
File qcRead1 = if runAdapterClipping
then select_first([Cutadapt.cutRead1])
else read1
File? qcRead2 = if runAdapterClipping
then Cutadapt.cutRead2
else read2
File read1htmlReport = FastqcRead1.htmlReport
File read1reportZip = FastqcRead1.reportZip
File? read2htmlReport = FastqcRead2.htmlReport
File? read2reportZip = FastqcRead2.reportZip
File? read1afterHtmlReport = FastqcRead1After.htmlReport
File? read1afterReportZip = FastqcRead1After.reportZip
File? read2afterHtmlReport = FastqcRead2After.htmlReport
File? read2afterReportZip = FastqcRead2After.reportZip
File? cutadaptReport = Cutadapt.report
Array[File] fastqcSummaries = select_all([FastqcRead1.summary, FastqcRead2.summary ,FastqcRead1After.summary, FastqcRead2After.summary])
Array[File] reports = select_all([
read1htmlReport,
read1reportZip,
read2htmlReport,
read2reportZip,
read1afterHtmlReport,
read1afterReportZip,
read2afterHtmlReport,
read2afterReportZip,
cutadaptReport
])
}
parameter_meta {
# inputs
read1: {description: "The first or single end fastq file to be run through cutadapt.", category: "required"}
read2: {description: "An optional second end fastq file to be run through cutadapt.", category: "common"}
outputDir: {description: "The directory to which the outputs will be written.", category: "common"}
readgroupName: {description: "The name of the readgroup.", category: "common"}
runAdapterClipping: {description: "Whether or not adapters should be removed from the reads.", category: "advanced"}
extractFastqcZip: {description: "Whether to extract Fastqc's report zip files.", category: "advanced"}
adapterForward: {description: "The adapter to be removed from the reads first or single end reads.", category: "common"}
adapterReverse: {description: "The adapter to be removed from the reads second end reads.", category: "common"}
contaminations: {description: "Contaminants/adapters to be removed from the reads.", category: "common"}
dockerImages: {description: "The docker images used. Changing this may result in errors which the developers may choose not to address.", category: "advanced"}
# outputs
qcRead1: {description: "The first or single end fastq file processed by CutAdapt."}
qcRead2: {description: "An optional second end fastq file processed by CutAdapt."}
read1htmlReport: {description: "Fastqc HTML report for the first or single end fastq file."}
read1reportZip: {description: "Fastqc zip archive containing data for the first or single end fastq file."}
read2htmlReport: {description: "Fastqc HTML report for the optional second end fastq file."}
read2reportZip: {description: "Fastqc zip archive containing data for the optional second end fastq file."}
read1afterHtmlReport: {description: "Fastqc HTML report for the first or single end fastq file after CutAdapt processing."}
read1afterReportZip: {description: "Fastqc zip archive containing data for the first or single end fastq file after CutAdapt processing."}
read2afterHtmlReport: {description: "Fastqc HTML report for the optional second end fastq file after CutAdapt processing."}
read2afterReportZip: {description: "Fastqc zip archive containing data for the optional second end fastq file after CutAdapt processing."}
cutadaptReport: {description: "Report from CutAdapt processing of input fastq file(s)."}
fastqcSummaries: {description: "Fastqc summary file(s)."}
reports: {description: "Collection of all reports produced by the workflow."}
}
}