modified: fm2.wdl
[GalaxyCodeBases.git] / etc / gatk-wdl / fm2 / tasks / sample.wdl
blob5da0223b12e8b784afa7a4e31c9c6a31f48ce5b9
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 outSNPtxt = fm2callSNP.outSNPtxt
113                 File outSTRtxt = fm2callSTR.outSTRtxt
114                 Array[File] reports = flatten(qualityControl.reports)
115         }
117         parameter_meta {
118                 # inputs
119                 sample: {description: "The sample information: sample id, readgroups, etc.", category: "required"}
120                 sampleDir: {description: "The directory the output should be written to.", category: "required"}
121                 platform: {description: "The platform used for sequencing.", category: "advanced"}
122                 useBwaKit: {description: "Whether or not BWA kit should be used. If false BWA mem will be used.", category: "advanced"}
123                 bwaIndex: {description: "The BWA index files. These or the bwaMem2Index should be provided.", category: "common"}
124                 adapterForward: {description: "The adapter to be removed from the reads first or single end reads.", category: "common"}
125                 adapterReverse: {description: "The adapter to be removed from the reads second end reads.", category: "common"}
126                 bwaThreads: {description: "The amount of threads for the alignment process.", category: "advanced"}
127                 dockerImages: {description: "The docker images used.", category: "required"}
129                 # outputs
130                 markdupBam: {description: ""}
131                 markdupBamIndex: {description: ""}
132                 reports: {description: ""}
133         }