HaplotypeCaller now uses insertions and softclipped bases as possible triggers. LocusIteratorByState tags pileup elements with the required info to make this calculation efficient. The days of the extended event pileup are coming to a close.
This commit is contained in:
parent
44c3a41f67
commit
cdff23269d
|
|
@ -176,6 +176,10 @@ public class LocusIteratorByState extends LocusIterator {
|
|||
return String.format("%s ro=%d go=%d co=%d cec=%d %s", read.getReadName(), readOffset, genomeOffset, cigarOffset, cigarElementCounter, curElement);
|
||||
}
|
||||
|
||||
public CigarOperator peekForwardOnGenome() {
|
||||
return ( cigarElementCounter + 1 > curElement.getLength() && cigarOffset + 1 < nCigarElements ? cigar.getCigarElement(cigarOffset + 1) : curElement ).getOperator();
|
||||
}
|
||||
|
||||
public CigarOperator stepForwardOnGenome() {
|
||||
// we enter this method with readOffset = index of the last processed base on the read
|
||||
// (-1 if we did not process a single base yet); this can be last matching base, or last base of an insertion
|
||||
|
|
@ -455,6 +459,7 @@ public class LocusIteratorByState extends LocusIterator {
|
|||
final SAMRecordState state = iterator.next(); // state object with the read/offset information
|
||||
final GATKSAMRecord read = (GATKSAMRecord) state.getRead(); // the actual read
|
||||
final CigarOperator op = state.getCurrentCigarOperator(); // current cigar operator
|
||||
final CigarOperator nextOp = state.peekForwardOnGenome(); // next cigar operator
|
||||
final int readOffset = state.getReadOffset(); // the base offset on this read
|
||||
final int eventStartOffset = state.getReadEventStartOffset(); // this will be -1 if base is not a deletion, or if base is the first deletion in the event. Otherwise, it will give the last base before the deletion began.
|
||||
|
||||
|
|
@ -467,13 +472,13 @@ public class LocusIteratorByState extends LocusIterator {
|
|||
if (op == CigarOperator.D) {
|
||||
if (readInfo.includeReadsWithDeletionAtLoci()) { // only add deletions to the pileup if we are authorized to do so
|
||||
int leftAlignedStart = (eventStartOffset < 0) ? readOffset : eventStartOffset;
|
||||
pile.add(new PileupElement(read, leftAlignedStart, true));
|
||||
pile.add(new PileupElement(read, leftAlignedStart, true, nextOp == CigarOperator.I, false));
|
||||
size++;
|
||||
nDeletions++;
|
||||
}
|
||||
} else {
|
||||
if (!filterBaseInRead(read, location.getStart())) {
|
||||
pile.add(new PileupElement(read, readOffset, false));
|
||||
pile.add(new PileupElement(read, readOffset, false, nextOp == CigarOperator.I, op == CigarOperator.S));
|
||||
size++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ public class SNPGenotypeLikelihoodsCalculationModel extends GenotypeLikelihoodsC
|
|||
|
||||
public class BAQedPileupElement extends PileupElement {
|
||||
public BAQedPileupElement( final PileupElement PE ) {
|
||||
super(PE.getRead(), PE.getOffset(), PE.isDeletion());
|
||||
super(PE.getRead(), PE.getOffset(), PE.isDeletion(), PE.isBeforeInsertion(), PE.isSoftClipped());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
|||
for (int i = 0; i < reads.size(); i++) {
|
||||
GATKSAMRecord read = reads.get(i);
|
||||
int offset = offsets.get(i);
|
||||
pileup.add(createNewPileupElement(read, offset, BaseUtils.simpleBaseToBaseIndex(read.getReadBases()[offset]) == BaseUtils.D));
|
||||
pileup.add(createNewPileupElement(read, offset, false, false, false)); // only used to create fake pileups for testing so ancillary information is not important
|
||||
}
|
||||
|
||||
return pileup;
|
||||
|
|
@ -196,7 +196,7 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
|||
|
||||
UnifiedPileupElementTracker<PE> pileup = new UnifiedPileupElementTracker<PE>();
|
||||
for (GATKSAMRecord read : reads) {
|
||||
pileup.add(createNewPileupElement(read, offset, BaseUtils.simpleBaseToBaseIndex(read.getReadBases()[offset]) == BaseUtils.D));
|
||||
pileup.add(createNewPileupElement(read, offset, false, false, false)); // only used to create fake pileups for testing so ancillary information is not important
|
||||
}
|
||||
|
||||
return pileup;
|
||||
|
|
@ -204,7 +204,7 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
|||
|
||||
protected abstract AbstractReadBackedPileup<RBP, PE> createNewPileup(GenomeLoc loc, PileupElementTracker<PE> pileupElementTracker);
|
||||
|
||||
protected abstract PE createNewPileupElement(GATKSAMRecord read, int offset, boolean isDeletion);
|
||||
protected abstract PE createNewPileupElement(GATKSAMRecord read, int offset, boolean isDeletion, boolean isBeforeInsertion, boolean isSoftClipped);
|
||||
|
||||
// --------------------------------------------------------
|
||||
//
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import java.util.Arrays;
|
|||
* Time: 2:57:55 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
// Extended events are slated for removal
|
||||
public class ExtendedEventPileupElement extends PileupElement {
|
||||
public enum Type {
|
||||
NOEVENT, DELETION, INSERTION
|
||||
|
|
@ -46,7 +48,7 @@ public class ExtendedEventPileupElement extends PileupElement {
|
|||
|
||||
|
||||
public ExtendedEventPileupElement(GATKSAMRecord read, int offset, int eventLength, String eventBases, Type type) {
|
||||
super(read, offset, type == Type.DELETION);
|
||||
super(read, offset, type == Type.DELETION, false, false); // extended events are slated for removal
|
||||
this.read = read;
|
||||
this.offset = offset;
|
||||
this.eventLength = eventLength;
|
||||
|
|
|
|||
|
|
@ -23,47 +23,46 @@ public class PileupElement implements Comparable<PileupElement> {
|
|||
protected final GATKSAMRecord read;
|
||||
protected final int offset;
|
||||
protected final boolean isDeletion;
|
||||
protected final boolean isBeforeInsertion;
|
||||
protected final boolean isSoftClipped;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new pileup element.
|
||||
*
|
||||
* @param read the read we are adding to the pileup
|
||||
* @param offset the position in the read for this base. All deletions must be left aligned! (-1 is only allowed for reads starting with insertions)
|
||||
* @param isDeletion whether or not this base is a deletion
|
||||
* @param read the read we are adding to the pileup
|
||||
* @param offset the position in the read for this base. All deletions must be left aligned! (-1 is only allowed for reads starting with insertions)
|
||||
* @param isDeletion whether or not this base is a deletion
|
||||
* @param isBeforeInsertion whether or not this base is before an insertion
|
||||
* @param isSoftClipped whether or not this base was softclipped
|
||||
*/
|
||||
@Requires({
|
||||
"read != null",
|
||||
"offset >= -1",
|
||||
"offset <= read.getReadLength()"})
|
||||
public PileupElement(GATKSAMRecord read, int offset, boolean isDeletion) {
|
||||
public PileupElement(final GATKSAMRecord read, final int offset, final boolean isDeletion, final boolean isBeforeInsertion, final boolean isSoftClipped) {
|
||||
if (offset < 0 && isDeletion)
|
||||
throw new ReviewedStingException("Pileup Element cannot create a deletion with a negative offset");
|
||||
|
||||
this.read = read;
|
||||
this.offset = offset;
|
||||
this.isDeletion = isDeletion;
|
||||
this.isBeforeInsertion = isBeforeInsertion;
|
||||
this.isSoftClipped = isSoftClipped;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Creates a NON DELETION pileup element.
|
||||
// *
|
||||
// * use this constructor only for insertions and matches/mismatches.
|
||||
// * @param read the read we are adding to the pileup
|
||||
// * @param offset the position in the read for this base. All deletions must be left aligned! (-1 is only allowed for reads starting with insertions)
|
||||
// */
|
||||
// @Requires({
|
||||
// "read != null",
|
||||
// "offset >= -1",
|
||||
// "offset <= read.getReadLength()"})
|
||||
// public PileupElement( GATKSAMRecord read, int offset ) {
|
||||
// this(read, offset, false);
|
||||
// }
|
||||
//
|
||||
public boolean isDeletion() {
|
||||
return isDeletion;
|
||||
}
|
||||
|
||||
public boolean isBeforeInsertion() {
|
||||
return isBeforeInsertion;
|
||||
}
|
||||
|
||||
public boolean isSoftClipped() {
|
||||
return isSoftClipped;
|
||||
}
|
||||
|
||||
public boolean isInsertionAtBeginningOfRead() {
|
||||
return offset == -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class ReadBackedExtendedEventPileupImpl extends AbstractReadBackedPileup<
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ExtendedEventPileupElement createNewPileupElement(GATKSAMRecord read, int offset, boolean isDeletion) {
|
||||
protected ExtendedEventPileupElement createNewPileupElement(GATKSAMRecord read, int offset, boolean isDeletion, boolean isBeforeInsertion, boolean isSoftClipped) {
|
||||
throw new UnsupportedOperationException("Not enough information provided to create a new pileup element");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class ReadBackedPileupImpl extends AbstractReadBackedPileup<ReadBackedPil
|
|||
}
|
||||
|
||||
@Override
|
||||
protected PileupElement createNewPileupElement(GATKSAMRecord read, int offset, boolean isDeletion) {
|
||||
return new PileupElement(read, offset, isDeletion);
|
||||
protected PileupElement createNewPileupElement(GATKSAMRecord read, int offset, boolean isDeletion, boolean isBeforeInsertion, boolean isSoftClipped) {
|
||||
return new PileupElement(read, offset, isDeletion, isBeforeInsertion, isSoftClipped);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,10 +361,10 @@ public class ArtificialSAMUtils {
|
|||
final GATKSAMRecord left = pair.get(0);
|
||||
final GATKSAMRecord right = pair.get(1);
|
||||
|
||||
pileupElements.add(new PileupElement(left, pos - leftStart, false));
|
||||
pileupElements.add(new PileupElement(left, pos - leftStart, false, false, false));
|
||||
|
||||
if (pos >= right.getAlignmentStart() && pos <= right.getAlignmentEnd()) {
|
||||
pileupElements.add(new PileupElement(right, pos - rightStart, false));
|
||||
pileupElements.add(new PileupElement(right, pos - rightStart, false, false, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ public class ReadUtilsUnitTest extends BaseTest {
|
|||
|
||||
@Test
|
||||
public void testReducedReadPileupElement() {
|
||||
PileupElement readp = new PileupElement(read, 0, false);
|
||||
PileupElement reducedreadp = new PileupElement(reducedRead, 0, false);
|
||||
PileupElement readp = new PileupElement(read, 0, false, false, false);
|
||||
PileupElement reducedreadp = new PileupElement(reducedRead, 0, false, false, false);
|
||||
|
||||
Assert.assertFalse(readp.getRead().isReducedRead());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue