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