diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SnpEff.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SnpEff.java index b9b97e154..cac59c8bb 100644 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SnpEff.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SnpEff.java @@ -24,6 +24,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broad.tribble.Feature; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -43,8 +44,8 @@ import java.util.*; * (http://snpeff.sourceforge.net/). * * For each variant, chooses one of the effects of highest biological impact from the SnpEff - * output file (which must be bound to an RMD track named "SnpEff"), and adds annotations - * on that effect. + * output file (which must be provided on the command line via --snpEffFile:SnpEff ), + * and adds annotations on that effect. * * The possible biological effects and their associated impacts are defined in the class: * org.broadinstitute.sting.utils.codecs.snpEff.SnpEffConstants @@ -68,28 +69,32 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio public static final String CODON_NUM_KEY = "CODON_NUM"; public static final String CDS_SIZE_KEY = "CDS_SIZE"; - // Name of the RMD track bound to the raw SnpEff-generated output file: - public static final String RMD_TRACK_NAME = "SnpEff"; - public Map annotate ( RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc ) { - List snpEffFeatures = tracker.getReferenceMetaData(RMD_TRACK_NAME); + List features = tracker.getValues(Feature.class); // Add only annotations for one of the most biologically-significant effects as defined in // the SnpEffConstants class: - SnpEffFeature mostSignificantEffect = getMostSignificantEffect(snpEffFeatures); + SnpEffFeature mostSignificantEffect = getMostSignificantEffect(features); + + if ( mostSignificantEffect == null ) { + return null; + } + return generateAnnotations(mostSignificantEffect); } - private SnpEffFeature getMostSignificantEffect ( List snpEffFeatures ) { + private SnpEffFeature getMostSignificantEffect ( List features ) { SnpEffFeature mostSignificantEffect = null; - for ( Object feature : snpEffFeatures ) { - SnpEffFeature snpEffFeature = (SnpEffFeature)feature; + for ( Feature feature : features ) { + if ( feature instanceof SnpEffFeature ) { + SnpEffFeature snpEffFeature = (SnpEffFeature)feature; - if ( mostSignificantEffect == null || - snpEffFeature.isHigherImpactThan(mostSignificantEffect) ) { + if ( mostSignificantEffect == null || + snpEffFeature.isHigherImpactThan(mostSignificantEffect) ) { - mostSignificantEffect = snpEffFeature; + mostSignificantEffect = snpEffFeature; + } } } diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index 85035ba93..ef408fae3 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -37,6 +37,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnot import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.utils.classloader.PluginManager; +import org.broadinstitute.sting.utils.codecs.snpEff.SnpEffFeature; import org.broadinstitute.sting.utils.codecs.vcf.*; import org.broadinstitute.sting.utils.variantcontext.VariantContext; import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils; @@ -55,6 +56,9 @@ public class VariantAnnotator extends RodWalker { @Input(fullName="variants", shortName = "V", doc="Input VCF file", required=true) public RodBinding variants; + @Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false) + public RodBinding snpEffFile; + @Output(doc="File to which variants should be written",required=true) protected VCFWriter vcfWriter = null; diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java index fe7e8b1d8..cbfb3cd0b 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorIntegrationTest.java @@ -129,8 +129,8 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest { @Test public void testSnpEffAnnotations() { WalkerTestSpec spec = new WalkerTestSpec( - "-T VariantAnnotator -R " + b37KGReference + " -NO_HEADER -o %s -A SnpEff -B:variant,VCF " + - validationDataLocation + "1000G.exomes.vcf -B:SnpEff,SnpEff " + validationDataLocation + + "-T VariantAnnotator -R " + b37KGReference + " -NO_HEADER -o %s -A SnpEff --variants:VCF " + + validationDataLocation + "1000G.exomes.vcf --snpEffFile:SnpEff " + validationDataLocation + "snpEff_1.9.6_1000G.exomes.vcf_hg37.61.out -L 1:26,000,000-26,500,000", 1, Arrays.asList("c08648a078368c80530bff004b3157f1")