From b2da50cbe4ff0004fdc5338a0df879e061dd0f9d Mon Sep 17 00:00:00 2001
From: Wai Yi Leung <w.y.leung@lumc.nl>
Date: Thu, 5 Feb 2015 15:44:11 +0100
Subject: [PATCH] Making the output files Option[File], and use Some() to
 verify whether it was set or not

---
 .../extensions/igvtools/IGVToolsCount.scala   | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/igvtools/IGVToolsCount.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/igvtools/IGVToolsCount.scala
index 2f6275176..4c5f1f255 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/igvtools/IGVToolsCount.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/igvtools/IGVToolsCount.scala
@@ -20,10 +20,10 @@ class IGVToolsCount(val root: Configurable) extends IGVTools {
   var genomeChromSizes: File = _
 
   @Output
-  protected var tdf: File = _
+  protected var tdf: Option[File] = _
 
   @Output
-  protected var wig: File = _
+  protected var wig: Option[File] = _
 
   var maxZoom: Option[Int] = config("maxZoom")
   var windowSize: Option[Int] = config("windowSize")
@@ -46,8 +46,8 @@ class IGVToolsCount(val root: Configurable) extends IGVTools {
     super.afterGraph
     if (!input.exists()) throw new FileNotFoundException("Input bam is required for IGVToolsCount")
 
-    this.tdf = new File(input.getAbsolutePath + ".tdf")
-    this.wig = new File(input.getAbsolutePath.stripSuffix(".bam") + ".wig")
+    this.tdf = Some(new File(input.getAbsolutePath + ".tdf"))
+    this.wig = Some(new File(input.getAbsolutePath.stripSuffix(".bam") + ".wig"))
   }
 
   def cmdLine = {
@@ -72,14 +72,14 @@ class IGVToolsCount(val root: Configurable) extends IGVTools {
 
   /**
    * This part should never fail, these values are set within this wrapper
-   * 
+   *
    */
   private def outputArg: String = {
-    (tdf.isInstanceOf[File], wig.isInstanceOf[File]) match {
-      case (false, false) => throw new IllegalArgumentException("Either TDF or WIG should be supplied");
-      case (true, false)  => tdf.getAbsolutePath;
-      case (false, true)  => wig.getAbsolutePath;
-      case (true, true)   => tdf.getAbsolutePath + "," + wig.getAbsolutePath;
+    (tdf, wig) match {
+      case (None, None)       => throw new IllegalArgumentException("Either TDF or WIG should be supplied");
+      case (Some(a), None)    => a.getAbsolutePath;
+      case (None, Some(b))    => b.getAbsolutePath;
+      case (Some(a), Some(b)) => a.getAbsolutePath + "," + b.getAbsolutePath;
     }
   }
 }
-- 
GitLab