From ec347f6de261af143718b67f4edf0dbf761c2544 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Thu, 16 Apr 2015 13:33:15 +0200
Subject: [PATCH] Added rna metrics

---
 .../sasc/biopet/pipelines/bammetrics/BamMetrics.scala  | 10 ++++++++++
 .../extensions/picard/CollectRnaSeqMetrics.scala       |  7 ++++---
 2 files changed, 14 insertions(+), 3 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 8c94ac09c..affed4885 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
@@ -38,6 +38,8 @@ class BamMetrics(val root: Configurable) extends QScript with SummaryQScript wit
   /** Bed of amplicon that is used */
   var ampliconBedFile: Option[File] = config("amplicon_bed")
 
+  var rnaMetrics: Boolean = config("rna_metrcis", default = false)
+
   /** return location of summary file */
   def summaryFile = (sampleId, libId) match {
     case (Some(sampleId), Some(libId)) => new File(outputDir, sampleId + "-" + libId + ".BamMetrics.summary.json")
@@ -70,6 +72,14 @@ class BamMetrics(val root: Configurable) extends QScript with SummaryQScript wit
 
     add(CollectGcBiasMetrics(this, inputBam, outputDir))
 
+    if (rnaMetrics) {
+      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"))
+      add(rnaMetrics)
+    }
+
     case class Intervals(bed: File, intervals: File)
 
     // Create temp jobs to convert bed files to intervals lists
diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectRnaSeqMetrics.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectRnaSeqMetrics.scala
index dd922fce5..10708d6ff 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectRnaSeqMetrics.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectRnaSeqMetrics.scala
@@ -32,7 +32,8 @@ class CollectRnaSeqMetrics(val root: Configurable) extends Picard with Summariza
   var input: File = null
 
   @Input(doc = "Gene annotations in refFlat form", required = true)
-  var refFlat: File = null
+  var refFlat: File = config("refFlat")
+  //TODO: RefFlat could break gentrap, needs to be checked
 
   @Input(doc = "Location of rRNA sequences in interval list format", required = false)
   var ribosomalIntervals: Option[File] = config("ribosomal_intervals")
@@ -99,9 +100,9 @@ class CollectRnaSeqMetrics(val root: Configurable) extends Picard with Summariza
     required("STRAND_SPECIFICITY=", strandSpecificity, spaceSeparated = false) +
     required("MINIMUM_LENGTH=", minimumLength, spaceSeparated = false) +
     required("CHART_OUTPUT=", chartOutput, spaceSeparated = false) +
-    repeat("IGNORE_SEQUENCE=", ignoreSequence, spaceSeparated = false) +
+    optional("IGNORE_SEQUENCE=", ignoreSequence, spaceSeparated = false) +
     required("RRNA_FRAGMENT_PERCENTAGE=", rRNAFragmentPercentage, spaceSeparated = false) +
-    repeat("METRIC_ACCUMULATION_LEVEL=", metricAccumulationLevel, spaceSeparated = false) +
+    optional("METRIC_ACCUMULATION_LEVEL=", metricAccumulationLevel, spaceSeparated = false) +
     required("REFERENCE_SEQUENCE=", referenceSequence, spaceSeparated = false) +
     required("ASSUME_SORTED=", assumeSorted, spaceSeparated = false) +
     required("STOP_AFTER=", stopAfter, spaceSeparated = false)
-- 
GitLab