From e01a682ccf993792dd328d34b50611dfec239ae4 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Wed, 26 Sep 2018 13:27:29 +0200
Subject: [PATCH] Added CaseControl tool

---
 biopet/sampleconfig.wdl | 40 ++++++++++++++++++++++++++++++++++++++++
 common.wdl              |  7 +++++++
 2 files changed, 47 insertions(+)

diff --git a/biopet/sampleconfig.wdl b/biopet/sampleconfig.wdl
index 61defae..dacf47e 100644
--- a/biopet/sampleconfig.wdl
+++ b/biopet/sampleconfig.wdl
@@ -1,5 +1,7 @@
 version 1.0
 
+import "../common.wdl" as common
+
 task SampleConfig {
     input {
         File? toolJar
@@ -77,3 +79,41 @@ task SampleConfigCromwellArrays {
         memory: ceil(memory * memoryMultiplier)
     }
 }
+
+task CaseControl {
+    input {
+        File? toolJar
+        String? preCommand
+        Array[File]+ inputFiles
+        Array[File]+ sampleConfigs
+        String outputPath
+        String controlTag = "control"
+
+        Int memory = 4
+        Float memoryMultiplier = 1.5
+    }
+
+    String toolCommand = if defined(toolJar)
+        then "java -Xmx" + memory + "G -jar " + toolJar
+        else "biopet-sampleconfig -Xmx" + memory + "G"
+
+    command {
+        set -e -o pipefail
+        ~{preCommand}
+        mkdir -p $(dirname ~{outputPath})
+        ~{toolCommand} CromwellArrays \
+        -i ~{sep="-i " inputFiles} \
+        -s ~{sep="-s " inputFiles} \
+        ~{"-o " + outputPath} \
+        ~{"--controlTag " + controlTag}
+    }
+
+    output {
+        File outputFile = outputPath
+        Array[CaseControl] controls = read_json(outputFile)
+    }
+
+    runtime {
+        memory: ceil(memory * memoryMultiplier)
+    }
+}
diff --git a/common.wdl b/common.wdl
index af3b66b..c618cbf 100644
--- a/common.wdl
+++ b/common.wdl
@@ -163,3 +163,10 @@ struct FastqPair {
     File? R2
     File? R2_md5
 }
+
+struct CaseControl {
+    String inputName
+    IndexedBamFile inputBam
+    String controlName
+    IndexedBamFile controlBam
+}
-- 
GitLab