3 # Copyright (c) 2018 Leiden University Medical Center
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 import "BamMetrics/bammetrics.wdl" as bammetrics
24 import "gatk-preprocess/gatk-preprocess.wdl" as preprocess
25 import "structs.wdl" as structs
26 import "tasks/bwa.wdl" as bwa
27 import "tasks/sambamba.wdl" as sambamba
28 import "QC/QC.wdl" as qc
31 workflow SampleWorkflow {
36 File referenceFastaFai
37 File referenceFastaDict
41 Map[String, String] dockerImages
42 String platform = "illumina"
43 Boolean useBwaKit = false
46 String? adapterForward
47 String? adapterReverse
49 meta {allowNestedInputs: true}
51 scatter (readgroup in sample.readgroups) {
52 String readgroupDir = sampleDir + "/lib_" + readgroup.lib_id + "--rg_" + readgroup.id
56 outputDir = readgroupDir,
59 adapterForward = adapterForward,
60 adapterReverse = adapterReverse,
61 dockerImages = dockerImages
65 call bwa.Mem as bwaMem {
69 outputPath = readgroupDir + "/" + sample.id + "-" + readgroup.lib_id + "-" + readgroup.id + ".bam",
70 readgroup = "@RG\\tID:~{sample.id}-~{readgroup.lib_id}-~{readgroup.id}\\tLB:~{readgroup.lib_id}\\tSM:~{sample.id}\\tPL:~{platform}",
73 dockerImage = dockerImages["bwa+samtools"]
78 call bwa.Kit as bwakit {
82 outputPrefix = readgroupDir + "/" + sample.id + "-" + readgroup.lib_id + "-" + readgroup.id,
83 readgroup = "@RG\\tID:~{sample.id}-~{readgroup.lib_id}-~{readgroup.id}\\tLB:~{readgroup.lib_id}\\tSM:~{sample.id}\\tPL:~{platform}",
86 dockerImage = dockerImages["bwakit+samtools"]
91 call sambamba.Markdup as markdup {
93 inputBams = if useBwaKit
94 then select_all(bwakit.outputBam)
95 else select_all(bwaMem.outputBam),
96 outputPath = sampleDir + "/" + sample.id + ".markdup.bam",
97 dockerImage = dockerImages["sambamba"]
100 call preprocess.GatkPreprocess as bqsr {
102 bam = markdup.outputBam,
103 bamIndex = markdup.outputBamIndex,
104 outputDir = sampleDir,
105 bamName = sample.id + ".bqsr",
106 referenceFasta = referenceFasta,
107 referenceFastaFai = referenceFastaFai,
108 referenceFastaDict = referenceFastaDict,
110 dbsnpVCFIndex = dbsnpVCFIndex,
111 dockerImages = dockerImages,
115 call bammetrics.BamMetrics as metrics {
117 bam = markdup.outputBam,
118 bamIndex = markdup.outputBamIndex,
119 outputDir = sampleDir,
120 referenceFasta = referenceFasta,
121 referenceFastaFai = referenceFastaFai,
122 referenceFastaDict = referenceFastaDict,
123 dockerImages = dockerImages
127 File markdupBam = markdup.outputBam
128 File markdupBamIndex = markdup.outputBamIndex
129 File recalibratedBam = bqsr.recalibratedBam
130 File recalibratedBamIndex = bqsr.recalibratedBamIndex
131 Array[File] reports = flatten([flatten(QC.reports),
138 sample: {description: "The sample information: sample id, readgroups, etc.", category: "required"}
139 sampleDir: {description: "The directory the output should be written to.", category: "required"}
140 bwaIndex: {description: "The BWA index files.", category: "required"}
141 referenceFasta: { description: "The reference fasta file", category: "required" }
142 referenceFastaFai: { description: "Fasta index (.fai) file of the reference", category: "required" }
143 referenceFastaDict: { description: "Sequence dictionary (.dict) file of the reference", category: "required" }
144 dbsnpVCF: { description: "dbsnp VCF file used for checking known sites", category: "required"}
145 dbsnpVCFIndex: { description: "Index (.tbi) file for the dbsnp VCF", category: "required"}
146 dockerImages: {description: "The docker images used.", category: "required"}
147 platform: {description: "The platform used for sequencing.", category: "advanced"}
148 useBwaKit: {description: "Whether or not BWA kit should be used. If false BWA mem will be used.", category: "advanced"}
149 adapterForward: {description: "The adapter to be removed from the reads first or single end reads.", category: "common"}
150 adapterReverse: {description: "The adapter to be removed from the reads second end reads.", category: "common"}
151 scatters: {description: "List of bed files to be used for scattering", category: "advanced"}
152 bwaThreads: {description: "The amount of threads for the alignment process", category: "advanced"}