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
c779f1f0
Commit
c779f1f0
authored
Jan 05, 2017
by
Peter van 't Hof
Browse files
Merge branch 'fix-biopet-509' into 'develop'
Check whether sample exists in vcf file [Biopet-509] See merge request !506
parents
8ead9c4f
7979998e
Changes
2
Hide whitespace changes
Inline
Side-by-side
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/VcfFilter.scala
View file @
c779f1f0
...
...
@@ -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 @
c779f1f0
...
...
@@ -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