Skip to content
Snippets Groups Projects
Commit 4cb2adf1 authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Adding Scaladocs to KrakenReportToJson and remove redundant code

parent 4c405315
No related branches found
No related tags found
No related merge requests found
......@@ -18,9 +18,9 @@ package nl.lumc.sasc.biopet.extensions.kraken
import java.io.File
import nl.lumc.sasc.biopet.core.{ BiopetCommandLineFunction, Version }
import nl.lumc.sasc.biopet.core.{BiopetCommandLineFunction, Version}
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
import org.broadinstitute.gatk.utils.commandline.{Input, Output}
/** Extension for Kraken */
class Kraken(val root: Configurable) extends BiopetCommandLineFunction with Version {
......@@ -65,13 +65,13 @@ class Kraken(val root: Configurable) extends BiopetCommandLineFunction with Vers
/** Returns command to execute */
def cmdLine = required(executable) +
"--db" + required(db) +
required("--db", db) +
optional("--threads", nCoresRequest) +
conditional(quick, "--quick") +
optional("--min_hits", minHits) +
optional("--unclassified-out ", unclassified_out.get) +
optional("--classified-out ", classified_out.get) +
"--output" + required(output) +
required("--output", output) +
conditional(preLoad, "--preload") +
conditional(paired, "--paired") +
conditional(paired, "--check-names") +
......
......@@ -9,7 +9,7 @@ import nl.lumc.sasc.biopet.core.ToolCommandFunction
import nl.lumc.sasc.biopet.core.summary.Summarizable
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
import org.broadinstitute.gatk.utils.commandline.{Argument, Input, Output}
/**
* KrakenReportToJson function class for usage in Biopet pipelines
......@@ -51,12 +51,5 @@ object KrakenReportToJson {
report.output = new File(output, input.getName.substring(0, input.getName.lastIndexOf(".")) + ".kraken.json")
report
}
def apply(root: Configurable, input: File, outDir: String): KrakenReportToJson = {
val report = new KrakenReportToJson(root)
report.inputReport = input
report.output = new File(outDir, input.getName.substring(0, input.getName.lastIndexOf(".")) + ".kraken.json")
report
}
}
......@@ -92,6 +92,15 @@ object KrakenReportToJson extends ToolCommand {
.parse(args, Args())
.getOrElse(sys.exit(1))
/**
* Takes a line from the kraken report, converts into Map with taxonID and
* information on this hit as `KrakenHit`. `KrakenHit` is used later on for
* building the tree
*
* @param krakenRawHit Line from the KrakenReport output
* @param skipNames Specify to skip names in the report output to reduce size of JSON
* @return
*/
def parseLine(krakenRawHit: String, skipNames: Boolean): Map[Long, KrakenHit] = {
val values: Array[String] = krakenRawHit.stripLineEnd.split("\t")
......@@ -118,6 +127,14 @@ object KrakenReportToJson extends ToolCommand {
))
}
/**
* Read the `KrakenReport` output and transform into `Map` by TaxonID and `KrakenHit`
* A JSON-string output is given.
*
* @param reportRaw The `KrakenReport` output
* @param skipNames Specify to skip names in the report output to reduce size of JSON
* @return
*/
def reportToJson(reportRaw: File, skipNames: Boolean): String = {
val reader = Source.fromFile(reportRaw)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment