Commit aac5ea06 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added filter on HET_REF

parent 20c57725
......@@ -22,6 +22,7 @@ class VcfFilter(val root: Configurable) extends BiopetJavaCommandLineFunction {
var minTotalDepth: Option[Int] = _
var minAlternateDepth: Option[Int] = _
var minSamplesPass: Option[Int] = _
var filterRefCalls: Boolean = _
override val defaultVmem = "8G"
memoryLimit = Option(4.0)
......@@ -31,6 +32,7 @@ class VcfFilter(val root: Configurable) extends BiopetJavaCommandLineFunction {
minTotalDepth = config("min_total_depth")
minAlternateDepth = config("min_alternate_depth")
minSamplesPass = config("min_samples_pass")
filterRefCalls = config("filter_ref_calls")
}
override def commandLine = super.commandLine +
......@@ -39,7 +41,8 @@ class VcfFilter(val root: Configurable) extends BiopetJavaCommandLineFunction {
optional("-minSampleDepth", minSampleDepth) +
optional("-minTotalDepth", minTotalDepth) +
optional("-minAlternateDepth", minAlternateDepth) +
optional("-minSamplesPass", minSamplesPass)
optional("-minSamplesPass", minSamplesPass) +
conditional(filterRefCalls, "-filterRefCalls")
}
object VcfFilter {
......@@ -49,6 +52,7 @@ object VcfFilter {
var minTotalDepth = -1
var minAlternateDepth = -1
var minSamplesPass = 0
var filterRefCalls = false
/**
* @param args the command line arguments
*/
......@@ -61,6 +65,7 @@ object VcfFilter {
case "-minTotalDepth" => minTotalDepth = args(t+1).toInt
case "-minAlternateDepth" => minAlternateDepth = args(t+1).toInt
case "-minSamplesPass" => minSamplesPass = args(t+1).toInt
case "-filterRefCalls" => filterRefCalls = true
case _ =>
}
}
......@@ -73,7 +78,8 @@ object VcfFilter {
for (record <- reader) {
val genotypes = for (genotype <- record.getGenotypes) yield {
genotype.getDP >= minSampleDepth &&
List(genotype.getAD:_*).tail.count(_ >= minAlternateDepth) > 0
List(genotype.getAD:_*).tail.count(_ >= minAlternateDepth) > 0 &&
!(filterRefCalls && genotype.isHomRef)
}
if (record.getAttributeAsInt("DP", -1) >= minTotalDepth && genotypes.count(_ == true) >= minSamplesPass)
......
Supports Markdown
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