Adding read position rank sum test to the list of annotations that get produced with the HaplotypeCaller
This commit is contained in:
parent
08a1ef2681
commit
cf705f6c62
|
|
@ -30,7 +30,7 @@ public class BaseQualityRankSumTest extends RankSumTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected void fillQualsFromPileup(final Allele ref, final List<Allele> alts, final Map<Allele, List<GATKSAMRecord>> stratifiedContext, final List<Double> refQuals, List<Double> altQuals) {
|
protected void fillQualsFromPileup(final Allele ref, final List<Allele> alts, final int refLoc, final Map<Allele, List<GATKSAMRecord>> stratifiedContext, final List<Double> refQuals, final List<Double> altQuals) {
|
||||||
// TODO -- implement me; how do we pull out the correct offset from the read?
|
// TODO -- implement me; how do we pull out the correct offset from the read?
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class MappingQualityRankSumTest extends RankSumTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillQualsFromPileup(final Allele ref, final List<Allele> alts, final Map<Allele, List<GATKSAMRecord>> stratifiedContext, final List<Double> refQuals, List<Double> altQuals) {
|
protected void fillQualsFromPileup(final Allele ref, final List<Allele> alts, final int refLoc, final Map<Allele, List<GATKSAMRecord>> stratifiedContext, final List<Double> refQuals, final List<Double> altQuals) {
|
||||||
for ( final Map.Entry<Allele, List<GATKSAMRecord>> alleleBin : stratifiedContext.entrySet() ) {
|
for ( final Map.Entry<Allele, List<GATKSAMRecord>> alleleBin : stratifiedContext.entrySet() ) {
|
||||||
final boolean matchesRef = ref.equals(alleleBin.getKey());
|
final boolean matchesRef = ref.equals(alleleBin.getKey());
|
||||||
final boolean matchesAlt = alts.contains(alleleBin.getKey());
|
final boolean matchesAlt = alts.contains(alleleBin.getKey());
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ public abstract class RankSumTest extends InfoFieldAnnotation implements Standar
|
||||||
if ( context == null )
|
if ( context == null )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fillQualsFromPileup(vc.getReference(), vc.getAlternateAlleles(), context, refQuals, altQuals);
|
fillQualsFromPileup(vc.getReference(), vc.getAlternateAlleles(), vc.getStart(), context, refQuals, altQuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( refQuals.size() == 0 || altQuals.size() == 0 )
|
if ( refQuals.size() == 0 || altQuals.size() == 0 )
|
||||||
|
|
@ -146,7 +146,7 @@ public abstract class RankSumTest extends InfoFieldAnnotation implements Standar
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void fillQualsFromPileup(final Allele ref, final List<Allele> alts, final Map<Allele, List<GATKSAMRecord>> stratifiedContext, final List<Double> refQuals, List<Double> altQuals);
|
protected abstract void fillQualsFromPileup(final Allele ref, final List<Allele> alts, final int refLoc, final Map<Allele, List<GATKSAMRecord>> stratifiedContext, final List<Double> refQuals, List<Double> altQuals);
|
||||||
|
|
||||||
protected abstract void fillQualsFromPileup(final byte ref, final List<Byte> alts, final ReadBackedPileup pileup, final List<Double> refQuals, final List<Double> altQuals);
|
protected abstract void fillQualsFromPileup(final byte ref, final List<Byte> alts, final ReadBackedPileup pileup, final List<Double> refQuals, final List<Double> altQuals);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||||
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
|
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
|
||||||
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
|
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
|
||||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||||
|
import org.broadinstitute.sting.utils.sam.ReadUtils;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -47,11 +48,7 @@ public class ReadPosRankSumTest extends RankSumTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillQualsFromPileup(final Allele ref, final List<Allele> alts, final Map<Allele, List<GATKSAMRecord>> stratifiedContext, final List<Double> refQuals, List<Double> altQuals) {
|
protected void fillQualsFromPileup(final Allele ref, final List<Allele> alts, final int refLoc, final Map<Allele, List<GATKSAMRecord>> stratifiedContext, final List<Double> refQuals, final List<Double> altQuals) {
|
||||||
// TODO -- implement me; how do we pull out the correct offset from the read?
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
for ( final Map.Entry<Allele, List<GATKSAMRecord>> alleleBin : stratifiedContext.entrySet() ) {
|
for ( final Map.Entry<Allele, List<GATKSAMRecord>> alleleBin : stratifiedContext.entrySet() ) {
|
||||||
final boolean matchesRef = ref.equals(alleleBin.getKey());
|
final boolean matchesRef = ref.equals(alleleBin.getKey());
|
||||||
final boolean matchesAlt = alts.contains(alleleBin.getKey());
|
final boolean matchesAlt = alts.contains(alleleBin.getKey());
|
||||||
|
|
@ -59,13 +56,21 @@ public class ReadPosRankSumTest extends RankSumTest {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for ( final GATKSAMRecord read : alleleBin.getValue() ) {
|
for ( final GATKSAMRecord read : alleleBin.getValue() ) {
|
||||||
|
final int offset = ReadUtils.getReadCoordinateForReferenceCoordinate( read.getUnclippedStart(), read.getCigar(), refLoc, ReadUtils.ClippingTail.RIGHT_TAIL, true );
|
||||||
|
if ( offset == ReadUtils.CLIPPING_GOAL_NOT_REACHED )
|
||||||
|
continue;
|
||||||
|
int readPos = AlignmentUtils.calcAlignmentByteArrayOffset( read.getCigar(), offset, false, false, 0, 0 );
|
||||||
|
|
||||||
|
final int numAlignedBases = AlignmentUtils.getNumAlignedBases( read );
|
||||||
|
if (readPos > numAlignedBases / 2)
|
||||||
|
readPos = numAlignedBases - (readPos + 1);
|
||||||
|
|
||||||
if ( matchesRef )
|
if ( matchesRef )
|
||||||
refQuals.add((double)read.getMappingQuality());
|
refQuals.add((double) readPos);
|
||||||
else
|
else
|
||||||
altQuals.add((double)read.getMappingQuality());
|
altQuals.add((double) readPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillIndelQualsFromPileup(ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals) {
|
protected void fillIndelQualsFromPileup(ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals) {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class PileupElement implements Comparable<PileupElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PileupElement(final GATKSAMRecord read, final int offset, final boolean isDeletion, final boolean isBeforeDeletion, final boolean isAfterDeletion, final boolean isBeforeInsertion, final boolean isAfterInsertion, final boolean isNextToSoftClip) {
|
public PileupElement(final GATKSAMRecord read, final int offset, final boolean isDeletion, final boolean isBeforeDeletion, final boolean isAfterDeletion, final boolean isBeforeInsertion, final boolean isAfterInsertion, final boolean isNextToSoftClip) {
|
||||||
this(read,offset, isDeletion, isBeforeDeletion, isAfterDeletion, isBeforeInsertion, isAfterInsertion, isNextToSoftClip, null, -1);
|
this(read, offset, isDeletion, isBeforeDeletion, isAfterDeletion, isBeforeInsertion, isAfterInsertion, isNextToSoftClip, null, -1);
|
||||||
}
|
}
|
||||||
public boolean isDeletion() {
|
public boolean isDeletion() {
|
||||||
return isDeletion;
|
return isDeletion;
|
||||||
|
|
|
||||||
|
|
@ -381,15 +381,19 @@ public class AlignmentUtils {
|
||||||
return alignment;
|
return alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int calcAlignmentByteArrayOffset(final Cigar cigar, PileupElement pileup, final int alignmentStart, final int refLocus) {
|
public static int calcAlignmentByteArrayOffset(final Cigar cigar, final PileupElement pileupElement, final int alignmentStart, final int refLocus) {
|
||||||
int pileupOffset = pileup.getOffset();
|
return calcAlignmentByteArrayOffset( cigar, pileupElement.getOffset(), pileupElement.isInsertionAtBeginningOfRead(), pileupElement.isDeletion(), alignmentStart, refLocus );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int calcAlignmentByteArrayOffset(final Cigar cigar, final int offset, final boolean isInsertionAtBeginningOfRead, final boolean isDeletion, final int alignmentStart, final int refLocus) {
|
||||||
|
int pileupOffset = offset;
|
||||||
|
|
||||||
// Special case for reads starting with insertion
|
// Special case for reads starting with insertion
|
||||||
if (pileup.isInsertionAtBeginningOfRead())
|
if (isInsertionAtBeginningOfRead)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Reassign the offset if we are in the middle of a deletion because of the modified representation of the read bases
|
// Reassign the offset if we are in the middle of a deletion because of the modified representation of the read bases
|
||||||
if (pileup.isDeletion()) {
|
if (isDeletion) {
|
||||||
pileupOffset = refLocus - alignmentStart;
|
pileupOffset = refLocus - alignmentStart;
|
||||||
final CigarElement ce = cigar.getCigarElement(0);
|
final CigarElement ce = cigar.getCigarElement(0);
|
||||||
if (ce.getOperator() == CigarOperator.S) {
|
if (ce.getOperator() == CigarOperator.S) {
|
||||||
|
|
@ -414,7 +418,7 @@ public class AlignmentUtils {
|
||||||
break;
|
break;
|
||||||
case D:
|
case D:
|
||||||
case N:
|
case N:
|
||||||
if (!pileup.isDeletion()) {
|
if (!isDeletion) {
|
||||||
alignmentPos += elementLength;
|
alignmentPos += elementLength;
|
||||||
} else {
|
} else {
|
||||||
if (pos + elementLength - 1 >= pileupOffset) {
|
if (pos + elementLength - 1 >= pileupOffset) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue