From 9a6b384adb80fc61f35a702ed385ebe7a52ec8db Mon Sep 17 00:00:00 2001 From: depristo Date: Fri, 26 Feb 2010 00:29:17 +0000 Subject: [PATCH] Support for no qual fields in VCF; better support for Mendelian violation calculations git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2893 348d0f76-0448-11de-a6fe-93d51630548a --- .../variantcontext/InferredGeneticContext.java | 2 +- .../sting/gatk/refdata/VariantContextAdaptors.java | 6 ++++-- .../varianteval2/MendelianViolationEvaluator.java | 10 +++++----- .../variantcontext/VariantContextIntegrationTest.java | 1 + .../varianteval2/VariantEval2IntegrationTest.java | 8 ++++---- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/InferredGeneticContext.java b/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/InferredGeneticContext.java index 957b70978..d5843776f 100755 --- a/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/InferredGeneticContext.java +++ b/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/InferredGeneticContext.java @@ -100,7 +100,7 @@ final class InferredGeneticContext { // --------------------------------------------------------------------------------------------------------- public boolean hasNegLog10PError() { - return getNegLog10PError() == NO_NEG_LOG_10PERROR; + return getNegLog10PError() != NO_NEG_LOG_10PERROR; } /** diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java b/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java index de9c592f7..c603b3bb2 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java @@ -176,7 +176,8 @@ public class VariantContextAdaptors { genotypes.put(g.getSampleName(), g); } - VariantContext vc = new VariantContext(name, vcf.getLocation(), alleles, genotypes, vcf.getNegLog10PError(), filters, attributes); + double qual = vcf.getQual() == -1 ? VariantContext.NO_NEG_LOG_10PERROR : vcf.getNegLog10PError(); + VariantContext vc = new VariantContext(name, vcf.getLocation(), alleles, genotypes, qual, filters, attributes); vc.validate(); return vc; } else @@ -207,7 +208,8 @@ public class VariantContextAdaptors { String contig = vc.getLocation().getContig(); long position = vc.getLocation().getStart(); String ID = vc.hasAttribute("ID") ? vc.getAttributeAsString("ID") : "."; - double qual = vc.getPhredScaledQual(); + double qual = vc.hasNegLog10PError() ? vc.getPhredScaledQual() : -1; + String filters = vc.isFiltered() ? Utils.join(";", Utils.sorted(vc.getFilters())) : VCFRecord.PASSES_FILTERS; Map alleleMap = new HashMap(); diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/MendelianViolationEvaluator.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/MendelianViolationEvaluator.java index 00e0cd95e..2a4053622 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/MendelianViolationEvaluator.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/MendelianViolationEvaluator.java @@ -94,16 +94,16 @@ public class MendelianViolationEvaluator extends VariantEvaluator { public String update1(VariantContext vc, RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { if ( vc.isBiallelic() && vc.hasGenotypes() ) { // todo -- currently limited to biallelic loci - nVariants++; - Genotype momG = vc.getGenotype(trio.mom); Genotype dadG = vc.getGenotype(trio.dad); Genotype childG = vc.getGenotype(trio.child); - if ( momG == null || dadG == null || childG == null ) - throw new IllegalArgumentException(String.format("VariantContext didn't contain genotypes for expected trio members: mom=%s dad=%s child=%s", trio.mom, trio.dad, trio.child)); - if ( includeGenotype(momG) && includeGenotype(dadG) && includeGenotype(childG) ) { + nVariants++; + + if ( momG == null || dadG == null || childG == null ) + throw new IllegalArgumentException(String.format("VariantContext didn't contain genotypes for expected trio members: mom=%s dad=%s child=%s", trio.mom, trio.dad, trio.child)); + // all genotypes are good, so let's see if child is a violation if ( isViolation(vc, momG, dadG, childG) ) { diff --git a/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextIntegrationTest.java b/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextIntegrationTest.java index d491fda8f..52547fdb0 100755 --- a/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextIntegrationTest.java +++ b/java/test/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextIntegrationTest.java @@ -1,3 +1,4 @@ + package org.broadinstitute.sting.gatk.contexts.variantcontext; import org.broadinstitute.sting.WalkerTest; diff --git a/java/test/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2IntegrationTest.java b/java/test/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2IntegrationTest.java index af9dd2704..c505bd6f7 100755 --- a/java/test/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2IntegrationTest.java +++ b/java/test/org/broadinstitute/sting/oneoffprojects/walkers/varianteval2/VariantEval2IntegrationTest.java @@ -21,7 +21,7 @@ public class VariantEval2IntegrationTest extends WalkerTest { public void testVE2Simple() { HashMap expectations = new HashMap(); expectations.put("-L 1:1-10,000,000", "d58a2a22e5fb3a3d8d90ba02de37f62b"); - expectations.put("-L 1:1-10,000,000 -family NA19238+NA19239=NA19240 -MVQ 0", "8a928c8ad99428445e53b0b83f8ccdfa"); + expectations.put("-L 1:1-10,000,000 -family NA19238+NA19239=NA19240 -MVQ 0", "03cddae2afbe0d1a8f5e3490aebc7c9c"); for ( Map.Entry entry : expectations.entrySet() ) { String extraArgs = entry.getKey(); @@ -41,10 +41,10 @@ public class VariantEval2IntegrationTest extends WalkerTest { " -B dbsnp_130,dbSNP," + GATKDataLocation + "dbsnp_130_b36.rod" + " -B comp_hapmap,VCF," + validationDataLocation + "CEU_hapmap_nogt_23.vcf"; - String eqMD5s = "380e082222111c7bf962095d9afca8da"; // next two examples should be the same! + String eqMD5s = "1606e285d9bd586dc6662b1ace0a3a0e"; // next two examples should be the same! expectations.put("", eqMD5s); expectations.put(" -known comp_hapmap -known dbsnp", eqMD5s); - expectations.put(" -known comp_hapmap", "90d7d4d0ff370e9457978b2869782aa0"); + expectations.put(" -known comp_hapmap", "44773a96d1c5904a57e0e983836768e4"); for ( Map.Entry entry : expectations.entrySet() ) { String extraArgs2 = entry.getKey(); @@ -62,7 +62,7 @@ public class VariantEval2IntegrationTest extends WalkerTest { String extraArgs = "-L 1:1-10,000,000 -family NA19238+NA19239=NA19240 -MVQ 30"; WalkerTestSpec spec = new WalkerTestSpec( root + " " + extraArgs + " -o %s -outputVCF %s", 2, - Arrays.asList("b7d52d13e6eb3d593395a644583e449a", "9ec81f7389c0971e44e4b8d2d4af3008")); + Arrays.asList("1f2e04f8af061b7190758679a7840f12", "9ec81f7389c0971e44e4b8d2d4af3008")); executeTest("testVE2WriteVCF", spec); } }