Added back the MQ0 annotation - however, it's not yet standard (since mq0 reads are filtered out by default in the genotyper). But it'll work when using the Annotator as a standalone.

While I'm at it, change getPileup to getBasePileup to remove all of the deprecation warnings.



git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2502 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2010-01-05 17:07:19 +00:00
parent a4b69d0adf
commit 8b087305f3
8 changed files with 37 additions and 7 deletions

View File

@ -39,7 +39,7 @@ public class AlleleBalance extends StandardVariantAnnotation {
if ( genotypeStr.length() != 2 )
return null;
final String bases = new String(context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getPileup().getBases()).toUpperCase();
final String bases = new String(context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup().getBases()).toUpperCase();
if ( bases.length() == 0 )
return null;

View File

@ -14,7 +14,7 @@ public class DepthOfCoverage extends StandardVariantAnnotation {
public String annotate(ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, Variation variation) {
int depth = 0;
for ( String sample : stratifiedContexts.keySet() )
depth += stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getPileup().size();
depth += stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).size();
return String.format("%d", depth);
}

View File

@ -0,0 +1,30 @@
package org.broadinstitute.sting.gatk.walkers.annotator;
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.genotype.Variation;
import org.broadinstitute.sting.utils.genotype.vcf.VCFInfoHeaderLine;
import java.util.Map;
public class MappingQualityZero implements VariantAnnotation {
public String annotate(ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, Variation variation) {
int mq0 = 0;
for ( String sample : stratifiedContexts.keySet() ) {
ReadBackedPileup pileup = stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup();
for (PileupElement p : pileup ) {
if ( p.getMappingQual() == 0 )
mq0++;
}
}
return String.format("%d", mq0);
}
public String getKeyName() { return "MQ0"; }
public VCFInfoHeaderLine getDescription() { return new VCFInfoHeaderLine(getKeyName(), 1, VCFInfoHeaderLine.INFO_TYPE.Integer, "Total Mapping Quality Zero Reads"); }
}

View File

@ -18,7 +18,7 @@ public class RMSMappingQuality extends StandardVariantAnnotation {
public String annotate(ReferenceContext ref, Map<String, StratifiedAlignmentContext> stratifiedContexts, Variation variation) {
ArrayList<Integer> qualities = new ArrayList<Integer>();
for ( String sample : stratifiedContexts.keySet() ) {
ReadBackedPileup pileup = stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getPileup();
ReadBackedPileup pileup = stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup();
for (PileupElement p : pileup )
qualities.add(p.getRead().getMappingQuality());
}

View File

@ -36,7 +36,7 @@ public class RankSumTest implements VariantAnnotation {
if ( context == null )
continue;
fillQualsFromPileup(ref.getBase(), variation.getAlternativeBaseForSNP(), context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getPileup(), refQuals, altQuals);
fillQualsFromPileup(ref.getBase(), variation.getAlternativeBaseForSNP(), context.getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(), refQuals, altQuals);
}
}

View File

@ -37,7 +37,7 @@ public class SecondBaseSkew implements VariantAnnotation {
Pair<Integer, Integer> depth = new Pair<Integer, Integer>(0, 0);
for ( String sample : stratifiedContexts.keySet() ) {
Pair<Integer, Integer> sampleDepth = getSecondaryPileupNonrefCount(ref.getBase(), stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getPileup(), snp);
Pair<Integer, Integer> sampleDepth = getSecondaryPileupNonrefCount(ref.getBase(), stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup(), snp);
depth.first += sampleDepth.first;
depth.second += sampleDepth.second;
}

View File

@ -15,7 +15,7 @@ public class SpanningDeletions extends StandardVariantAnnotation {
int deletions = 0;
int depth = 0;
for ( String sample : stratifiedContexts.keySet() ) {
ReadBackedPileup pileup = stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getPileup();
ReadBackedPileup pileup = stratifiedContexts.get(sample).getContext(StratifiedAlignmentContext.StratifiedContextType.COMPLETE).getBasePileup();
deletions += pileup.getNumberOfDeletions();
depth += pileup.size();
}

View File

@ -166,7 +166,7 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
if ( BaseUtils.simpleBaseToBaseIndex(ref.getBase()) != -1 &&
variant.isBiallelic() &&
variant.isSNP() ) {
Map<String, StratifiedAlignmentContext> stratifiedContexts = StratifiedAlignmentContext.splitContextBySample(context.getPileup(), null, null);
Map<String, StratifiedAlignmentContext> stratifiedContexts = StratifiedAlignmentContext.splitContextBySample(context.getBasePileup(), null, null);
if ( stratifiedContexts != null )
annotations = getAnnotations(ref, stratifiedContexts, variant, requestedAnnotations);
}