From 85898c4d4ea63f6323a69d4a4d5f9ec7472d020d Mon Sep 17 00:00:00 2001
From: ffinfo <pjrvanthof@gmail.com>
Date: Thu, 13 Sep 2018 11:04:26 +0200
Subject: [PATCH] Dynamic index searching

---
 samtools.wdl | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/samtools.wdl b/samtools.wdl
index ff2daf0..0d43015 100644
--- a/samtools.wdl
+++ b/samtools.wdl
@@ -36,11 +36,10 @@ task Index {
     }
 
     output {
+        File index = select_first(flatten([[bamIndexPath], glob(sub(basename(bamFile), "\.bam$", "") + "*.bai")]))
         IndexedBamFile outputBam = object {
           file: bamFile,
-          index: if defined(bamIndexPath)
-                              then select_first([bamIndexPath])
-                              else bamFile + ".bai"
+          index: index
         }
     }
 }
-- 
GitLab