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

Adding tags to db

parent 481937c7
......@@ -262,14 +262,14 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
val db = SummaryDb.openSqliteSummary(summaryDbFile)
val namesOld = Await.result(db.getSamples(runId = Some(summaryRunId)).map(_.map(_.name).toSet), Duration.Inf)
for ((sampleName, sample) <- samples) {
val sampleTags = if (sample.sampleTags.nonEmpty) Some(ConfigUtils.mapToJson(sample.sampleTags).nospaces) else None
val sampleId: Int = if (!namesOld.contains(sampleName))
Await.result(db.createSample(sampleName, summaryRunId), Duration.Inf)
Await.result(db.createSample(sampleName, summaryRunId, sampleTags), Duration.Inf)
else Await.result(db.getSamples(runId = Some(summaryRunId), name = Some(sampleName)).map(_.head.id), Duration.Inf)
// TODO: Add tags
val libNamesOld = Await.result(db.getLibraries(runId = summaryRunId, sampleId = sampleId).map(_.map(_.name)), Duration.Inf)
for ((libName, lib) <- sample.libraries) {
if (!libNamesOld.contains(libName)) db.createLibrary(libName, summaryRunId, sampleId)
// TODO: Add tags
val libraryTags = if (lib.libTags.nonEmpty) Some(ConfigUtils.mapToJson(sample.sampleTags).nospaces) else None
if (!libNamesOld.contains(libName)) Await.result(db.createLibrary(libName, summaryRunId, sampleId, libraryTags), Duration.Inf)
}
}
db.close()
......
......@@ -54,12 +54,15 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
}
def init(): Unit = {
if (qscript == root) {
if (qscript == root) { // This initialize the database
qscript match {
case s: MultiSampleQScript => s.initSummaryDb
case _ => qscript.summaryRunId
}
} // This initialize the database
val db = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
db.close()
}
for (q <- qscript.summaryQScripts)
deps :+= q.summaryFile
for ((_, l) <- qscript.summarizables; s <- l) {
......
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