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 eb8dd53f0..8861d1acc 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java @@ -44,6 +44,7 @@ import org.broadinstitute.sting.utils.sam.ReadUtils; public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation { private final static boolean DEBUG = false; private final static int MIN_CONTEXT_WING_SIZE = 10; + private final static int MAX_CONSENSUS_HAPLOTYPES_TO_CONSIDER = 20; private final static char REGEXP_WILDCARD = '.'; public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { @@ -124,7 +125,7 @@ public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation { */ } - if (!foundHaplotypeMatch) { + if (!foundHaplotypeMatch && haplotypeList.size() < MAX_CONSENSUS_HAPLOTYPES_TO_CONSIDER) { haplotypeList.add(elem); } } @@ -293,7 +294,7 @@ public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation { byte haplotypeBase = haplotypeBases[i]; byte readBase = readBases[baseOffset]; - boolean matched = BaseUtils.basesAreEqual(readBase, haplotypeBase ); + boolean matched = readBase == haplotypeBase; double e = QualityUtils.qualToErrorProb(readQuals[baseOffset]); expected += e; mismatches += matched ? e : 1 - e / 3; 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 22e52dbd8..4ee7c0820 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java @@ -23,7 +23,13 @@ public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotatio if ( stratifiedContexts.size() == 0 ) return null; - ArrayList qualities = new ArrayList(); + int totalSize = 0; + for ( StratifiedAlignmentContext context : stratifiedContexts.values() ) + totalSize += context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size(); + + int[] qualities = new int[totalSize]; + int index = 0; + for ( Map.Entry sample : stratifiedContexts.entrySet() ) { AlignmentContext context = sample.getValue().getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE); ReadBackedPileup pileup = null; @@ -34,14 +40,11 @@ public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotatio if (pileup != null) { for (PileupElement p : pileup ) - qualities.add(p.getRead().getMappingQuality()); + qualities[index++] = p.getRead().getMappingQuality(); } } - int[] quals = new int[qualities.size()]; - int index = 0; - for ( Integer i : qualities ) - quals[index++] = i; - double rms = MathUtils.rms(quals); + + double rms = MathUtils.rms(qualities); Map map = new HashMap(); map.put(getKeyNames().get(0), String.format("%.2f", rms)); return map; diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/genotyper/UnifiedGenotyperEngine.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/genotyper/UnifiedGenotyperEngine.java index 55959f7c7..6cd1bb7a8 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/genotyper/UnifiedGenotyperEngine.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/genotyper/UnifiedGenotyperEngine.java @@ -318,12 +318,6 @@ public class UnifiedGenotyperEngine { ReadBackedPileup pileup = rawContext.getBasePileup(); - // filter the reads - filterPileup(pileup, badBaseFilter); - - // filter the context based on bad mates and mismatch rate - //pileup = pileup.getFilteredPileup(badReadPileupFilter); - // don't call when there is no coverage if ( pileup.size() == 0 && !UAC.ALL_BASES_MODE ) return null; @@ -335,6 +329,9 @@ public class UnifiedGenotyperEngine { // stratify the AlignmentContext and cut by sample stratifiedContexts = StratifiedAlignmentContext.splitContextBySample(pileup, UAC.ASSUME_SINGLE_SAMPLE); + + // filter the reads + filterPileup(stratifiedContexts, badBaseFilter); } return stratifiedContexts; @@ -405,11 +402,14 @@ public class UnifiedGenotyperEngine { verboseWriter.println(); } - private void filterPileup(ReadBackedPileup pileup, BadBaseFilter badBaseFilter) { - for ( PileupElement p : pileup ) { - final SAMRecord read = p.getRead(); - if ( read instanceof GATKSAMRecord ) - ((GATKSAMRecord)read).setGoodBases(badBaseFilter, true); + private void filterPileup(Map stratifiedContexts, BadBaseFilter badBaseFilter) { + for ( StratifiedAlignmentContext context : stratifiedContexts.values() ) { + ReadBackedPileup pileup = context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(); + for ( PileupElement p : pileup ) { + final SAMRecord read = p.getRead(); + if ( read instanceof GATKSAMRecord ) + ((GATKSAMRecord)read).setGoodBases(badBaseFilter, true); + } } }