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
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.config.Configurable
import nl.lumc.sasc.biopet.core.summary.{Summarizable, SummaryQScript}
......@@ -36,17 +36,22 @@ class CollectMultipleMetrics(val parent: Configurable)
override def defaultCoreMemory = 8.0
@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")
var reference: File = null
var reference: File = _
@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)
var program: List[String] =
config("metrics_programs", default = Programs.values.iterator.toList.map(_.toString))
var program: List[Programs.Value] = {
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)
var assumeSorted: Boolean = config("assume_sorted", default = false)
......@@ -61,52 +66,51 @@ class CollectMultipleMetrics(val parent: Configurable)
super.beforeGraph()
if (reference == null) reference = referenceFasta()
program.foreach {
case p if p == Programs.CollectAlignmentSummaryMetrics.toString =>
case Programs.CollectAlignmentSummaryMetrics =>
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_histogram.pdf")
case p if p == Programs.QualityScoreDistribution.toString =>
case Programs.QualityScoreDistribution =>
outputFiles :+= new File(outputName + ".quality_distribution_metrics")
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.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.pdf")
case p => Logging.addError("Program '" + p + "' does not exist for 'CollectMultipleMetrics'")
}
}
override def cmdLine =
override def cmdLine: String =
super.cmdLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", outputName, spaceSeparated = false) +
conditional(assumeSorted, "ASSUME_SORTED=true") +
optional("STOP_AFTER=", stopAfter, 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 = {
def summarizable(stats: () => Any): Summarizable = new Summarizable {
def summaryStats = stats()
def summaryStats: Any = stats()
def summaryFiles: Map[String, File] = Map()
}
program
.foreach { p =>
p match {
case _ if p == Programs.CollectAlignmentSummaryMetrics.toString =>
.foreach {
case Programs.CollectAlignmentSummaryMetrics =>
qscript.addSummarizable(
summarizable(
() =>
Picard.getMetrics(new File(outputName + ".alignment_summary_metrics"),
groupBy = Some("CATEGORY"))),
p,
Programs.CollectAlignmentSummaryMetrics.toString,
forceSingle = true)
case _ if p == Programs.CollectInsertSizeMetrics.toString =>
case Programs.CollectInsertSizeMetrics =>
qscript.addSummarizable(
summarizable(
() =>
......@@ -118,43 +122,42 @@ class CollectMultipleMetrics(val parent: Configurable)
new File(outputName + ".insert_size_metrics"))
)
else Map()),
p,
Programs.CollectInsertSizeMetrics.toString,
forceSingle = true
)
case _ if p == Programs.QualityScoreDistribution.toString =>
case Programs.QualityScoreDistribution =>
qscript.addSummarizable(
summarizable(
() => Picard.getHistogram(new File(outputName + ".quality_distribution_metrics"))),
p,
Programs.QualityScoreDistribution.toString,
forceSingle = true)
case _ if p == Programs.MeanQualityByCycle.toString =>
case Programs.MeanQualityByCycle =>
qscript.addSummarizable(
summarizable(
() => Picard.getHistogram(new File(outputName + ".quality_by_cycle_metrics"))),
p,
Programs.MeanQualityByCycle.toString,
forceSingle = true)
case _ if p == Programs.CollectBaseDistributionByCycle.toString =>
case Programs.CollectBaseDistributionByCycle =>
qscript.addSummarizable(
summarizable(
() =>
Picard.getHistogram(new File(outputName + ".base_distribution_by_cycle_metrics"),
tag = "METRICS CLASS")),
p,
Programs.CollectBaseDistributionByCycle.toString,
forceSingle = true)
case _ => None
}
}
}
def summaryStats = Map()
def summaryFiles: Map[String, File] = {
program
.map {
case p if p == Programs.CollectInsertSizeMetrics.toString =>
case Programs.CollectInsertSizeMetrics =>
Map("insert_size_histogram" -> new File(outputName + ".insert_size_histogram.pdf"),
"insert_size_metrics" -> new File(outputName + ".insert_size_metrics"))
case otherwise => Map()
case _ => Map()
}
.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