Made the necessary changes to get SnpEff support working with the new rodbinding system.
This commit is contained in:
parent
b180a1311a
commit
2efa376619
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
package org.broadinstitute.sting.gatk.walkers.annotator;
|
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.AlignmentContext;
|
||||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||||
|
|
@ -43,8 +44,8 @@ import java.util.*;
|
||||||
* (http://snpeff.sourceforge.net/).
|
* (http://snpeff.sourceforge.net/).
|
||||||
*
|
*
|
||||||
* For each variant, chooses one of the effects of highest biological impact from the SnpEff
|
* 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
|
* output file (which must be provided on the command line via --snpEffFile:SnpEff <filename>),
|
||||||
* on that effect.
|
* and adds annotations on that effect.
|
||||||
*
|
*
|
||||||
* The possible biological effects and their associated impacts are defined in the class:
|
* The possible biological effects and their associated impacts are defined in the class:
|
||||||
* org.broadinstitute.sting.utils.codecs.snpEff.SnpEffConstants
|
* 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 CODON_NUM_KEY = "CODON_NUM";
|
||||||
public static final String CDS_SIZE_KEY = "CDS_SIZE";
|
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<String, Object> annotate ( RefMetaDataTracker tracker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc ) {
|
public Map<String, Object> annotate ( RefMetaDataTracker tracker, ReferenceContext ref, Map<String, AlignmentContext> stratifiedContexts, VariantContext vc ) {
|
||||||
List<Object> snpEffFeatures = tracker.getReferenceMetaData(RMD_TRACK_NAME);
|
List<Feature> features = tracker.getValues(Feature.class);
|
||||||
|
|
||||||
// Add only annotations for one of the most biologically-significant effects as defined in
|
// Add only annotations for one of the most biologically-significant effects as defined in
|
||||||
// the SnpEffConstants class:
|
// the SnpEffConstants class:
|
||||||
SnpEffFeature mostSignificantEffect = getMostSignificantEffect(snpEffFeatures);
|
SnpEffFeature mostSignificantEffect = getMostSignificantEffect(features);
|
||||||
|
|
||||||
|
if ( mostSignificantEffect == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return generateAnnotations(mostSignificantEffect);
|
return generateAnnotations(mostSignificantEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SnpEffFeature getMostSignificantEffect ( List<Object> snpEffFeatures ) {
|
private SnpEffFeature getMostSignificantEffect ( List<Feature> features ) {
|
||||||
SnpEffFeature mostSignificantEffect = null;
|
SnpEffFeature mostSignificantEffect = null;
|
||||||
|
|
||||||
for ( Object feature : snpEffFeatures ) {
|
for ( Feature feature : features ) {
|
||||||
SnpEffFeature snpEffFeature = (SnpEffFeature)feature;
|
if ( feature instanceof SnpEffFeature ) {
|
||||||
|
SnpEffFeature snpEffFeature = (SnpEffFeature)feature;
|
||||||
|
|
||||||
if ( mostSignificantEffect == null ||
|
if ( mostSignificantEffect == null ||
|
||||||
snpEffFeature.isHigherImpactThan(mostSignificantEffect) ) {
|
snpEffFeature.isHigherImpactThan(mostSignificantEffect) ) {
|
||||||
|
|
||||||
mostSignificantEffect = snpEffFeature;
|
mostSignificantEffect = snpEffFeature;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnot
|
||||||
import org.broadinstitute.sting.utils.BaseUtils;
|
import org.broadinstitute.sting.utils.BaseUtils;
|
||||||
import org.broadinstitute.sting.utils.SampleUtils;
|
import org.broadinstitute.sting.utils.SampleUtils;
|
||||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
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.codecs.vcf.*;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
|
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
|
||||||
|
|
@ -55,6 +56,9 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
|
||||||
@Input(fullName="variants", shortName = "V", doc="Input VCF file", required=true)
|
@Input(fullName="variants", shortName = "V", doc="Input VCF file", required=true)
|
||||||
public RodBinding<VariantContext> variants;
|
public RodBinding<VariantContext> variants;
|
||||||
|
|
||||||
|
@Input(fullName="snpEffFile", shortName = "snpEffFile", doc="SnpEff file", required=false)
|
||||||
|
public RodBinding<SnpEffFeature> snpEffFile;
|
||||||
|
|
||||||
@Output(doc="File to which variants should be written",required=true)
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
protected VCFWriter vcfWriter = null;
|
protected VCFWriter vcfWriter = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,8 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSnpEffAnnotations() {
|
public void testSnpEffAnnotations() {
|
||||||
WalkerTestSpec spec = new WalkerTestSpec(
|
WalkerTestSpec spec = new WalkerTestSpec(
|
||||||
"-T VariantAnnotator -R " + b37KGReference + " -NO_HEADER -o %s -A SnpEff -B:variant,VCF " +
|
"-T VariantAnnotator -R " + b37KGReference + " -NO_HEADER -o %s -A SnpEff --variants:VCF " +
|
||||||
validationDataLocation + "1000G.exomes.vcf -B:SnpEff,SnpEff " + validationDataLocation +
|
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",
|
"snpEff_1.9.6_1000G.exomes.vcf_hg37.61.out -L 1:26,000,000-26,500,000",
|
||||||
1,
|
1,
|
||||||
Arrays.asList("c08648a078368c80530bff004b3157f1")
|
Arrays.asList("c08648a078368c80530bff004b3157f1")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue