From 6eaf21442d9352266f0ac3e108cf1dc084c1c9f4 Mon Sep 17 00:00:00 2001
From: Redmar van den Berg <RedmarvandenBerg@lumc.nl>
Date: Wed, 7 Oct 2020 14:07:39 +0200
Subject: [PATCH] Ensure that the index and bamfiles are in the same folder

---
 bam2fastx.wdl | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/bam2fastx.wdl b/bam2fastx.wdl
index 42240cd..1843475 100644
--- a/bam2fastx.wdl
+++ b/bam2fastx.wdl
@@ -91,12 +91,25 @@ task Bam2Fastq {
     command {
         set -e
         mkdir -p "$(dirname ~{outputPrefix})"
+
+        # Localise the bam and pbi files so they are next to each other in the
+        # current folder
+        bamfiles=""
+        for bamfile in ~{sep=" " bam};do
+            ln $bamfile .
+            bamfiles=$bamfiles" $(basename $bamfile)"
+        done
+
+        for bamindex in ~{sep=" " bamIndex}; do
+            ln $bamindex .
+        done
+
         bam2fastq \
         --output ~{outputPrefix} \
         -c ~{compressionLevel} \
         ~{true="--split-barcodes" false="" splitByBarcode} \
         ~{"--seqid-prefix " + seqIdPrefix} \
-        ~{sep=" " bam}
+        $bamfiles
     }
 
     output {
-- 
GitLab