From e6f468b647518f8e3ef8fb030bb4d4eee95eceea Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Mon, 17 Dec 2012 11:54:47 -0500 Subject: [PATCH] Refactored the quasi-useful IndelType annotation into the more useful VariantType. The indels are still annotated as before, but now all other variant types are annotated too. I'm doing this because of requests on the forum but am not making it standard. If we find it to be useful we can turn it on by default later. --- .../{IndelType.java => VariantType.java} | 56 +++++++++---------- .../sting/utils/IndelUtils.java | 4 +- 2 files changed, 27 insertions(+), 33 deletions(-) rename public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/{IndelType.java => VariantType.java} (52%) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantType.java similarity index 52% rename from public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java rename to public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantType.java index c67d829c2..a5c2b32f0 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantType.java @@ -15,9 +15,9 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext; import java.util.*; /** - * Rough category of indel type (insertion, deletion, multi-allelic, other) + * Assigns a roughly correct category of the variant type (SNP, MNP, insertion, deletion, etc.) */ -public class IndelType extends InfoFieldAnnotation implements ExperimentalAnnotation { +public class VariantType extends InfoFieldAnnotation implements ExperimentalAnnotation { public Map annotate(final RefMetaDataTracker tracker, final AnnotatorCompatible walker, @@ -26,41 +26,35 @@ public class IndelType extends InfoFieldAnnotation implements ExperimentalAnnota final VariantContext vc, final Map stratifiedPerReadAlleleLikelihoodMap) { - int run; - if (vc.isMixed()) { - Map map = new HashMap(); - map.put(getKeyNames().get(0), String.format("%s", "MIXED")); - return map; - - } - else if ( vc.isIndel() ) { - String type=""; - if (!vc.isBiallelic()) - type = "MULTIALLELIC_INDEL"; - else { - if (vc.isSimpleInsertion()) - type = "INS."; - else if (vc.isSimpleDeletion()) - type = "DEL."; - else - type = "OTHER."; - ArrayList inds = IndelUtils.findEventClassificationIndex(vc, ref); - for (int k : inds) { - type = type+ IndelUtils.getIndelClassificationName(k)+"."; - } - } - Map map = new HashMap(); - map.put(getKeyNames().get(0), String.format("%s", type)); - return map; + StringBuffer type = new StringBuffer(""); + if ( vc.isVariant() && !vc.isBiallelic() ) + type.append("MULTIALLELIC_"); + if ( !vc.isIndel() ) { + type.append(vc.getType().toString()); } else { - return null; + if (vc.isSimpleInsertion()) + type.append("INSERTION."); + else if (vc.isSimpleDeletion()) + type.append("DELETION."); + else + type.append("COMPLEX."); + ArrayList inds = IndelUtils.findEventClassificationIndex(vc, ref); + type.append(IndelUtils.getIndelClassificationName(inds.get(0))); + + for (int i = 1; i < inds.size(); i++ ) { + type.append("."); + type.append(IndelUtils.getIndelClassificationName(inds.get(i))); + } } + Map map = new HashMap(); + map.put(getKeyNames().get(0), String.format("%s", type)); + return map; } - public List getKeyNames() { return Arrays.asList("IndelType"); } + public List getKeyNames() { return Arrays.asList("VariantType"); } - public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("IndelType", 1, VCFHeaderLineType.String, "Indel type description")); } + public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("VariantType", 1, VCFHeaderLineType.String, "Variant type description")); } } diff --git a/public/java/src/org/broadinstitute/sting/utils/IndelUtils.java b/public/java/src/org/broadinstitute/sting/utils/IndelUtils.java index c6ca39f4b..9b1cc9733 100755 --- a/public/java/src/org/broadinstitute/sting/utils/IndelUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/IndelUtils.java @@ -122,9 +122,9 @@ public class IndelUtils { ArrayList inds = new ArrayList(); if ( vc.isSimpleInsertion() ) { - indelAlleleString = vc.getAlternateAllele(0).getDisplayString(); + indelAlleleString = vc.getAlternateAllele(0).getDisplayString().substring(1); } else if ( vc.isSimpleDeletion() ) { - indelAlleleString = vc.getReference().getDisplayString(); + indelAlleleString = vc.getReference().getDisplayString().substring(1); } else { inds.add(IND_FOR_OTHER_EVENT);