Commit 20eb2f37 authored by Sander Bollen's avatar Sander Bollen
Browse files

Some extras for VcfWithVcfTest

parent 8a5bf774
......@@ -99,7 +99,7 @@ object VcfWithVcf extends ToolCommand {
| By default we will return all values found for a given field.
| With <method> the values will processed after getting it from the secondary VCF file, posible methods are:
| - max : takes maximum of found value, only works for numeric (integer/float) fields
| - min : takes minemal of found value, only works for numeric (integer/float) fields
| - min : takes minimum of found value, only works for numeric (integer/float) fields
| - unique: takes only unique values """.stripMargin
opt[Boolean]("match") valueName "<Boolean>" maxOccurs 1 action { (x, c) =>
c.copy(matchAllele = x)
......@@ -124,7 +124,7 @@ object VcfWithVcf extends ToolCommand {
for (x <- commandArgs.fields) {
if (header.hasInfoLine(x.outputField))
throw new IllegalArgumentException("Field '" + x.outputField + "' already exist in input vcf")
throw new IllegalArgumentException("Field '" + x.outputField + "' already exists in input vcf")
if (!secondHeader.hasInfoLine(x.inputField))
throw new IllegalArgumentException("Field '" + x.inputField + "' does not exist in secondary vcf")
......
......@@ -48,15 +48,47 @@ class VcfWithVcfTest extends TestNGSuite with MockitoSugar with Matchers {
}
@Test def testOutputTypeVcfGz() = {
val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf").getAbsolutePath
val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf.gz").getAbsolutePath
val arguments = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ")
main(arguments)
}
@Test def testOutputTypeBcf() = {
val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf").getAbsolutePath
val tmpPath = File.createTempFile("VcfWithVcf_", ".bcf").getAbsolutePath
val arguments = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ")
main(arguments)
}
@Test def testOutputFieldException = {
val tmpPath = File.createTempFile("VCFWithVCf", ".vcf").getAbsolutePath
val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ:AC")
an [IllegalArgumentException] should be thrownBy main(args)
val thrown = the [IllegalArgumentException] thrownBy main(args)
thrown.getMessage should equal("Field 'AC' already exists in input vcf")
}
@Test def testInputFieldException = {
val tmpPath = File.createTempFile("VCFWithVCf", ".vcf").getAbsolutePath
val args = Array("-I", unveppedPath, "-s", unveppedPath, "-o", tmpPath, "-f", "CSQ:NEW_CSQ")
an [IllegalArgumentException] should be thrownBy main(args)
val thrown = the [IllegalArgumentException] thrownBy main(args)
thrown.getMessage should equal("Field 'CSQ' does not exist in secondary vcf")
}
@Test def testMinMethodException = {
val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf").getAbsolutePath
val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ:CSQ:min")
an [IllegalArgumentException] should be thrownBy main(args)
val thrown = the [IllegalArgumentException] thrownBy main(args)
thrown.getMessage should equal("Type of field CSQ is not numeric")
}
@Test def testMaxMethodException = {
val tmpPath = File.createTempFile("VcfWithVcf_", ".vcf").getAbsolutePath
val args = Array("-I", unveppedPath, "-s", veppedPath, "-o", tmpPath, "-f", "CSQ:CSQ:max")
an [IllegalArgumentException] should be thrownBy main(args)
val thrown = the [IllegalArgumentException] thrownBy main(args)
thrown.getMessage should equal("Type of field CSQ is not numeric")
}
}
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