From 0f4f1881838c644227d4ae6c240c01e7e0254bee Mon Sep 17 00:00:00 2001
From: Wai Yi Leung <w.y.leung@lumc.nl>
Date: Thu, 22 Oct 2015 16:23:03 +0200
Subject: [PATCH] Bugfix in KrakenReportToJson, include Root and Unclassified
 in any case.

---
 .../nl/lumc/sasc/biopet/tools/KrakenReportToJson.scala   | 9 ++++-----
 .../nl/lumc/sasc/biopet/pipelines/gears/Gears.scala      | 8 ++++----
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/KrakenReportToJson.scala b/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/KrakenReportToJson.scala
index 3f2f83286..1c8ee5681 100644
--- a/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/KrakenReportToJson.scala
+++ b/public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/KrakenReportToJson.scala
@@ -19,13 +19,13 @@ package nl.lumc.sasc.biopet.tools
  * Created by wyleung on 25-9-15.
  */
 
-import java.io.{ PrintWriter, File }
+import java.io.{File, PrintWriter}
 
 import nl.lumc.sasc.biopet.utils.ConfigUtils._
 import nl.lumc.sasc.biopet.utils.ToolCommand
-import scala.collection.mutable.ListBuffer
-import scala.collection.mutable
 
+import scala.collection.mutable
+import scala.collection.mutable.ListBuffer
 import scala.io.Source
 
 case class KrakenHit(taxonomyID: Long,
@@ -120,7 +120,6 @@ object KrakenReportToJson extends ToolCommand {
 
   def reportToJson(reportRaw: File, skipNames: Boolean): String = {
     val reader = Source.fromFile(reportRaw)
-    //    val lines = reader.getLines().toList.filter(!_.isEmpty)
 
     /*
     * http://ccb.jhu.edu/software/kraken/MANUAL.html
@@ -135,7 +134,7 @@ object KrakenReportToJson extends ToolCommand {
 
     lines = reader.getLines()
       .map(line => parseLine(line, skipNames))
-      .filter(p => p.head._2.cladeSize > 0)
+      .filter(p => (p.head._2.cladeSize > 0) || List(0L, 1L).contains(p.head._2.taxonomyID))
       .foldLeft(Map.empty[Long, KrakenHit])((a, b) => {
         a + b.head
       })
diff --git a/public/gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/Gears.scala b/public/gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/Gears.scala
index da59e40cf..e8ddd6184 100644
--- a/public/gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/Gears.scala
+++ b/public/gears/src/main/scala/nl/lumc/sasc/biopet/pipelines/gears/Gears.scala
@@ -17,10 +17,10 @@ package nl.lumc.sasc.biopet.pipelines.gears
 
 import nl.lumc.sasc.biopet.core.PipelineCommand
 import nl.lumc.sasc.biopet.core.summary.SummaryQScript
-import nl.lumc.sasc.biopet.extensions.kraken.{ Kraken, KrakenReport }
+import nl.lumc.sasc.biopet.extensions.kraken.{Kraken, KrakenReport}
 import nl.lumc.sasc.biopet.extensions.picard.SamToFastq
 import nl.lumc.sasc.biopet.extensions.sambamba.SambambaView
-import nl.lumc.sasc.biopet.extensions.tools.{ FastqSync, KrakenReportToJson }
+import nl.lumc.sasc.biopet.extensions.tools.{FastqSync, KrakenReportToJson}
 import nl.lumc.sasc.biopet.utils.config.Configurable
 import org.broadinstitute.gatk.queue.QScript
 
@@ -44,8 +44,8 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript {
 
   /** Executed before running the script */
   def init(): Unit = {
-    require(fastqR1.isDefined || bamFile.isDefined, "Must define fastq file(s) or a bam file")
-    require(fastqR1.isDefined != bamFile.isDefined, "Can't define a bam file and a R1 file")
+    require(fastqR1.isDefined || bamFile.isDefined, "Please specify fastq-file(s) or bam file")
+    require(fastqR1.isDefined != bamFile.isDefined, "Provide either a bam file or la R1 file")
 
     if (outputName == null) {
       if (fastqR1.isDefined) outputName = fastqR1.map(_.getName
-- 
GitLab