From 25aaee6ed731600a867677a7993d6f09902df116 Mon Sep 17 00:00:00 2001 From: bow <bow@bow.web.id> Date: Wed, 8 Apr 2015 15:10:29 +0200 Subject: [PATCH] Try to convert numeric values appropriately in Picard metrics parsing --- .../picard/CollectAlignmentSummaryMetrics.scala | 2 +- .../sasc/biopet/extensions/picard/MarkDuplicates.scala | 2 +- .../nl/lumc/sasc/biopet/extensions/picard/Picard.scala | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectAlignmentSummaryMetrics.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectAlignmentSummaryMetrics.scala index 10cae9a65..541ee75b8 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectAlignmentSummaryMetrics.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/CollectAlignmentSummaryMetrics.scala @@ -70,7 +70,7 @@ class CollectAlignmentSummaryMetrics(val root: Configurable) extends Picard with case None => Map() case Some((header, content)) => (for (category <- 0 until content.size) yield { - content(category)(0) -> ( + content(category)(0).toString -> ( for ( i <- 1 until header.size if i < content(category).size ) yield { diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/MarkDuplicates.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/MarkDuplicates.scala index 5a3121221..52777a467 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/MarkDuplicates.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/MarkDuplicates.scala @@ -103,7 +103,7 @@ class MarkDuplicates(val root: Configurable) extends Picard with Summarizable { case None => Map() case Some((header, content)) => (for (category <- 0 until content.size) yield { - content(category)(0) -> ( + content(category)(0).toString -> ( for ( i <- 1 until header.size if i < content(category).size ) yield { diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/Picard.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/Picard.scala index 064a182e3..03f7ba975 100644 --- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/Picard.scala +++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/picard/Picard.scala @@ -21,6 +21,7 @@ import scala.io.Source import org.broadinstitute.gatk.utils.commandline.Argument import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction +import nl.lumc.sasc.biopet.utils.tryToParseNumber /** * General picard extension @@ -80,7 +81,7 @@ object Picard { * @param file input metrics file * @return (header, content) */ - def getMetrics(file: File): Option[(Array[String], List[Array[String]])] = + def getMetrics(file: File): Option[(Array[String], List[Array[Any]])] = if (file.exists) { val lines = Source.fromFile(file).getLines().toArray @@ -88,9 +89,10 @@ object Picard { val end = lines.indexOf("", start) val header = lines(start).split("\t") - val content = (for (i <- (start + 1) until end) yield lines(i).split("\t")).toList + val content = (for (i <- (start + 1) until end) yield lines(i).split("\t")) + .map(row => row.map(col => tryToParseNumber(col).getOrElse(col))) - Option((header, content)) + Option((header, content.toList)) } else { None } -- GitLab