-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbwa_mem2.wdl
81 lines (60 loc) · 2.03 KB
/
bwa_mem2.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
version 1.0
workflow alignShortReads {
call bwaMem2
output {
File aligned_bam = bwaMem2.aligned_bam
File aligned_bam_idx = bwaMem2.aligned_bam_idx
}
}
task bwaMem2 {
input {
String docker_image = "jiminpark/aligners"
String sample_name
File fastq1
File fastq2
File reference
String? additional_args
Int threads = 64
Int memSizeGB = 128
}
Int file_size = ceil(size(fastq1, "GB"))
Int diskSizeGB = 3 * file_size
command <<<
# Set the exit code of a pipeline to that of the rightmost command
# to exit with a non-zero status, or zero if all commands of the pipeline exit
set -o pipefail
# cause a bash script to exit immediately when a command fails
set -e
# cause the bash shell to treat unset variables as an error and exit immediately
set -u
# echo each line of the script to stdout so we can see what is happening
# to turn off echo do 'set +o xtrace'
set -o xtrace
mkdir working
cd working
# check if length of "additional_args" is zero
if [[ "~{additional_args}" == "" ]]
then
ADDITIONAL_ARGS=""
else
ADDITIONAL_ARGS="~{additional_args}"
fi
# index reference
bwa-mem2 index ~{reference}
# align with bwa-mem2 and sort with samtools
bwa-mem2 mem -M ${ADDITIONAL_ARGS} -t ~{threads} ~{reference} ~{fastq1} ~{fastq2} \
| samtools sort -@4 -m 4G > ~{sample_name}_Illumina.GRCh38.sorted.bam
# index bam
samtools index -@ ~{threads} ~{sample_name}_Illumina.GRCh38.sorted.bam
>>>
output {
File aligned_bam = "working/~{sample_name}_Illumina.GRCh38.sorted.bam"
File aligned_bam_idx = "working/~{sample_name}_Illumina.GRCh38.sorted.bam.bai"
}
runtime {
memory: memSizeGB + " GB"
cpu: threads
disks: "local-disk " + diskSizeGB + " SSD"
docker: docker_image
}
}