diff --git a/java/src/org/broadinstitute/sting/gatk/contexts/StratifiedAlignmentContext.java b/java/src/org/broadinstitute/sting/gatk/contexts/StratifiedAlignmentContext.java index 9f1bb7984..4e3d0d609 100755 --- a/java/src/org/broadinstitute/sting/gatk/contexts/StratifiedAlignmentContext.java +++ b/java/src/org/broadinstitute/sting/gatk/contexts/StratifiedAlignmentContext.java @@ -25,9 +25,7 @@ package org.broadinstitute.sting.gatk.contexts; -import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; import org.broadinstitute.sting.gatk.datasources.sample.Sample; -import org.broadinstitute.sting.utils.HasGenomeLocation; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.exceptions.UserException; @@ -36,11 +34,10 @@ import org.broadinstitute.sting.utils.pileup.*; import java.util.*; /** - * Useful class for storing different AlignmentContexts + * Useful utilities for storing different AlignmentContexts * User: ebanks - * Modified: chartl (split by read group) */ -public class StratifiedAlignmentContext implements HasGenomeLocation { +public class StratifiedAlignmentContext { // Definitions: // COMPLETE = full alignment context @@ -49,144 +46,86 @@ public class StratifiedAlignmentContext implements // public enum StratifiedContextType { COMPLETE, FORWARD, REVERSE } - private GenomeLoc loc; - private RBP basePileup = null; - - // - // accessors - // - public GenomeLoc getLocation() { return loc; } - - public StratifiedAlignmentContext(GenomeLoc loc) { - this(loc,null); + private StratifiedAlignmentContext() { + // cannot be instantiated } - public StratifiedAlignmentContext(GenomeLoc loc, RBP pileup) { - this.loc = loc; - this.basePileup = pileup; - } - - public AlignmentContext getContext(StratifiedContextType type) { + /** + * Returns a potentially derived subcontext containing only forward, reverse, or in fact all reads + * in alignment context context. + * + * @param context + * @param type + * @return + */ + public static AlignmentContext stratify(AlignmentContext context, StratifiedContextType type) { switch(type) { case COMPLETE: - return new AlignmentContext(loc,basePileup); + return context; case FORWARD: - return new AlignmentContext(loc,basePileup.getPositiveStrandPileup()); + return new AlignmentContext(context.getLocation(),context.getPileup().getPositiveStrandPileup()); case REVERSE: - return new AlignmentContext(loc,basePileup.getNegativeStrandPileup()); + return new AlignmentContext(context.getLocation(),context.getPileup().getNegativeStrandPileup()); default: throw new ReviewedStingException("Unable to get alignment context for type = " + type); } } - /** - * Splits the given AlignmentContext into a StratifiedAlignmentContext per sample. - * - * @param pileup the original pileup - * - * @return a Map of sample name to StratifiedAlignmentContext - * - **/ - public static Map splitContextBySample(RBP pileup) { - return splitContextBySample(pileup, null); + public static Map splitContextBySampleName(AlignmentContext context) { + return splitContextBySampleName(context, null); } - /** - * Splits the given AlignmentContext into a StratifiedAlignmentContext per sample. - * - * @param pileup the original pileup - * @param assumedSingleSample if not null, any read without a readgroup will be given this sample name - * - * @return a Map of sample name to StratifiedAlignmentContext - * - **/ - public static Map splitContextBySample(RBP pileup, Sample assumedSingleSample) { - - GenomeLoc loc = pileup.getLocation(); - HashMap contexts = new HashMap(); - - for(Sample sample: pileup.getSamples()) { - RBP pileupBySample = (RBP)pileup.getPileupForSample(sample); - - // Don't add empty pileups to the split context. - if(pileupBySample.size() == 0) - continue; - - if(sample != null) - contexts.put(sample,new StratifiedAlignmentContext(loc,pileupBySample)); - else { - if(assumedSingleSample == null) { - throw new UserException.ReadMissingReadGroup(pileupBySample.iterator().next().getRead()); - } - contexts.put(assumedSingleSample,new StratifiedAlignmentContext(loc,pileupBySample)); - } + public static Map splitContextBySample(AlignmentContext context) { + Map m = new HashMap(); + for ( Map.Entry entry : splitContextBySampleName(context, null).entrySet() ) { + m.put(new Sample(entry.getKey()), entry.getValue()); } - - return contexts; - } - - - - public static Map splitContextBySampleName(RBP pileup) { - return splitContextBySampleName(pileup, null); + return m; } /** * Splits the given AlignmentContext into a StratifiedAlignmentContext per sample, but referencd by sample name instead * of sample object. * - * @param pileup the original pileup + * @param context the original pileup * * @return a Map of sample name to StratifiedAlignmentContext * **/ - public static Map splitContextBySampleName(RBP pileup, String assumedSingleSample) { + public static Map splitContextBySampleName(AlignmentContext context, String assumedSingleSample) { + GenomeLoc loc = context.getLocation(); + HashMap contexts = new HashMap(); - GenomeLoc loc = pileup.getLocation(); - HashMap contexts = new HashMap(); - - for(String sample: pileup.getSampleNames()) { - RBP pileupBySample = (RBP)pileup.getPileupForSampleName(sample); + for(String sample: context.getPileup().getSampleNames()) { + ReadBackedPileup pileupBySample = context.getPileup().getPileupForSampleName(sample); // Don't add empty pileups to the split context. if(pileupBySample.size() == 0) continue; if(sample != null) - contexts.put(sample,new StratifiedAlignmentContext(loc,pileupBySample)); + contexts.put(sample, new AlignmentContext(loc, pileupBySample)); else { if(assumedSingleSample == null) { throw new UserException.ReadMissingReadGroup(pileupBySample.iterator().next().getRead()); } - contexts.put(assumedSingleSample,new StratifiedAlignmentContext(loc,pileupBySample)); + contexts.put(assumedSingleSample,new AlignmentContext(loc, pileupBySample)); } } return contexts; } - - /** - * Splits the given AlignmentContext into a StratifiedAlignmentContext per read group. - * - * @param pileup the original pileup - * @return a Map of sample name to StratifiedAlignmentContext - * TODO - support for collapsing or assuming read groups if they are missing - * - **/ - public static Map> splitContextByReadGroup(RBP pileup) { - HashMap> contexts = new HashMap>(); - for(String readGroupId: pileup.getReadGroups()) - contexts.put(readGroupId,new StratifiedAlignmentContext(pileup.getLocation(),(RBP)pileup.getPileupForReadGroup(readGroupId))); - return contexts; + public static Map splitContextBySampleName(ReadBackedPileup pileup, String assumedSingleSample) { + return splitContextBySampleName(new AlignmentContext(pileup.getLocation(), pileup)); } - public static AlignmentContext joinContexts(Collection contexts) { + public static AlignmentContext joinContexts(Collection contexts) { // validation GenomeLoc loc = contexts.iterator().next().getLocation(); boolean isExtended = contexts.iterator().next().basePileup instanceof ReadBackedExtendedEventPileup; - for(StratifiedAlignmentContext context: contexts) { + for(AlignmentContext context: contexts) { if(!loc.equals(context.getLocation())) throw new ReviewedStingException("Illegal attempt to join contexts from different genomic locations"); if(isExtended != (context.basePileup instanceof ReadBackedExtendedEventPileup)) @@ -196,7 +135,7 @@ public class StratifiedAlignmentContext implements AlignmentContext jointContext; if(isExtended) { List pe = new ArrayList(); - for(StratifiedAlignmentContext context: contexts) { + for(AlignmentContext context: contexts) { for(PileupElement pileupElement: context.basePileup) pe.add((ExtendedEventPileupElement)pileupElement); } @@ -204,7 +143,7 @@ public class StratifiedAlignmentContext implements } else { List pe = new ArrayList(); - for(StratifiedAlignmentContext context: contexts) { + for(AlignmentContext context: contexts) { for(PileupElement pileupElement: context.basePileup) pe.add(pileupElement); } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java index f03140c51..d3beb64aa 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java @@ -29,8 +29,8 @@ import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import org.broadinstitute.sting.utils.*; @@ -44,7 +44,7 @@ import java.util.Arrays; public class AlleleBalance implements InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; @@ -61,12 +61,12 @@ public class AlleleBalance implements InfoFieldAnnotation { if ( !genotype.getValue().isHet() ) continue; - StratifiedAlignmentContext context = stratifiedContexts.get(genotype.getKey()); + AlignmentContext context = stratifiedContexts.get(genotype.getKey()); if ( context == null ) continue; if ( vc.isSNP() ) { - final String bases = new String(context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup().getBases()); + final String bases = new String(context.getBasePileup().getBases()); if ( bases.length() == 0 ) return null; char refChr = vc.getReference().toString().charAt(0); @@ -83,7 +83,7 @@ public class AlleleBalance implements InfoFieldAnnotation { ratio += genotype.getValue().getNegLog10PError() * ((double)refCount / (double)(refCount + altCount)); totalWeights += genotype.getValue().getNegLog10PError(); } else if ( vc.isIndel() ) { - final ReadBackedExtendedEventPileup indelPileup = context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getExtendedEventPileup(); + final ReadBackedExtendedEventPileup indelPileup = context.getExtendedEventPileup(); if ( indelPileup == null ) { continue; } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java index 6bc9a709b..b853ed5f3 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java @@ -14,52 +14,51 @@ import java.util.*; public class AlleleBalanceBySample implements GenotypeAnnotation, ExperimentalAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g) { - Double ratio = annotateSNP(stratifiedContext, vc, g); - if (ratio == null) - return null; + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + Double ratio = annotateSNP(stratifiedContext, vc, g); + if (ratio == null) + return null; Map map = new HashMap(); map.put(getKeyNames().get(0), String.format("%.2f", ratio.doubleValue())); - return map; + return map; - } + } - private Double annotateSNP(StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + private Double annotateSNP(AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + double ratio = -1; - double ratio = -1; + if ( !vc.isSNP() ) + return null; - if ( !vc.isSNP() ) - return null; - - if ( !vc.isBiallelic() ) - return null; + if ( !vc.isBiallelic() ) + return null; if ( g == null || !g.isCalled() ) return null; - if (!g.isHet()) - return null; + if (!g.isHet()) + return null; Set altAlleles = vc.getAlternateAlleles(); if ( altAlleles.size() == 0 ) return null; - final String bases = new String(stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup().getBases()); - if ( bases.length() == 0 ) - return null; - char refChr = vc.getReference().toString().charAt(0); - char altChr = vc.getAlternateAllele(0).toString().charAt(0); + final String bases = new String(stratifiedContext.getBasePileup().getBases()); + if ( bases.length() == 0 ) + return null; + char refChr = vc.getReference().toString().charAt(0); + char altChr = vc.getAlternateAllele(0).toString().charAt(0); - int refCount = MathUtils.countOccurrences(refChr, bases); - int altCount = MathUtils.countOccurrences(altChr, bases); + int refCount = MathUtils.countOccurrences(refChr, bases); + int altCount = MathUtils.countOccurrences(altChr, bases); - // sanity check - if ( refCount + altCount == 0 ) - return null; + // sanity check + if ( refCount + altCount == 0 ) + return null; - ratio = ((double)refCount / (double)(refCount + altCount)); - return ratio; + ratio = ((double)refCount / (double)(refCount + altCount)); + return ratio; } public List getKeyNames() { return Arrays.asList("AB"); } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AnnotationByDepth.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AnnotationByDepth.java index e9c654dd6..9b1ee4b4f 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AnnotationByDepth.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AnnotationByDepth.java @@ -1,7 +1,7 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.util.variantcontext.Genotype; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import java.util.Map; @@ -10,7 +10,7 @@ import java.util.Map; public abstract class AnnotationByDepth implements InfoFieldAnnotation { - protected int annotationByVariantDepth(final Map genotypes, Map stratifiedContexts) { + protected int annotationByVariantDepth(final Map genotypes, Map stratifiedContexts) { int depth = 0; for ( Map.Entry genotype : genotypes.entrySet() ) { @@ -18,9 +18,9 @@ public abstract class AnnotationByDepth implements InfoFieldAnnotation { if ( genotype.getValue().isHomRef() ) continue; - StratifiedAlignmentContext context = stratifiedContexts.get(genotype.getKey()); + AlignmentContext context = stratifiedContexts.get(genotype.getKey()); if ( context != null ) - depth += context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size(); + depth += context.size(); } return depth; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java index 5fff0349c..fb094087d 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java @@ -34,8 +34,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import org.broadinstitute.sting.utils.BaseUtils; @@ -48,14 +48,14 @@ import java.util.Arrays; public class BaseCounts implements InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; int[] counts = new int[4]; - for ( Map.Entry sample : stratifiedContexts.entrySet() ) { - for (byte base : sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup().getBases() ) { + for ( Map.Entry sample : stratifiedContexts.entrySet() ) { + for (byte base : sample.getValue().getBasePileup().getBases() ) { int index = BaseUtils.simpleBaseToBaseIndex(base); if ( index != -1 ) counts[index]++; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java index 5e56ade8c..9c5ba40aa 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java @@ -29,8 +29,8 @@ import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; import org.broad.tribble.vcf.VCFConstants; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; @@ -45,7 +45,7 @@ public class ChromosomeCounts implements InfoFieldAnnotation, StandardAnnotation new VCFInfoHeaderLine(VCFConstants.ALLELE_COUNT_KEY, -1, VCFHeaderLineType.Integer, "Allele count in genotypes, for each ALT allele, in the same order as listed"), new VCFInfoHeaderLine(VCFConstants.ALLELE_NUMBER_KEY, 1, VCFHeaderLineType.Integer, "Total number of alleles in called genotypes") }; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( ! vc.hasGenotypes() ) return null; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java index 9e5b515d3..2169c4683 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java @@ -4,8 +4,8 @@ import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; import org.broad.tribble.vcf.VCFConstants; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; @@ -17,13 +17,13 @@ import java.util.Arrays; public class DepthOfCoverage implements InfoFieldAnnotation, StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; int depth = 0; - for ( Map.Entry sample : stratifiedContexts.entrySet() ) - depth += sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size(); + for ( Map.Entry sample : stratifiedContexts.entrySet() ) + depth += sample.getValue().size(); Map map = new HashMap(); map.put(getKeyNames().get(0), String.format("%d", depth)); return map; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java index d9d7baa4b..2e033a865 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java @@ -6,8 +6,8 @@ import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFCompoundHeaderLine; import org.broad.tribble.vcf.VCFFormatHeaderLine; import org.broad.tribble.vcf.VCFHeaderLineType; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation; @@ -28,7 +28,7 @@ public class DepthPerAlleleBySample implements GenotypeAnnotation, StandardAnnot private static String DEL = "DEL"; // constant, for speed: no need to create a key string for deletion allele every time - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { if ( g == null || !g.isCalled() ) return null; @@ -40,15 +40,15 @@ public class DepthPerAlleleBySample implements GenotypeAnnotation, StandardAnnot return null; } - private Map annotateSNP(StratifiedAlignmentContext stratifiedContext, VariantContext vc) { + private Map annotateSNP(AlignmentContext stratifiedContext, VariantContext vc) { - if ( ! stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).hasBasePileup() ) return null; + if ( ! stratifiedContext.hasBasePileup() ) return null; HashMap alleleCounts = new HashMap(); for ( Allele allele : vc.getAlleles() ) alleleCounts.put(allele.getBases()[0], 0); - ReadBackedPileup pileup = stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedPileup pileup = stratifiedContext.getBasePileup(); for ( PileupElement p : pileup ) { if ( alleleCounts.containsKey(p.getBase()) ) alleleCounts.put(p.getBase(), alleleCounts.get(p.getBase())+1); @@ -65,14 +65,13 @@ public class DepthPerAlleleBySample implements GenotypeAnnotation, StandardAnnot return map; } - private Map annotateIndel(StratifiedAlignmentContext stratifiedContext, VariantContext vc) { + private Map annotateIndel(AlignmentContext stratifiedContext, VariantContext vc) { - if ( ! stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).hasExtendedEventPileup() ) { + if ( ! stratifiedContext.hasExtendedEventPileup() ) { return null; } - ReadBackedExtendedEventPileup pileup = stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getExtendedEventPileup(); - //ReadBackedPileup pileup = stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedExtendedEventPileup pileup = stratifiedContext.getExtendedEventPileup(); if ( pileup == null ) return null; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java index a76b4986e..25871b0ed 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java @@ -24,8 +24,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.WorkInProgressAnnotation; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -50,7 +50,7 @@ public class FisherStrand implements InfoFieldAnnotation, WorkInProgressAnnotati private static final String ALTREV = "ALTREV"; private static final String FS = "FS"; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( ! vc.isVariant() || vc.isFiltered() || ! vc.isBiallelic() || ! vc.isSNP() ) return null; @@ -200,11 +200,11 @@ public class FisherStrand implements InfoFieldAnnotation, WorkInProgressAnnotati * allele2 # # * @return a 2x2 contingency table */ - private static int[][] getContingencyTable(Map stratifiedContexts, Allele ref, Allele alt) { + private static int[][] getContingencyTable(Map stratifiedContexts, Allele ref, Allele alt) { int[][] table = new int[2][2]; - for ( Map.Entry sample : stratifiedContexts.entrySet() ) { - for (PileupElement p : sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup()) { + for ( Map.Entry sample : stratifiedContexts.entrySet() ) { + for (PileupElement p : sample.getValue().getBasePileup()) { if ( p.isDeletion() ) // ignore deletions continue; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java index da9d0ea0c..8dc7b294c 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java @@ -3,8 +3,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import org.broadinstitute.sting.utils.BaseUtils; @@ -17,7 +17,7 @@ import java.util.Arrays; public class GCContent implements InfoFieldAnnotation, ExperimentalAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { double content = computeGCContent(ref); Map map = new HashMap(); map.put(getKeyNames().get(0), String.format("%.2f", content)); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java index 3719dceb2..c8addaf09 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java @@ -56,7 +56,7 @@ public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation { return p.getOffset() == -1 || ((GATKSAMRecord)p.getRead()).isGoodBase(p.getOffset()); // Use all reads from the filtered context } - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( !vc.isBiallelic() || stratifiedContexts.size() == 0 ) // size 0 means that call was made by someone else and we have no data here return null; @@ -83,9 +83,9 @@ public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation { if (haplotypes != null) { final Set> genotypes = vc.getGenotypes().entrySet(); for ( final Map.Entry genotype : genotypes ) { - final StratifiedAlignmentContext thisContext = stratifiedContexts.get(genotype.getKey()); + final AlignmentContext thisContext = stratifiedContexts.get(genotype.getKey()); if ( thisContext != null ) { - final AlignmentContext aContext = thisContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE); + final AlignmentContext aContext = thisContext; final ReadBackedPileup thisPileup; if (aContext.hasExtendedEventPileup()) thisPileup = aContext.getExtendedEventPileup(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java index 22bbc874b..05f7fa2e6 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java @@ -5,8 +5,8 @@ import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import org.broadinstitute.sting.utils.QualityUtils; @@ -23,7 +23,7 @@ public class HardyWeinberg implements InfoFieldAnnotation, WorkInProgressAnnotat private static final int MIN_GENOTYPE_QUALITY = 10; private static final int MIN_NEG_LOG10_PERROR = MIN_GENOTYPE_QUALITY / 10; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { final Map genotypes = vc.getGenotypes(); if ( genotypes == null || genotypes.size() < MIN_SAMPLES ) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java index 57557f6f5..16287491c 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java @@ -3,8 +3,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation; @@ -20,7 +20,7 @@ public class HomopolymerRun implements InfoFieldAnnotation, StandardAnnotation { private boolean ANNOTATE_INDELS = true; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( !vc.isBiallelic() ) return null; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java index b44b561c7..2a0ae0290 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java @@ -3,12 +3,11 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; -import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.IndelUtils; import java.util.*; @@ -22,7 +21,7 @@ import java.util.*; */ public class IndelType implements InfoFieldAnnotation, ExperimentalAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { int run; if ( vc.isIndel() && vc.isBiallelic() ) { diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java index 851cc2a91..b3e3a742c 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java @@ -3,8 +3,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; @@ -18,16 +18,16 @@ import java.util.Arrays; public class LowMQ implements InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; double mq0 = 0; double mq10 = 0; double total = 0; - for ( Map.Entry sample : stratifiedContexts.entrySet() ) + for ( Map.Entry sample : stratifiedContexts.entrySet() ) { - ReadBackedPileup pileup = sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedPileup pileup = sample.getValue().getBasePileup(); for (PileupElement p : pileup ) { if ( p.getMappingQual() == 0 ) { mq0 += 1; } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java index 7382a5bbd..665f5c0a4 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java @@ -6,7 +6,6 @@ import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation; @@ -21,13 +20,13 @@ import java.util.Map; public class MappingQualityZero implements InfoFieldAnnotation, StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; int mq0 = 0; - for ( Map.Entry sample : stratifiedContexts.entrySet() ) { - AlignmentContext context = sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE); + for ( Map.Entry sample : stratifiedContexts.entrySet() ) { + AlignmentContext context = sample.getValue(); ReadBackedPileup pileup = null; if (context.hasExtendedEventPileup()) pileup = context.getExtendedEventPileup(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java index a011b5dfd..de64741dd 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java @@ -28,7 +28,6 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; @@ -52,12 +51,11 @@ import java.util.Arrays; */ public class MappingQualityZeroBySample implements GenotypeAnnotation { public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, - StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + AlignmentContext context, VariantContext vc, Genotype g) { if ( g == null || !g.isCalled() ) return null; int mq0 = 0; - AlignmentContext context = stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE); ReadBackedPileup pileup = null; if (vc.isIndel() && context.hasExtendedEventPileup()) pileup = context.getExtendedEventPileup(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java index 7046da8ea..9bed1d396 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java @@ -5,8 +5,8 @@ import org.broad.tribble.util.variantcontext.GenotypeLikelihoods; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation; @@ -20,7 +20,7 @@ import java.util.Arrays; public class QualByDepth extends AnnotationByDepth implements InfoFieldAnnotation, StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; @@ -37,11 +37,11 @@ public class QualByDepth extends AnnotationByDepth implements InfoFieldAnnotatio if ( genotype.getValue().isHomRef() ) continue; - StratifiedAlignmentContext context = stratifiedContexts.get(genotype.getKey()); + AlignmentContext context = stratifiedContexts.get(genotype.getKey()); if ( context == null ) continue; - depth += context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size(); + depth += context.size(); if ( genotype.getValue().hasLikelihoods() ) { GenotypeLikelihoods GLs = genotype.getValue().getLikelihoods(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java index 4ee7c0820..4ac4880d3 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java @@ -6,7 +6,6 @@ import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation; @@ -19,19 +18,19 @@ import java.util.*; public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; int totalSize = 0; - for ( StratifiedAlignmentContext context : stratifiedContexts.values() ) - totalSize += context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size(); + for ( AlignmentContext context : stratifiedContexts.values() ) + totalSize += context.size(); int[] qualities = new int[totalSize]; int index = 0; - for ( Map.Entry sample : stratifiedContexts.entrySet() ) { - AlignmentContext context = sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE); + for ( Map.Entry sample : stratifiedContexts.entrySet() ) { + AlignmentContext context = sample.getValue(); ReadBackedPileup pileup = null; if (context.hasExtendedEventPileup()) pileup = context.getExtendedEventPileup(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java index 47461cd9f..6773ecb0c 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java @@ -2,8 +2,8 @@ package org.broadinstitute.sting.gatk.walkers.annotator; import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*; import org.broadinstitute.sting.utils.*; @@ -20,7 +20,7 @@ import java.util.HashMap; public abstract class RankSumTest implements InfoFieldAnnotation, ExperimentalAnnotation { private static final double minPValue = 1e-20; - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; @@ -35,11 +35,11 @@ public abstract class RankSumTest implements InfoFieldAnnotation, ExperimentalAn final ArrayList altQuals = new ArrayList(); for ( final Map.Entry genotype : genotypes.entrySet() ) { - final StratifiedAlignmentContext context = stratifiedContexts.get(genotype.getKey()); + final AlignmentContext context = stratifiedContexts.get(genotype.getKey()); if ( context == null ) { continue; } - fillQualsFromPileup(ref.getBase(), vc.getAlternateAllele(0).getBases()[0], context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(), refQuals, altQuals); + fillQualsFromPileup(ref.getBase(), vc.getAlternateAllele(0).getBases()[0], context.getBasePileup(), refQuals, altQuals); } final MannWhitneyU mannWhitneyU = new MannWhitneyU(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java index f478e810d..3f0105376 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java @@ -25,11 +25,11 @@ package org.broadinstitute.sting.gatk.walkers.annotator; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.GenotypeAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.pileup.ReadBackedExtendedEventPileup; @@ -60,7 +60,7 @@ public class ReadDepthAndAllelicFractionBySample implements GenotypeAnnotation { private static String DEL = "DEL"; // constant, for speed: no need to create a key string for deletion allele every time public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, - StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g) { + AlignmentContext stratifiedContext, VariantContext vc, Genotype g) { if ( g == null || !g.isCalled() ) return null; @@ -72,15 +72,15 @@ public class ReadDepthAndAllelicFractionBySample implements GenotypeAnnotation { return null; } - private Map annotateSNP(StratifiedAlignmentContext stratifiedContext, VariantContext vc) { + private Map annotateSNP(AlignmentContext stratifiedContext, VariantContext vc) { - if ( ! stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).hasBasePileup() ) return null; + if ( ! stratifiedContext.hasBasePileup() ) return null; HashMap alleleCounts = new HashMap(); for ( Allele allele : vc.getAlternateAlleles() ) alleleCounts.put(allele.getBases()[0], 0); - ReadBackedPileup pileup = stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedPileup pileup = stratifiedContext.getBasePileup(); int totalDepth = pileup.size(); Map map = new HashMap(); @@ -110,16 +110,15 @@ public class ReadDepthAndAllelicFractionBySample implements GenotypeAnnotation { return map; } - private Map annotateIndel(StratifiedAlignmentContext + private Map annotateIndel(AlignmentContext stratifiedContext, VariantContext vc) { - if ( ! stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).hasExtendedEventPileup() ) { + if ( ! stratifiedContext.hasExtendedEventPileup() ) { return null; } - ReadBackedExtendedEventPileup pileup = stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getExtendedEventPileup(); - //ReadBackedPileup pileup = stratifiedContext.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedExtendedEventPileup pileup = stratifiedContext.getExtendedEventPileup(); if ( pileup == null ) return null; int totalDepth = pileup.size(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SBByDepth.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SBByDepth.java index 1cf195636..5e38fd5b2 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SBByDepth.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SBByDepth.java @@ -5,8 +5,8 @@ import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFConstants; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import java.util.Arrays; @@ -18,7 +18,7 @@ import java.util.Map; public class SBByDepth extends AnnotationByDepth { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java index 387e32188..b221c3329 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java @@ -5,7 +5,6 @@ import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation; @@ -19,14 +18,14 @@ import java.util.Map; public class SpanningDeletions implements InfoFieldAnnotation, StandardAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; int deletions = 0; int depth = 0; - for ( Map.Entry sample : stratifiedContexts.entrySet() ) { - AlignmentContext context = sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE); + for ( Map.Entry sample : stratifiedContexts.entrySet() ) { + AlignmentContext context = sample.getValue(); ReadBackedPileup pileup = null; if (context.hasExtendedEventPileup()) pileup = context.getExtendedEventPileup(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java index b3c99b5ed..1be4b1261 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotator.java @@ -209,7 +209,7 @@ public class VariantAnnotator extends RodWalker { Collection annotatedVCs = VCs; // if the reference base is not ambiguous, we can annotate - Map stratifiedContexts; + Map stratifiedContexts; if ( BaseUtils.simpleBaseToBaseIndex(ref.getBase()) != -1 ) { if ( ! context.hasExtendedEventPileup() ) { stratifiedContexts = StratifiedAlignmentContext.splitContextBySampleName(context.getBasePileup(), ASSUME_SINGLE_SAMPLE); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java index beeaff20e..4a042568a 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java @@ -41,8 +41,8 @@ import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.*; import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.datasources.rmd.ReferenceOrderedDataSource; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.utils.helpers.DbSNPHelper; @@ -147,20 +147,7 @@ public class VariantAnnotatorEngine { return descriptions; } - // A slightly simplified interface for when you don't have any reads, so the stratifiedContexts aren't necessary, and - // you only permit a single return value - public VariantContext annotateContext(RefMetaDataTracker tracker, ReferenceContext ref, VariantContext vc) { - Collection results = this.annotateContext(tracker, ref, EMPTY_STRATIFIED_ALIGNMENT_CONTEXT, vc); - - if ( results.size() != 1 ) - throw new ReviewedStingException("BUG: annotateContext call requires 1 resulting annotated VC, but got " + results); - - return results.iterator().next(); - - } - private static final Map EMPTY_STRATIFIED_ALIGNMENT_CONTEXT = (Map)Collections.EMPTY_MAP; - - public Collection annotateContext(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Collection annotateContext(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { Map infoAnnotations = new LinkedHashMap(vc.getAttributes()); @@ -246,14 +233,14 @@ public class VariantAnnotatorEngine { } } - private Map annotateGenotypes(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + private Map annotateGenotypes(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( requestedGenotypeAnnotations.size() == 0 ) return vc.getGenotypes(); Map genotypes = new HashMap(vc.getNSamples()); for ( Map.Entry g : vc.getGenotypes().entrySet() ) { Genotype genotype = g.getValue(); - StratifiedAlignmentContext context = stratifiedContexts.get(g.getKey()); + AlignmentContext context = stratifiedContexts.get(g.getKey()); if ( context == null ) { genotypes.put(g.getKey(), genotype); continue; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java index 548041dd9..caa32fef3 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java @@ -32,8 +32,8 @@ import org.broad.tribble.util.variantcontext.Allele; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.refdata.features.annotator.AnnotatorInputTableFeature; import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; @@ -140,7 +140,7 @@ public class GenomicAnnotation implements InfoFieldAnnotation { */ public Map annotate(final RefMetaDataTracker tracker, final ReferenceContext ref, - final Map stratifiedContexts, + final Map stratifiedContexts, final VariantContext vc) { //iterate over each record that overlaps the current locus, and, if it passes certain filters, diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotator.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotator.java index 3b4ee9863..c52768ce0 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotator.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotator.java @@ -249,7 +249,7 @@ public class GenomicAnnotator extends RodWalker implements Tre (vc.isVariant() && !vc.isBiallelic()) ) { results.add(vc); } else { - Map stratifiedContexts = StratifiedAlignmentContext.splitContextBySampleName(context.getBasePileup()); + Map stratifiedContexts = StratifiedAlignmentContext.splitContextBySampleName(context); if ( stratifiedContexts != null ) results.addAll(engine.annotateContext(tracker, ref, stratifiedContexts, vc)); else diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java index 946780959..ee0038ee8 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java @@ -3,9 +3,9 @@ package org.broadinstitute.sting.gatk.walkers.annotator.interfaces; import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFFormatHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import java.util.Map; import java.util.List; @@ -13,7 +13,7 @@ import java.util.List; public interface GenotypeAnnotation { // return annotations for the given contexts/genotype split by sample - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, StratifiedAlignmentContext stratifiedContext, VariantContext vc, Genotype g); + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g); // return the FORMAT keys public List getKeyNames(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java index 53444db01..c82da908f 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java @@ -2,9 +2,9 @@ package org.broadinstitute.sting.gatk.walkers.annotator.interfaces; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import java.util.Map; import java.util.List; @@ -12,7 +12,7 @@ import java.util.List; public interface InfoFieldAnnotation { // return annotations for the given contexts split by sample - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc); + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc); // return the INFO keys public List getKeyNames(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DindelGenotypeLikelihoodsCalculationModel.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DindelGenotypeLikelihoodsCalculationModel.java index 595ac5fe5..c4a713d1b 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DindelGenotypeLikelihoodsCalculationModel.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DindelGenotypeLikelihoodsCalculationModel.java @@ -85,7 +85,7 @@ public class DindelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoo private ArrayList computeConsensusAlleles(ReferenceContext ref, - Map contexts, + Map contexts, StratifiedAlignmentContext.StratifiedContextType contextType) { Allele refAllele=null, altAllele=null; GenomeLoc loc = ref.getLocus(); @@ -99,8 +99,8 @@ public class DindelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoo int insCount = 0, delCount = 0; // quick check of total number of indels in pileup - for ( Map.Entry sample : contexts.entrySet() ) { - AlignmentContext context = sample.getValue().getContext(contextType); + for ( Map.Entry sample : contexts.entrySet() ) { + AlignmentContext context = StratifiedAlignmentContext.stratify(sample.getValue(), contextType); final ReadBackedExtendedEventPileup indelPileup = context.getExtendedEventPileup(); insCount += indelPileup.getNumberOfInsertions(); @@ -110,8 +110,9 @@ public class DindelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoo if (insCount < minIndelCountForGenotyping && delCount < minIndelCountForGenotyping) return aList; - for ( Map.Entry sample : contexts.entrySet() ) { - AlignmentContext context = sample.getValue().getContext(contextType); + for ( Map.Entry sample : contexts.entrySet() ) { + // todo -- warning, can be duplicating expensive partition here + AlignmentContext context = StratifiedAlignmentContext.stratify(sample.getValue(), contextType); final ReadBackedExtendedEventPileup indelPileup = context.getExtendedEventPileup(); @@ -266,7 +267,7 @@ public class DindelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoo } public Allele getLikelihoods(RefMetaDataTracker tracker, ReferenceContext ref, - Map contexts, + Map contexts, StratifiedAlignmentContext.StratifiedContextType contextType, GenotypePriors priors, Map GLs, @@ -353,8 +354,8 @@ public class DindelGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoo double[][] haplotypeLikehoodMatrix; - for ( Map.Entry sample : contexts.entrySet() ) { - AlignmentContext context = sample.getValue().getContext(contextType); + for ( Map.Entry sample : contexts.entrySet() ) { + AlignmentContext context = StratifiedAlignmentContext.stratify(sample.getValue(), contextType); ReadBackedPileup pileup = null; if (context.hasExtendedEventPileup()) diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoodsCalculationModel.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoodsCalculationModel.java index 1127f8d05..c431f8412 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoodsCalculationModel.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/GenotypeLikelihoodsCalculationModel.java @@ -26,6 +26,7 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import org.apache.log4j.Logger; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; @@ -78,7 +79,7 @@ public abstract class GenotypeLikelihoodsCalculationModel implements Cloneable { */ public abstract Allele getLikelihoods(RefMetaDataTracker tracker, ReferenceContext ref, - Map contexts, + Map contexts, StratifiedAlignmentContext.StratifiedContextType contextType, GenotypePriors priors, Map GLs, diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SNPGenotypeLikelihoodsCalculationModel.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SNPGenotypeLikelihoodsCalculationModel.java index ae2e1b91d..42de14b42 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SNPGenotypeLikelihoodsCalculationModel.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SNPGenotypeLikelihoodsCalculationModel.java @@ -26,6 +26,7 @@ package org.broadinstitute.sting.gatk.walkers.genotyper; import org.broad.tribble.util.variantcontext.VariantContext; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.exceptions.StingException; import org.broadinstitute.sting.utils.genotype.DiploidGenotype; @@ -54,7 +55,7 @@ public class SNPGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoodsC public Allele getLikelihoods(RefMetaDataTracker tracker, ReferenceContext ref, - Map contexts, + Map contexts, StratifiedAlignmentContext.StratifiedContextType contextType, GenotypePriors priors, Map GLs, @@ -98,8 +99,8 @@ public class SNPGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoodsC Allele altAllele = Allele.create(bestAlternateAllele, false); - for ( Map.Entry sample : contexts.entrySet() ) { - ReadBackedPileup pileup = sample.getValue().getContext(contextType).getBasePileup(); + for ( Map.Entry sample : contexts.entrySet() ) { + ReadBackedPileup pileup = StratifiedAlignmentContext.stratify(sample.getValue(), contextType).getBasePileup(); // create the GenotypeLikelihoods object DiploidSNPGenotypeLikelihoods GL = new DiploidSNPGenotypeLikelihoods((DiploidSNPGenotypePriors)priors, UAC.PCR_error); @@ -124,12 +125,12 @@ public class SNPGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoodsC return refAllele; } - protected void initializeBestAlternateAllele(byte ref, Map contexts) { + protected void initializeBestAlternateAllele(byte ref, Map contexts) { int[] qualCounts = new int[4]; - for ( Map.Entry sample : contexts.entrySet() ) { + for ( Map.Entry sample : contexts.entrySet() ) { // calculate the sum of quality scores for each base - ReadBackedPileup pileup = sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedPileup pileup = sample.getValue().getBasePileup(); for ( PileupElement p : pileup ) { // ignore deletions and filtered bases if ( p.isDeletion() || diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java index 4ec0e4358..c2a7ca52e 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperEngine.java @@ -166,7 +166,7 @@ public class UnifiedGenotyperEngine { && UAC.GenotypingMode == GenotypeLikelihoodsCalculationModel.GENOTYPING_MODE.GENOTYPE_GIVEN_ALLELES) return null; */ - Map stratifiedContexts = getFilteredAndStratifiedContexts(UAC, refContext, rawContext); + Map stratifiedContexts = getFilteredAndStratifiedContexts(UAC, refContext, rawContext); if ( stratifiedContexts == null ) return (UAC.OutputMode != OUTPUT_MODE.EMIT_ALL_SITES ? null : new VariantCallContext(generateEmptyContext(tracker, refContext, stratifiedContexts, rawContext), refContext.getBase(), false)); @@ -187,13 +187,13 @@ public class UnifiedGenotyperEngine { * @return the VariantContext object */ public VariantContext calculateLikelihoods(RefMetaDataTracker tracker, ReferenceContext refContext, AlignmentContext rawContext, Allele alternateAlleleToUse) { - Map stratifiedContexts = getFilteredAndStratifiedContexts(UAC, refContext, rawContext); + Map stratifiedContexts = getFilteredAndStratifiedContexts(UAC, refContext, rawContext); if ( stratifiedContexts == null ) return null; return calculateLikelihoods(tracker, refContext, stratifiedContexts, StratifiedAlignmentContext.StratifiedContextType.COMPLETE, alternateAlleleToUse); } - private VariantContext calculateLikelihoods(RefMetaDataTracker tracker, ReferenceContext refContext, Map stratifiedContexts, StratifiedAlignmentContext.StratifiedContextType type, Allele alternateAlleleToUse) { + private VariantContext calculateLikelihoods(RefMetaDataTracker tracker, ReferenceContext refContext, Map stratifiedContexts, StratifiedAlignmentContext.StratifiedContextType type, Allele alternateAlleleToUse) { // initialize the data for this thread if that hasn't been done yet if ( glcm.get() == null ) { @@ -210,7 +210,7 @@ public class UnifiedGenotyperEngine { return null; } - private VariantContext generateEmptyContext(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, AlignmentContext rawContext) { + private VariantContext generateEmptyContext(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, AlignmentContext rawContext) { VariantContext vc; if ( UAC.GenotypingMode == GenotypeLikelihoodsCalculationModel.GENOTYPING_MODE.GENOTYPE_GIVEN_ALLELES ) { final VariantContext vcInput = tracker.getVariantContext(ref, "alleles", null, ref.getLocus(), true); @@ -288,11 +288,11 @@ public class UnifiedGenotyperEngine { * @return the VariantCallContext object */ public VariantCallContext calculateGenotypes(RefMetaDataTracker tracker, ReferenceContext refContext, AlignmentContext rawContext, VariantContext vc) { - Map stratifiedContexts = getFilteredAndStratifiedContexts(UAC, refContext, rawContext); + Map stratifiedContexts = getFilteredAndStratifiedContexts(UAC, refContext, rawContext); return calculateGenotypes(tracker, refContext, rawContext, stratifiedContexts, vc); } - private VariantCallContext calculateGenotypes(RefMetaDataTracker tracker, ReferenceContext refContext, AlignmentContext rawContext, Map stratifiedContexts, VariantContext vc) { + private VariantCallContext calculateGenotypes(RefMetaDataTracker tracker, ReferenceContext refContext, AlignmentContext rawContext, Map stratifiedContexts, VariantContext vc) { // initialize the data for this thread if that hasn't been done yet if ( afcm.get() == null ) { @@ -452,10 +452,10 @@ public class UnifiedGenotyperEngine { return ( d >= 0.0 && d <= 1.0 ); } - private Map getFilteredAndStratifiedContexts(UnifiedArgumentCollection UAC, ReferenceContext refContext, AlignmentContext rawContext) { + private Map getFilteredAndStratifiedContexts(UnifiedArgumentCollection UAC, ReferenceContext refContext, AlignmentContext rawContext) { BadBaseFilter badReadPileupFilter = new BadBaseFilter(refContext, UAC); - Map stratifiedContexts = null; + Map stratifiedContexts = null; if ( UAC.GLmodel == GenotypeLikelihoodsCalculationModel.Model.DINDEL && rawContext.hasExtendedEventPileup() ) { @@ -493,7 +493,7 @@ public class UnifiedGenotyperEngine { AFs[i] = AlleleFrequencyCalculationModel.VALUE_NOT_CALCULATED; } - private VariantCallContext estimateReferenceConfidence(VariantContext vc, Map contexts, double theta, boolean ignoreCoveredSamples, double initialPofRef) { + private VariantCallContext estimateReferenceConfidence(VariantContext vc, Map contexts, double theta, boolean ignoreCoveredSamples, double initialPofRef) { if ( contexts == null ) return null; @@ -509,7 +509,7 @@ public class UnifiedGenotyperEngine { int depth = 0; if (isCovered) { - AlignmentContext context = contexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE); + AlignmentContext context = contexts.get(sample); if (context.hasBasePileup()) depth = context.getBasePileup().size(); @@ -559,11 +559,11 @@ public class UnifiedGenotyperEngine { verboseWriter.println(); } - private boolean filterPileup(Map stratifiedContexts, BadBaseFilter badBaseFilter) { + private boolean filterPileup(Map stratifiedContexts, BadBaseFilter badBaseFilter) { int numDeletions = 0, pileupSize = 0; - for ( StratifiedAlignmentContext context : stratifiedContexts.values() ) { - ReadBackedPileup pileup = context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + for ( AlignmentContext context : stratifiedContexts.values() ) { + ReadBackedPileup pileup = context.getBasePileup(); for ( PileupElement p : pileup ) { final SAMRecord read = p.getRead(); diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/AlleleBalanceHistogramWalker.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/AlleleBalanceHistogramWalker.java index 8af48ccc7..e4f314b97 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/AlleleBalanceHistogramWalker.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/AlleleBalanceHistogramWalker.java @@ -70,7 +70,7 @@ public class AlleleBalanceHistogramWalker extends LocusWalker } private HashMap getAlleleBalanceBySample(VariantContext vc, ReferenceContext ref, AlignmentContext context) { - Map sampleContext = StratifiedAlignmentContext.splitContextBySampleName(context.getBasePileup(),null); + Map sampleContext = StratifiedAlignmentContext.splitContextBySampleName(context); HashMap balances = new HashMap(); System.out.println("----- "+ref.getLocus()+" -----"); int returnedBalances = 0; @@ -86,25 +86,19 @@ public class AlleleBalanceHistogramWalker extends LocusWalker return balances; } - private long getCoverage(StratifiedAlignmentContext context) { - return context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size(); + private long getCoverage(AlignmentContext context) { + return context.size(); } - private Double getAlleleBalance(ReferenceContext ref, StratifiedAlignmentContext context, char snpBase) { - if ( context == null ) { + private Double getAlleleBalance(ReferenceContext ref, AlignmentContext alicon, char snpBase) { + if ( alicon == null ) { //System.out.println("Stratified context was null"); return null; } int refBases = 0; int altBases = 0; - AlignmentContext alicon = context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE); - if ( alicon == null ) { - System.out.println("Alignment context from stratified was null"); - return null; - } - for ( PileupElement e : alicon.getBasePileup() ) { if ( BaseUtils.basesAreEqual( e.getBase(), ref.getBase() ) ) { refBases++; diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java index 085708571..2a5b9a717 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java @@ -468,8 +468,8 @@ public class MendelianViolationClassifier extends LocusWalker splitContext = StratifiedAlignmentContext.splitContextBySampleName(context.getBasePileup()); - Double proportion = getAlleleProportion(parental,splitContext.get(trioStructure.child)); + Map splitContext = StratifiedAlignmentContext.splitContextBySampleName(context); + Double proportion = getAlleleProportion(parental, splitContext.get(trioStructure.child)); if ( proportion != null ) { violation.addAttribute(MendelianInfoKey.ProportionOfParentAllele.getKey(), proportion); if ( ! deNovoRange.contains(proportion) ) { @@ -502,7 +502,7 @@ public class MendelianViolationClassifier extends LocusWalker splitCon = StratifiedAlignmentContext.splitContextBySampleName(context.getBasePileup()); + Map splitCon = StratifiedAlignmentContext.splitContextBySampleName(context); Pair triAl = getTriAllelicQuality(tracker, ref, trio, splitCon); if ( triAl != null ) { violation.addAttribute(MendelianInfoKey.TriAllelicBase.getKey(),triAl.first.toString()); @@ -536,11 +536,11 @@ public class MendelianViolationClassifier extends LocusWalker= 10 && e.getMappingQual() >= 10 ) { total++; if ( e.getBase() == a.getBases()[0]) { @@ -556,11 +556,11 @@ public class MendelianViolationClassifier extends LocusWalker getTriAllelicQuality(RefMetaDataTracker tracker, ReferenceContext ref, VariantContext var, Map strat) { + private Pair getTriAllelicQuality(RefMetaDataTracker tracker, ReferenceContext ref, VariantContext var, Map strat) { int conf = 0; Allele alt = null; - for ( Map.Entry sEntry : strat.entrySet() ) { - VariantCallContext call = engine.calculateLikelihoodsAndGenotypes(tracker, ref, sEntry.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE)); + for ( Map.Entry sEntry : strat.entrySet() ) { + VariantCallContext call = engine.calculateLikelihoodsAndGenotypes(tracker, ref, sEntry.getValue()); if ( call != null && call.confidentlyCalled ) { if ( call.isSNP() ) { if ( ! call.getAlternateAllele(0).basesMatch(var.getAlternateAllele(0))) { diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/HammingDistance.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/HammingDistance.java index 7d4b3a4ce..95a980a8a 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/HammingDistance.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/HammingDistance.java @@ -4,8 +4,8 @@ import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; @@ -21,7 +21,7 @@ import java.util.*; */ public class HammingDistance implements ExperimentalAnnotation, InfoFieldAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( tracker == null ) { return null; } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/InsertSizeDistribution.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/InsertSizeDistribution.java index 011ef56df..d1618697e 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/InsertSizeDistribution.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/InsertSizeDistribution.java @@ -2,8 +2,8 @@ package org.broadinstitute.sting.oneoffprojects.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.utils.pileup.PileupElement; @@ -25,10 +25,10 @@ public class InsertSizeDistribution implements InfoFieldAnnotation { public List getKeyNames() { return Arrays.asList("INSIZE"); } public List getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine(getKeyNames().get(0),1, VCFHeaderLineType.Integer,"Do not use this if your name is not Chris")); } - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext variant) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext variant) { int weirdInsertSizeReads = 0; for ( String sample : context.keySet() ) { - ReadBackedPileup pileup = context.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedPileup pileup = context.get(sample).getBasePileup(); for (PileupElement e : pileup ) { if ( Math.abs(e.getRead().getInferredInsertSize()) > INSERT_SIZE_LOWER_BOUND ) { weirdInsertSizeReads++; diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfNonrefBasesSupportingSNP.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfNonrefBasesSupportingSNP.java index 1f80701d9..51ebfb2db 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfNonrefBasesSupportingSNP.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfNonrefBasesSupportingSNP.java @@ -28,13 +28,13 @@ package org.broadinstitute.sting.oneoffprojects.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import java.util.Map; import java.util.HashMap; @@ -57,13 +57,13 @@ public class ProportionOfNonrefBasesSupportingSNP implements InfoFieldAnnotation return Arrays.asList(new VCFInfoHeaderLine(KEY_NAME,1, VCFHeaderLineType.Float,"Simple proportion of non-reference bases that are the SNP base")); } - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { if ( ! vc.isSNP() || ! vc.isBiallelic() ) return null; Pair totalNonref_totalSNP = new Pair(0,0); for ( String sample : context.keySet() ) { - ReadBackedPileup pileup = context.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedPileup pileup = context.get(sample).getBasePileup(); totalNonref_totalSNP = getNonrefAndSNP(pileup, ref.getBaseAsChar(), vc.getAlternateAllele(0).toString().charAt(0), totalNonref_totalSNP); } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfRefSecondBasesSupportingSNP.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfRefSecondBasesSupportingSNP.java index 30332ce65..91348bc8b 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfRefSecondBasesSupportingSNP.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfRefSecondBasesSupportingSNP.java @@ -28,6 +28,7 @@ package org.broadinstitute.sting.oneoffprojects.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.utils.BaseUtils; @@ -35,7 +36,6 @@ import org.broadinstitute.sting.utils.collections.Pair; import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import java.util.Map; import java.util.HashMap; @@ -55,13 +55,13 @@ public class ProportionOfRefSecondBasesSupportingSNP implements InfoFieldAnnotat public List getKeyNames() { return Arrays.asList(KEY_NAME); } - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { if ( ! vc.isSNP() || ! vc.isBiallelic() ) return null; Pair totalAndSNPSupporting = new Pair(0,0); for ( String sample : context.keySet() ) { - ReadBackedPileup pileup = context.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedPileup pileup = context.get(sample).getBasePileup(); totalAndSNPSupporting = getTotalRefAndSNPSupportCounts(pileup, ref.getBaseAsChar(), vc.getAlternateAllele(0).toString().charAt(0), totalAndSNPSupporting); } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfSNPSecondBasesSupportingRef.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfSNPSecondBasesSupportingRef.java index 5ba088093..6dbcd5e73 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfSNPSecondBasesSupportingRef.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/ProportionOfSNPSecondBasesSupportingRef.java @@ -28,8 +28,8 @@ package org.broadinstitute.sting.oneoffprojects.walkers.annotator; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; import org.broadinstitute.sting.utils.collections.Pair; @@ -58,13 +58,13 @@ public class ProportionOfSNPSecondBasesSupportingRef implements InfoFieldAnnotat public boolean useZeroQualityReads() { return USE_MAPQ0_READS; } - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map context, VariantContext vc) { if ( ! vc.isSNP() || ! vc.isBiallelic() ) return null; Pair totalAndSNPSupporting = new Pair(0,0); for ( String sample : context.keySet() ) { - ReadBackedPileup pileup = context.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + ReadBackedPileup pileup = context.get(sample).getBasePileup(); totalAndSNPSupporting = getTotalSNPandRefSupporting(pileup, ref.getBaseAsChar(), vc.getAlternateAllele(0).toString().charAt(0), totalAndSNPSupporting); } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/QualByDepthV2.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/QualByDepthV2.java index 8de8ee5f8..72079733e 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/QualByDepthV2.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/annotator/QualByDepthV2.java @@ -4,8 +4,8 @@ import org.broad.tribble.util.variantcontext.Genotype; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeaderLineType; import org.broad.tribble.vcf.VCFInfoHeaderLine; +import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; -import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; import org.broadinstitute.sting.gatk.walkers.annotator.AnnotationByDepth; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation; @@ -21,7 +21,7 @@ import java.util.Map; * This does not necessarily work well in the case of non-confident genotypes (could over or under penalize) */ public class QualByDepthV2 extends AnnotationByDepth implements ExperimentalAnnotation { - public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { + public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( stratifiedContexts.size() == 0 ) return null; diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/association/MapExtender.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/association/MapExtender.java index 7ca1f8a0d..23b323dec 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/association/MapExtender.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/association/MapExtender.java @@ -38,8 +38,8 @@ public class MapExtender { readFilteredPileup = new HashMap(); if ( current != null ) { - for ( Map.Entry sac : current.getContext().entrySet() ) { - AlignmentContext context = sac.getValue().getContext(TYPE); + for ( Map.Entry sac : current.getContext().entrySet() ) { + AlignmentContext context = StratifiedAlignmentContext.stratify(sac.getValue(), TYPE); if ( context.hasBasePileup() ) { fullPileup.put(sac.getKey(),context.getBasePileup()); } else if ( context.hasExtendedEventPileup() ) { @@ -66,7 +66,7 @@ public class MapExtender { public Map getFullPileup() { return fullPileup; } public Map getReadFilteredPileup(){ return readFilteredPileup; } - public Map getPreviousContext() { + public Map getPreviousContext() { return previous != null ? previous.getContext() : null; } @@ -78,7 +78,7 @@ public class MapExtender { return previous != null ? previous.getTracker() : null; } - public Map getContext() { + public Map getContext() { return current != null ? current.getContext() : null; } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/association/MapHolder.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/association/MapHolder.java index f669022bc..47fc8e469 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/association/MapHolder.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/association/MapHolder.java @@ -11,15 +11,15 @@ import java.util.Map; public class MapHolder { private RefMetaDataTracker tracker; private ReferenceContext ref; - private Map alignments; + private Map alignments; public MapHolder(RefMetaDataTracker t, ReferenceContext r, AlignmentContext a) { tracker = t; ref = r; - alignments = StratifiedAlignmentContext.splitContextBySample(a.getBasePileup()); + alignments = StratifiedAlignmentContext.splitContextBySample(a); } - public Map getContext() { + public Map getContext() { return alignments; }