From bf6145791588577ee502749a7662f0683e67aab9 Mon Sep 17 00:00:00 2001
From: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
Date: Fri, 5 Jun 2020 07:56:50 +0200
Subject: [PATCH] try to fix memory

---
 star.wdl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/star.wdl b/star.wdl
index b1c662f..f154913 100644
--- a/star.wdl
+++ b/star.wdl
@@ -104,7 +104,9 @@ task Star {
         Int runThreadN = 4
         # Use a margin of 30% index size. Real memory usage is ~30 GiB for a 27 GiB index. 
         Int memoryGb = 1 + ceil(size(indexFiles, "G") * 1.3)
-        String memory = "~{memoryGb}G"
+        # For some reason doing above calculation inside a string does not work.
+        # So we solve it with an optional memory string and using select_first.
+        String? memory
         # 1 minute initialization + time reading in index (1 minute per G) + time aligning data.
         Int timeMinutes = 1 + ceil(size(indexFiles, "G")) + ceil(size(flatten([inputR1, inputR2]), "G") * 180 / runThreadN)
         String dockerImage = "quay.io/biocontainers/star:2.7.3a--0"
@@ -137,7 +139,7 @@ task Star {
 
     runtime {
         cpu: runThreadN
-        memory: memory
+        memory: select_first([memory, "~{memoryGb}G"])
         time_minutes: timeMinutes
         docker: dockerImage
     }
-- 
GitLab