Commit 38b152be authored by Peter van 't Hof's avatar Peter van 't Hof

Fixing BIOPET-491

parent 21fa48ed
......@@ -42,4 +42,6 @@ trait Summarizable {
def resolveSummaryConflict(v1: Any, v2: Any, key: String): Any = {
throw new IllegalStateException("Merge can not have same key by default")
}
def summaryDeps: List[File] = Nil
}
......@@ -56,13 +56,16 @@ class WriteSummary(val root: Configurable) extends InProcessFunction with Config
def init(): Unit = {
for (q <- qscript.summaryQScripts)
deps :+= q.summaryFile
for ((_, l) <- qscript.summarizables; s <- l) s match {
case f: QFunction if qscript.functions.contains(f) => try {
deps :+= f.firstOutput
} catch {
case e: NullPointerException => logger.warn("Queue values are not init")
for ((_, l) <- qscript.summarizables; s <- l) {
deps :::= s.summaryDeps
s match {
case f: QFunction if qscript.functions.contains(f) => try {
deps :+= f.firstOutput
} catch {
case e: NullPointerException => logger.warn("Queue values are not init")
}
case _ =>
}
case _ =>
}
jobOutputFile = new File(out.getParentFile, ".%s.%s.out".format(out.getName, analysisName))
......
......@@ -84,6 +84,8 @@ class Sickle(val root: Configurable) extends BiopetCommandLineFunction with Summ
(if (outputAsStsout) "" else " > " + required(outputStats))
}
override def summaryDeps = outputStats :: super.summaryDeps
/** returns stats map for summary */
def summaryStats: Map[String, Any] = {
// regex for single run
......
......@@ -94,6 +94,8 @@ class FastqSync(val root: Configurable) extends ToolCommandFunction with Summari
)
}
override def summaryDeps = outputStats :: super.summaryDeps
override def resolveSummaryConflict(v1: Any, v2: Any, key: String): Any = {
(v1, v2) match {
case (v1: Int, v2: Int) => v1 + v2
......
......@@ -14,12 +14,12 @@
*/
package nl.lumc.sasc.biopet.pipelines.flexiprep
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{ BiopetFifoPipe, PipelineCommand, SampleLibraryTag }
import nl.lumc.sasc.biopet.extensions.{ Gzip, Zcat }
import nl.lumc.sasc.biopet.core.summary.{Summarizable, SummaryQScript}
import nl.lumc.sasc.biopet.core.{BiopetFifoPipe, PipelineCommand, SampleLibraryTag}
import nl.lumc.sasc.biopet.extensions.{Gzip, Zcat}
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.utils.IoUtils._
import nl.lumc.sasc.biopet.extensions.tools.{ FastqSync, SeqStat, ValidateFastq }
import nl.lumc.sasc.biopet.extensions.tools.{FastqSync, SeqStat, ValidateFastq}
import nl.lumc.sasc.biopet.utils.Logging
import org.broadinstitute.gatk.queue.QScript
......@@ -206,8 +206,8 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
fqSync.outputFastq2 = new File(outDir, fastqR2Qc.get.getName)
fqSync.outputStats = new File(outDir, s"${sampleId.getOrElse("x")}-${libId.getOrElse("x")}.sync.stats")
val pipe = new BiopetFifoPipe(this, fqSync :: Nil) {
override def configNamespace = "qc-cmd"
val pipe = new BiopetFifoPipe(this, fqSync :: Nil) with Summarizable {
override def configNamespace = "qc_cmd"
override def beforeGraph(): Unit = {
fqSync.beforeGraph()
......@@ -223,11 +223,20 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
commands.foreach(addPipeJob)
super.beforeCmd()
}
/** Must return files to store into summary */
def summaryFiles: Map[String, File] = Map()
/** Must returns stats to store into summary */
def summaryStats: Any = Map()
override def summaryDeps = qcCmdR1.summaryDeps ::: qcCmdR2.summaryDeps ::: super.summaryDeps
}
pipe.deps ::= fastqcR1.output
pipe.deps ::= fastqcR2.output
pipe.isIntermediate = !keepQcFastqFiles
addSummarizable(pipe, "qc_cmd")
add(pipe)
addSummarizable(fqSync, "fastq_sync")
......
......@@ -65,6 +65,8 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
def summaryStats = Map()
override def summaryDeps = trim.map(_.summaryDeps).toList.flatten ::: super.summaryDeps
override def addToQscriptSummary(qscript: SummaryQScript, name: String): Unit = {
clip match {
case Some(job) => qscript.addSummarizable(job, s"clipping_$read")
......
Markdown is supported
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