Commit 6f58b7e2 authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Adding krakenreport2json to gears pipeline

parent 45b54bc6
......@@ -85,8 +85,7 @@ object KrakenReportToJson extends ToolCommand {
.parse(args, Args())
.getOrElse(sys.exit(1))
def parseLine( krakenRawHit: String ): Map[Long, KrakenHit] = {
def parseLine(krakenRawHit: String): Map[Long, KrakenHit] = {
val values: Array[String] = krakenRawHit.stripLineEnd.split("\t")
val scientificName: String = values(5)
val cladeLevel = spacePattern.findFirstIn(scientificName).getOrElse("").length / 2
......@@ -111,7 +110,7 @@ object KrakenReportToJson extends ToolCommand {
def reportToJson(reportRaw: File): String = {
val reader = Source.fromFile(reportRaw)
// val lines = reader.getLines().toList.filter(!_.isEmpty)
// val lines = reader.getLines().toList.filter(!_.isEmpty)
/*
* http://ccb.jhu.edu/software/kraken/MANUAL.html
......@@ -125,11 +124,11 @@ object KrakenReportToJson extends ToolCommand {
* */
val lines = reader.getLines()
.map(line => parseLine(line))
.filter(p => p.head._2.cladeSize > 0)
.foldLeft(Map.empty[Long, KrakenHit])( (a,b) => {
a + b.head
} )
.map(line => parseLine(line))
.filter(p => p.head._2.cladeSize > 0)
.foldLeft(Map.empty[Long, KrakenHit])((a, b) => {
a + b.head
})
lines.keys.foreach(k => {
// append itself to the children attribute of the parent
......
......@@ -22,6 +22,7 @@ import nl.lumc.sasc.biopet.extensions.picard.SamToFastq
import nl.lumc.sasc.biopet.extensions.sambamba.SambambaView
import nl.lumc.sasc.biopet.extensions.tools.FastqSync
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.tools.KrakenReportToJson
import org.broadinstitute.gatk.queue.QScript
/**
......@@ -113,6 +114,11 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript { qscrip
krakenReport.output = new File(outputDir, s"$outputName.krkn.full")
add(krakenReport)
val krakenReportJSON = new KrakenReportToJson(qscript)
krakenReportJSON.input = krakenReport.output
krakenReportJSON.output = new File(outputDir, s"$outputName.krkn.json")
add(krakenReportJSON)
addSummaryJobs()
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment