Commit 5c13638f authored by Sander Bollen's avatar Sander Bollen
Browse files

Merge branch 'fix-BIOPET-491' into 'develop'

Fixing BIOPET-491



See merge request !493
parents 6dd35b5a 2ed72dd5
......@@ -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.debug("Queue values are not initialized")
}
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
......
......@@ -59,4 +59,6 @@ class BamStats(val root: Configurable) extends ToolCommandFunction with Referenc
def summaryFiles: Map[String, File] = Map()
def summaryStats: Map[String, Any] = ConfigUtils.fileToConfigMap(bamstatsSummary)
override def summaryDeps: List[File] = bamstatsSummary :: super.summaryDeps
}
......@@ -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,7 +14,7 @@
*/
package nl.lumc.sasc.biopet.pipelines.flexiprep
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
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
......@@ -179,9 +179,8 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
var R1 = R1_in
var R2 = R2_in
val qcCmdR1 = new QcCommand(this, fastqcR1)
val qcCmdR1 = new QcCommand(this, fastqcR1, "R1")
qcCmdR1.input = R1_in
qcCmdR1.read = "R1"
qcCmdR1.output = if (paired) new File(outDir, fastqR1Qc.getName.stripSuffix(".gz"))
else fastqR1Qc
qcCmdR1.deps :+= fastqcR1.output
......@@ -189,10 +188,9 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
addSummarizable(qcCmdR1, "qc_command_R1")
if (paired) {
val qcCmdR2 = new QcCommand(this, fastqcR2)
val qcCmdR2 = new QcCommand(this, fastqcR2, "R2")
qcCmdR2.input = R2_in.get
qcCmdR2.output = new File(outDir, fastqR2Qc.get.getName.stripSuffix(".gz"))
qcCmdR2.read = "R2"
addSummarizable(qcCmdR2, "qc_command_R2")
qcCmdR1.compress = false
......@@ -206,8 +204,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 +221,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")
......
......@@ -26,7 +26,7 @@ import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
/**
* Created by pjvan_thof on 9/22/15.
*/
class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetCommandLineFunction with Summarizable {
class QcCommand(val root: Configurable, val fastqc: Fastqc, val read: String) extends BiopetCommandLineFunction with Summarizable {
val flexiprep = root match {
case f: Flexiprep => f
......@@ -41,14 +41,17 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
var compress = true
var read: String = _
override def defaultCoreMemory = 2.0
override def defaultThreads = 3
val seqtk = new SeqtkSeq(root)
var clip: Option[Cutadapt] = if (!flexiprep.skipClip) Some(new Cutadapt(root, fastqc)) else None
var trim: Option[Sickle] = None
var trim: Option[Sickle] = if (!flexiprep.skipTrim) {
val sickle = new Sickle(root)
sickle.outputStats = new File(flexiprep.outputDir, s"${flexiprep.sampleId.getOrElse("x")}-${flexiprep.libId.getOrElse("x")}.$read.trim.stats")
Some(sickle)
} else None
lazy val outputCommand: BiopetCommandLineFunction = if (compress) {
val gzip = Gzip(root)
gzip.output = output
......@@ -65,6 +68,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")
......@@ -84,6 +89,7 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
require(read != null)
deps ::= input
outputFiles :+= output
trim.foreach(outputFiles :+= _.outputStats)
}
override def beforeCmd(): Unit = {
......@@ -119,17 +125,14 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
} else None
} else None
trim = if (!flexiprep.skipTrim) {
val sickle = new Sickle(root)
sickle.outputStats = new File(flexiprep.outputDir, s"${flexiprep.sampleId.getOrElse("x")}-${flexiprep.libId.getOrElse("x")}.$read.trim.stats")
sickle.inputR1 = clip match {
trim.foreach { t =>
t.outputR1 = new File(output.getParentFile, input.getName + ".sickle.fq")
t.inputR1 = clip match {
case Some(c) => c.fastqOutput
case _ => seqtk.output
}
sickle.outputR1 = new File(output.getParentFile, input.getName + ".sickle.fq")
addPipeJob(sickle)
Some(sickle)
} else None
addPipeJob(t)
}
val outputFile = (clip, trim) match {
case (_, Some(t)) => t.outputR1
......
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