From 0da332ac020937c5a3de01a923472660cb3ecc00 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Tue, 23 Aug 2016 11:54:00 +0200
Subject: [PATCH] Removed insertsize plot on single end from report

---
 .../scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala  | 1 +
 .../biopet/pipelines/mapping/MultisampleMappingReport.scala    | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala b/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala
index b0a435ff2..369e50dc6 100644
--- a/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala
+++ b/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/Mapping.scala
@@ -126,6 +126,7 @@ class Mapping(val root: Configurable) extends QScript with SummaryQScript with S
     "skip_metrics" -> skipMetrics,
     "skip_flexiprep" -> skipFlexiprep,
     "skip_markduplicates" -> skipMarkduplicates,
+    "paired" -> inputR2.isDefined,
     "aligner" -> aligner,
     "chunking" -> chunking,
     "number_of_chunks" -> (if (chunking) numberChunks.getOrElse(1) else None)
diff --git a/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/MultisampleMappingReport.scala b/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/MultisampleMappingReport.scala
index 9a079045f..85709c12c 100644
--- a/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/MultisampleMappingReport.scala
+++ b/mapping/src/main/scala/nl/lumc/sasc/biopet/pipelines/mapping/MultisampleMappingReport.scala
@@ -49,6 +49,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
     val wgsExecuted = summary.getSampleValues("bammetrics", "stats", "wgs").values.exists(_.isDefined)
     val rnaExecuted = summary.getSampleValues("bammetrics", "stats", "rna").values.exists(_.isDefined)
     val insertsizeExecuted = summary.getSampleValues("bammetrics", "stats", "CollectInsertSizeMetrics", "metrics").values.exists(_ != Some(None))
+    val pairedFound = summary.getLibraryValues("mapping", "settings", "paired").exists(_._2 == Some(true))
     val flexiprepExecuted = summary.getLibraryValues("flexiprep")
       .exists { case ((sample, lib), value) => value.isDefined }
 
@@ -71,7 +72,7 @@ trait MultisampleMappingReportTrait extends MultisampleReportBuilder {
         List("Alignment" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/alignmentSummary.ssp",
           Map("sampleLevel" -> true, "showPlot" -> true, "showTable" -> false)
         )) ++
-        (if (insertsizeExecuted) List("Insert Size" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp",
+        (if (insertsizeExecuted && pairedFound) List("Insert Size" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/insertSize.ssp",
           Map("sampleLevel" -> true, "showPlot" -> true, "showTable" -> false)))
         else Nil) ++
         (if (wgsExecuted) List("Whole genome coverage" -> ReportSection("/nl/lumc/sasc/biopet/pipelines/bammetrics/wgsHistogram.ssp",
-- 
GitLab