From 6645955ea453995d8348364f507b33eba612711e Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Sun, 16 Aug 2015 15:11:04 +0200
Subject: [PATCH] Switched library to an Option[String]

---
 .../nl/lumc/sasc/biopet/tools/SamplesTsvToJson.scala   | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJson.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJson.scala
index 46cd2b40c..a461bdcac 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJson.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJson.scala
@@ -50,16 +50,14 @@ object SamplesTsvToJson extends ToolCommand {
       val librariesValues: List[Map[String, Any]] = for (tsvLine <- lines.tail) yield {
         val values = tsvLine.split("\t")
         val sample = values(sampleColumn)
-        val library = if (libraryColumn != -1) values(libraryColumn) else null
+        val library = if (libraryColumn != -1) Some(values(libraryColumn)) else None
         val valuesMap = (for (
           t <- 0 until values.size if !values(t).isEmpty && t != sampleColumn && t != libraryColumn
         ) yield header(t) -> values(t)).toMap
-        val map: Map[String, Any] = if (library != null) {
-          Map("samples" -> Map(sample -> Map("libraries" -> Map(library -> valuesMap))))
-        } else {
-          Map("samples" -> Map(sample -> valuesMap))
+        library match {
+          case Some(lib) => Map("samples" -> Map(sample -> Map("libraries" -> Map(library -> valuesMap))))
+          case _ => Map("samples" -> Map(sample -> valuesMap))
         }
-        map
       }
       librariesValues.foldLeft(Map[String, Any]())((acc, kv) => mergeMaps(acc, kv))
     }
-- 
GitLab