From eebab126a20caa960a3e40ef490793aa801a78a5 Mon Sep 17 00:00:00 2001
From: Wai Yi Leung <w.y.leung@lumc.nl>
Date: Wed, 27 Jan 2016 16:16:44 +0100
Subject: [PATCH] Pindel update wrapper, specifing the output files (pindel
 generates more files)

---
 .../extensions/pindel/PindelCaller.scala      | 32 +++++++++++++++++++
 .../biopet/extensions/pindel/PindelVCF.scala  | 12 ++++---
 .../pipelines/shiva/svcallers/Pindel.scala    | 10 ++++--
 3 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/pindel/PindelCaller.scala b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/pindel/PindelCaller.scala
index f0bc396a3..426dd52dd 100644
--- a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/pindel/PindelCaller.scala
+++ b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/pindel/PindelCaller.scala
@@ -59,6 +59,21 @@ class PindelCaller(val root: Configurable) extends BiopetCommandLineFunction wit
   @Output(doc = "Output file of pindel, pointing to the DEL file")
   var outputFile: File = _
 
+  @Output(doc="", required=false)
+  var outputINV: File = _
+  @Output(doc="", required=false)
+  var outputTD: File = _
+  @Output(doc="", required=false)
+  var outputLI: File = _
+  @Output(doc="", required=false)
+  var outputBP: File = _
+  @Output(doc="", required=false)
+  var outputSI: File = _
+  @Output(doc="", required=false)
+  var outputRP: File = _
+  @Output(doc="", required=false)
+  var outputCloseEndMapped: File = _
+
   var RP: Option[Int] = config("RP")
   var minDistanceToTheEnd: Option[Int] = config("min_distance_to_the_end")
   // var threads
@@ -126,6 +141,23 @@ class PindelCaller(val root: Configurable) extends BiopetCommandLineFunction wit
       }
     }
 
+    /** setting the output files for the many outputfiles pindel has */
+
+    outputINV = new File(outputPrefix + File.separator, "sample_INV")
+    outputTD = new File(outputPrefix + File.separator, "sample_TD")
+    if (reportLongInsertions) {
+      outputLI = new File(outputPrefix + File.separator, "sample_LI")
+    }
+    if (reportBreakpoints){
+      outputBP = new File(outputPrefix + File.separator, "sample_BP")
+    }
+    outputSI = new File(outputPrefix + File.separator, "sample_SI")
+
+    outputRP = new File(outputPrefix + File.separator, "sample_RP")
+    if (reportCloseMappedReads) {
+      outputCloseEndMapped = new File(outputPrefix + File.separator, "sample_CloseEndMapped")
+    }
+
     // set the output file, the DELetion call is always made
     // TODO: add more outputs for the LI, SI, INV etc...
     outputFile = new File(outputPrefix + File.separator, "sample_D")
diff --git a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/pindel/PindelVCF.scala b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/pindel/PindelVCF.scala
index 8b257bd4e..6d69531e8 100644
--- a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/pindel/PindelVCF.scala
+++ b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/pindel/PindelVCF.scala
@@ -15,8 +15,8 @@ class PindelVCF(val root: Configurable) extends BiopetCommandLineFunction with R
   override def defaultCoreMemory = 2.0
   override def defaultThreads = 1
 
-  def versionRegex = """Version:? (.*)""".r
-  override def versionExitcode = List(1)
+  def versionRegex = """Version:?[ ]+(.*)""".r
+  override def versionExitcode = List(0)
   def versionCommand = executable + " -h"
 
   /**
@@ -28,12 +28,15 @@ class PindelVCF(val root: Configurable) extends BiopetCommandLineFunction with R
   @Output
   var outputVCF: File = _
 
-  var referenceDate: String = config("reference_date", freeVar = false)
+  var rDate: String = config("rdate", freeVar = false)
 
   override def beforeGraph: Unit = {
     if (reference == null) reference = referenceFasta()
   }
 
+  @Input
+  var pindelOutputInputHolder: File = _
+
   var pindelOutput: Option[File] = config("pindel_output")
   var pindelOutputRoot: Option[File] = config("pindel_output_root")
   var chromosome: Option[String] = config("chromosome")
@@ -60,8 +63,9 @@ class PindelVCF(val root: Configurable) extends BiopetCommandLineFunction with R
   var gatkCompatible: Boolean = config("gatk_compatible", default = false)
 
   def cmdLine = required(executable) +
+    required("--reference", reference) +
     required("--reference_name", referenceSpecies) +
-    required("--reference_date", referenceDate) +
+    required("--reference_date", rDate) +
     optional("--pindel_output", pindelOutput) +
     optional("--pindel_output_root", pindelOutputRoot) +
     required("--vcf", outputVCF) +
diff --git a/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/svcallers/Pindel.scala b/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/svcallers/Pindel.scala
index ee4d8289b..a318c5eb9 100644
--- a/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/svcallers/Pindel.scala
+++ b/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/svcallers/Pindel.scala
@@ -29,6 +29,11 @@ class Pindel(val root: Configurable) extends SvCaller {
 
   def this() = this(null)
 
+  /** Default pipeline config */
+  override def defaults = Map("pindelvcf" -> Map(
+    "rdate" -> new SimpleDateFormat("yyyyMMdd").format(Calendar.getInstance().getTime())
+  ))
+
   def biopetScript() {
     for ((sample, bamFile) <- inputBams) {
       val pindelDir = new File(outputDir, sample)
@@ -51,8 +56,9 @@ class Pindel(val root: Configurable) extends SvCaller {
       val todayformat = new SimpleDateFormat("yyyyMMdd")
 
       val pindelVcf = new PindelVCF(this)
-      pindelVcf.pindelOutputRoot = Some(pindelDir)
-      pindelVcf.referenceDate = todayformat.format(today) // officially, we should enter the date of the genome here
+      pindelVcf.pindelOutputInputHolder = pindel.outputFile
+      pindelVcf.pindelOutputRoot = Some(new File(pindelDir, "sample"))
+      pindelVcf.rDate = todayformat.format(today) // officially, we should enter the date of the genome here
       pindelVcf.outputVCF = new File(pindelDir, s"${sample}.pindel.vcf")
       add(pindelVcf)
     }
-- 
GitLab