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

Added checksum cache

parent e8f474c1
......@@ -11,16 +11,23 @@ import nl.lumc.sasc.biopet.extensions.Md5sum
trait SummaryQScript extends BiopetQScript {
/** Key is sample/library, None is sample or library is not applicable */
private[summary] var summarizables: Map[(Option[String], Option[String]), List[Summarizable]] = Map()
private[summary] var summarizables: Map[(String, Option[String], Option[String]), List[Summarizable]] = Map()
private[summary] var summaryQScripts: List[SummaryQScript] = Nil
def summaryFile: File
def addSummarizable(summarizable: Summarizable,
sampleId: Option[String] = None,
libraryId: Option[String] = None): Unit = {
require(libraryId.isDefined == sampleId.isDefined) // Library always require a sample
summarizables += (sampleId, libraryId) -> (summarizable :: summarizables.getOrElse((sampleId, libraryId), Nil))
def addSummarizable(summarizable: Summarizable, name: String): Unit = {
//TODO: Automatic sample capture
addSummarizable(summarizable, name, None, None)
}
def addSummarizable(summarizable: Summarizable, name: String, sampleId: Option[String]): Unit = {
addSummarizable(summarizable, name, sampleId, None)
}
def addSummarizable(summarizable: Summarizable, name: String, sampleId: Option[String], libraryId: Option[String]): Unit = {
if (libraryId.isDefined) require(sampleId.isDefined) // Library always require a sample
summarizables += (name, sampleId, libraryId) -> (summarizable :: summarizables.getOrElse((name, sampleId, libraryId), Nil))
}
def addSummaryQScript(summaryQScript: SummaryQScript): Unit = {
......@@ -31,13 +38,11 @@ trait SummaryQScript extends BiopetQScript {
val writeSummary = new WriteSummary(this)
//Automatic checksums
val keepChecksums: Boolean = config("keep_checksums_files", default = false)
for ((_, summarizableList) <- summarizables; summarizable <- summarizableList; (_, file) <- summarizable.summaryFiles) {
if (writeSummary.md5sum) {
if (writeSummary.md5sum && !SummaryQScript.md5sumCache.contains(file)) {
val md5sum = Md5sum(this, file)
md5sum.isIntermediate = !keepChecksums
writeSummary.deps :+= md5sum.output
SummaryQScript.md5sumCache += file -> md5sum.output
add(md5sum)
}
//TODO: add more checksums types
......@@ -46,3 +51,8 @@ trait SummaryQScript extends BiopetQScript {
add(writeSummary)
}
}
object SummaryQScript {
import scala.collection.mutable.Map
protected[summary] val md5sumCache: Map[File, File] = Map()
}
\ No newline at end of file
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