modified: openstmerge.py
[GalaxyCodeBases.git] / etc / gatk-wdl / fm2 / tasks / sample.wdl
blob689742aa2358f00292d71612c6e158d29047cab5
1 version 1.0
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
21 # SOFTWARE.
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
30 import "QC.wdl" as qc
31 #import "tasks/umi-tools.wdl" as umiTools
33 workflow SampleWorkflow {
34         input {
35                 Sample sample
36                 String sampleDir
37                 String platform = "illumina"
38                 Boolean useBwaKit = false
40                 BwaIndex bwaIndex
41                 GatkIndex GatkIndex
42                 String? adapterForward
43                 String? adapterReverse
44                 Int? minBWAmatchLen = 200
46                 Int bwaThreads = 4
47                 Map[String, String] dockerImages
48         }
50         scatter (readgroup in sample.readgroups) {
51                 String readgroupDir = sampleDir + "/lib_" + readgroup.lib_id + "--rg_" + readgroup.id
52                 call qc.QC as qualityControl {
53                         input:
54                                 outputDir = readgroupDir,
55                                 read1 = readgroup.R1,
56                                 read2 = readgroup.R2,
57                                 adapterForward = adapterForward,
58                                 adapterReverse = adapterReverse,
59                 }
60                 call bwa.Mem as bwaMem {
61                         input:
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]),
67                                 threads = bwaThreads,
68                                 usePostalt = useBwaKit,
69                                 dockerImage = dockerImages["bwakit+samtools"]
70                 }
71                 Boolean paired = defined(readgroup.R2)
73         }
74         call sambamba.Markdup as markdup {
75                 input:
76                         inputBams = select_all(bwaMem.outputBam),
77                         outputPath = sampleDir + "/" + sample.id + ".markdup.bam",
78                         dockerImage = dockerImages["sambamba"]
79         }
81         call fgifm2.FilterSamReads as FilterSam {
82                 input:
83                         inputBam = markdup.outputBam,
84                         inputBamIndex = markdup.outputBamIndex,
85                         outputBamPath = sampleDir + "/" + sample.id + ".fM.bam",
86                         minMatchLen = minBWAmatchLen
87         }
88         call fgifm2.callSNP as fm2callSNP {
89                 input:
90                         inputBam = markdup.outputBam,
91                         inputBamIndex = markdup.outputBamIndex,
92                         GatkIndex = GatkIndex,
93                         outputPath = sampleDir + "/SNP/",
94                         helperPl = "bin/fsnp.pl"
95         }
96         call fgifm2.callSTR as fm2callSTR {
97                 input:
98                         inputBam = FilterSam.outputBam,
99                         inputBamIndex = FilterSam.outputBamIndex,
100                         outputPath = sampleDir + "/STR/",
101                         helperBED = "bin/LN-mid.bed",
102                         helperPl = "bin/fstr.pl"
103         }
105         output {
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
121         }
123         parameter_meta {
124                 # inputs
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"}
135                 # outputs
136                 markdupBam: {description: ""}
137                 markdupBamIndex: {description: ""}
138                 reports: {description: ""}
139         }