Commit d82b56a0 authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Updated krakentojson report and enforce check-names with-in Kraken

parent ceaa8fd0
......@@ -39,11 +39,6 @@ class Kraken(val root: Configurable) extends BiopetCommandLineFunction {
var db: File = config("db")
var inputFastQ: Boolean = true
var compression: Boolean = false
var compressionGzip: Boolean = false
var compressionBzip: Boolean = false
var quick: Boolean = false
var minHits: Option[Int] = config("min_hits")
......@@ -68,8 +63,6 @@ class Kraken(val root: Configurable) extends BiopetCommandLineFunction {
def cmdLine = required(executable) +
"--db" + required(db) +
optional("--threads", nCoresRequest) +
conditional(inputFastQ, "--fastq-input") +
conditional(!inputFastQ, "--fasta-input") +
conditional(quick, "--quick") +
optional("--min_hits", minHits) +
optional("--unclassified-out ", unclassified_out.get) +
......@@ -77,5 +70,6 @@ class Kraken(val root: Configurable) extends BiopetCommandLineFunction {
"--output" + required(output) +
conditional(preLoad, "--preload") +
conditional(paired, "--paired") +
conditional(paired, "--check-names") +
repeat(input)
}
......@@ -44,9 +44,9 @@ class KrakenReport(val root: Configurable) extends BiopetCommandLineFunction {
var output: File = _
def cmdLine: String = {
val cmd: String = "--db " + required(db) +
val cmd: String = required(executable) + "--db " + required(db) +
conditional(show_zeros, "--show-zeros") +
input.getAbsolutePath + ">" + output.getAbsolutePath
required(input.getAbsolutePath) + " > " + required(output.getAbsolutePath)
cmd
}
}
......@@ -24,14 +24,17 @@ class KrakenReportToJson(val root: Configurable) extends ToolCommandFuntion with
var inputReport: File = null
@Argument(required = false)
var skipNames: Boolean = true
var skipNames: Boolean = false
@Output(doc = "Output JSON", shortName = "output", required = true)
var output: File = null
override def defaultCoreMemory = 1.0
override def cmdLine = super.cmdLine + required("-i", inputReport) + required("-o", output)
override def cmdLine = super.cmdLine +
required("-i", inputReport) +
required("-o", output) +
conditional(skipNames, "--skipnames")
def summaryStats: Map[String, Any] = {
val map = ConfigUtils.fileToConfigMap(output)
......
......@@ -56,7 +56,7 @@ object KrakenReportToJson extends ToolCommand {
var cladeIDs: mutable.ArrayBuffer[Long] = mutable.ArrayBuffer.fill(32)(0)
val spacePattern = "^( +)".r
case class Args(krakenreport: File = null, outputJson: Option[File] = None, skipNames: Boolean = true) extends AbstractArgs
case class Args(krakenreport: File = null, outputJson: Option[File] = None, skipNames: Boolean = false) extends AbstractArgs
class OptParser extends AbstractOptParser {
......@@ -93,6 +93,9 @@ object KrakenReportToJson extends ToolCommand {
def parseLine(krakenRawHit: String, skipNames: Boolean): Map[Long, KrakenHit] = {
val values: Array[String] = krakenRawHit.stripLineEnd.split("\t")
assert(values.length == 6)
val scientificName: String = values(5)
val cladeLevel = spacePattern.findFirstIn(scientificName).getOrElse("").length / 2
......
......@@ -74,16 +74,10 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript {
samFilterUnmapped.isIntermediate = false
add(samFilterUnmapped)
val samNameSort = new SortSam(qscript)
samNameSort.input = samFilterUnmapped.output
samNameSort.output = new File(outputDir, s"$outputName.unmapped.nsort.bam")
samNameSort.sortOrder = "queryname"
samNameSort.isIntermediate = false
add(samNameSort)
// start bam to fastq (only on unaligned reads) also extract the matesam
val samToFastq = new SamToFastq(qscript)
samToFastq.input= samNameSort.output
samToFastq.input= samFilterUnmapped.output
samToFastq.stringency = Some("LENIENT")
samToFastq.fastqR1 = new File(outputDir, s"$outputName.unmapped.R1.fq.gz")
samToFastq.fastqR2 = new File(outputDir, s"$outputName.unmapped.R2.fq.gz")
samToFastq.fastqUnpaired = new File(outputDir, s"$outputName.unmapped.singleton.fq.gz")
......@@ -136,9 +130,9 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript {
GearsOutputFiles ++ Map("kraken_report_output" -> krakenReport.output)
val krakenReportJSON = new KrakenReportToJson(qscript)
krakenReportJSON.inputReport = krakenAnalysis.output
krakenReportJSON.inputReport = krakenReport.output
krakenReportJSON.output = new File(outputDir, s"$outputName.krkn.json")
krakenReportJSON.skipNames = config("skipNames", default = true)
krakenReportJSON.skipNames = config("skipNames", default = false)
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