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
1100b72d
Commit
1100b72d
authored
Oct 13, 2015
by
Sander Bollen
Browse files
Add minimum genome quality to VcfFilter
parent
07d1825f
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/VcfFilter.scala
View file @
1100b72d
...
...
@@ -54,7 +54,8 @@ object VcfFilter extends ToolCommand {
filterHetVarToHomVar
:
List
[(
String
,
String
)]
=
Nil
,
filterRefCalls
:
Boolean
=
false
,
filterNoCalls
:
Boolean
=
false
,
iDset
:
Set
[
String
]
=
Set
())
extends
AbstractArgs
iDset
:
Set
[
String
]
=
Set
(),
minGenomeQuality
:
Int
=
0
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
'I'
,
"inputVcf"
)
required
()
maxOccurs
1
valueName
"<file>"
action
{
(
x
,
c
)
=>
...
...
@@ -128,6 +129,8 @@ object VcfFilter extends ToolCommand {
opt
[
File
](
"idFile"
)
unbounded
()
action
{
(
x
,
c
)
=>
c
.
copy
(
iDset
=
c
.
iDset
++
Source
.
fromFile
(
x
).
getLines
())
}
text
"File that contain list of IDs to get from vcf file"
opt
[
Int
](
"minGenomeQuality"
)
unbounded
()
action
{
(
x
,
c
)
=>
c
.
copy
(
minGenomeQuality
=
x
)}
}
/** @param args the command line arguments */
...
...
@@ -161,6 +164,7 @@ object VcfFilter extends ToolCommand {
hasMinTotalDepth
(
record
,
cmdArgs
.
minTotalDepth
)
&&
hasMinSampleDepth
(
record
,
cmdArgs
.
minSampleDepth
,
cmdArgs
.
minSamplesPass
)
&&
minAlternateDepth
(
record
,
cmdArgs
.
minAlternateDepth
,
cmdArgs
.
minSamplesPass
)
&&
minGenomeQuality
(
record
,
cmdArgs
.
minGenomeQuality
,
cmdArgs
.
minSamplesPass
)
&&
(
cmdArgs
.
mustHaveVariant
.
isEmpty
||
mustHaveVariant
(
record
,
cmdArgs
.
mustHaveVariant
))
&&
calledIn
(
record
,
cmdArgs
.
calledIn
)
&&
hasGenotype
(
record
,
cmdArgs
.
mustHaveGenotype
)
&&
...
...
@@ -263,6 +267,18 @@ object VcfFilter extends ToolCommand {
})
>=
minSamplesPass
}
/**
* Checks if genome quality field has minimum value
* @param record VCF record
* @param minGQ smallest GQ allowed
* @param minSamplesPass number of samples to consider
* @return
*/
def
minGenomeQuality
(
record
:
VariantContext
,
minGQ
:
Int
,
minSamplesPass
:
Int
=
1
)
:
Boolean
=
{
record
.
getGenotypes
.
count
(
x
=>
if
(!
x
.
hasGQ
)
false
else
if
(
x
.
getGQ
>=
minGQ
)
true
else
false
)
>=
minSamplesPass
}
/**
* Checks if given samples does have a variant hin this record
* @param record VCF record
...
...
public/biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/VcfFilterTest.scala
View file @
1100b72d
...
...
@@ -138,6 +138,15 @@ class VcfFilterTest extends TestNGSuite with MockitoSugar with Matchers {
minAlternateDepth
(
record
,
20
,
2
)
shouldBe
false
}
@Test
def
testHasMinGQ
()
=
{
val
reader
=
new
VCFFileReader
(
vepped
,
false
)
val
record
=
reader
.
iterator
().
next
()
minGenomeQuality
(
record
,
99
,
1
)
shouldBe
true
minGenomeQuality
(
record
,
99
,
2
)
shouldBe
true
minGenomeQuality
(
record
,
99
,
3
)
shouldBe
true
}
@Test
def
testMustHaveVariant
()
=
{
val
reader
=
new
VCFFileReader
(
vepped
,
false
)
val
record
=
reader
.
iterator
().
next
()
...
...
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