-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfasta_to_bam_single_sample.wdl
More file actions
109 lines (93 loc) · 2.95 KB
/
fasta_to_bam_single_sample.wdl
File metadata and controls
109 lines (93 loc) · 2.95 KB
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
version 1.0
workflow FastqToBamWorkflow {
input {
File fastq
File ref_fasta
File ref_fasta_index
File ref_dict
Int cpu = 2
String memory = "16G"
String disks = "local-disk 200 HDD"
Int? num_threads
Int? num_sort_threads
String sample_id
String read_group_prefix = "srg1"
String read_group_id = read_group_prefix + "_" + sample_id
String read_group_lb = sample_id
String read_group_pl = "illumina"
String read_group_sm = sample_id
}
String prefix = basename(fastq, ".fastq.gz")
call FastqToBam {
input:
fastq = fastq,
ref_fasta = ref_fasta,
ref_fasta_index = ref_fasta_index,
ref_dict = ref_dict,
prefix = prefix,
cpu = cpu,
memory = memory,
disks = disks,
num_threads = select_first([num_threads, 16]),
num_sort_threads = select_first([num_sort_threads, 4]),
read_group_id = read_group_id,
read_group_lb = read_group_lb,
read_group_pl = read_group_pl,
read_group_sm = read_group_sm
}
output {
File bam = FastqToBam.bam
File bai = FastqToBam.bai
}
}
task FastqToBam {
input {
File fastq
File ref_fasta
File ref_fasta_index
File ref_dict
String prefix
Int cpu = 2
String memory = "16G"
String disks = "local-disk 200 HDD"
Int num_threads = 16
Int num_sort_threads = 4
String read_group_id
String read_group_lb
String read_group_pl
String read_group_sm
}
command <<<
set -euxo pipefail
ls -lh ~{fastq}
ls -lh ~{ref_fasta}
ls -lh ~{ref_fasta_index}
ls -lh ~{ref_dict}
minimap2 -ayYL --MD -eqx -x map-hifi -t~{num_threads} ~{ref_fasta} ~{fastq} > ~{prefix}.sam 2> ~{prefix}.minimap2.log
if [ $? -ne 0 ]; then
echo "minimap2 failed. Check the log file ~{prefix}.minimap2.log for details." >&2
cat ~{prefix}.minimap2.log
exit 1
fi
head -n 50 ~{prefix}.sam
samtools addreplacerg -r "ID:~{read_group_id}" -r "LB:~{read_group_lb}" -r "PL:~{read_group_pl}" -r "SM:~{read_group_sm}" -O BAM -o ~{prefix}.rg.bam ~{prefix}.sam
# Sort the BAM file
samtools sort -@~{num_sort_threads} --no-PG -o ~{prefix}.sorted.bam ~{prefix}.rg.bam
ls -lh ~{prefix}.sorted.bam
# Index the BAM file
samtools index ~{prefix}.sorted.bam
>>>
output {
File bam = "~{prefix}.sorted.bam"
File bai = "~{prefix}.sorted.bam.bai"
File minimap2_log = "~{prefix}.minimap2.log"
File sam = "~{prefix}.sam"
File rg_bam = "~{prefix}.rg.bam"
}
runtime {
docker: "us.gcr.io/broad-dsp-lrma/lr-align:0.1.28"
cpu: cpu
memory: memory
disks: disks
}
}