Commit 659f81e6 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Fixed single end metrics

parent 58a0162c
...@@ -16,7 +16,7 @@ package nl.lumc.sasc.biopet.extensions.picard ...@@ -16,7 +16,7 @@ package nl.lumc.sasc.biopet.extensions.picard
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.{Reference, BiopetQScript} import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.utils.Logging import nl.lumc.sasc.biopet.utils.Logging
import nl.lumc.sasc.biopet.utils.config.Configurable import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.summary.{Summarizable, SummaryQScript} import nl.lumc.sasc.biopet.core.summary.{Summarizable, SummaryQScript}
...@@ -36,17 +36,22 @@ class CollectMultipleMetrics(val parent: Configurable) ...@@ -36,17 +36,22 @@ class CollectMultipleMetrics(val parent: Configurable)
override def defaultCoreMemory = 8.0 override def defaultCoreMemory = 8.0
@Input(doc = "The input SAM or BAM files to analyze", required = true) @Input(doc = "The input SAM or BAM files to analyze", required = true)
var input: File = null var input: File = _
@Input(doc = "The reference file for the bam files.", shortName = "R") @Input(doc = "The reference file for the bam files.", shortName = "R")
var reference: File = null var reference: File = _
@Output(doc = "Base name of output files", required = true) @Output(doc = "Base name of output files", required = true)
var outputName: File = null var outputName: File = _
@Argument(doc = "Base name of output files", required = true) @Argument(doc = "Base name of output files", required = true)
var program: List[String] = var program: List[Programs.Value] = {
config("metrics_programs", default = Programs.values.iterator.toList.map(_.toString)) val value: List[String] = config("metrics_programs")
value match {
case Nil => Programs.values.toList
case list => list.flatMap(x => Programs.values.find(_.toString.toLowerCase == x.toLowerCase))
}
}
@Argument(doc = "Assume alignment file is sorted by position", required = false) @Argument(doc = "Assume alignment file is sorted by position", required = false)
var assumeSorted: Boolean = config("assume_sorted", default = false) var assumeSorted: Boolean = config("assume_sorted", default = false)
...@@ -61,52 +66,51 @@ class CollectMultipleMetrics(val parent: Configurable) ...@@ -61,52 +66,51 @@ class CollectMultipleMetrics(val parent: Configurable)
super.beforeGraph() super.beforeGraph()
if (reference == null) reference = referenceFasta() if (reference == null) reference = referenceFasta()
program.foreach { program.foreach {
case p if p == Programs.CollectAlignmentSummaryMetrics.toString => case Programs.CollectAlignmentSummaryMetrics =>
outputFiles :+= new File(outputName + ".alignment_summary_metrics") outputFiles :+= new File(outputName + ".alignment_summary_metrics")
case p if p == Programs.CollectInsertSizeMetrics.toString => case Programs.CollectInsertSizeMetrics =>
outputFiles :+= new File(outputName + ".insert_size_metrics") outputFiles :+= new File(outputName + ".insert_size_metrics")
outputFiles :+= new File(outputName + ".insert_size_histogram.pdf") outputFiles :+= new File(outputName + ".insert_size_histogram.pdf")
case p if p == Programs.QualityScoreDistribution.toString => case Programs.QualityScoreDistribution =>
outputFiles :+= new File(outputName + ".quality_distribution_metrics") outputFiles :+= new File(outputName + ".quality_distribution_metrics")
outputFiles :+= new File(outputName + ".test.quality_distribution.pdf") outputFiles :+= new File(outputName + ".test.quality_distribution.pdf")
case p if p == Programs.MeanQualityByCycle.toString => case Programs.MeanQualityByCycle =>
outputFiles :+= new File(outputName + ".quality_by_cycle_metrics") outputFiles :+= new File(outputName + ".quality_by_cycle_metrics")
outputFiles :+= new File(outputName + ".quality_by_cycle.pdf") outputFiles :+= new File(outputName + ".quality_by_cycle.pdf")
case p if p == Programs.CollectBaseDistributionByCycle.toString => case Programs.CollectBaseDistributionByCycle =>
outputFiles :+= new File(outputName + ".base_distribution_by_cycle_metrics") outputFiles :+= new File(outputName + ".base_distribution_by_cycle_metrics")
outputFiles :+= new File(outputName + ".base_distribution_by_cycle.pdf") outputFiles :+= new File(outputName + ".base_distribution_by_cycle.pdf")
case p => Logging.addError("Program '" + p + "' does not exist for 'CollectMultipleMetrics'") case p => Logging.addError("Program '" + p + "' does not exist for 'CollectMultipleMetrics'")
} }
} }
override def cmdLine = override def cmdLine: String =
super.cmdLine + super.cmdLine +
required("INPUT=", input, spaceSeparated = false) + required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", outputName, spaceSeparated = false) + required("OUTPUT=", outputName, spaceSeparated = false) +
conditional(assumeSorted, "ASSUME_SORTED=true") + conditional(assumeSorted, "ASSUME_SORTED=true") +
optional("STOP_AFTER=", stopAfter, spaceSeparated = false) + optional("STOP_AFTER=", stopAfter, spaceSeparated = false) +
optional("REFERENCE_SEQUENCE=", reference, spaceSeparated = false) + optional("REFERENCE_SEQUENCE=", reference, spaceSeparated = false) +
repeat("PROGRAM=", program, spaceSeparated = false) repeat("PROGRAM=", program.map(_.toString), spaceSeparated = false)
override def addToQscriptSummary(qscript: SummaryQScript): Unit = { override def addToQscriptSummary(qscript: SummaryQScript): Unit = {
def summarizable(stats: () => Any): Summarizable = new Summarizable { def summarizable(stats: () => Any): Summarizable = new Summarizable {
def summaryStats = stats() def summaryStats: Any = stats()
def summaryFiles: Map[String, File] = Map() def summaryFiles: Map[String, File] = Map()
} }
program program
.foreach { p => .foreach {
p match { case Programs.CollectAlignmentSummaryMetrics =>
case _ if p == Programs.CollectAlignmentSummaryMetrics.toString =>
qscript.addSummarizable( qscript.addSummarizable(
summarizable( summarizable(
() => () =>
Picard.getMetrics(new File(outputName + ".alignment_summary_metrics"), Picard.getMetrics(new File(outputName + ".alignment_summary_metrics"),
groupBy = Some("CATEGORY"))), groupBy = Some("CATEGORY"))),
p, Programs.CollectAlignmentSummaryMetrics.toString,
forceSingle = true) forceSingle = true)
case _ if p == Programs.CollectInsertSizeMetrics.toString => case Programs.CollectInsertSizeMetrics =>
qscript.addSummarizable( qscript.addSummarizable(
summarizable( summarizable(
() => () =>
...@@ -118,43 +122,42 @@ class CollectMultipleMetrics(val parent: Configurable) ...@@ -118,43 +122,42 @@ class CollectMultipleMetrics(val parent: Configurable)
new File(outputName + ".insert_size_metrics")) new File(outputName + ".insert_size_metrics"))
) )
else Map()), else Map()),
p, Programs.CollectInsertSizeMetrics.toString,
forceSingle = true forceSingle = true
) )
case _ if p == Programs.QualityScoreDistribution.toString => case Programs.QualityScoreDistribution =>
qscript.addSummarizable( qscript.addSummarizable(
summarizable( summarizable(
() => Picard.getHistogram(new File(outputName + ".quality_distribution_metrics"))), () => Picard.getHistogram(new File(outputName + ".quality_distribution_metrics"))),
p, Programs.QualityScoreDistribution.toString,
forceSingle = true) forceSingle = true)
case _ if p == Programs.MeanQualityByCycle.toString => case Programs.MeanQualityByCycle =>
qscript.addSummarizable( qscript.addSummarizable(
summarizable( summarizable(
() => Picard.getHistogram(new File(outputName + ".quality_by_cycle_metrics"))), () => Picard.getHistogram(new File(outputName + ".quality_by_cycle_metrics"))),
p, Programs.MeanQualityByCycle.toString,
forceSingle = true) forceSingle = true)
case _ if p == Programs.CollectBaseDistributionByCycle.toString => case Programs.CollectBaseDistributionByCycle =>
qscript.addSummarizable( qscript.addSummarizable(
summarizable( summarizable(
() => () =>
Picard.getHistogram(new File(outputName + ".base_distribution_by_cycle_metrics"), Picard.getHistogram(new File(outputName + ".base_distribution_by_cycle_metrics"),
tag = "METRICS CLASS")), tag = "METRICS CLASS")),
p, Programs.CollectBaseDistributionByCycle.toString,
forceSingle = true) forceSingle = true)
case _ => None case _ => None
} }
} }
}
def summaryStats = Map() def summaryStats = Map()
def summaryFiles: Map[String, File] = { def summaryFiles: Map[String, File] = {
program program
.map { .map {
case p if p == Programs.CollectInsertSizeMetrics.toString => case Programs.CollectInsertSizeMetrics =>
Map("insert_size_histogram" -> new File(outputName + ".insert_size_histogram.pdf"), Map("insert_size_histogram" -> new File(outputName + ".insert_size_histogram.pdf"),
"insert_size_metrics" -> new File(outputName + ".insert_size_metrics")) "insert_size_metrics" -> new File(outputName + ".insert_size_metrics"))
case otherwise => Map() case _ => Map()
} }
.foldLeft(Map.empty[String, File]) { case (acc, m) => acc ++ m } .foldLeft(Map.empty[String, File]) { case (acc, m) => acc ++ m }
} }
......
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