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

Added settings

parent 43d7c6f1
......@@ -114,13 +114,41 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
sampleId = sampleId.map(Await.result(_, Duration.Inf))).map(_.head.id))
db.createOrUpdateStat(qscript.summaryRunId, pipelineId, Some(Await.result(moduleId, Duration.Inf)),
sampleId.map(Await.result(_, Duration.Inf)), libId.map(Await.result(_, Duration.Inf)), stats.nospaces)
//TODO: Add Files
}
//TODO: Add Files
//TODO: Add executables
//TODO: Add Settings
qscript match {
case tag: SampleLibraryTag =>
val sampleId = tag.sampleId.flatMap(name => Await.result(db.getSampleId(qscript.summaryRunId, name), Duration.Inf))
val libId = tag.libId.flatMap(name => sampleId.flatMap(sampleId => Await.result(db.getLibraryId(qscript.summaryRunId, sampleId, name), Duration.Inf)))
//TODO: Add files
db.createOrUpdateSetting(qscript.summaryRunId, pipelineId, None, sampleId, libId, ConfigUtils.mapToJson(tag.summarySettings).nospaces)
case q: MultiSampleQScript =>
// Global level
//TODO: Add files
db.createOrUpdateSetting(qscript.summaryRunId, pipelineId, None, None, None, ConfigUtils.mapToJson(q.summarySettings).nospaces)
for ((sampleName, sample) <- q.samples) {
// Sample level
val sampleId = Await.result(db.getSampleId(qscript.summaryRunId, sampleName), Duration.Inf).getOrElse(throw new IllegalStateException("Sample should already exist in database"))
//TODO: Add files
db.createOrUpdateSetting(qscript.summaryRunId, pipelineId, None, Some(sampleId), None, ConfigUtils.mapToJson(sample.summarySettings).nospaces)
for ((libName, lib) <- sample.libraries) {
// Library level
val libId = Await.result(db.getLibraryId(qscript.summaryRunId, sampleId, libName), Duration.Inf).getOrElse(throw new IllegalStateException("Library should already exist in database"))
//TODO: Add files
db.createOrUpdateSetting(qscript.summaryRunId, pipelineId, None, Some(sampleId), Some(libId), ConfigUtils.mapToJson(lib.summarySettings).nospaces)
}
}
case q =>
//TODO: Add files
db.createOrUpdateSetting(qscript.summaryRunId, pipelineId, None, None, None, ConfigUtils.mapToJson(q.summarySettings).nospaces)
}
//TODO: Add executables
db.close()
......
......@@ -64,6 +64,10 @@ class SummaryDb(db: Database) extends Closeable {
db.run(q.result)
}
def getSampleId(runId: Int, sampleName: String) = {
getSamples(runId = Some(runId), name = Some(sampleName)).map(_.headOption.map(_.id))
}
def getSampleTags(sampleId: Int): Future[Option[Map[String, Any]]] = {
db.run(samples.filter(_.id === sampleId).map(_.tags).result)
.map(_.headOption.flatten.map(ConfigUtils.jsonTextToMap))
......@@ -86,6 +90,10 @@ class SummaryDb(db: Database) extends Closeable {
db.run(q.result)
}
def getLibraryId(runId: Int, sampleId: Int, name: String) = {
getLibraries(runId = Some(runId), sampleId = Some(sampleId), name = Some(name)).map(_.headOption.map(_.id))
}
def getLibraryTags(libId: Int): Future[Option[Map[String, Any]]] = {
db.run(libraries.filter(_.id === libId).map(_.tags).result)
.map(_.headOption.flatten.map(ConfigUtils.jsonTextToMap))
......
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