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 "bwa.wdl" as bwa
27 import "fgi.wdl" as fgifm2
28 import "sambamba.wdl" as sambamba
29 #import "tasks/picard.wdl" as picard
31 #import "tasks/umi-tools.wdl" as umiTools
33 workflow SampleWorkflow {
37 String platform = "illumina"
38 Boolean useBwaKit = false
42 String? adapterForward
43 String? adapterReverse
44 Int? minBWAmatchLen = 200
47 Map[String, String] dockerImages
50 scatter (readgroup in sample.readgroups) {
51 String readgroupDir = sampleDir + "/lib_" + readgroup.lib_id + "--rg_" + readgroup.id
52 call qc.QC as qualityControl {
54 outputDir = readgroupDir,
57 adapterForward = adapterForward,
58 adapterReverse = adapterReverse,
60 call bwa.Mem as bwaMem {
62 read1 = qualityControl.qcRead1,
63 read2 = qualityControl.qcRead2,
64 outputPrefix = readgroupDir + "/" + sample.id + "-" + readgroup.lib_id + "-" + readgroup.id,
65 readgroup = "@RG\\tID:~{sample.id}-~{readgroup.lib_id}-~{readgroup.id}\\tLB:~{readgroup.lib_id}\\tSM:~{sample.id}\\tPL:~{platform}",
66 bwaIndex = select_first([bwaIndex]),
68 usePostalt = useBwaKit,
69 dockerImage = dockerImages["bwakit+samtools"]
71 Boolean paired = defined(readgroup.R2)
74 call sambamba.Markdup as markdup {
76 inputBams = select_all(bwaMem.outputBam),
77 outputPath = sampleDir + "/" + sample.id + ".markdup.bam",
78 dockerImage = dockerImages["sambamba"]
81 call fgifm2.FilterSamReads as FilterSam {
83 inputBam = markdup.outputBam,
84 inputBamIndex = markdup.outputBamIndex,
85 outputBamPath = sampleDir + "/" + sample.id + ".fM.bam",
86 minMatchLen = minBWAmatchLen
88 call fgifm2.callSNP as fm2callSNP {
90 inputBam = markdup.outputBam,
91 inputBamIndex = markdup.outputBamIndex,
92 GatkIndex = GatkIndex,
93 outputPath = sampleDir + "/SNP/",
94 helperPl = "bin/fsnp.pl"
96 call fgifm2.callSTR as fm2callSTR {
98 inputBam = FilterSam.outputBam,
99 inputBamIndex = FilterSam.outputBamIndex,
100 outputPath = sampleDir + "/STR/",
101 helperBED = "bin/LN-mid.bed",
102 helperPl = "bin/fstr.pl"
106 File markdupBam = markdup.outputBam
107 File markdupBamIndex = markdup.outputBamIndex
108 File filteredBam = FilterSam.outputBam
109 File filteredBamIndex = FilterSam.outputBamIndex
110 File outSNP0txt = fm2callSNP.outSNP0txt
111 File outSTR0txt = fm2callSTR.outSTR0txt
112 File outSNP1txt = fm2callSNP.outSNP1txt
113 File outSNPtxt = fm2callSNP.outSNPtxt
114 File outSTRtxt = fm2callSTR.outSTRtxt
115 Array[File] reports = flatten(qualityControl.reports)
116 File outbcfFile = fm2callSNP.outbcfFile
117 File outsnpFile = fm2callSNP.outsnpFile
118 File outsnpIndexFile = fm2callSNP.outsnpIndexFile
119 File outsnp0File = fm2callSNP.outsnp0File
120 File outsnp0IndexFile = fm2callSNP.outsnp0IndexFile
125 sample: {description: "The sample information: sample id, readgroups, etc.", category: "required"}
126 sampleDir: {description: "The directory the output should be written to.", category: "required"}
127 platform: {description: "The platform used for sequencing.", category: "advanced"}
128 useBwaKit: {description: "Whether or not BWA kit should be used. If false BWA mem will be used.", category: "advanced"}
129 bwaIndex: {description: "The BWA index files. These or the bwaMem2Index should be provided.", category: "common"}
130 adapterForward: {description: "The adapter to be removed from the reads first or single end reads.", category: "common"}
131 adapterReverse: {description: "The adapter to be removed from the reads second end reads.", category: "common"}
132 bwaThreads: {description: "The amount of threads for the alignment process.", category: "advanced"}
133 dockerImages: {description: "The docker images used.", category: "required"}
136 markdupBam: {description: ""}
137 markdupBamIndex: {description: ""}
138 reports: {description: ""}