Skip to content

Commit c53b197

Browse files
committed
Add Samtools depth task
1 parent 2387f27 commit c53b197

File tree

1 file changed

+82
-13
lines changed

1 file changed

+82
-13
lines changed

CoverageProfiler/CoverageProfiler.wdl

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,53 @@ version 1.0
33
workflow coverageProfile {
44
input {
55
String sampleName
6+
String coverageTool = "Samtools"
67
File alignedBam
78
File alignedBamIndex
89
File referenceFasta
910
File referenceDict
1011
File referenceFai
1112
File intervals
13+
Int MinBaseQuality = 20
14+
Int MinMappingQuality = 20
1215
}
13-
call DepthOfCoverage {
14-
input:
15-
sampleName = sampleName,
16-
alignedBam = alignedBam,
17-
alignedBamIndex = alignedBamIndex,
18-
referenceFasta = referenceFasta,
19-
referenceDict = referenceDict,
20-
referenceFai = referenceFai,
21-
intervals = intervals
16+
if (coverageTool =="Samtools") {
17+
call SamtoolsDepth {
18+
input:
19+
sampleName = sampleName,
20+
alignedBam = alignedBam,
21+
alignedBamIndex = alignedBamIndex,
22+
referenceFasta = referenceFasta,
23+
referenceDict = referenceDict,
24+
referenceFai = referenceFai,
25+
intervals = intervals,
26+
minBaseQuality = MinBaseQuality,
27+
minMappingQuality = MinMappingQuality
28+
}
29+
}
30+
if (coverageTool == "DepthOfCoverage") {
31+
call DepthOfCoverage {
32+
input:
33+
sampleName = sampleName,
34+
alignedBam = alignedBam,
35+
alignedBamIndex = alignedBamIndex,
36+
referenceFasta = referenceFasta,
37+
referenceDict = referenceDict,
38+
referenceFai = referenceFai,
39+
intervals = intervals,
40+
minBaseQuality = MinBaseQuality,
41+
minMappingQuality = MinMappingQuality
42+
}
2243
}
2344
output {
24-
File coveragebyInterval = DepthOfCoverage.sample_interval_summary
25-
Float meanCoverage = DepthOfCoverage.mean_coverage
45+
File? DepthOfCoverageIntervalCov = DepthOfCoverage.sample_interval_summary
46+
Float? DepthOfCoverageMeanCoverage = DepthOfCoverage.mean_coverage
47+
File? SamtoolsDepthProfile = SamtoolsDepth.depth_profile
2648
}
2749
meta {
2850
author: "Yueyao Gao"
2951
30-
description: "Calculates the depth of coverage of an input sample using GATK's DepthOfCoverage tool."
52+
description: "Calculates the depth of coverage of an input sample"
3153

3254
}
3355
}
@@ -40,6 +62,8 @@ workflow coverageProfile {
4062
File referenceDict
4163
File referenceFai
4264
File intervals
65+
Int minBaseQuality
66+
Int minMappingQuality
4367
Int? mem_gb
4468
Int? cpu
4569
String gatk_docker = "broadinstitute/gatk:4.5.0.0"
@@ -56,6 +80,9 @@ workflow coverageProfile {
5680
--input ~{alignedBam} \
5781
--read-index ~{alignedBamIndex} \
5882
--reference ~{referenceFasta} \
83+
--minimum-mapping-quality ~{minMappingQuality} \
84+
--min-base-quality ~{minBaseQuality} \
85+
--count-type COUNT_READS \ # Count all reads independently (even if from the same fragment). The only option supported by GATK 4.5.0.0.
5986
--output output/~{sampleName}
6087

6188
cat output/~{sampleName}.sample_interval_summary | awk 'BEGIN {FS = ","}{print $3}' | tail -n 1 > output/mean_coverage.txt
@@ -68,6 +95,48 @@ workflow coverageProfile {
6895
memory: machine_mem_mb + " MB"
6996
cpu: select_first([cpu, 1])
7097
docker: gatk_docker
71-
disks: "local-disk 500 HDD"
98+
disks: "local-disk 500 SSD"
99+
}
100+
}
101+
102+
103+
task SamtoolsDepth {
104+
input {
105+
String sampleName
106+
File alignedBam
107+
File alignedBamIndex
108+
File referenceFasta
109+
File referenceDict
110+
File referenceFai
111+
File intervals
112+
Int minBaseQuality
113+
Int minMappingQuality
114+
Int? mem_gb
115+
Int? cpu
116+
String samtools_docker = "euformatics/samtools:1.20"
117+
}
118+
command <<<
119+
# Create directories for output
120+
mkdir input
121+
readlink -f ~{alignedBam} > input/bam_path.txt
122+
123+
# Run samtools depth
124+
samtools depth \
125+
-b ~{intervals} \
126+
-f input/bam_path.txt \
127+
--min-BQ ~{minBaseQuality} \
128+
--min-MQ ~{minMappingQuality} \
129+
-s \ # Remove Overlapping Reads, Count fragment
130+
-o output/~{sampleName}_samtools.depth
131+
132+
>>>
133+
output {
134+
File depth_profile = "output/~{sampleName}_samtools.depth"
135+
}
136+
runtime {
137+
memory: select_first([mem_gb, 7]) * 1000 + " MB"
138+
cpu: select_first([cpu, 1])
139+
docker: samtools_docker
140+
disks: "local-disk 500 SSD"
72141
}
73142
}

0 commit comments

Comments
 (0)