From d107727ca687131832837af04a38f2d60800d1cb Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Sun, 29 Nov 2015 14:37:15 +0100
Subject: [PATCH] Fix graph issues

---
 .../pipelines/flexiprep/Flexiprep.scala       |  1 +
 .../pipelines/flexiprep/QcCommand.scala       | 23 ++++++++++---------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala b/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala
index 1f1f2510c..7c2b9ace1 100644
--- a/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala
+++ b/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala
@@ -195,6 +195,7 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
 
         override def beforeGraph(): Unit = {
           fqSync.beforeGraph()
+          commands = qcCmdR1.jobs ::: qcCmdR2.jobs ::: fqSync :: Nil
           super.beforeGraph()
         }
 
diff --git a/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/QcCommand.scala b/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/QcCommand.scala
index 4cb06039b..8eb65f074 100644
--- a/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/QcCommand.scala
+++ b/public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/QcCommand.scala
@@ -50,7 +50,15 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
   val seqtk = new SeqtkSeq(root)
   var clip: Option[Cutadapt] = None
   var trim: Option[Sickle] = None
-  var outputCommand: BiopetCommandLineFunction = null
+  lazy val outputCommand: BiopetCommandLineFunction = if (compress) {
+    val gzip = Gzip(root)
+    gzip.output = output
+    gzip
+  } else {
+    val cat = Cat(root)
+    cat.output = output
+    cat
+  }
 
   def jobs = (Some(seqtk) :: clip :: trim :: Some(outputCommand) :: Nil).flatten
 
@@ -123,16 +131,9 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
       case _            => seqtk.output
     }
 
-    if (compress) outputCommand = {
-      val gzip = new Gzip(root)
-      gzip.output = output
-      outputFile :<: gzip
-    }
-    else outputCommand = {
-      val cat = new Cat(root)
-      cat.input = outputFile :: Nil
-      cat.output = output
-      cat
+    outputCommand match {
+      case gzip: Gzip => outputFile :<: gzip
+      case cat: Cat => cat.input = outputFile :: Nil
     }
 
     seqtk.beforeGraph()
-- 
GitLab