From 9f156dafccd4381a8ecd0be2be493160329fb0f1 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Wed, 11 May 2016 15:11:53 +0200
Subject: [PATCH] Added bedtools sorted flag as default

---
 .../nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala  | 2 ++
 .../sasc/biopet/extensions/bedtools/BedtoolsCoverage.scala     | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala b/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala
index 78bf5f309..5eed1f904 100644
--- a/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala
+++ b/bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala
@@ -41,6 +41,8 @@ class BamMetrics(val root: Configurable) extends QScript
   @Input(doc = "Bam File", shortName = "BAM", required = true)
   var inputBam: File = _
 
+  override def defaults = Map("bedtoolscoverage" -> Map("sorted" -> true))
+
   /** return location of summary file */
   def summaryFile = (sampleId, libId) match {
     case (Some(s), Some(l)) => new File(outputDir, s + "-" + l + ".BamMetrics.summary.json")
diff --git a/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/bedtools/BedtoolsCoverage.scala b/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/bedtools/BedtoolsCoverage.scala
index 85cd80712..90830dc0c 100644
--- a/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/bedtools/BedtoolsCoverage.scala
+++ b/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/bedtools/BedtoolsCoverage.scala
@@ -41,6 +41,8 @@ class BedtoolsCoverage(val root: Configurable) extends Bedtools {
   @Argument(doc = "diffStrand", required = false)
   var diffStrand: Boolean = false
 
+  var sorted: Boolean = config("sorted", default = false, freeVar = false)
+
   override def defaultCoreMemory = 4.0
 
   /** Returns command to execute */
@@ -50,6 +52,7 @@ class BedtoolsCoverage(val root: Configurable) extends Bedtools {
     conditional(depth, "-d") +
     conditional(sameStrand, "-s") +
     conditional(diffStrand, "-S") +
+    conditional(sorted, "-sorted") +
     (if (outputAsStsout) "" else " > " + required(output))
 }
 
-- 
GitLab