Commit 14e2e355 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Fix unit testing

parent 9e21462b
......@@ -42,7 +42,7 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction {
var opt_front: Set[String] = Set()
if (config.contains("front")) for (adapter <- config("front").asList) opt_front += adapter.toString
var opt_discard: Boolean = config("discard")
var opt_discard: Boolean = config("discard", default = false)
var opt_minimum_length: String = config("minimum_length", 1)
var opt_maximum_length: String = config("maximum_length")
......
......@@ -39,9 +39,9 @@ class Fastqc(val root: Configurable) extends BiopetCommandLineFunction {
executable = config("exe", default = "fastqc")
var java_exe: String = config("exe", default = "java", submodule = "java", freeVar = false)
var kmers: Option[Int] = config("kmers")
var quiet: Boolean = config("quiet")
var noextract: Boolean = config("noextract")
var nogroup: Boolean = config("nogroup")
var quiet: Boolean = config("quiet", default = false)
var noextract: Boolean = config("noextract", default = false)
var nogroup: Boolean = config("nogroup", default = false)
var extract: Boolean = config("extract", default = true)
override val versionRegex = """FastQC (.*)""".r
......
......@@ -42,10 +42,10 @@ class RunGubbins(val root: Configurable) extends BiopetCommandLineFunction {
var iterations: Option[Int] = config("iterations")
var minSnps: Option[Int] = config("min_snps")
var convergeMethod: String = config("converge_method")
var useTimeStamp: Boolean = config("use_time_stamp")
var useTimeStamp: Boolean = config("use_time_stamp", default = false)
var prefix: String = config("prefix")
var verbose: Boolean = config("verbose")
var noCleanup: Boolean = config("no_cleanup")
var verbose: Boolean = config("verbose", default = false)
var noCleanup: Boolean = config("no_cleanup", default = false)
override def afterGraph: Unit = {
super.afterGraph
......
......@@ -46,9 +46,9 @@ class Sickle(val root: Configurable) extends BiopetCommandLineFunction {
var qualityType: String = config("qualitytype")
var qualityThreshold: Option[Int] = config("qualityThreshold")
var lengthThreshold: Option[Int] = config("lengthThreshold")
var noFiveprime: Boolean = config("noFiveprime")
var discardN: Boolean = config("discardN")
var quiet: Boolean = config("quiet")
var noFiveprime: Boolean = config("noFiveprime", default = false)
var discardN: Boolean = config("discardN", default = false)
var quiet: Boolean = config("quiet", default = false)
var defaultQualityType: String = config("defaultqualitytype", default = "sanger")
override val versionRegex = """sickle version (.*)""".r
override def versionCommand = executable + " --version"
......
......@@ -36,7 +36,7 @@ class Bwa(val root: Configurable) extends BiopetCommandLineFunction {
var R: String = config("R")
var k: Option[Int] = config("k")
var r: Option[Float] = config("r")
var S: Boolean = config("S")
var S: Boolean = config("S", default = false)
var M: Boolean = config("M", default = true)
var w: Option[Int] = config("w")
var d: Option[Int] = config("d")
......@@ -44,8 +44,8 @@ class Bwa(val root: Configurable) extends BiopetCommandLineFunction {
var D: Option[Float] = config("D")
var W: Option[Int] = config("W")
var m: Option[Int] = config("m")
var P: Boolean = config("P")
var e: Boolean = config("e")
var P: Boolean = config("P", default = false)
var e: Boolean = config("e", default = false)
var A: Option[Int] = config("A")
var B: Option[Int] = config("B")
var O: String = config("O")
......@@ -53,13 +53,13 @@ class Bwa(val root: Configurable) extends BiopetCommandLineFunction {
var L: String = config("L")
var U: Option[Int] = config("U")
var x: String = config("x")
var p: Boolean = config("p")
var p: Boolean = config("p", default = false)
var v: Option[Int] = config("v")
var T: Option[Int] = config("T")
var h: Option[Int] = config("h")
var a: Boolean = config("a")
var C: Boolean = config("C")
var Y: Boolean = config("Y")
var a: Boolean = config("a", default = false)
var C: Boolean = config("C", default = false)
var Y: Boolean = config("Y", default = false)
var I: String = config("I")
executable = config("exe", default = "bwa", freeVar = false)
......
......@@ -29,7 +29,7 @@ class CollectAlignmentSummaryMetrics(val root: Configurable) extends Picard {
var maxInstertSize: Option[Int] = config("maxInstertSize")
@Argument(doc = "ADAPTER_SEQUENCE", required = false)
var adapterSequence: List[String] = config("adapterSequence")
var adapterSequence: List[String] = config("adapterSequence", default = Nil)
@Argument(doc = "IS_BISULFITE_SEQUENCED", required = false)
var isBisulfiteSequenced: Option[Boolean] = config("isBisulfiteSequenced")
......@@ -44,7 +44,7 @@ class CollectAlignmentSummaryMetrics(val root: Configurable) extends Picard {
var assumeSorted: Boolean = config("assumeSorted", default = true)
@Argument(doc = "METRIC_ACCUMULATION_LEVEL", required = false)
var metricAccumulationLevel: List[String] = config("metricaccumulationlevel")
var metricAccumulationLevel: List[String] = config("metricaccumulationlevel", default = Nil)
@Argument(doc = "STOP_AFTER", required = false)
var stopAfter: Option[Long] = config("stopAfter")
......
......@@ -19,6 +19,8 @@ import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output, Argument }
import scala.collection.immutable.Nil
class CollectInsertSizeMetrics(val root: Configurable) extends Picard {
javaMainClass = "picard.analysis.CollectInsertSizeMetrics"
......@@ -47,7 +49,7 @@ class CollectInsertSizeMetrics(val root: Configurable) extends Picard {
var stopAfter: Option[Long] = config("stopAfter")
@Argument(doc = "METRIC_ACCUMULATION_LEVEL", required = false)
var metricAccumulationLevel: List[String] = config("metricaccumulationlevel")
var metricAccumulationLevel: List[String] = config("metricaccumulationlevel", default = Nil)
@Argument(doc = "HISTOGRAM_WIDTH", required = false)
var histogramWidth: Option[Int] = config("histogramWidth")
......
......@@ -19,7 +19,7 @@ import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
abstract class Samtools extends BiopetCommandLineFunction {
override def subPath = "samtools" :: super.subPath
executable = config("exe", default = "samtools", freeVar = false)
executable = config("exe", default = "samtools")
override def versionCommand = executable
override val versionRegex = """Version: (.*)""".r
override val versionExitcode = List(0, 1)
......
......@@ -58,28 +58,28 @@ class SeqtkSeq(val root: Configurable) extends Seqtk {
var L: Option[Int] = config("L")
/** mask complement region (effective with -M) */
var c: Boolean = config("c")
var c: Boolean = config("c", default = false)
/** reverse complement */
var r: Boolean = config("r")
var r: Boolean = config("r", default = false)
/** force FASTA output (discard quality) */
var A: Boolean = config("A")
var A: Boolean = config("A", default = false)
/** drop comments at the header lines */
var C: Boolean = config("C")
var C: Boolean = config("C", default = false)
/** drop sequences containing ambiguous bases */
var N: Boolean = config("N")
var N: Boolean = config("N", default = false)
/** output the 2n-1 reads only */
var flag1: Boolean = config("1")
var flag1: Boolean = config("1", default = false)
/** output the 2n reads only */
var flag2: Boolean = config("2")
var flag2: Boolean = config("2", default = false)
/** shift quality by '(-Q) - 33' */
var V: Boolean = config("V")
var V: Boolean = config("V", default = false)
def cmdLine = {
required(executable) +
......
......@@ -40,7 +40,7 @@ class VcfFilter(val root: Configurable) extends BiopetJavaCommandLineFunction {
var minTotalDepth: Option[Int] = config("min_total_depth")
var minAlternateDepth: Option[Int] = config("min_alternate_depth")
var minSamplesPass: Option[Int] = config("min_samples_pass")
var filterRefCalls: Boolean = config("filter_ref_calls")
var filterRefCalls: Boolean = config("filter_ref_calls", default = false)
override val defaultVmem = "8G"
memoryLimit = Option(4.0)
......
......@@ -354,7 +354,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2long(value: ConfigValue): Long = {
if (value != null && value.value != null && value.value != None) any2long(value.value) else 0
if (value != null && value.value != null && value.value != None) any2long(value.value)
else throw new IllegalStateException("Value does not exist")
}
/**
......@@ -372,7 +373,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2int(value: ConfigValue): Int = {
if (value != null && value.value != null && value.value != None) any2int(value.value) else 0
if (value != null && value.value != null && value.value != None) any2int(value.value)
else throw new IllegalStateException("Value does not exist")
}
/**
......@@ -390,7 +392,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2double(value: ConfigValue): Double = {
if (value != null && value.value != null && value.value != None) any2double(value.value) else 0
if (value != null && value.value != null && value.value != None) any2double(value.value)
else throw new IllegalStateException("Value does not exist")
}
/**
......@@ -408,7 +411,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2float(value: ConfigValue): Float = {
if (value != null && value.value != null && value.value != None) any2float(value.value) else 0
if (value != null && value.value != null && value.value != None) any2float(value.value)
else throw new IllegalStateException("Value does not exist")
}
/**
......@@ -426,7 +430,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2boolean(value: ConfigValue): Boolean = {
if (value != null && value.value != null && value.value != None) any2boolean(value.value) else false
if (value != null && value.value != null && value.value != None) any2boolean(value.value)
else throw new IllegalStateException("Value does not exist")
}
/**
......@@ -444,7 +449,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2list(value: ConfigValue): List[Any] = {
if (value != null && value.value != null && value.value != None) any2list(value.value) else null
if (value != null && value.value != null && value.value != None) any2list(value.value)
else throw new IllegalStateException("Value does not exist")
}
/**
......@@ -453,7 +459,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2stringList(value: ConfigValue): List[String] = {
if (value != null && value.value != null && value.value != None) any2stringList(value.value) else null
if (value != null && value.value != null && value.value != None) any2stringList(value.value)
else throw new IllegalStateException("Value does not exist")
}
/**
......@@ -462,7 +469,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2stringSet(value: ConfigValue): Set[String] = {
if (value != null && value.value != null && value.value != None) any2stringList(value.value).toSet else null
if (value != null && value.value != null && value.value != None) any2stringList(value.value).toSet
else throw new IllegalStateException("Value does not exist")
}
/**
......@@ -471,7 +479,8 @@ object ConfigUtils extends Logging {
* @return
*/
implicit def configValue2map(value: ConfigValue): Map[String, Any] = {
if (value != null && value.value != null && value.value != None) any2map(value.value) else null
if (value != null && value.value != null && value.value != None) any2map(value.value)
else throw new IllegalStateException("Value does not exist")
}
}
}
......@@ -169,17 +169,20 @@ class ConfigUtilsTest extends TestNGSuite with Matchers {
@Test def testImplicits: Unit = {
val index = ConfigValueIndex("test", Nil, "test")
new ImplicitConversions {
var map: Map[String, Any] = ConfigValue(index, index, Map())
map = ConfigValue(index, index, null)
configValue2list(ConfigValue(index, index, List(""))) shouldBe List("")
configValue2list(ConfigValue(index, index, null)) shouldBe null
intercept[IllegalStateException] {
configValue2list(ConfigValue(index, index, null))
}
configValue2stringList(ConfigValue(index, index, List(""))) shouldBe List("")
configValue2stringList(ConfigValue(index, index, null)) shouldBe null
intercept[IllegalStateException] {
configValue2stringList(ConfigValue(index, index, null))
}
configValue2stringSet(ConfigValue(index, index, List(""))) shouldBe Set("")
configValue2stringSet(ConfigValue(index, index, null)) shouldBe null
intercept[IllegalStateException] {
configValue2stringSet(ConfigValue(index, index, null))
}
var int: Int = ConfigValue(index, index, 1)
intercept[IllegalStateException] {
......
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