From 64134d4609a7bdd887812f8ec192f0f5dd5c25ad Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Fri, 29 Jan 2016 14:05:45 +0100
Subject: [PATCH] wgs and rna metrics now got config value to enable/disable
 them

---
 .../biopet/pipelines/bammetrics/BamMetrics.scala  | 15 ++++++++-------
 .../extensions/picard/CollectRnaSeqMetrics.scala  |  2 +-
 .../sasc/biopet/pipelines/gentrap/Gentrap.scala   |  8 ++++----
 .../pipelines/gentrap/scripts/PlotHeatmap.scala   |  2 +-
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala b/public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala
index 01fd32ab2..78bf5f309 100644
--- a/public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala
+++ b/public/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala
@@ -17,6 +17,7 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
 
 import java.io.File
 
+import nl.lumc.sasc.biopet.core.annotations.{ RibosomalRefFlat, AnnotationRefFlat }
 import nl.lumc.sasc.biopet.utils.config.Configurable
 import nl.lumc.sasc.biopet.core.summary.SummaryQScript
 import nl.lumc.sasc.biopet.core.{ Reference, BiopetFifoPipe, PipelineCommand, SampleLibraryTag }
@@ -31,16 +32,15 @@ class BamMetrics(val root: Configurable) extends QScript
   with SummaryQScript
   with SampleLibraryTag
   with Reference
-  with TargetRegions {
+  with TargetRegions
+  with AnnotationRefFlat
+  with RibosomalRefFlat {
 
   def this() = this(null)
 
   @Input(doc = "Bam File", shortName = "BAM", required = true)
   var inputBam: File = _
 
-  /** Settings for CollectRnaSeqMetrics */
-  var transcriptRefFlatFile: Option[File] = config("transcript_refflat")
-
   /** return location of summary file */
   def summaryFile = (sampleId, libId) match {
     case (Some(s), Some(l)) => new File(outputDir, s + "-" + l + ".BamMetrics.summary.json")
@@ -92,7 +92,7 @@ class BamMetrics(val root: Configurable) extends QScript
     add(gcBiasMetrics)
     addSummarizable(gcBiasMetrics, "gc_bias")
 
-    if (transcriptRefFlatFile.isEmpty) {
+    if (config("wgs_metrics", default = true)) {
       val wgsMetrics = new CollectWgsMetrics(this)
       wgsMetrics.input = inputBam
       wgsMetrics.output = swapExt(outputDir, inputBam, ".bam", ".wgs.metrics")
@@ -100,12 +100,13 @@ class BamMetrics(val root: Configurable) extends QScript
       addSummarizable(wgsMetrics, "wgs")
     }
 
-    if (transcriptRefFlatFile.isDefined) {
+    if (config("rna_metrics", default = false)) {
       val rnaMetrics = new CollectRnaSeqMetrics(this)
       rnaMetrics.input = inputBam
       rnaMetrics.output = swapExt(outputDir, inputBam, ".bam", ".rna.metrics")
       rnaMetrics.chartOutput = Some(swapExt(outputDir, inputBam, ".bam", ".rna.metrics.pdf"))
-      rnaMetrics.refFlat = transcriptRefFlatFile.get
+      rnaMetrics.refFlat = annotationRefFlat()
+      rnaMetrics.ribosomalIntervals = ribosomalRefFlat()
       add(rnaMetrics)
       addSummarizable(rnaMetrics, "rna")
     }
diff --git a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectRnaSeqMetrics.scala b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectRnaSeqMetrics.scala
index 2aca96da6..29c3ef7aa 100644
--- a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectRnaSeqMetrics.scala
+++ b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectRnaSeqMetrics.scala
@@ -36,7 +36,7 @@ class CollectRnaSeqMetrics(val root: Configurable) extends Picard with Summariza
   var refFlat: File = null
 
   @Input(doc = "Location of rRNA sequences in interval list format", required = false)
-  var ribosomalIntervals: Option[File] = config("ribosomal_intervals")
+  var ribosomalIntervals: Option[File] = None
 
   @Output(doc = "Output metrics file", required = true)
   var output: File = null
diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala
index 455bbd9c9..043cd83dc 100644
--- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala
+++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/Gentrap.scala
@@ -93,12 +93,12 @@ class Gentrap(val root: Configurable) extends QScript
     "merge_strategy" -> "preprocessmergesam",
     "gsnap" -> Map(
       "novelsplicing" -> 1,
-      "batch" -> 4,
-      "format" -> "sam"
+      "batch" -> 4
     ),
     "shivavariantcalling" -> Map("variantcallers" -> List("varscan_cns_singlesample")),
     "bammetrics" -> Map(
-      "transcript_refflat" -> annotationRefFlat,
+      "wgs_metrics" -> false,
+      "rna_metrics" -> true,
       "collectrnaseqmetrics" -> ((if (strandProtocol.isSet) Map(
         "strand_specificity" -> (strandProtocol() match {
           case StrandProtocol.NonSpecific => StrandSpecificity.NONE.toString
@@ -106,7 +106,7 @@ class Gentrap(val root: Configurable) extends QScript
           case otherwise                  => throw new IllegalStateException(otherwise.toString)
         })
       )
-      else Map()) ++ (if (ribosomalRefFlat.isSet) ribosomalRefFlat().map("ribosomal_intervals" -> _.getAbsolutePath).toList else Nil))
+      else Map()))
     ),
     "cutadapt" -> Map("minimum_length" -> 20),
     // avoid conflicts when merging since the MarkDuplicate tags often cause merges to fail
diff --git a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/PlotHeatmap.scala b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/PlotHeatmap.scala
index 998ece67c..decd56a55 100644
--- a/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/PlotHeatmap.scala
+++ b/public/gentrap/src/main/scala/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/PlotHeatmap.scala
@@ -43,7 +43,7 @@ class PlotHeatmap(val root: Configurable) extends RscriptCommandLineFunction {
     (if (useLog) Seq("-L") else Seq()) ++
     (countType match {
       case Some(t) => Seq("-C", t)
-      case _ => Seq()
+      case _       => Seq()
     }) ++
     Seq("-I", input.getAbsolutePath, "-O", output.getAbsolutePath)
 }
-- 
GitLab