From ad73824fde8950bc9068704a3cc99d7200c07b9c Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Mon, 21 Sep 2015 14:58:11 +0200
Subject: [PATCH] Fix summary when --sample flag is used in multisample
 pipelines

---
 .../main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala | 6 +++++-
 .../scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala | 2 +-
 .../nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala   | 6 +++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala
index f35c07a0a..91b265986 100644
--- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala
+++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetQScript.scala
@@ -86,7 +86,11 @@ trait BiopetQScript extends Configurable with GatkLogging {
       globalConfig.writeReport(qSettings.runName, new File(outputDir, ".log/" + qSettings.runName))
     else Logging.addError("Parent of output dir: '" + outputDir.getParent + "' is not writeable, outputdir can not be created")
 
-    reportClass.foreach(add(_))
+    this match {
+      case q: MultiSampleQScript if (q.onlySamples.nonEmpty) =>
+        logger.info("Write summary is skipped because sample flag is used")
+      case _ => reportClass.foreach(add(_))
+    }
 
     Logging.checkErrors()
   }
diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala
index d8756c7b9..baf9f5acb 100644
--- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala
+++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/MultiSampleQScript.scala
@@ -26,7 +26,7 @@ trait MultiSampleQScript extends SummaryQScript {
   qscript =>
 
   @Argument(doc = "Only Sample", shortName = "s", required = false, fullName = "sample")
-  private val onlySamples: List[String] = Nil
+  private[core] val onlySamples: List[String] = Nil
 
   require(globalConfig.map.contains("samples"), "No Samples found in config")
 
diff --git a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala
index 52c77fe8a..1876c2fb0 100644
--- a/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala
+++ b/public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryQScript.scala
@@ -135,7 +135,11 @@ trait SummaryQScript extends BiopetQScript {
     for ((_, file) <- this.summaryFiles)
       addChecksum(file)
 
-    add(writeSummary)
+    this match {
+      case q: MultiSampleQScript if (q.onlySamples.nonEmpty) =>
+        logger.info("Write summary is skipped because sample flag is used")
+      case _ => add(writeSummary)
+    }
   }
 }
 
-- 
GitLab