Skip to content
Snippets Groups Projects
Commit 091f86da authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Extended sample handing in multisample qscript

parent 3230d5d4
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri ...@@ -62,7 +62,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
} }
val multisampleVariantcalling = new GatkVariantcalling(this) { val multisampleVariantcalling = new GatkVariantcalling(this) {
override protected lazy val configName = "gatkvariantcalling" override def configName = "gatkvariantcalling"
override def configPath: List[String] = "multisample" :: super.configPath override def configPath: List[String] = "multisample" :: super.configPath
} }
...@@ -97,7 +97,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri ...@@ -97,7 +97,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
val allRawVcfFiles = for ((sampleID, sampleOutput) <- samplesOutput) yield sampleOutput.variantcalling.rawFilterVcfFile val allRawVcfFiles = for ((sampleID, sampleOutput) <- samplesOutput) yield sampleOutput.variantcalling.rawFilterVcfFile
val gatkVariantcalling = new GatkVariantcalling(this) { val gatkVariantcalling = new GatkVariantcalling(this) {
override protected lazy val configName = "gatkvariantcalling" override def configName = "gatkvariantcalling"
override def configPath: List[String] = "multisample" :: super.configPath override def configPath: List[String] = "multisample" :: super.configPath
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package nl.lumc.sasc.biopet.core package nl.lumc.sasc.biopet.core
import nl.lumc.sasc.biopet.core.config.{ Config, Configurable } import nl.lumc.sasc.biopet.core.config.{ ConfigValue, Config, Configurable }
import nl.lumc.sasc.biopet.utils.ConfigUtils._ import nl.lumc.sasc.biopet.utils.ConfigUtils._
trait MultiSampleQScript extends BiopetQScript { trait MultiSampleQScript extends BiopetQScript {
...@@ -39,7 +39,9 @@ trait MultiSampleQScript extends BiopetQScript { ...@@ -39,7 +39,9 @@ trait MultiSampleQScript extends BiopetQScript {
var sample = any2map(value) var sample = any2map(value)
if (!sample.contains("ID")) sample += ("ID" -> key) if (!sample.contains("ID")) sample += ("ID" -> key)
if (sample("ID") == key) { if (sample("ID") == key) {
setCurrentSample(key)
samplesOutput += key -> runSingleSampleJobs(sample) samplesOutput += key -> runSingleSampleJobs(sample)
unsetCurrentSample()
} else logger.warn("Key is not the same as ID on value for sample") } else logger.warn("Key is not the same as ID on value for sample")
} }
else logger.warn("No Samples found in config") else logger.warn("No Samples found in config")
...@@ -63,11 +65,58 @@ trait MultiSampleQScript extends BiopetQScript { ...@@ -63,11 +65,58 @@ trait MultiSampleQScript extends BiopetQScript {
var library = any2map(value) var library = any2map(value)
if (!library.contains("ID")) library += ("ID" -> key) if (!library.contains("ID")) library += ("ID" -> key)
if (library("ID") == key) { if (library("ID") == key) {
setCurrentLibrary(key)
output += key -> runSingleLibraryJobs(library, sampleConfig) output += key -> runSingleLibraryJobs(library, sampleConfig)
unsetCurrentLibrary()
} else logger.warn("Key is not the same as ID on value for run of sample: " + sampleID) } else logger.warn("Key is not the same as ID on value for run of sample: " + sampleID)
} }
} else logger.warn("No runs found in config for sample: " + sampleID) } else logger.warn("No runs found in config for sample: " + sampleID)
return output return output
} }
def runSingleLibraryJobs(runConfig: Map[String, Any], sampleConfig: Map[String, Any]): LibraryOutput def runSingleLibraryJobs(runConfig: Map[String, Any], sampleConfig: Map[String, Any]): LibraryOutput
private var currentSample: String = null
private var currentLibrary: String = null
def setCurrentSample(sample: String) {
currentSample = sample
}
def unsetCurrentSample() {
currentSample = null
}
def setCurrentLibrary(library: String) {
currentLibrary = library
}
def unsetCurrentLibrary() {
currentLibrary = null
}
override protected[core] def configFullPath: List[String] = {
(if (currentSample != null) "samples" :: currentSample :: Nil else Nil) :::
(if (currentLibrary != null) "libraries" :: currentLibrary :: Nil else Nil) :::
super.configFullPath
}
protected class ConfigFunctions extends super.ConfigFunctions {
override def apply(key: String,
default: Any = null,
submodule: String = null,
required: Boolean = false,
freeVar: Boolean = true,
sample: String = currentSample,
library: String = currentLibrary): ConfigValue = {
super.apply(key, default, submodule, required, freeVar, sample, library)
}
override def contains(key: String,
submodule: String = null,
freeVar: Boolean = true,
sample: String = currentSample,
library: String = currentLibrary) = {
super.contains(key, submodule, freeVar, sample, library)
}
}
} }
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
package nl.lumc.sasc.biopet.core package nl.lumc.sasc.biopet.core
trait ToolCommand extends MainCommand with Logging { trait ToolCommand extends MainCommand with Logging {
abstract class AbstractArgs { protected abstract class AbstractArgs {
} }
abstract class AbstractOptParser extends scopt.OptionParser[Args](commandName) { protected abstract class AbstractOptParser extends scopt.OptionParser[Args](commandName) {
opt[String]('l', "log_level") foreach { x => opt[String]('l', "log_level") foreach { x =>
x.toLowerCase match { x.toLowerCase match {
case "debug" => logger.setLevel(org.apache.log4j.Level.DEBUG) case "debug" => logger.setLevel(org.apache.log4j.Level.DEBUG)
...@@ -44,6 +44,6 @@ trait ToolCommand extends MainCommand with Logging { ...@@ -44,6 +44,6 @@ trait ToolCommand extends MainCommand with Logging {
} text ("Print version") } text ("Print version")
} }
type Args <: AbstractArgs protected type Args <: AbstractArgs
type OptParser <: AbstractOptParser protected type OptParser <: AbstractOptParser
} }
\ No newline at end of file
...@@ -21,9 +21,9 @@ import nl.lumc.sasc.biopet.utils.ConfigUtils.ImplicitConversions ...@@ -21,9 +21,9 @@ import nl.lumc.sasc.biopet.utils.ConfigUtils.ImplicitConversions
trait Configurable extends ImplicitConversions { trait Configurable extends ImplicitConversions {
val root: Configurable val root: Configurable
lazy val configPath: List[String] = if (root != null) root.configFullPath else List() def configPath: List[String] = if (root != null) root.configFullPath else List()
protected[config] lazy val configName = getClass.getSimpleName.toLowerCase protected[core] def configName = getClass.getSimpleName.toLowerCase
protected[config] lazy val configFullPath: List[String] = configPath ::: configName :: Nil protected[core] def configFullPath: List[String] = configPath ::: configName :: Nil
var defaults: scala.collection.mutable.Map[String, Any] = if (root != null) scala.collection.mutable.Map(root.defaults.toArray: _*) var defaults: scala.collection.mutable.Map[String, Any] = if (root != null) scala.collection.mutable.Map(root.defaults.toArray: _*)
else scala.collection.mutable.Map() else scala.collection.mutable.Map()
......
...@@ -200,6 +200,7 @@ object ConfigUtils extends Logging { ...@@ -200,6 +200,7 @@ object ConfigUtils extends Logging {
any match { any match {
case i: Int => i case i: Int => i
case i: Double => i.toInt case i: Double => i.toInt
case i: Long => i.toInt
case i: String => { case i: String => {
logger.warn("Value '" + any + "' is a string insteadof int in json file, trying auto convert") logger.warn("Value '" + any + "' is a string insteadof int in json file, trying auto convert")
i.toInt i.toInt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment