Renaming VariantAnnotator SnpEff keys

This is to head off potential confusion with the output from the SnpEff tool itself,
which also uses a key named EFF.
This commit is contained in:
David Roazen 2011-09-15 16:09:07 -04:00
parent 1971fb35d7
commit d78e00e5b2
4 changed files with 53 additions and 45 deletions

View File

@ -68,23 +68,31 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio
// Key names for the INFO field annotations we will add to each record, along // Key names for the INFO field annotations we will add to each record, along
// with parsing-related information: // with parsing-related information:
public enum InfoFieldKey { public enum InfoFieldKey {
EFF (-1), EFFECT_KEY ("SNPEFF_EFFECT", -1),
EFF_IMPACT (0), IMPACT_KEY ("SNPEFF_IMPACT", 0),
EFF_CODON_CHANGE (1), CODON_CHANGE_KEY ("SNPEFF_CODON_CHANGE", 1),
EFF_AMINO_ACID_CHANGE (2), AMINO_ACID_CHANGE_KEY ("SNPEFF_AMINO_ACID_CHANGE", 2),
EFF_GENE_NAME (3), GENE_NAME_KEY ("SNPEFF_GENE_NAME", 3),
EFF_GENE_BIOTYPE (4), GENE_BIOTYPE_KEY ("SNPEFF_GENE_BIOTYPE", 4),
EFF_TRANSCRIPT_ID (6), TRANSCRIPT_ID_KEY ("SNPEFF_TRANSCRIPT_ID", 6),
EFF_EXON_ID (7); EXON_ID_KEY ("SNPEFF_EXON_ID", 7);
// Actual text of the key
private final String keyName;
// Index within the effect metadata subfields from the SnpEff EFF annotation // Index within the effect metadata subfields from the SnpEff EFF annotation
// where each key's associated value can be found during parsing. // where each key's associated value can be found during parsing.
private final int fieldIndex; private final int fieldIndex;
InfoFieldKey ( int fieldIndex ) { InfoFieldKey ( String keyName, int fieldIndex ) {
this.keyName = keyName;
this.fieldIndex = fieldIndex; this.fieldIndex = fieldIndex;
} }
public String getKeyName() {
return keyName;
}
public int getFieldIndex() { public int getFieldIndex() {
return fieldIndex; return fieldIndex;
} }
@ -292,27 +300,27 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio
} }
public List<String> getKeyNames() { public List<String> getKeyNames() {
return Arrays.asList( InfoFieldKey.EFF.toString(), return Arrays.asList( InfoFieldKey.EFFECT_KEY.getKeyName(),
InfoFieldKey.EFF_IMPACT.toString(), InfoFieldKey.IMPACT_KEY.getKeyName(),
InfoFieldKey.EFF_CODON_CHANGE.toString(), InfoFieldKey.CODON_CHANGE_KEY.getKeyName(),
InfoFieldKey.EFF_AMINO_ACID_CHANGE.toString(), InfoFieldKey.AMINO_ACID_CHANGE_KEY.getKeyName(),
InfoFieldKey.EFF_GENE_NAME.toString(), InfoFieldKey.GENE_NAME_KEY.getKeyName(),
InfoFieldKey.EFF_GENE_BIOTYPE.toString(), InfoFieldKey.GENE_BIOTYPE_KEY.getKeyName(),
InfoFieldKey.EFF_TRANSCRIPT_ID.toString(), InfoFieldKey.TRANSCRIPT_ID_KEY.getKeyName(),
InfoFieldKey.EFF_EXON_ID.toString() InfoFieldKey.EXON_ID_KEY.getKeyName()
); );
} }
public List<VCFInfoHeaderLine> getDescriptions() { public List<VCFInfoHeaderLine> getDescriptions() {
return Arrays.asList( return Arrays.asList(
new VCFInfoHeaderLine(InfoFieldKey.EFF.toString(), 1, VCFHeaderLineType.String, "The highest-impact effect resulting from the current variant (or one of the highest-impact effects, if there is a tie)"), new VCFInfoHeaderLine(InfoFieldKey.EFFECT_KEY.getKeyName(), 1, VCFHeaderLineType.String, "The highest-impact effect resulting from the current variant (or one of the highest-impact effects, if there is a tie)"),
new VCFInfoHeaderLine(InfoFieldKey.EFF_IMPACT.toString(), 1, VCFHeaderLineType.String, "Impact of the highest-impact effect resulting from the current variant " + Arrays.toString(EffectImpact.values())), new VCFInfoHeaderLine(InfoFieldKey.IMPACT_KEY.getKeyName(), 1, VCFHeaderLineType.String, "Impact of the highest-impact effect resulting from the current variant " + Arrays.toString(EffectImpact.values())),
new VCFInfoHeaderLine(InfoFieldKey.EFF_CODON_CHANGE.toString(), 1, VCFHeaderLineType.String, "Old/New codon for the highest-impact effect resulting from the current variant"), new VCFInfoHeaderLine(InfoFieldKey.CODON_CHANGE_KEY.getKeyName(), 1, VCFHeaderLineType.String, "Old/New codon for the highest-impact effect resulting from the current variant"),
new VCFInfoHeaderLine(InfoFieldKey.EFF_AMINO_ACID_CHANGE.toString(), 1, VCFHeaderLineType.String, "Old/New amino acid for the highest-impact effect resulting from the current variant"), new VCFInfoHeaderLine(InfoFieldKey.AMINO_ACID_CHANGE_KEY.getKeyName(), 1, VCFHeaderLineType.String, "Old/New amino acid for the highest-impact effect resulting from the current variant"),
new VCFInfoHeaderLine(InfoFieldKey.EFF_GENE_NAME.toString(), 1, VCFHeaderLineType.String, "Gene name for the highest-impact effect resulting from the current variant"), new VCFInfoHeaderLine(InfoFieldKey.GENE_NAME_KEY.getKeyName(), 1, VCFHeaderLineType.String, "Gene name for the highest-impact effect resulting from the current variant"),
new VCFInfoHeaderLine(InfoFieldKey.EFF_GENE_BIOTYPE.toString(), 1, VCFHeaderLineType.String, "Gene biotype for the highest-impact effect resulting from the current variant"), new VCFInfoHeaderLine(InfoFieldKey.GENE_BIOTYPE_KEY.getKeyName(), 1, VCFHeaderLineType.String, "Gene biotype for the highest-impact effect resulting from the current variant"),
new VCFInfoHeaderLine(InfoFieldKey.EFF_TRANSCRIPT_ID.toString(), 1, VCFHeaderLineType.String, "Transcript ID for the highest-impact effect resulting from the current variant"), new VCFInfoHeaderLine(InfoFieldKey.TRANSCRIPT_ID_KEY.getKeyName(), 1, VCFHeaderLineType.String, "Transcript ID for the highest-impact effect resulting from the current variant"),
new VCFInfoHeaderLine(InfoFieldKey.EFF_EXON_ID.toString(), 1, VCFHeaderLineType.String, "Exon ID for the highest-impact effect resulting from the current variant") new VCFInfoHeaderLine(InfoFieldKey.EXON_ID_KEY.getKeyName(), 1, VCFHeaderLineType.String, "Exon ID for the highest-impact effect resulting from the current variant")
); );
} }
@ -375,16 +383,16 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio
} }
try { try {
impact = EffectImpact.valueOf(effectMetadata[InfoFieldKey.EFF_IMPACT.getFieldIndex()]); impact = EffectImpact.valueOf(effectMetadata[InfoFieldKey.IMPACT_KEY.getFieldIndex()]);
} }
catch ( IllegalArgumentException e ) { catch ( IllegalArgumentException e ) {
parseError(String.format("Unrecognized value for effect impact: %s", effectMetadata[InfoFieldKey.EFF_IMPACT.getFieldIndex()])); parseError(String.format("Unrecognized value for effect impact: %s", effectMetadata[InfoFieldKey.IMPACT_KEY.getFieldIndex()]));
} }
codonChange = effectMetadata[InfoFieldKey.EFF_CODON_CHANGE.getFieldIndex()]; codonChange = effectMetadata[InfoFieldKey.CODON_CHANGE_KEY.getFieldIndex()];
aminoAcidChange = effectMetadata[InfoFieldKey.EFF_AMINO_ACID_CHANGE.getFieldIndex()]; aminoAcidChange = effectMetadata[InfoFieldKey.AMINO_ACID_CHANGE_KEY.getFieldIndex()];
geneName = effectMetadata[InfoFieldKey.EFF_GENE_NAME.getFieldIndex()]; geneName = effectMetadata[InfoFieldKey.GENE_NAME_KEY.getFieldIndex()];
geneBiotype = effectMetadata[InfoFieldKey.EFF_GENE_BIOTYPE.getFieldIndex()]; geneBiotype = effectMetadata[InfoFieldKey.GENE_BIOTYPE_KEY.getFieldIndex()];
if ( effectMetadata[SNPEFF_CODING_FIELD_INDEX].trim().length() > 0 ) { if ( effectMetadata[SNPEFF_CODING_FIELD_INDEX].trim().length() > 0 ) {
try { try {
@ -398,8 +406,8 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio
coding = EffectCoding.UNKNOWN; coding = EffectCoding.UNKNOWN;
} }
transcriptID = effectMetadata[InfoFieldKey.EFF_TRANSCRIPT_ID.getFieldIndex()]; transcriptID = effectMetadata[InfoFieldKey.TRANSCRIPT_ID_KEY.getFieldIndex()];
exonID = effectMetadata[InfoFieldKey.EFF_EXON_ID.getFieldIndex()]; exonID = effectMetadata[InfoFieldKey.EXON_ID_KEY.getFieldIndex()];
} }
private void parseError ( String message ) { private void parseError ( String message ) {
@ -443,14 +451,14 @@ public class SnpEff extends InfoFieldAnnotation implements ExperimentalAnnotatio
public Map<String, Object> getAnnotations() { public Map<String, Object> getAnnotations() {
Map<String, Object> annotations = new LinkedHashMap<String, Object>(Utils.optimumHashSize(InfoFieldKey.values().length)); Map<String, Object> annotations = new LinkedHashMap<String, Object>(Utils.optimumHashSize(InfoFieldKey.values().length));
addAnnotation(annotations, InfoFieldKey.EFF.toString(), effect.toString()); addAnnotation(annotations, InfoFieldKey.EFFECT_KEY.getKeyName(), effect.toString());
addAnnotation(annotations, InfoFieldKey.EFF_IMPACT.toString(), impact.toString()); addAnnotation(annotations, InfoFieldKey.IMPACT_KEY.getKeyName(), impact.toString());
addAnnotation(annotations, InfoFieldKey.EFF_CODON_CHANGE.toString(), codonChange); addAnnotation(annotations, InfoFieldKey.CODON_CHANGE_KEY.getKeyName(), codonChange);
addAnnotation(annotations, InfoFieldKey.EFF_AMINO_ACID_CHANGE.toString(), aminoAcidChange); addAnnotation(annotations, InfoFieldKey.AMINO_ACID_CHANGE_KEY.getKeyName(), aminoAcidChange);
addAnnotation(annotations, InfoFieldKey.EFF_GENE_NAME.toString(), geneName); addAnnotation(annotations, InfoFieldKey.GENE_NAME_KEY.getKeyName(), geneName);
addAnnotation(annotations, InfoFieldKey.EFF_GENE_BIOTYPE.toString(), geneBiotype); addAnnotation(annotations, InfoFieldKey.GENE_BIOTYPE_KEY.getKeyName(), geneBiotype);
addAnnotation(annotations, InfoFieldKey.EFF_TRANSCRIPT_ID.toString(), transcriptID); addAnnotation(annotations, InfoFieldKey.TRANSCRIPT_ID_KEY.getKeyName(), transcriptID);
addAnnotation(annotations, InfoFieldKey.EFF_EXON_ID.toString(), exonID); addAnnotation(annotations, InfoFieldKey.EXON_ID_KEY.getKeyName(), exonID);
return annotations; return annotations;
} }

View File

@ -62,8 +62,8 @@ public class FunctionalClass extends VariantStratifier {
annotationId++; annotationId++;
} while (eval.hasAttribute(key)); } while (eval.hasAttribute(key));
} else if ( eval.hasAttribute(SnpEff.InfoFieldKey.EFF.name() ) ) { } else if ( eval.hasAttribute(SnpEff.InfoFieldKey.EFFECT_KEY.getKeyName() ) ) {
SnpEff.EffectType snpEffType = SnpEff.EffectType.valueOf(eval.getAttribute(SnpEff.InfoFieldKey.EFF.name()).toString()); SnpEff.EffectType snpEffType = SnpEff.EffectType.valueOf(eval.getAttribute(SnpEff.InfoFieldKey.EFFECT_KEY.getKeyName()).toString());
if ( snpEffType == SnpEff.EffectType.STOP_GAINED ) if ( snpEffType == SnpEff.EffectType.STOP_GAINED )
type = FunctionalType.nonsense; type = FunctionalType.nonsense;
else if ( snpEffType == SnpEff.EffectType.NON_SYNONYMOUS_CODING ) else if ( snpEffType == SnpEff.EffectType.NON_SYNONYMOUS_CODING )

View File

@ -134,7 +134,7 @@ public class VariantAnnotatorIntegrationTest extends WalkerTest {
validationDataLocation + "1kg_exomes_unfiltered.AFR.unfiltered.vcf --snpEffFile " + validationDataLocation + validationDataLocation + "1kg_exomes_unfiltered.AFR.unfiltered.vcf --snpEffFile " + validationDataLocation +
"snpEff.AFR.unfiltered.vcf -L 1:1-1,500,000", "snpEff.AFR.unfiltered.vcf -L 1:1-1,500,000",
1, 1,
Arrays.asList("a1c3ba9efc28ee0606339604095076ea") Arrays.asList("486fc6a5ca1819f5ab180d5d72b1ebc9")
); );
executeTest("Testing SnpEff annotations", spec); executeTest("Testing SnpEff annotations", spec);
} }

View File

@ -32,7 +32,7 @@ public class VariantEvalIntegrationTest extends WalkerTest {
1, 1,
Arrays.asList("f5f811ceb973d7fd6c1b2b734f1b2b12") Arrays.asList("f5f811ceb973d7fd6c1b2b734f1b2b12")
); );
executeTest("testStratifySamplesAndExcludeMonomorphicSites", spec); executeTest("testFunctionClassWithSnpeff", spec);
} }
@Test @Test