Commit 97d77eb7 authored by Peter van 't Hof's avatar Peter van 't Hof

Merge remote-tracking branch 'remotes/origin/develop' into fix-BIOPET-719

parents 4d81e180 df582f1a
......@@ -177,6 +177,11 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
val libId = tag.libId.flatMap(name =>
sampleId.flatMap(sampleId =>
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)
Await.result(WriteSummary.createFile(db,
qscript.summaryRunId,
......@@ -353,7 +358,10 @@ object WriteSummary {
/** Retrive checksum from file */
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,
......
......@@ -44,6 +44,8 @@ class RefflatStats(val parent: Configurable) extends ToolCommandFunction with Re
@Output(required = true)
var intronOutput: File = _
override def defaultCoreMemory = 5.0
override def beforeGraph(): Unit = {
super.beforeGraph()
if (reference == null) reference = referenceFasta()
......
......@@ -80,8 +80,13 @@ class Star(val parent: Configurable)
var genomeSAindexNbases: Option[Long] = config("genomesaindexnbases")
var genomeSAsparseD: Option[Int] = config("genomesasparsed")
private def defaultGtf: Option[File] = config("annotation_gtf")
@Input(required = false)
var sjdbGTFfile: Option[File] = config("sjdbgtfile")
var sjdbGTFfile: Option[File] = defaultGtf match {
case Some(file) => config("sjdbgtfile", default = file)
case _ => config("sjdbgtfile")
}
var sjdbGTFchrPrefix: Option[String] = config("sjdbgtfchrprefix")
var sjdbGTFfeatureExon: Option[String] = config("sjdbgtffeatureexon")
var sjdbGTFtagExonParentTranscript: Option[String] = config("sjdbgtftagexonparenttranscript")
......
......@@ -31,16 +31,17 @@ object ValidateAnnotation extends ToolCommand {
gtfFiles: List[File] = Nil)
class OptParser extends AbstractOptParser[Args](commandName) {
opt[File]('r', "refflatFile") maxOccurs 1 valueName "<file>" action { (x, c) =>
opt[File]('r', "refflatFile") unbounded () maxOccurs 1 valueName "<file>" action { (x, c) =>
c.copy(refflatFile = Some(x))
} text "Refflat file to check"
opt[File]('g', "gtfFile") valueName "<file>" action { (x, c) =>
opt[File]('g', "gtfFile") unbounded () valueName "<file>" action { (x, c) =>
c.copy(gtfFiles = x :: c.gtfFiles)
} text "Gtf files to check"
opt[File]('R', "reference") required () maxOccurs 1 valueName "<file>" action { (x, c) =>
c.copy(reference = x)
opt[File]('R', "reference") unbounded () required () maxOccurs 1 valueName "<file>" action {
(x, c) =>
c.copy(reference = x)
} text "Reference fasta to check vcf file against"
opt[Unit]("disableFail") maxOccurs 1 valueName "<file>" action { (_, c) =>
opt[Unit]("disableFail") unbounded () maxOccurs 1 valueName "<file>" action { (_, c) =>
c.copy(failOnError = false)
} text "Do not fail on error. The tool will still exit when encountering an error, but will do so with exit code 0"
}
......
......@@ -110,8 +110,6 @@ object Schema {
def * =
(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]
......@@ -131,9 +129,6 @@ object Schema {
def * =
(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]
......@@ -163,7 +158,7 @@ object Schema {
(runId, pipelineId, moduleId, sampleId, libraryId, key, path, md5, link, size) <> (File.tupled, File.unapply)
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]
......
......@@ -54,7 +54,7 @@ trait Measurement extends SummaryQScript with Reference { qscript: QScript =>
require(bamFiles.nonEmpty)
}
lazy val mergeCountFiles: Boolean = config("merge_count_files", default = true)
lazy val mergeCountFiles: Boolean = config("merge_count_files", default = bamFiles.size > 1)
private var extraSummaryFiles: Map[String, File] = Map()
......
......@@ -101,17 +101,13 @@ class Shiva(val parent: Configurable)
/** Sample specific settings */
override def summarySettings: Map[String, Any] =
super.summarySettings ++
Map(
"single_sample_variantcalling" -> variantcalling.isDefined,
"use_indel_realigner" -> useIndelRealigner
)
Map("use_indel_realigner" -> useIndelRealigner)
/** Class to generate jobs for a library */
class Library(libId: String) extends super.Library(libId) {
override def summaryFiles: Map[String, File] =
super.summaryFiles ++
variantcalling.map("final" -> _.finalFile) ++
bqsrFile.map("baserecal" -> _) ++
bqsrAfterFile.map("baserecal_after" -> _)
......@@ -140,20 +136,10 @@ class Shiva(val parent: Configurable)
/** Library specific settings */
override def summarySettings: Map[String, Any] = super.summarySettings ++ Map(
"library_variantcalling" -> variantcalling.isDefined,
"use_base_recalibration" -> useBaseRecalibration,
"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 */
override def addJobs(): Unit = {
super.addJobs()
......@@ -164,15 +150,6 @@ class Shiva(val parent: Configurable)
useIndelRealigner || libraries.size > 1,
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 */
......@@ -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 =
config("keep_merged_files", default = !useIndelRealigner)
......@@ -235,9 +207,6 @@ class Shiva(val parent: Configurable)
bamFile.map(swapExt(sampleDir, _, ".bam", ".realign.bam"))
} else bamFile
override def summaryFiles: Map[String, File] =
super.summaryFiles ++ variantcalling.map("final" -> _.finalFile)
/** This will add sample jobs */
override def addJobs(): Unit = {
super.addJobs()
......@@ -245,15 +214,6 @@ class Shiva(val parent: Configurable)
if (useIndelRealigner) {
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
......
......@@ -60,8 +60,6 @@ trait ShivaTestTrait extends TestNGSuite with Matchers {
def realignProvider = Array(false, true)
def baseRecalibrationProvider = Array(false, true)
def multisampleCalling: Boolean = true
def sampleCalling = false
def libraryCalling = false
def dbsnp = true
def svCalling = false
def cnvCalling = false
......@@ -86,8 +84,6 @@ trait ShivaTestTrait extends TestNGSuite with Matchers {
ConfigUtils.mergeMaps(
Map(
"multisample_variantcalling" -> multisampleCalling,
"single_sample_variantcalling" -> sampleCalling,
"library_variantcalling" -> libraryCalling,
"use_indel_realigner" -> realign,
"use_base_recalibration" -> baseRecalibration,
"sv_calling" -> svCalling,
......@@ -133,26 +129,24 @@ trait ShivaTestTrait extends TestNGSuite with Matchers {
pipeline.samples foreach {
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.libraries.foreach {
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_base_recalibration") shouldBe Some(
baseRecalibration && dbsnp)
}
}
pipeline.functions.count(_.isInstanceOf[VcfStats]) shouldBe ((if (multisampleCalling) 2
else 0) +
(if (sampleCalling) numberSamples * 2 else 0) +
(if (libraryCalling) numberLibs * 2 else 0))
pipeline.functions.count(_.isInstanceOf[VcfStats]) shouldBe (if (multisampleCalling) 2
else 0)
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
@AfterClass def removeTempOutputDir(): Unit = {
dirs.filter(_.exists()).foreach { dir =>
try {
FileUtils.deleteDirectory(dir)
......@@ -175,20 +169,6 @@ class ShivaNoPrintReadsTest extends ShivaTestTrait {
override def realignProvider = Array(x = 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 {
override def sample1 = Array(x = true)
override def sample2 = Array(x = false)
......
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