From cbd73126850923a40b298d7df68f6ef817c16276 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:23:47 +0200 Subject: [PATCH] Added exeption on duplicate sample/libs --- .../scala/nl/lumc/sasc/biopet/tools/SamplesTsvToJson.scala | 6 ++++++ 1 file changed, 6 insertions(+) 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 a461bdcac..f30a45c01 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 @@ -19,6 +19,7 @@ import java.io.File import nl.lumc.sasc.biopet.core.ToolCommand import nl.lumc.sasc.biopet.utils.ConfigUtils._ +import scala.collection.mutable import scala.io.Source @@ -47,10 +48,15 @@ object SamplesTsvToJson extends ToolCommand { val libraryColumn = header.indexOf("library") if (sampleColumn == -1) throw new IllegalStateException("sample column does not exist in: " + inputFile) + val sampleLibCache: mutable.Set[(String, Option[String])] = mutable.Set() + 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) Some(values(libraryColumn)) else None + if (sampleLibCache.contains((sample, library))) + throw new IllegalStateException(s"Combination of $sample and $library is found multiple times") + else sampleLibCache.add((sample, library)) val valuesMap = (for ( t <- 0 until values.size if !values(t).isEmpty && t != sampleColumn && t != libraryColumn ) yield header(t) -> values(t)).toMap -- GitLab