From 05a55103f65c2ebb308a0f3e7d1545b21c28dba2 Mon Sep 17 00:00:00 2001
From: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
Date: Wed, 31 Jan 2018 11:35:30 +0100
Subject: [PATCH] output as sorted and indexed bam

---
 bwa.wdl | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/bwa.wdl b/bwa.wdl
index 04320ad..6cd0cda 100644
--- a/bwa.wdl
+++ b/bwa.wdl
@@ -2,7 +2,7 @@ task mem {
     File read1
     File referenceFile
     File? read2
-    String? outputFile
+    String? outputFile = "aligned.bam"
     String? preCommand
     Int? threads = 1
     String? memory = "4G"
@@ -78,10 +78,12 @@ task mem {
         ${true="-Y" false="" Y } \
         ${true="-M" false="" M } \
         ${"-I " + I } \
-        ${referenceFile} ${read1} ${read2}
+        ${referenceFile} ${read1} ${read2} \
+        | picard SortSam CREATE_INDEX=TRUE TMP_DIR=null \
+        INPUT=/dev/stdin OUTPUT=${outputFile}
     }
     output {
-        File samFile = if defined(outputFile) then select_first([outputFile]) else stdout()
+        File samFile = select_first([outputFile])
     }
     runtime {
         cpu: select_first([threads])
-- 
GitLab