Commit 627f9574 authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Small fixes in report

parent 73033e0d
...@@ -175,7 +175,7 @@ function loadTable(d, target) { ...@@ -175,7 +175,7 @@ function loadTable(d, target) {
.data(child) .data(child)
.on("click", outerclick); .on("click", outerclick);
row.append("td").attr("class", "col-md-3").text( child.size ); row.append("td").attr("class", "col-md-3").text( child.size );
row.append("td").attr("class", "col-md-3").text( child.value ); row.append("td").attr("class", "col-md-3").text( child.count );
} }
...@@ -221,7 +221,7 @@ var y = d3.scale.sqrt() ...@@ -221,7 +221,7 @@ var y = d3.scale.sqrt()
var color = d3.scale.category20c(); var color = d3.scale.category20c();
var svg = d3.select("body").append("svg") var svg = d3.select("#svgholder").append("svg")
.attr("width", width) .attr("width", width)
.attr("height", height) .attr("height", height)
.append("g") .append("g")
...@@ -248,7 +248,7 @@ var arc = d3.svg.arc() ...@@ -248,7 +248,7 @@ var arc = d3.svg.arc()
// Keep track of the node that is currently being displayed as the root. // Keep track of the node that is currently being displayed as the root.
var node; var node;
d3.json("./tst.json", function(error, root) { function loadGears( root ) {
console.log(root); console.log(root);
node = root; node = root;
var path = svg.datum(root).selectAll("path") var path = svg.datum(root).selectAll("path")
...@@ -291,9 +291,7 @@ d3.json("./tst.json", function(error, root) { ...@@ -291,9 +291,7 @@ d3.json("./tst.json", function(error, root) {
// Get total size of the tree = value of root node from partition. // Get total size of the tree = value of root node from partition.
totalSize = path.node().__data__.value; totalSize = path.node().__data__.value;
}
});
d3.select(self.frameElement).style("height", height + "px"); d3.select(self.frameElement).style("height", height + "px");
......
...@@ -148,18 +148,12 @@ object KrakenReportToJson extends ToolCommand { ...@@ -148,18 +148,12 @@ object KrakenReportToJson extends ToolCommand {
} }
}) })
val result = Map("unclasified" -> lines(0).toJSON(withChildren = false), val result = Map("unclassified" -> lines(0).toJSON(withChildren = false),
"classified" -> lines(1).toJSON(withChildren = true)) "classified" -> lines(1).toJSON(withChildren = true))
mapToJson(result).spaces2 mapToJson(result).spaces2
} }
def summary: String = {
val result = Map("unclasified" -> lines(0).toJSON(withChildren = false),
"classified" -> lines(1).toJSON(withChildren = true))
mapToJson(result).spaces2
}
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val commandArgs: Args = parseArgs(args) val commandArgs: Args = parseArgs(args)
......
...@@ -33,9 +33,7 @@ ...@@ -33,9 +33,7 @@
#if (showPlot) #if (showPlot)
<div class="row"> <div class="row">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script> <div class="col-md-12">
<script src="${rootPath}ext/js/gears.js"></script>
<h3 id='currentlevel'>Root</h3> <h3 id='currentlevel'>Root</h3>
<div> <div>
<span id="selection_name"></span> - <span id="selection_name"></span> -
...@@ -49,7 +47,15 @@ ...@@ -49,7 +47,15 @@
</form> </form>
<div id="sequence"></div> <div id="sequence"></div>
<div id="datatable"> <div id="datatable"></div>
<div id="svgholder"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
<script src="${rootPath}ext/js/gears.js"></script>
<script type="application/ecmascript"> <script type="application/ecmascript">
#{ #{
...@@ -58,9 +64,9 @@ ...@@ -58,9 +64,9 @@
}# }#
var krakenresult = JSON.parse('<%= unescape(bla) %>'); var krakenresult = JSON.parse('<%= unescape(bla) %>');
loadGears(krakenresult.kraken.classified);
</script>
</script>
</div>
</div> </div>
#end #end
...@@ -18,9 +18,9 @@ package nl.lumc.sasc.biopet.pipelines.gears ...@@ -18,9 +18,9 @@ package nl.lumc.sasc.biopet.pipelines.gears
import nl.lumc.sasc.biopet.core.PipelineCommand import nl.lumc.sasc.biopet.core.PipelineCommand
import nl.lumc.sasc.biopet.core.summary.SummaryQScript 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.{ SortSam, SamToFastq } import nl.lumc.sasc.biopet.extensions.picard.SamToFastq
import nl.lumc.sasc.biopet.extensions.sambamba.SambambaView import nl.lumc.sasc.biopet.extensions.sambamba.SambambaView
import nl.lumc.sasc.biopet.extensions.tools.{ KrakenReportToJson, FastqSync } import nl.lumc.sasc.biopet.extensions.tools.{ FastqSync, KrakenReportToJson }
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript import org.broadinstitute.gatk.queue.QScript
...@@ -30,27 +30,25 @@ import org.broadinstitute.gatk.queue.QScript ...@@ -30,27 +30,25 @@ import org.broadinstitute.gatk.queue.QScript
class Gears(val root: Configurable) extends QScript with SummaryQScript { class Gears(val root: Configurable) extends QScript with SummaryQScript {
def this() = this(null) def this() = this(null)
@Input(shortName = "R1", required = false) @Input(doc = "R1 reads in FastQ format", shortName = "R1", required = false)
var fastqFileR1: Option[File] = None var fastqR1: Option[File] = None
@Input(shortName = "R2", required = false) @Input(doc = "R2 reads in FastQ format", shortName = "R2", required = false)
var fastqFileR2: Option[File] = None var fastqR2: Option[File] = None
@Input(doc = "From the bam all the upmapped reads are used for kraken", shortName = "bam", required = false) @Input(doc = "All unmapped reads will be extracted from this bam for analysis", shortName = "bam", required = false)
var bamFile: Option[File] = None var bamFile: Option[File] = None
@Argument(required = false) @Argument(required = false)
var outputName: String = _ var outputName: String = _
var GearsOutputFiles: scala.collection.mutable.Map[String, File] = scala.collection.mutable.Map.empty
/** Executed before running the script */ /** Executed before running the script */
def init(): Unit = { def init(): Unit = {
require(fastqFileR1.isDefined || bamFile.isDefined, "Must define fastq file(s) or a bam file") require(fastqR1.isDefined || bamFile.isDefined, "Must define fastq file(s) or a bam file")
require(fastqFileR1.isDefined != bamFile.isDefined, "Can't define a bam file and a R1 file") require(fastqR1.isDefined != bamFile.isDefined, "Can't define a bam file and a R1 file")
if (outputName == null) { if (outputName == null) {
if (fastqFileR1.isDefined) outputName = fastqFileR1.map(_.getName if (fastqR1.isDefined) outputName = fastqR1.map(_.getName
.stripSuffix(".gz") .stripSuffix(".gz")
.stripSuffix(".fastq") .stripSuffix(".fastq")
.stripSuffix(".fq")) .stripSuffix(".fq"))
...@@ -97,41 +95,41 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript { ...@@ -97,41 +95,41 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript {
// TODO: need some sanity check on whether R2 is really containing reads (e.g. Single End libraries) // TODO: need some sanity check on whether R2 is really containing reads (e.g. Single End libraries)
fastqSync.outputFastq2 = new File(outputDir, s"$outputName.unmapped.R2.sync.fq.gz") fastqSync.outputFastq2 = new File(outputDir, s"$outputName.unmapped.R2.sync.fq.gz")
fastqSync.outputStats = new File(outputDir, s"$outputName.sync.stats.json") fastqSync.outputStats = new File(outputDir, s"$outputName.sync.stats")
add(fastqSync) add(fastqSync)
addSummarizable(fastqSync, "fastqsync")
GearsOutputFiles += ("fastqsync_stats" -> fastqSync.outputStats) outputFiles += ("fastqsync_stats" -> fastqSync.outputStats)
GearsOutputFiles += ("fastqsync_R1" -> fastqSync.outputFastq1) outputFiles += ("fastqsync_R1" -> fastqSync.outputFastq1)
GearsOutputFiles += ("fastqsync_R2" -> fastqSync.outputFastq2) outputFiles += ("fastqsync_R2" -> fastqSync.outputFastq2)
List(fastqSync.outputFastq1, fastqSync.outputFastq2) List(fastqSync.outputFastq1, fastqSync.outputFastq2)
}.getOrElse(List(fastqFileR1, fastqFileR2).flatten) }.getOrElse(List(fastqR1, fastqR2).flatten)
// start kraken // start kraken
val krakenAnalysis = new Kraken(this) val krakenAnalysis = new Kraken(this)
krakenAnalysis.input = fastqFiles krakenAnalysis.input = fastqFiles
krakenAnalysis.output = new File(outputDir, s"$outputName.krkn.raw") krakenAnalysis.output = new File(outputDir, s"$outputName.krkn.raw")
krakenAnalysis.paired = (fastqFiles.length == 2) krakenAnalysis.paired = fastqFiles.length == 2
krakenAnalysis.classified_out = Option(new File(outputDir, s"$outputName.krkn.classified.fastq")) krakenAnalysis.classified_out = Some(new File(outputDir, s"$outputName.krkn.classified.fastq"))
krakenAnalysis.unclassified_out = Option(new File(outputDir, s"$outputName.krkn.unclassified.fastq")) krakenAnalysis.unclassified_out = Some(new File(outputDir, s"$outputName.krkn.unclassified.fastq"))
add(krakenAnalysis) add(krakenAnalysis)
GearsOutputFiles += ("kraken_output_raw" -> krakenAnalysis.output) outputFiles += ("kraken_output_raw" -> krakenAnalysis.output)
GearsOutputFiles += ("kraken_classified_out" -> krakenAnalysis.classified_out.getOrElse("")) outputFiles += ("kraken_classified_out" -> krakenAnalysis.classified_out.getOrElse(""))
GearsOutputFiles += ("kraken_unclassified_out" -> krakenAnalysis.unclassified_out.getOrElse("")) outputFiles += ("kraken_unclassified_out" -> krakenAnalysis.unclassified_out.getOrElse(""))
// create kraken summary file // create kraken summary file
val krakenReport = new KrakenReport(this) val krakenReport = new KrakenReport(this)
krakenReport.input = krakenAnalysis.output krakenReport.input = krakenAnalysis.output
krakenReport.show_zeros = true krakenReport.show_zeros = true
krakenReport.output = new File(outputDir, s"$outputName.krkn.full") krakenReport.output = new File(outputDir, s"$outputName.krkn.full")
add(krakenReport) add(krakenReport)
GearsOutputFiles += ("kraken_report_input" -> krakenReport.input) outputFiles += ("kraken_report_input" -> krakenReport.input)
GearsOutputFiles += ("kraken_report_output" -> krakenReport.output) outputFiles += ("kraken_report_output" -> krakenReport.output)
val krakenReportJSON = new KrakenReportToJson(this) val krakenReportJSON = new KrakenReportToJson(this)
krakenReportJSON.inputReport = krakenReport.output krakenReportJSON.inputReport = krakenReport.output
...@@ -140,8 +138,8 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript { ...@@ -140,8 +138,8 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript {
add(krakenReportJSON) add(krakenReportJSON)
addSummarizable(krakenReportJSON, "krakenreport") addSummarizable(krakenReportJSON, "krakenreport")
GearsOutputFiles += ("kraken_report_json_input" -> krakenReportJSON.inputReport) outputFiles += ("kraken_report_json_input" -> krakenReportJSON.inputReport)
GearsOutputFiles += ("kraken_report_json_output" -> krakenReportJSON.output) outputFiles += ("kraken_report_json_output" -> krakenReportJSON.output)
addSummaryJobs() addSummaryJobs()
} }
...@@ -152,13 +150,13 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript { ...@@ -152,13 +150,13 @@ class Gears(val root: Configurable) extends QScript with SummaryQScript {
/** Pipeline settings shown in the summary file */ /** Pipeline settings shown in the summary file */
def summarySettings: Map[String, Any] = Map.empty ++ def summarySettings: Map[String, Any] = Map.empty ++
(if (bamFile.isDefined) Map("input_bam" -> bamFile.get) else Map()) ++ (if (bamFile.isDefined) Map("input_bam" -> bamFile.get) else Map()) ++
(if (fastqFileR1.isDefined) Map("input_R1" -> fastqFileR1.get) else Map()) (if (fastqR1.isDefined) Map("input_R1" -> fastqR1.get) else Map())
/** Statistics shown in the summary file */ /** Statistics shown in the summary file */
def summaryFiles: Map[String, File] = Map.empty ++ def summaryFiles: Map[String, File] = Map.empty ++
(if (bamFile.isDefined) Map("input_bam" -> bamFile.get) else Map()) ++ (if (bamFile.isDefined) Map("input_bam" -> bamFile.get) else Map()) ++
(if (fastqFileR1.isDefined) Map("input_R1" -> fastqFileR1.get) else Map()) ++ (if (fastqR1.isDefined) Map("input_R1" -> fastqR1.get) else Map()) ++
GearsOutputFiles outputFiles
} }
/** This object give a default main method to the pipelines */ /** This object give a default main method to the pipelines */
......
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