-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSamtools_Coverage_MapStats.wdl
135 lines (116 loc) · 2.46 KB
/
Samtools_Coverage_MapStats.wdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
## Workflow: Header, Map Rate, Meandepth
## Inputs:
## (I1) BAM File (.bam)
## (I2) BAM Index (.bai)
## Outputs:
## (O1) File containing the header of the BAM file
## (O2) File indicating the mapping rate
## (O3) File indicating the average depth
version 1.0
workflow HeaderMaprateDepth{
input{
File input_bam
File index_bam
String filename
Int preemptible = 3
Int cpu = 1
Int memoryGB = 8
}
call mapCaller{
input:
input_bam=input_bam,
index_bam=index_bam,
filename=filename,
memoryGB=memoryGB,
preemptible=preemptible,
cpu=cpu
}
call depthCaller{
input:
input_bam=input_bam,
index_bam=index_bam,
filename=filename,
memoryGB=memoryGB,
preemptible=preemptible,
cpu=cpu
}
output {
File maprate = mapCaller.maprate
File meandepth = depthCaller.meandepth
}
}
# This task calls the header from a BAM file.
task headCaller{
input{
File input_bam
File index_bam
String filename
Int preemptible
Int cpu
Int memoryGB
}
Int diskSpace = 3*ceil(size(input_bam, "GB") + size(index_bam, "GB"))
command {
samtools view -H ${input_bam} > ${filename}_header.txt
}
output {
File header = "${filename}_header.txt"
}
runtime {
docker: "staphb/samtools:1.14"
preemptible: preemptible
disks: "local-disk ${diskSpace} HDD"
cpu: cpu
memory: memoryGB
}
}
# This task calls the mapping rate from a BAM file by highlighting the "%" chr.
task mapCaller {
input {
File input_bam
File index_bam
String filename
Int preemptible
Int cpu
Int memoryGB
}
Int diskSpace = 3*ceil(size(input_bam, "GB") + size(index_bam, "GB"))
command {
samtools flagstat ${input_bam} | grep "%" > ${filename}_maprate.txt
}
output {
File maprate = "${filename}_maprate.txt"
}
runtime {
docker: "staphb/samtools:1.14"
preemptible: preemptible
disks: "local-disk ${diskSpace} HDD"
cpu: cpu
memory: memoryGB
}
}
# This task retrieves the mean depth from a BAM file by means of samtools:coverage.
task depthCaller {
input {
File input_bam
File index_bam
String filename
Int preemptible
Int cpu
Int memoryGB
}
Int diskSpace = 3*ceil(size(input_bam, "GB") + size(index_bam, "GB"))
command {
samtools coverage -m ${input_bam} > ${filename}_meandepth.txt
}
output {
File meandepth = "${filename}_meandepth.txt"
}
runtime {
docker: "staphb/samtools:1.14"
preemptible: preemptible
disks: "local-disk ${diskSpace} HDD"
cpu: cpu
memory: memoryGB
}
}