From 727dac7b7a00d80ab2e927ce9d30dc62936cd334 Mon Sep 17 00:00:00 2001 From: fromer Date: Mon, 29 Nov 2010 21:24:30 +0000 Subject: [PATCH] Added MNP annotation of the number of AA changes occuring in the SAME RefSeq entry (numAAchanges), and if this number is > 1 for any of the alt alleles (alleleHasMultAAchanges) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4746 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/phasing/AnnotateMNPsWalker.java | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/phasing/AnnotateMNPsWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/phasing/AnnotateMNPsWalker.java index 0920fed12..4121c5257 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/phasing/AnnotateMNPsWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/phasing/AnnotateMNPsWalker.java @@ -98,6 +98,8 @@ public class AnnotateMNPsWalker extends RodWalker { protected final static String REFSEQ_PROTEIN_COORD_DESCRIPTION = "proteinCoordStr"; protected final static String REFSEQ_CODING_ANNOTATIONS = "codingVariants"; + protected final static String REFSEQ_NUM_AA_CHANGES = "numAAchanges"; + protected final static String REFSEQ_HAS_MULT_AA_CHANGES = "alleleHasMultAAchanges"; public void initialize() { rodNames = new LinkedList(); @@ -230,7 +232,9 @@ public class AnnotateMNPsWalker extends RodWalker { RefSeqFeatureList feature = nameToFeatureEntry.getValue(); CodonAnnotationsForAltAlleles codonAnnotationsForAlleles = new CodonAnnotationsForAltAlleles(vc, feature); - annotations.put(kb.getKey(REFSEQ_CODING_ANNOTATIONS), codonAnnotationsForAlleles.toString()); + annotations.put(kb.getKey(REFSEQ_CODING_ANNOTATIONS), codonAnnotationsForAlleles.getCodonAnnotationsString()); + annotations.put(kb.getKey(REFSEQ_NUM_AA_CHANGES), codonAnnotationsForAlleles.getNumAAchangesString()); + annotations.put(kb.getKey(REFSEQ_HAS_MULT_AA_CHANGES), codonAnnotationsForAlleles.hasAlleleWithMultipleAAchanges); annotations.put(kb.getKey(REFSEQ_NAME), featureName); annotations.put(kb.getKey(REFSEQ_NAME2), feature.name2); annotations.put(kb.getKey(REFSEQ_POSITION_TYPE), REFSEQ_CDS); @@ -438,10 +442,18 @@ public class AnnotateMNPsWalker extends RodWalker { private final static String CODON_ANNOTATION_DELIM = ","; private List alleleAnnotations; + private int[] alleleToNumAAchanges; + private boolean hasAlleleWithMultipleAAchanges; public CodonAnnotationsForAltAlleles(VariantContext vc, RefSeqFeatureList feature) { this.alleleAnnotations = new LinkedList(); + Set altAlleles = vc.getAlternateAlleles(); + int numAltAlleles = altAlleles.size(); + this.alleleToNumAAchanges = new int[numAltAlleles]; + for (int i = 0; i < numAltAlleles; i++) + this.alleleToNumAAchanges[i] = 0; + int MNPstart = vc.getStart(); int MNPstop = vc.getEnd(); int MNPlength = MNPstop - MNPstart + 1; @@ -462,12 +474,21 @@ public class AnnotateMNPsWalker extends RodWalker { CodingRefSeqFeature firstFeatureForCodon = feature.refSeqFeatures[indices.get(0)]; String refCodon = firstFeatureForCodon.referenceCodon; - SingleCodonAnnotationsForAlleles codonAnnotation = new SingleCodonAnnotationsForAlleles(codonIndex, vc.getAlternateAlleles(), MNPlength, refCodon, firstFeatureForCodon, indices, feature); + SingleCodonAnnotationsForAlleles codonAnnotation = new SingleCodonAnnotationsForAlleles(codonIndex, altAlleles, MNPlength, refCodon, firstFeatureForCodon, indices, feature); alleleAnnotations.add(codonAnnotation); + + // From a single codon, summarize the data for ALL alleles: + for (int i = 0; i < numAltAlleles; i++) { + if (codonAnnotation.annotationsForAlleles[i].codonFunc.changesAA) { + alleleToNumAAchanges[i]++; + if (alleleToNumAAchanges[i] > 1) + this.hasAlleleWithMultipleAAchanges = true; + } + } } } - public String toString() { + public String getCodonAnnotationsString() { StringBuilder sb = new StringBuilder(); int index = 0; @@ -480,6 +501,18 @@ public class AnnotateMNPsWalker extends RodWalker { return sb.toString(); } + + public String getNumAAchangesString() { + StringBuilder sb = new StringBuilder(); + + for (int index = 0; index < alleleToNumAAchanges.length; index++) { + sb.append(alleleToNumAAchanges[index]); + if (index < alleleToNumAAchanges.length - 1) + sb.append(SingleCodonAnnotationsForAlleles.ALLELE_ANNOTATION_DELIM); + } + + return sb.toString(); + } } private static class SingleCodonAnnotationsForAlleles { @@ -494,7 +527,7 @@ public class AnnotateMNPsWalker extends RodWalker { private String refCodon; private String refAA; - private List annotationsForAlleles; + private SingleCodonAnnotationsForAllele[] annotationsForAlleles; public SingleCodonAnnotationsForAlleles(int codonIndex, Collection altAlleles, int MNPlength, String refCodon, CodingRefSeqFeature firstFeatureForCodon, List indices, RefSeqFeatureList feature) { if (refCodon.length() != CodonAnnotationsForAltAlleles.NUM_CODON_INDICES) @@ -507,8 +540,9 @@ public class AnnotateMNPsWalker extends RodWalker { this.codonIndex = codonIndex; this.refCodon = refCodon; this.refAA = refAA.getCode(); - this.annotationsForAlleles = new LinkedList(); + this.annotationsForAlleles = new SingleCodonAnnotationsForAllele[altAlleles.size()]; + int altInd = 0; for (Allele altAllele : altAlleles) { if (altAllele.length() != MNPlength) throw new ReviewedStingException("length(altAllele) != length(MNP)"); @@ -540,7 +574,8 @@ public class AnnotateMNPsWalker extends RodWalker { String variantCodon = new String(ByteArrayToPrimitive(variantCodonArr)).toUpperCase(); SingleCodonAnnotationsForAllele alleleAnnotation = new SingleCodonAnnotationsForAllele(variantCodon, refCodon, refAA, codonIndex); - annotationsForAlleles.add(alleleAnnotation); + annotationsForAlleles[altInd] = alleleAnnotation; + altInd++; } } @@ -554,7 +589,7 @@ public class AnnotateMNPsWalker extends RodWalker { int index = 0; for (SingleCodonAnnotationsForAllele annotation : annotationsForAlleles) { sb.append(annotation); - if (index < annotationsForAlleles.size() - 1) + if (index < annotationsForAlleles.length - 1) sb.append(ALLELE_ANNOTATION_DELIM); index++; }