Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
biopet.biopet
Commits
c75b0c16
Commit
c75b0c16
authored
Mar 07, 2016
by
Sander Bollen
Browse files
the whole shebang in one generator
parent
9ae98ae9
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/biopet-tools-extensions/src/test/scala/VcfFilterTest.scala
View file @
c75b0c16
...
...
@@ -15,164 +15,6 @@ class VcfFilterTest extends TestNGSuite with Matchers {
s
.
replace
(
"'"
,
""
).
replace
(
" "
,
" "
).
trim
}
def
createFilterer
=
{
val
filterer
=
new
VcfFilter
(
null
)
val
iVcf
=
File
.
createTempFile
(
"vcfFilter"
,
".vcf.gz"
)
val
oVcf
=
File
.
createTempFile
(
"vcfFilter"
,
".vcf.gz"
)
iVcf
.
deleteOnExit
()
oVcf
.
deleteOnExit
()
filterer
.
inputVcf
=
iVcf
filterer
.
outputVcf
=
oVcf
filterer
}
@DataProvider
(
name
=
"intArguments"
)
def
intArguments
=
{
Array
(
Array
(
"minSampleDepth"
,
Some
(
50
)),
Array
(
"minTotalDepth"
,
Some
(
50
)),
Array
(
"minAlternateDepth"
,
Some
(
50
)),
Array
(
"minSamplesPass"
,
Some
(
5
)),
Array
(
"minGenomeQuality"
,
Some
(
100
))
)
}
@DataProvider
(
name
=
"stringArguments"
)
def
stringArguments
=
{
Array
(
Array
(
"resToDom"
,
Some
(
"dummy"
)),
Array
(
"trioCompound"
,
Some
(
"dummy"
)),
Array
(
"deNovoInSample"
,
Some
(
"dummy"
)),
Array
(
"deNovoTrio"
,
Some
(
"dummy"
)),
Array
(
"trioLossOfHet"
,
Some
(
"dummy"
))
)
}
@DataProvider
(
name
=
"listArguments"
)
def
listArguments
=
{
Array
(
Array
(
"mustHaveVariant"
,
List
(
"sample1"
,
"sample2"
)),
Array
(
"calledIn"
,
List
(
"sample1"
,
"sample2"
)),
Array
(
"mustHaveGenotype"
,
List
(
"sample1:HET"
,
"sample2:HET"
)),
Array
(
"diffGenotype"
,
List
(
"sample1:sample2"
,
"sample2:sample3"
)),
Array
(
"filterHetVarToHomVar"
,
List
(
"sample1:sample2"
,
"sample2:sample3"
)),
Array
(
"id"
,
List
(
"rs01"
,
"rs02"
))
)
}
@DataProvider
(
name
=
"fileArguments"
)
def
fileArguments
=
{
val
invFile
=
File
.
createTempFile
(
"vcfFilter"
,
".vcf"
)
val
idFile
=
File
.
createTempFile
(
"vcfFilter"
,
".txt"
)
invFile
.
deleteOnExit
()
idFile
.
deleteOnExit
()
Array
(
Array
(
"invertedOutputVcf"
,
Some
(
invFile
)),
Array
(
"idFile"
,
Some
(
idFile
))
)
}
@Test
(
dataProvider
=
"intArguments"
)
def
testIntArguments
(
attr
:
String
,
value
:
Option
[
Int
])
=
{
val
filterer
=
createFilterer
attr
match
{
case
"minSampleDepth"
=>
filterer
.
minSampleDepth
=
value
case
"minTotalDepth"
=>
filterer
.
minTotalDepth
=
value
case
"minAlternateDepth"
=>
filterer
.
minAlternateDepth
=
value
case
"minSamplesPass"
=>
filterer
.
minSamplesPass
=
value
case
"minGenomeQuality"
=>
filterer
.
minGenomeQuality
=
value
case
_
=>
throw
new
IllegalArgumentException
}
val
cmdString
=
"--"
+
attr
+
" "
+
(
value
match
{
case
Some
(
v
)
=>
v
.
toString
case
_
=>
throw
new
IllegalArgumentException
})
cmd
(
filterer
.
cmdLine
).
contains
(
cmdString
)
shouldBe
true
}
@Test
(
dataProvider
=
"stringArguments"
)
def
testStringArguments
(
attr
:
String
,
value
:
Option
[
String
])
=
{
val
filterer
=
createFilterer
attr
match
{
case
"resToDom"
=>
filterer
.
resToDom
=
value
case
"trioCompound"
=>
filterer
.
trioCompound
=
value
case
"deNovoInSample"
=>
filterer
.
deNovoInSample
=
value
case
"deNovoTrio"
=>
filterer
.
deNovoTrio
=
value
case
"trioLossOfHet"
=>
filterer
.
trioLossOfHet
=
value
case
_
=>
throw
new
IllegalArgumentException
}
val
cmdString
=
"--"
+
attr
+
" "
+
(
value
match
{
case
Some
(
v
)
=>
v
case
_
=>
throw
new
IllegalArgumentException
})
cmd
(
filterer
.
cmdLine
).
contains
(
cmdString
)
shouldBe
true
}
@Test
(
dataProvider
=
"listArguments"
)
def
testListArguments
(
attr
:
String
,
value
:
List
[
String
])
=
{
val
filterer
=
createFilterer
attr
match
{
case
"mustHaveVariant"
=>
filterer
.
mustHaveVariant
=
value
case
"mustHaveGenotype"
=>
filterer
.
mustHaveGenotype
=
value
case
"calledIn"
=>
filterer
.
calledIn
=
value
case
"diffGenotype"
=>
filterer
.
diffGenotype
=
value
case
"filterHetVarToHomVar"
=>
filterer
.
filterHetVarToHomVar
=
value
case
"id"
=>
filterer
.
id
=
value
case
_
=>
throw
new
IllegalArgumentException
}
value
.
foreach
{
x
=>
val
cmdString
=
"--"
+
attr
+
" "
+
x
cmd
(
filterer
.
cmdLine
).
contains
(
cmdString
)
shouldBe
true
}
}
@Test
(
dataProvider
=
"fileArguments"
)
def
testFileArguments
(
attr
:
String
,
value
:
Option
[
File
])
=
{
val
filterer
=
createFilterer
attr
match
{
case
"invertedOutputVcf"
=>
filterer
.
invertedOutputVcf
=
value
case
"idFile"
=>
filterer
.
idFile
=
value
case
_
=>
throw
new
IllegalArgumentException
}
val
cmdString
=
"--"
+
attr
+
" "
+
(
value
match
{
case
Some
(
v
)
=>
v
.
getAbsolutePath
case
_
=>
throw
new
IllegalArgumentException
})
cmd
(
filterer
.
cmdLine
).
contains
(
cmdString
)
shouldBe
true
}
/**
* The following two tests are for arguments with a so-far unique type
*/
@Test
def
testMinQual
=
{
val
filterer
=
createFilterer
filterer
.
minQualScore
=
Option
(
50
)
cmd
(
filterer
.
cmdLine
).
contains
(
"--minQualScore 50.0"
)
shouldBe
true
}
@Test
def
testFilterRefCalls
=
{
val
filterer
=
createFilterer
filterer
.
filterRefCalls
=
true
cmd
(
filterer
.
cmdLine
).
contains
(
"--filterRefCalls"
)
shouldBe
true
}
@Test
def
testBeforeGraph
()
=
{
val
filterer
=
new
VcfFilter
(
null
)
...
...
@@ -192,35 +34,51 @@ class VcfFilterTest extends TestNGSuite with Matchers {
Array
(
()
=>
testCommand
(
minSampleDepth
=
Some
(
2
)),
()
=>
testCommand
(
minTotalDepth
=
Some
(
2
)),
()
=>
testCommand
(
minSampleDepth
=
Some
(
2
),
minTotalDepth
=
Some
(
2
))
()
=>
testCommand
(
minAlternateDepth
=
Some
(
2
)),
()
=>
testCommand
(
minSamplesPass
=
Some
(
2
)),
()
=>
testCommand
(
minGenomeQuality
=
Some
(
50
)),
()
=>
testCommand
(
filterRefCalls
=
true
),
()
=>
testCommand
(
invertedOutputVcf
=
Some
(
File
.
createTempFile
(
"vcfFilter"
,
".vcf"
))),
()
=>
testCommand
(
resToDom
=
Some
(
"dummy"
)),
()
=>
testCommand
(
trioCompound
=
Some
(
"dummy"
)),
()
=>
testCommand
(
deNovoInSample
=
Some
(
"dummy"
)),
()
=>
testCommand
(
deNovoTrio
=
Some
(
"dummy"
)),
()
=>
testCommand
(
trioLossOfHet
=
Some
(
"dummy"
)),
()
=>
testCommand
(
mustHaveVariant
=
List
(
"sample1"
,
"sample2"
)),
()
=>
testCommand
(
calledIn
=
List
(
"sample1"
,
"sample2"
)),
()
=>
testCommand
(
mustHaveGenotype
=
List
(
"sample1:HET"
,
"sample2:HET"
)),
()
=>
testCommand
(
diffGenotype
=
List
(
"sample1:sample2"
,
"sample2:sample3"
)),
()
=>
testCommand
(
minQualScore
=
Some
(
50.0
)),
()
=>
testCommand
(
filterHetVarToHomVar
=
List
(
"dummy"
)),
()
=>
testCommand
(
id
=
List
(
"rs01"
,
"rs02"
)),
()
=>
testCommand
(
idFile
=
Some
(
File
.
createTempFile
(
"vcfFilter"
,
".txt"
)))
).
map
(
Array
(
_
))
}
@Test
(
dataProvider
=
"functions"
)
def
executer
(
function0
:
Function0
[
Unit
])
:
Unit
=
function0
()
protected
def
testCommand
(
minSampleDepth
:
Option
[
Int
]
=
None
,
minTotalDepth
:
Option
[
Int
]
=
None
,
minAlternateDepth
:
Option
[
Int
]
=
None
,
minSamplesPass
:
Option
[
Int
]
=
None
,
minGenomeQuality
:
Option
[
Int
]
=
None
,
filterRefCalls
:
Boolean
=
false
,
invertedOutputVcf
:
Option
[
File
]
=
None
,
resToDom
:
Option
[
String
]
=
None
,
trioCompound
:
Option
[
String
]
=
None
,
deNovoInSample
:
Option
[
String
]
=
None
,
deNovoTrio
:
Option
[
String
]
=
None
,
trioLossOfHet
:
Option
[
String
]
=
None
,
mustHaveVariant
:
List
[
String
]
=
Nil
,
calledIn
:
List
[
String
]
=
Nil
,
mustHaveGenotype
:
List
[
String
]
=
Nil
,
diffGenotype
:
List
[
String
]
=
Nil
,
filterHetVarToHomVar
:
List
[
String
]
=
Nil
,
minQualScore
:
Option
[
Double
]
=
None
,
id
:
List
[
String
]
=
Nil
,
idFile
:
Option
[
File
]
=
None
)
:
Unit
=
{
protected
def
testCommand
(
minSampleDepth
:
Option
[
Int
]
=
None
,
minTotalDepth
:
Option
[
Int
]
=
None
,
minAlternateDepth
:
Option
[
Int
]
=
None
,
minSamplesPass
:
Option
[
Int
]
=
None
,
minGenomeQuality
:
Option
[
Int
]
=
None
,
filterRefCalls
:
Boolean
=
false
,
invertedOutputVcf
:
Option
[
File
]
=
None
,
resToDom
:
Option
[
String
]
=
None
,
trioCompound
:
Option
[
String
]
=
None
,
deNovoInSample
:
Option
[
String
]
=
None
,
deNovoTrio
:
Option
[
String
]
=
None
,
trioLossOfHet
:
Option
[
String
]
=
None
,
mustHaveVariant
:
List
[
String
]
=
Nil
,
calledIn
:
List
[
String
]
=
Nil
,
mustHaveGenotype
:
List
[
String
]
=
Nil
,
diffGenotype
:
List
[
String
]
=
Nil
,
filterHetVarToHomVar
:
List
[
String
]
=
Nil
,
minQualScore
:
Option
[
Double
]
=
None
,
id
:
List
[
String
]
=
Nil
,
idFile
:
Option
[
File
]
=
None
)
:
Unit
=
{
val
vcfFilter
=
new
VcfFilter
(
null
)
vcfFilter
.
minSampleDepth
=
minSampleDepth
vcfFilter
.
minTotalDepth
=
minTotalDepth
...
...
@@ -242,9 +100,91 @@ class VcfFilterTest extends TestNGSuite with Matchers {
vcfFilter
.
minQualScore
=
minQualScore
vcfFilter
.
id
=
id
vcfFilter
.
idFile
=
idFile
val
command
=
vcfFilter
.
commandLine
val
command
=
cmd
(
vcfFilter
.
cmdLine
)
var
cmdString
:
List
[
String
]
=
Nil
if
(
minSampleDepth
.
isDefined
)
{
cmdString
=
"--minSampleDepth "
+
minSampleDepth
.
getOrElse
(
""
)
::
cmdString
}
if
(
minTotalDepth
.
isDefined
)
{
cmdString
=
"--minTotalDepth "
+
minTotalDepth
.
getOrElse
(
""
)
::
cmdString
}
if
(
minAlternateDepth
.
isDefined
)
{
cmdString
=
"--minAlternateDepth "
+
minAlternateDepth
.
getOrElse
(
""
)
::
cmdString
}
if
(
minSamplesPass
.
isDefined
)
{
cmdString
=
"--minSamplesPass "
+
minSamplesPass
.
getOrElse
(
""
)
::
cmdString
}
if
(
minGenomeQuality
.
isDefined
)
{
cmdString
=
"--minGenomeQuality "
+
minGenomeQuality
.
getOrElse
(
""
)
::
cmdString
}
if
(
filterRefCalls
)
{
cmdString
=
"--filterRefCalls"
::
cmdString
}
if
(
invertedOutputVcf
.
isDefined
)
{
cmdString
=
"--invertedOutputVcf "
+
invertedOutputVcf
.
getOrElse
(
new
File
(
""
)).
getAbsolutePath
::
cmdString
}
if
(
resToDom
.
isDefined
)
{
cmdString
=
"--resToDom "
+
resToDom
.
getOrElse
(
""
)
::
cmdString
}
if
(
trioCompound
.
isDefined
)
{
cmdString
=
"--trioCompound "
+
trioCompound
.
getOrElse
(
""
)
::
cmdString
}
if
(
deNovoInSample
.
isDefined
)
{
cmdString
=
"--deNovoInSample "
+
deNovoInSample
.
getOrElse
(
""
)
::
cmdString
}
if
(
deNovoTrio
.
isDefined
)
{
cmdString
=
"--deNovoTrio "
+
deNovoTrio
.
getOrElse
(
""
)
::
cmdString
}
if
(
trioLossOfHet
.
isDefined
)
{
cmdString
=
"--trioLossOfHet "
+
trioLossOfHet
.
getOrElse
(
""
)
::
cmdString
}
if
(
mustHaveVariant
.
nonEmpty
)
{
cmdString
=
mustHaveVariant
.
map
(
x
=>
"--mustHaveVariant "
+
x
)
:::
cmdString
}
if
(
calledIn
.
nonEmpty
)
{
cmdString
=
calledIn
.
map
(
x
=>
"--calledIn "
+
x
)
:::
cmdString
}
if
(
mustHaveGenotype
.
nonEmpty
)
{
cmdString
=
mustHaveGenotype
.
map
(
x
=>
"--mustHaveGenotype "
+
x
)
:::
cmdString
}
if
(
diffGenotype
.
nonEmpty
)
{
cmdString
=
diffGenotype
.
map
(
x
=>
"--diffGenotype "
+
x
)
:::
cmdString
}
if
(
filterHetVarToHomVar
.
nonEmpty
)
{
cmdString
=
filterHetVarToHomVar
.
map
(
x
=>
"--filterHetVarToHomVar "
+
x
)
:::
cmdString
}
if
(
id
.
nonEmpty
)
{
cmdString
=
id
.
map
(
x
=>
"--id "
+
x
)
:::
cmdString
}
if
(
idFile
.
isDefined
)
{
cmdString
=
"--idFile "
+
idFile
.
getOrElse
(
new
File
(
""
)).
getAbsolutePath
::
cmdString
}
if
(
minQualScore
.
isDefined
)
{
cmdString
=
"--minQualScore "
+
minQualScore
.
getOrElse
(
""
)
::
cmdString
}
//TODO: add test on command test
cmdString
.
foreach
(
x
=>
command
.
contains
(
x
)
shouldBe
true
)
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment