From f9bbb353a1c133fc30ae2db6b2fcfeb69c4b7547 Mon Sep 17 00:00:00 2001
From: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
Date: Fri, 9 Nov 2018 15:57:49 +0100
Subject: [PATCH] continue on task

---
 gffcompare.wdl | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/gffcompare.wdl b/gffcompare.wdl
index 7f69ce8..a60ce6f 100644
--- a/gffcompare.wdl
+++ b/gffcompare.wdl
@@ -24,11 +24,15 @@ task GffCompare {
         Boolean noTmap = false
         Boolean verbose = false
         Boolean debugMode = false
+        # This workaround only works in the input section.
+        # Issue addressed at https://github.com/openwdl/wdl/pull/263
+        File? noneFile # This is a wdl workaround. Please do not assign!
     }
     # This allows for the creation of output directories"
     String dirPrefix= if defined(outputDir) then outputDir + "/" else ""
     String totalPrefix = dirPrefix + outPrefix
 
+
     parameter_meta {}
 
     command {
@@ -37,7 +41,7 @@ task GffCompare {
         ~{"mkdir -p " + outputDir}
         gffcompare \
         -r ~{referenceAnnotation} \
-        ~{"-o " + totalPrefix } \
+        ~{"-o '" + totalPrefix + "'"} \
         ~{"-s " + genomeSequences} \
         ~{"-e " + maxDistanceFreeEndsTerminalExons} \
         ~{"-d " + maxDistanceGroupingTranscriptStartSites} \
@@ -57,5 +61,20 @@ task GffCompare {
         ~{sep=" " + inputGtfFiles}
     }
 
-    output {}
+    # Output of gffcompare is not stable. It depends on the number of files in the input.
+    Int noFilesGtfList = if defined(inputGtfList) then length(read_lines(inputGtfList)) else 0
+    Int noInputFiles = if defined(inputGtfFiles) then length(inputGtfFiles) else 0
+    Boolean oneFile = (noFilesGtfList + noInputFiles) == 1
+    String annotatedName = if oneFile then "annotated" else "combined"
+
+    # Check if a redundant .gtf will be created
+    Boolean createRedundant = C || A || X
+
+    output {
+        File annotated = totalPrefix + "." + annotatedName + ".gtf"
+        File loci = totalPrefix + ".loci"
+        File stats = totalPrefix + ".stats"
+        File tracking = totalPrefix + ".tracking"
+        File? redundant = if createRedundant then totalPrefix + ".redundant.gtf" else noneFile
+    }
 }
\ No newline at end of file
-- 
GitLab