Commit 23bdc5b2 authored by Peter van 't Hof's avatar Peter van 't Hof Committed by GitHub
Browse files

Merge pull request #166 from biopet/fix-BIOPET-718

Removing sample/library variantcalling
parents c913b602 f3071de2
...@@ -177,6 +177,11 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co ...@@ -177,6 +177,11 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
val libId = tag.libId.flatMap(name => val libId = tag.libId.flatMap(name =>
sampleId.flatMap(sampleId => sampleId.flatMap(sampleId =>
Await.result(db.getLibraryId(qscript.summaryRunId, sampleId, name), Duration.Inf))) Await.result(db.getLibraryId(qscript.summaryRunId, sampleId, name), Duration.Inf)))
if (tag.sampleId.isDefined)
require(sampleId.isDefined, s"Sample '${tag.sampleId.get}' is not found in database yet")
if (tag.libId.isDefined)
require(libId.isDefined,
s"Library '${tag.libId.get}' for '${tag.sampleId}' is not found in database yet")
for ((key, file) <- qscript.summaryFiles.par) for ((key, file) <- qscript.summaryFiles.par)
Await.result(WriteSummary.createFile(db, Await.result(WriteSummary.createFile(db,
qscript.summaryRunId, qscript.summaryRunId,
...@@ -353,7 +358,10 @@ object WriteSummary { ...@@ -353,7 +358,10 @@ object WriteSummary {
/** Retrive checksum from file */ /** Retrive checksum from file */
def parseChecksum(checksumFile: File): String = { def parseChecksum(checksumFile: File): String = {
Source.fromFile(checksumFile).getLines().toList.head.split(" ")(0) val reader = Source.fromFile(checksumFile)
val lines = reader.getLines().toList
reader.close()
lines.head.split(" ")(0)
} }
def createFile(db: SummaryDbWrite, def createFile(db: SummaryDbWrite,
......
...@@ -110,8 +110,6 @@ object Schema { ...@@ -110,8 +110,6 @@ object Schema {
def * = def * =
(runId, pipelineId, moduleId, sampleId, libraryId, content) <> (Stat.tupled, Stat.unapply) (runId, pipelineId, moduleId, sampleId, libraryId, content) <> (Stat.tupled, Stat.unapply)
def idx = index("idx_stats", (runId, pipelineId, moduleId, sampleId, libraryId), unique = true)
} }
val stats = TableQuery[Stats] val stats = TableQuery[Stats]
...@@ -131,9 +129,6 @@ object Schema { ...@@ -131,9 +129,6 @@ object Schema {
def * = def * =
(runId, pipelineId, moduleId, sampleId, libraryId, content) <> (Setting.tupled, Setting.unapply) (runId, pipelineId, moduleId, sampleId, libraryId, content) <> (Setting.tupled, Setting.unapply)
def idx =
index("idx_settings", (runId, pipelineId, moduleId, sampleId, libraryId), unique = true)
} }
val settings = TableQuery[Settings] val settings = TableQuery[Settings]
...@@ -163,7 +158,7 @@ object Schema { ...@@ -163,7 +158,7 @@ object Schema {
(runId, pipelineId, moduleId, sampleId, libraryId, key, path, md5, link, size) <> (File.tupled, File.unapply) (runId, pipelineId, moduleId, sampleId, libraryId, key, path, md5, link, size) <> (File.tupled, File.unapply)
def idx = def idx =
index("idx_files", (runId, pipelineId, moduleId, sampleId, libraryId, key), unique = true) index("idx_files", (runId, pipelineId, moduleId, sampleId, libraryId, key))
} }
val files = TableQuery[Files] val files = TableQuery[Files]
......
...@@ -101,17 +101,13 @@ class Shiva(val parent: Configurable) ...@@ -101,17 +101,13 @@ class Shiva(val parent: Configurable)
/** Sample specific settings */ /** Sample specific settings */
override def summarySettings: Map[String, Any] = override def summarySettings: Map[String, Any] =
super.summarySettings ++ super.summarySettings ++
Map( Map("use_indel_realigner" -> useIndelRealigner)
"single_sample_variantcalling" -> variantcalling.isDefined,
"use_indel_realigner" -> useIndelRealigner
)
/** Class to generate jobs for a library */ /** Class to generate jobs for a library */
class Library(libId: String) extends super.Library(libId) { class Library(libId: String) extends super.Library(libId) {
override def summaryFiles: Map[String, File] = override def summaryFiles: Map[String, File] =
super.summaryFiles ++ super.summaryFiles ++
variantcalling.map("final" -> _.finalFile) ++
bqsrFile.map("baserecal" -> _) ++ bqsrFile.map("baserecal" -> _) ++
bqsrAfterFile.map("baserecal_after" -> _) bqsrAfterFile.map("baserecal_after" -> _)
...@@ -140,20 +136,10 @@ class Shiva(val parent: Configurable) ...@@ -140,20 +136,10 @@ class Shiva(val parent: Configurable)
/** Library specific settings */ /** Library specific settings */
override def summarySettings: Map[String, Any] = super.summarySettings ++ Map( override def summarySettings: Map[String, Any] = super.summarySettings ++ Map(
"library_variantcalling" -> variantcalling.isDefined,
"use_base_recalibration" -> useBaseRecalibration, "use_base_recalibration" -> useBaseRecalibration,
"useAnalyze_covariates" -> useAnalyzeCovariates "useAnalyze_covariates" -> useAnalyzeCovariates
) )
lazy val variantcalling: Option[ShivaVariantcalling with QScript] =
if (config("library_variantcalling", default = false).asBoolean &&
(bamFile.isDefined || preProcessBam.isDefined)) {
Some(
makeVariantcalling(multisample = false,
sample = Some(sampleId),
library = Some(libId)))
} else None
/** This will add jobs for this library */ /** This will add jobs for this library */
override def addJobs(): Unit = { override def addJobs(): Unit = {
super.addJobs() super.addJobs()
...@@ -164,15 +150,6 @@ class Shiva(val parent: Configurable) ...@@ -164,15 +150,6 @@ class Shiva(val parent: Configurable)
useIndelRealigner || libraries.size > 1, useIndelRealigner || libraries.size > 1,
usePrintReads) usePrintReads)
} }
variantcalling.foreach(vc => {
vc.sampleId = Some(sampleId)
vc.libId = Some(libId)
vc.outputDir = new File(libDir, "variantcalling")
if (preProcessBam.isDefined) vc.inputBams = Map(sampleId -> preProcessBam.get)
else vc.inputBams = Map(sampleId -> bamFile.get)
add(vc)
})
} }
/** Adds base recalibration jobs */ /** Adds base recalibration jobs */
...@@ -220,11 +197,6 @@ class Shiva(val parent: Configurable) ...@@ -220,11 +197,6 @@ class Shiva(val parent: Configurable)
} }
} }
lazy val variantcalling: Option[ShivaVariantcalling with QScript] =
if (config("single_sample_variantcalling", default = false).asBoolean) {
Some(makeVariantcalling(multisample = false, sample = Some(sampleId)))
} else None
override def keepMergedFiles: Boolean = override def keepMergedFiles: Boolean =
config("keep_merged_files", default = !useIndelRealigner) config("keep_merged_files", default = !useIndelRealigner)
...@@ -235,9 +207,6 @@ class Shiva(val parent: Configurable) ...@@ -235,9 +207,6 @@ class Shiva(val parent: Configurable)
bamFile.map(swapExt(sampleDir, _, ".bam", ".realign.bam")) bamFile.map(swapExt(sampleDir, _, ".bam", ".realign.bam"))
} else bamFile } else bamFile
override def summaryFiles: Map[String, File] =
super.summaryFiles ++ variantcalling.map("final" -> _.finalFile)
/** This will add sample jobs */ /** This will add sample jobs */
override def addJobs(): Unit = { override def addJobs(): Unit = {
super.addJobs() super.addJobs()
...@@ -245,15 +214,6 @@ class Shiva(val parent: Configurable) ...@@ -245,15 +214,6 @@ class Shiva(val parent: Configurable)
if (useIndelRealigner) { if (useIndelRealigner) {
addIndelRealign(bamFile.get, sampleDir, isIntermediate = false) addIndelRealign(bamFile.get, sampleDir, isIntermediate = false)
} }
preProcessBam.foreach { bam =>
variantcalling.foreach(vc => {
vc.sampleId = Some(sampleId)
vc.outputDir = new File(sampleDir, "variantcalling")
vc.inputBams = Map(sampleId -> bam)
add(vc)
})
}
} }
} // End of sample } // End of sample
......
...@@ -60,8 +60,6 @@ trait ShivaTestTrait extends TestNGSuite with Matchers { ...@@ -60,8 +60,6 @@ trait ShivaTestTrait extends TestNGSuite with Matchers {
def realignProvider = Array(false, true) def realignProvider = Array(false, true)
def baseRecalibrationProvider = Array(false, true) def baseRecalibrationProvider = Array(false, true)
def multisampleCalling: Boolean = true def multisampleCalling: Boolean = true
def sampleCalling = false
def libraryCalling = false
def dbsnp = true def dbsnp = true
def svCalling = false def svCalling = false
def cnvCalling = false def cnvCalling = false
...@@ -86,8 +84,6 @@ trait ShivaTestTrait extends TestNGSuite with Matchers { ...@@ -86,8 +84,6 @@ trait ShivaTestTrait extends TestNGSuite with Matchers {
ConfigUtils.mergeMaps( ConfigUtils.mergeMaps(
Map( Map(
"multisample_variantcalling" -> multisampleCalling, "multisample_variantcalling" -> multisampleCalling,
"single_sample_variantcalling" -> sampleCalling,
"library_variantcalling" -> libraryCalling,
"use_indel_realigner" -> realign, "use_indel_realigner" -> realign,
"use_base_recalibration" -> baseRecalibration, "use_base_recalibration" -> baseRecalibration,
"sv_calling" -> svCalling, "sv_calling" -> svCalling,
...@@ -133,26 +129,24 @@ trait ShivaTestTrait extends TestNGSuite with Matchers { ...@@ -133,26 +129,24 @@ trait ShivaTestTrait extends TestNGSuite with Matchers {
pipeline.samples foreach { pipeline.samples foreach {
case (_, sample) => case (_, sample) =>
sample.summarySettings.get("single_sample_variantcalling") shouldBe Some(sampleCalling) sample.summarySettings.get("single_sample_variantcalling") shouldBe None
sample.summarySettings.get("use_indel_realigner") shouldBe Some(realign) sample.summarySettings.get("use_indel_realigner") shouldBe Some(realign)
sample.libraries.foreach { sample.libraries.foreach {
case (_, lib) => case (_, lib) =>
lib.summarySettings.get("library_variantcalling") shouldBe Some(libraryCalling) lib.summarySettings.get("library_variantcalling") shouldBe None
lib.summarySettings.get("use_indel_realigner") shouldBe None // Should not exist anymore lib.summarySettings.get("use_indel_realigner") shouldBe None // Should not exist anymore
lib.summarySettings.get("use_base_recalibration") shouldBe Some( lib.summarySettings.get("use_base_recalibration") shouldBe Some(
baseRecalibration && dbsnp) baseRecalibration && dbsnp)
} }
} }
pipeline.functions.count(_.isInstanceOf[VcfStats]) shouldBe ((if (multisampleCalling) 2 pipeline.functions.count(_.isInstanceOf[VcfStats]) shouldBe (if (multisampleCalling) 2
else 0) + else 0)
(if (sampleCalling) numberSamples * 2 else 0) +
(if (libraryCalling) numberLibs * 2 else 0))
} }
} }
// remove temporary run directory all tests in the class have been run // remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = { @AfterClass def removeTempOutputDir(): Unit = {
dirs.filter(_.exists()).foreach { dir => dirs.filter(_.exists()).foreach { dir =>
try { try {
FileUtils.deleteDirectory(dir) FileUtils.deleteDirectory(dir)
...@@ -175,20 +169,6 @@ class ShivaNoPrintReadsTest extends ShivaTestTrait { ...@@ -175,20 +169,6 @@ class ShivaNoPrintReadsTest extends ShivaTestTrait {
override def realignProvider = Array(x = false) override def realignProvider = Array(x = false)
override def usePrintReads = false override def usePrintReads = false
} }
class ShivaLibraryCallingTest extends ShivaTestTrait {
override def sample1 = Array(true, false)
override def sample2 = Array(false, true)
override def realignProvider = Array(x = false)
override def baseRecalibrationProvider = Array(x = false)
override def libraryCalling = true
}
class ShivaSampleCallingTest extends ShivaTestTrait {
override def sample1 = Array(true, false)
override def sample2 = Array(false, true)
override def realignProvider = Array(x = false)
override def baseRecalibrationProvider = Array(x = false)
override def sampleCalling = true
}
class ShivaWithSvCallingTest extends ShivaTestTrait { class ShivaWithSvCallingTest extends ShivaTestTrait {
override def sample1 = Array(x = true) override def sample1 = Array(x = true)
override def sample2 = Array(x = false) override def sample2 = Array(x = false)
......
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