From b3545b27947b9221f9f5e30d55c70f2284d5d7cc Mon Sep 17 00:00:00 2001
From: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
Date: Fri, 4 May 2018 11:31:34 +0200
Subject: [PATCH] add fastq task

---
 samtools.wdl | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/samtools.wdl b/samtools.wdl
index 249143f..f425d2e 100644
--- a/samtools.wdl
+++ b/samtools.wdl
@@ -65,3 +65,50 @@ task Flagstat {
         File flagstat = outputPath
     }
 }
+
+task fastq {
+    String? preCommand
+    File inputBam
+    String outputRead1
+    String? outputRead2
+    String? outputRead0
+    Int? includeFilter
+    Int? excludeFilter
+    Int? excludeSpecificFilter
+    Boolean? appendReadNumber
+    Boolean? outputQuality
+    Int? compressionLevel
+    Int? threads
+    Int? memory
+    Int totalThreads = select_first([threads, 1])
+
+    command {
+        ${preCommand}
+        samtools fastq \
+        ${true="-1" false="-s" defined(outputRead2)} ${outputRead1} \
+        ${"-2 " + outputRead2} \
+        ${"-0 " + outputRead0} \
+        ${"-f " + includeFilter} \
+        ${"-F " + excludeFilter} \
+        ${"-G " + excludeSpecificFilter} \
+        ${true="-N" false="-n" appendReadNumber} \
+        ${true="-O" false="" outputQuality} \
+        ${"-c " + compressionLevel} \
+        ${"--threads " + totalThreads} \
+
+    }
+    runtime {
+        cpu: totalThreads
+        memory: select_first([memory, 1])
+    }
+    parameter_meta {
+        preCommand: "A command that is run before the task. Can be used to activate environments"
+        inputBam: "The bam file to process."
+        outputRead1: "If only outputRead1 is given '-s' flag is assumed. Else '-1'."
+        includeFilter: "Include reads with ALL of these flags. Corresponds to '-f'"
+        excludeFilter: "Exclude reads with ONE OR MORE of these flags. Corresponds to '-F'"
+        excludeSpecificFilter: "Exclude reads with ALL of these flags. Corresponds to '-G'"
+        appendReadNumber: "Append /1 and /2 to the read name, or don't. Corresponds to '-n/N"
+
+    }
+}
-- 
GitLab