Commit a327c58d authored by Peter van 't Hof's avatar Peter van 't Hof

Add sampleId and libId for single sample pipelines

parent b2475ba7
......@@ -56,13 +56,23 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
}
def init(): Unit = {
val db = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
if (qscript == root) { // This initialize the database
qscript match {
case s: MultiSampleQScript => s.initSummaryDb
case t:SampleLibraryTag => t.sampleId.foreach { case sampleName =>
val sampleId = Await.result(db.getSamples(name = Some(sampleName), runId = Some(qscript.summaryRunId)).map(_.headOption.map(_.id)), Duration.Inf).getOrElse {
Await.result(db.createSample(sampleName, qscript.summaryRunId), Duration.Inf)
}
t.libId.foreach {libName =>
val libId = Await.result(db.getSamples(name = Some(libName), runId = Some(qscript.summaryRunId), sampleId = Some(sampleId)).map(_.headOption.map(_.id)), Duration.Inf).getOrElse {
Await.result(db.createLibrary(libName, qscript.summaryRunId, sampleId), Duration.Inf)
}
}
}
case _ => qscript.summaryRunId
}
}
val db = SummaryDb.openSqliteSummary(qscript.summaryDbFile)
val pipelineId = Await.result(db.createPipeline(qscript.summaryName, qscript.summaryRunId), Duration.Inf)
qscript.summarizables.map(x => Await.result(db.createModule(x._1._1, qscript.summaryRunId, pipelineId), Duration.Inf))
db.close()
......
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