Commit 26243a6b authored by Sander Bollen's avatar Sander Bollen
Browse files

attempt fix for #386

parent 6efe0956
......@@ -16,10 +16,10 @@ package nl.lumc.sasc.biopet.tools
import java.io.File
import htsjdk.variant.variantcontext.{ GenotypeType, VariantContext }
import htsjdk.variant.variantcontext.writer.{ AsyncVariantContextWriter, VariantContextWriterBuilder }
import htsjdk.variant.variantcontext.{GenotypeType, VariantContext}
import htsjdk.variant.variantcontext.writer.{AsyncVariantContextWriter, VariantContextWriterBuilder}
import htsjdk.variant.vcf.VCFFileReader
import nl.lumc.sasc.biopet.utils.ToolCommand
import nl.lumc.sasc.biopet.utils.{ToolCommand, VcfUtils}
import scala.collection.JavaConversions._
import scala.io.Source
......@@ -315,11 +315,11 @@ object VcfFilter extends ToolCommand {
* Checks if given samples does have a variant hin this record
*
* @param record VCF record
* @param mustHaveVariant List of samples that should have this variant
* @param samples List of samples that should have this variant
* @return true if filter passed
*/
def mustHaveVariant(record: VariantContext, mustHaveVariant: List[String]): Boolean = {
!mustHaveVariant.map(record.getGenotype).exists(a => a.isHomRef || a.isNoCall)
def mustHaveVariant(record: VariantContext, samples: List[String]): Boolean = {
!samples.map(record.getGenotype).exists(a => a.isHomRef || a.isNoCall || VcfUtils.isCompoundNoCall(a))
}
/** Checks if given samples have the same genotype */
......
......@@ -140,4 +140,13 @@ object VcfUtils {
reader.close()
!hasNext
}
/**
* Check whether genotype is of the from 0/.
* @param genotype genotype
* @return boolean
*/
def isCompoundNoCall(genotype: Genotype): Boolean = {
!genotype.isHetNonRef && genotype.isMixed && genotype.getAlleles.last.basesMatch("")
}
}
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