From 508945fbfb9fcd0aa890097572da8044605cedc0 Mon Sep 17 00:00:00 2001
From: DavyCats <davycats.dc@gmail.com>
Date: Wed, 17 Oct 2018 14:47:04 +0200
Subject: [PATCH] add scatter reorder task

---
 biopet/biopet.wdl | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/biopet/biopet.wdl b/biopet/biopet.wdl
index c732d9c..867859e 100644
--- a/biopet/biopet.wdl
+++ b/biopet/biopet.wdl
@@ -200,6 +200,34 @@ task FastqSync {
     }
 }
 
+task ReorderGlobbedScatters {
+    input {
+        Array[File]+ scatters
+        String scatterDir
+    }
+
+    command <<<
+       python << CODE
+       from os.path import basename
+       scatters = ['~{sep="','" scatters}']
+       splitext = [basename(x).split(".") for x in scatters]
+       splitnum = [x.split("-") + [y] for x,y in splitext]
+       ordered = sorted(splitnum, key=lambda x: int(x[1]))
+       merged = ["~{scatterDir}/{}-{}.{}".format(x[0],x[1],x[2]) for x in ordered]
+       for x in merged:
+           print(x)
+       CODE
+    >>>
+
+    output {
+        Array[String] reorderedScatters = read_lines(stdout())
+    }
+
+    runtime {
+        memory: 1
+    }
+}
+
 task ScatterRegions {
     input {
         String? preCommand
-- 
GitLab