Commit 7eab836c authored by Peter van 't Hof's avatar Peter van 't Hof

Colapse all summaries into 1 connector

parent 1cf01f63
......@@ -272,7 +272,6 @@ trait MultiSampleQScript extends SummaryQScript { qscript: QScript =>
if (!libNamesOld.contains(libName)) Await.result(db.createLibrary(libName, summaryRunId, sampleId, libraryTags), Duration.Inf)
}
}
db.close()
}
}
......
......@@ -20,6 +20,8 @@ import nl.lumc.sasc.biopet.core._
import nl.lumc.sasc.biopet.core.extensions.{CheckChecksum, Md5sum}
import nl.lumc.sasc.biopet.utils.summary.db.SummaryDb
import org.broadinstitute.gatk.queue.QScript
import org.broadinstitute.gatk.queue.engine.JobRunInfo
import org.broadinstitute.gatk.queue.function.QFunction
import scala.collection.mutable
import scala.concurrent.Await
......@@ -198,6 +200,10 @@ trait SummaryQScript extends BiopetQScript { qscript: QScript =>
addedJobs = true
}
override def onExecutionDone(jobs: Map[QFunction, JobRunInfo], success: Boolean) = {
SummaryDb.closeAll()
}
}
object SummaryQScript {
......
......@@ -75,7 +75,7 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
}
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()
for (q <- qscript.summaryQScripts)
deps :+= q.summaryFile
for ((_, l) <- qscript.summarizables; s <- l) {
......@@ -179,8 +179,6 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
}
db.close()
///////////////// OLD //////////////////
for (((name, sampleId, libraryId), summarizables) <- qscript.summarizables; summarizable <- summarizables) {
summarizable.addToQscriptSummary(qscript, name)
......
......@@ -286,11 +286,20 @@ class SummaryDb(db: Database) extends Closeable {
}
object SummaryDb {
private var summaryConnections = Map[File, SummaryDb]()
def closeAll(): Unit = {
summaryConnections.foreach(_._2.close())
}
def openSqliteSummary(file: File): SummaryDb = {
val exist = file.exists()
val db = Database.forURL(s"jdbc:sqlite:${file.getAbsolutePath}", driver = "org.sqlite.JDBC")
val s = new SummaryDb(db)
if (!exist) s.createTables()
s
if (!summaryConnections.contains(file)) {
val exist = file.exists()
val db = Database.forURL(s"jdbc:sqlite:${file.getAbsolutePath}", driver = "org.sqlite.JDBC")
val s = new SummaryDb(db)
if (!exist) s.createTables()
summaryConnections += file -> s
}
summaryConnections(file)
}
}
\ No newline at end of file
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