From e86f6183a48dd587764e23740fd91188199eae4f Mon Sep 17 00:00:00 2001
From: bow <bow@bow.web.id>
Date: Tue, 17 Feb 2015 18:51:40 +0100
Subject: [PATCH] Fix cryptic pipeline errors caused by using directory as
 output files

---
 .../extensions/samtools/SamtoolsFlagstat.scala       | 12 +++---------
 .../nl/lumc/sasc/biopet/tools/BiopetFlagstat.scala   | 10 ++--------
 2 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/samtools/SamtoolsFlagstat.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/samtools/SamtoolsFlagstat.scala
index b57e67732..e26768455 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/samtools/SamtoolsFlagstat.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/samtools/SamtoolsFlagstat.scala
@@ -30,17 +30,11 @@ class SamtoolsFlagstat(val root: Configurable) extends Samtools {
 }
 
 object SamtoolsFlagstat {
-  def apply(root: Configurable, input: File, output: File): SamtoolsFlagstat = {
+  def apply(root: Configurable, input: File, outputDir: File): SamtoolsFlagstat = {
     val flagstat = new SamtoolsFlagstat(root)
     flagstat.input = input
-    flagstat.output = output
-    return flagstat
-  }
-
-  def apply(root: Configurable, input: File, outputDir: String): SamtoolsFlagstat = {
-    val dir = if (outputDir.endsWith("/")) outputDir else outputDir + "/"
-    val outputFile = new File(dir + swapExtension(input.getName))
-    return apply(root, input, outputFile)
+    flagstat.output = new File(outputDir + swapExtension(input.getName))
+    flagstat
   }
 
   def apply(root: Configurable, input: File): SamtoolsFlagstat = {
diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstat.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstat.scala
index 3aa5a2282..6f4ffbcd2 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstat.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/BiopetFlagstat.scala
@@ -40,17 +40,11 @@ class BiopetFlagstat(val root: Configurable) extends BiopetJavaCommandLineFuncti
 }
 
 object BiopetFlagstat extends ToolCommand {
-  def apply(root: Configurable, input: File, output: File): BiopetFlagstat = {
-    val flagstat = new BiopetFlagstat(root)
-    flagstat.input = input
-    flagstat.output = output
-    return flagstat
-  }
-  def apply(root: Configurable, input: File, outputDir: String): BiopetFlagstat = {
+  def apply(root: Configurable, input: File, outputDir: File): BiopetFlagstat = {
     val flagstat = new BiopetFlagstat(root)
     flagstat.input = input
     flagstat.output = new File(outputDir, input.getName.stripSuffix(".bam") + ".biopetflagstat")
-    return flagstat
+    flagstat
   }
 
   case class Args(inputFile: File = null, region: Option[String] = None) extends AbstractArgs
-- 
GitLab