@@ -3,31 +3,53 @@ version 1.0
3
3
workflow coverageProfile {
4
4
input {
5
5
String sampleName
6
+ String coverageTool = "Samtools"
6
7
File alignedBam
7
8
File alignedBamIndex
8
9
File referenceFasta
9
10
File referenceDict
10
11
File referenceFai
11
12
File intervals
13
+ Int MinBaseQuality = 20
14
+ Int MinMappingQuality = 20
12
15
}
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
+ }
22
43
}
23
44
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
26
48
}
27
49
meta {
28
50
author : "Yueyao Gao"
29
51
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"
31
53
32
54
}
33
55
}
@@ -40,6 +62,8 @@ workflow coverageProfile {
40
62
File referenceDict
41
63
File referenceFai
42
64
File intervals
65
+ Int minBaseQuality
66
+ Int minMappingQuality
43
67
Int ? mem_gb
44
68
Int ? cpu
45
69
String gatk_docker = "broadinstitute/gatk:4.5.0.0"
@@ -56,6 +80,9 @@ workflow coverageProfile {
56
80
--input ~ {alignedBam} \
57
81
--read-index ~ {alignedBamIndex} \
58
82
--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.
59
86
--output output/~{sampleName}
60
87
61
88
cat output/~{sampleName}.sample_interval_summary | awk ' BEGIN {FS = ","}{print $3}' | tail -n 1 > output/mean_coverage.txt
@@ -68,6 +95,48 @@ workflow coverageProfile {
68
95
memory : machine_mem_mb + " MB"
69
96
cpu : select_first ([cpu , 1 ])
70
97
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"
72
141
}
73
142
}
0 commit comments