From 24b72334b3b30da8384f2ffcf03ab673502c2320 Mon Sep 17 00:00:00 2001 From: David Roazen Date: Tue, 11 Oct 2011 11:32:27 -0400 Subject: [PATCH] UnifiedGenotyper now correctly initializes the VariantAnnotator engine. This allows the annotation classes to perform any necessary initialization/validation. For example, it allows the SnpEff annotator to (among other things) validate its rod binding. This will prevent a NullPointerException when SnpEff annotation is requested but no rod binding is present. Added an integration test to cover this case so that it doesn't break again. --- .../gatk/walkers/genotyper/UnifiedGenotyper.java | 8 +++++++- .../genotyper/UnifiedGenotyperIntegrationTest.java | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java index 428f97e2a..9fdf65015 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyper.java @@ -214,7 +214,13 @@ public class UnifiedGenotyper extends LocusWalker headerInfo = getHeaderInfo(); + + // invoke initialize() method on each of the annotation classes, allowing them to add their own header lines + // and perform any necessary initialization/validation steps + annotationEngine.invokeAnnotationInitializationMethods(headerInfo); + + writer.writeHeader(new VCFHeader(headerInfo, samples)); } private Set getHeaderInfo() { diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java index 41496bdf1..7ef75ec53 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java @@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import org.broadinstitute.sting.WalkerTest; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; +import org.broadinstitute.sting.utils.exceptions.UserException; import org.testng.annotations.Test; import java.io.File; @@ -285,6 +286,13 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { } - - + @Test + public void testSnpEffAnnotationRequestedWithoutRodBinding() { + WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec( + baseCommand + " -I " + validationDataLocation + "low_coverage_CEU.chr1.10k-11k.bam -o %s -L 1:10,022,000-10,025,000 " + + "-A SnpEff", + 1, + UserException.class); + executeTest("testSnpEffAnnotationRequestedWithoutRodBinding", spec); + } }