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
7979998e
Commit
7979998e
authored
Jan 05, 2017
by
Sander Bollen
Browse files
Check whether sample exists in vcf file
parent
725ed53a
Changes
2
Hide whitespace changes
Inline
Side-by-side
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/VcfFilter.scala
View file @
7979998e
...
...
@@ -319,6 +319,11 @@ object VcfFilter extends ToolCommand {
* @return true if filter passed
*/
def
mustHaveVariant
(
record
:
VariantContext
,
samples
:
List
[
String
])
:
Boolean
=
{
samples
.
foreach
{
s
=>
if
(!
record
.
getSampleNames
.
toList
.
contains
(
s
))
{
throw
new
IllegalArgumentException
(
s
"Sample name $s does not exist in VCF file"
)
}
}
!
samples
.
map
(
record
.
getGenotype
).
exists
(
a
=>
a
.
isHomRef
||
a
.
isNoCall
||
VcfUtils
.
isCompoundNoCall
(
a
))
}
...
...
biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala
View file @
7979998e
...
...
@@ -186,6 +186,8 @@ class VcfFilterTest extends TestNGSuite with MockitoSugar with Matchers {
mustHaveVariant
(
record
,
List
(
"Sample_101"
,
"Sample_102"
))
shouldBe
true
mustHaveVariant
(
record
,
List
(
"Sample_101"
,
"Sample_102"
,
"Sample_103"
))
shouldBe
false
an
[
IllegalArgumentException
]
shouldBe
thrownBy
(
mustHaveVariant
(
record
,
List
(
"notExistant"
)))
val
starReader
=
new
VCFFileReader
(
star
,
false
)
starReader
.
iterator
().
foreach
(
x
=>
mustHaveVariant
(
x
,
List
(
"Sample_101"
))
shouldBe
false
)
}
...
...
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