From a5010d8804155529c092fc60a752148635c9906d Mon Sep 17 00:00:00 2001
From: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
Date: Wed, 3 Jul 2019 09:18:32 +0200
Subject: [PATCH] fix samtools

---
 samtools.wdl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/samtools.wdl b/samtools.wdl
index 395c9ac..dcec975 100644
--- a/samtools.wdl
+++ b/samtools.wdl
@@ -31,14 +31,21 @@ task BgzipAndIndex {
 task Index {
     input {
         File bamFile
+        String bamPath = basename(bamFile)
         String dockerImage = "quay.io/biocontainers/samtools:1.8--h46bd0b3_5"
     }
-    String bamPath = basename(bamFile)
     String bamIndexPath = sub(bamPath, "\.bam$", ".bai")
 
     command {
-        ln ~{bamFile} ~{bamPath}
+        bash -c '
+        set -e
+        # Make sure bamPath does not exist.
+        if [ ! -f ~{bamPath} ]
+        then
+            ln ~{bamFile} ~{bamPath}
+        fi
         samtools index ~{bamPath} ~{bamIndexPath}
+        '
     }
 
     output {
-- 
GitLab