Support for reducedReads in the pileup and UG. Totally experimental -- the code interface could change, and so could the implementation. Only works for SNPs now. Pileup has contracts as well.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5936 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2011-06-03 16:39:01 +00:00
parent 2df12472c2
commit b4c479bcb0
3 changed files with 52 additions and 7 deletions

View File

@ -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) {

View File

@ -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());

View File

@ -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();
}
}