diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java index d2d5e347a..ab075eaf2 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/DiploidSNPGenotypeLikelihoods.java @@ -32,6 +32,7 @@ import org.broadinstitute.sting.utils.pileup.FragmentPileup; import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; import org.broadinstitute.sting.utils.pileup.PileupElement; import org.broadinstitute.sting.utils.genotype.DiploidGenotype; +import org.broadinstitute.sting.utils.sam.ReadUtils; import static java.lang.Math.log10; import static java.lang.Math.pow; @@ -270,8 +271,18 @@ public class DiploidSNPGenotypeLikelihoods implements Cloneable { } public int add(PileupElement elt, boolean ignoreBadBases, boolean capBaseQualsAtMappingQual, int minBaseQual) { byte obsBase = elt.getBase(); - byte qual = qualToUse(elt, ignoreBadBases, capBaseQualsAtMappingQual, minBaseQual); - return qual > 0 ? add(obsBase, qual, (byte)0, (byte)0) : 0; + + if ( elt.isReducedRead() ) { + // reduced read representation + byte qual = elt.getReducedQual(); + for ( int i = 0; i < elt.getReducedCount(); i++ ) { + add(obsBase, qual, (byte)0, (byte)0); + } + return elt.getQual(); + } else { + byte qual = qualToUse(elt, ignoreBadBases, capBaseQualsAtMappingQual, minBaseQual); + return qual > 0 ? add(obsBase, qual, (byte)0, (byte)0) : 0; + } } public int add(FragmentPileup.TwoReadPileupElement twoRead, boolean ignoreBadBases, boolean capBaseQualsAtMappingQual, int minBaseQual) { 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 bdccf4dd8..f278501b0 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SNPGenotypeLikelihoodsCalculationModel.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/SNPGenotypeLikelihoodsCalculationModel.java @@ -156,7 +156,7 @@ public class SNPGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoodsC ReadBackedPileup pileup = useBAQedPileup ? createBAQedPileup( sample.getValue().getBasePileup() ) : sample.getValue().getBasePileup(); for ( PileupElement p : pileup ) { // ignore deletions - if ( p.isDeletion() || p.getQual() < UAC.MIN_BASE_QUALTY_SCORE ) + if ( p.isDeletion() || (! p.isReducedRead() && p.getQual() < UAC.MIN_BASE_QUALTY_SCORE )) continue; final int index = BaseUtils.simpleBaseToBaseIndex(p.getBase()); diff --git a/java/src/org/broadinstitute/sting/utils/pileup/PileupElement.java b/java/src/org/broadinstitute/sting/utils/pileup/PileupElement.java index d47024525..51e02bf74 100755 --- a/java/src/org/broadinstitute/sting/utils/pileup/PileupElement.java +++ b/java/src/org/broadinstitute/sting/utils/pileup/PileupElement.java @@ -2,13 +2,14 @@ package org.broadinstitute.sting.utils.pileup; import org.broadinstitute.sting.utils.*; import net.sf.samtools.SAMRecord; +import org.broadinstitute.sting.utils.sam.ReadUtils; +import com.google.java.contract.*; /** * Created by IntelliJ IDEA. * User: depristo * Date: Apr 14, 2009 * Time: 8:54:05 AM - * To change this template use File | Settings | File Templates. */ public class PileupElement { public static final byte DELETION_BASE = BaseUtils.D; @@ -18,9 +19,13 @@ public class PileupElement { public static final byte T_FOLLOWED_BY_INSERTION_BASE = (byte) 89; public static final byte G_FOLLOWED_BY_INSERTION_BASE = (byte) 90; - protected SAMRecord read; - protected int offset; + protected final SAMRecord read; + protected final int offset; + @Requires({ + "read != null", + "offset >= -1", + "offset <= read.getReadLength()"}) public PileupElement( SAMRecord read, int offset ) { this.read = read; this.offset = offset; @@ -30,7 +35,10 @@ public class PileupElement { return offset == -1; } + @Ensures("result != null") public SAMRecord getRead() { return read; } + + @Ensures("result == offset") public int getOffset() { return offset; } public byte getBase() { @@ -45,8 +53,11 @@ public class PileupElement { return getQual(offset); } - public int getMappingQual() { return read.getMappingQuality(); } + public int getMappingQual() { + return read.getMappingQuality(); + } + @Ensures("result != null") public String toString() { return String.format("%s @ %d = %c Q%d", getRead().getReadName(), getOffset(), (char)getBase(), getQual()); } @@ -62,4 +73,27 @@ public class PileupElement { protected byte getQual(final int offset) { return isDeletion() ? DELETION_QUAL : read.getBaseQualities()[offset]; } + + // -------------------------------------------------------------------------- + // + // Reduced read accessors + // + // -------------------------------------------------------------------------- + + private Integer getReducedReadQualityTagValue() { + return (Integer)getRead().getAttribute(ReadUtils.REDUCED_READ_QUALITY_TAG); + } + + public boolean isReducedRead() { + return getReducedReadQualityTagValue() != null; + } + + public int getReducedCount() { + return (int)getQual(); + } + + public byte getReducedQual() { + return (byte)(int)getReducedReadQualityTagValue(); + } + } \ No newline at end of file