From f91f5982f82c12b331145a89856308c67a80b3fb Mon Sep 17 00:00:00 2001
From: pjvan_thof <pjrvanthof@gmail.com>
Date: Thu, 1 Mar 2018 14:27:49 +0100
Subject: [PATCH] Adding alignment step

---
 bwa.wdl      | 18 ++++++++++++++++++
 fastqc.wdl   | 10 +---------
 samtools.wdl | 24 ++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 9 deletions(-)
 create mode 100644 bwa.wdl
 create mode 100644 samtools.wdl

diff --git a/bwa.wdl b/bwa.wdl
new file mode 100644
index 0000000..e5bac65
--- /dev/null
+++ b/bwa.wdl
@@ -0,0 +1,18 @@
+task BwaMem {
+    File inputR1
+    File? inputR2
+    String referenceFasta
+    String outputPath
+    String? readgroup
+
+    command {
+        set -e -o pipefail
+        mkdir -p $(dirname ${outputPath})
+        bwa mem ${"-R '" + readgroup + "'"} \
+        ${referenceFasta} ${inputR1} ${inputR2} | samtools sort --output-fmt BAM - > ${outputPath}
+    }
+
+    output {
+        File bamFile = outputPath
+    }
+}
diff --git a/fastqc.wdl b/fastqc.wdl
index 657c792..d5cd520 100644
--- a/fastqc.wdl
+++ b/fastqc.wdl
@@ -48,15 +48,7 @@ task fastqc {
         File rawReport = reportDir + "/fastqc_data.txt"
         File htmlReport = reportDir + "/fastqc_report.html"
         File summary = reportDir + "/summary.txt"
-        File adapterContent = reportDir + "/Images/adapter_content.png"
-        File duplicationLevels = reportDir + "/Images/duplication_levels.png"
-        File perBaseNContent = reportDir + "/Images/per_base_n_content.png"
-        File perBaseQuality = reportDir + "/Images/per_base_quality.png"
-        File perBaseSequenceContent = reportDir + "/Images/per_base_sequence_content.png"
-        File perSequenceGCContent = reportDir + "/Images/per_sequence_gc_content.png"
-        File perSequenceQuality = reportDir + "/Images/per_sequence_quality.png"
-        File perTileQuality = reportDir + "/Images/per_tile_quality.png"
-        File sequenceLengthDistribution = reportDir + "/Images/sequence_length_distribution.png"
+        Array[File] images = glob(outdirPath + "/*/Images/*.png")
     }
 
     runtime {
diff --git a/samtools.wdl b/samtools.wdl
new file mode 100644
index 0000000..6fee4d0
--- /dev/null
+++ b/samtools.wdl
@@ -0,0 +1,24 @@
+task SamtoolsIndex {
+    String bamFilePath
+
+    command {
+        samtools index ${bamFilePath}
+    }
+
+    output {
+        File indexFile = bamFilePath + ".bai"
+    }
+}
+
+task SamtoolsMerge {
+    Array[File] bamFiles
+    String outputBamPath
+
+    command {
+        samtools merge ${outputBamPath} ${bamFiles}
+    }
+
+    output {
+        File bamFile = outputBamPath
+    }
+}
\ No newline at end of file
-- 
GitLab