}
@Test(dataProvider = "PileupElementTest")
public void testPileupElementTest(LIBSTest params) {
final GATKSAMRecord read = params.makeRead();
final AlignmentStateMachine state = new AlignmentStateMachine(read);
final LIBS_position tester = new LIBS_position(read);
while ( state.stepForwardOnGenome() != null ) {
tester.stepForwardOnGenome();
final PileupElement pe = state.makePileupElement();
Assert.assertEquals(pe.getRead(), read);
Assert.assertEquals(pe.getMappingQual(), read.getMappingQuality());
Assert.assertEquals(pe.getOffset(), state.getReadOffset());
Assert.assertEquals(pe.isDeletion(), state.getCigarOperator() == CigarOperator.D);
Assert.assertEquals(pe.isAfterInsertion(), tester.isAfterInsertion);
Assert.assertEquals(pe.isBeforeInsertion(), tester.isBeforeInsertion);
Assert.assertEquals(pe.isNextToSoftClip(), tester.isNextToSoftClip);
if ( ! hasNeighboringPaddedOps(params.getElements(), pe.getCurrentCigarOffset()) ) {
Assert.assertEquals(pe.isAfterDeletionEnd(), tester.isAfterDeletionEnd);
Assert.assertEquals(pe.isBeforeDeletionStart(), tester.isBeforeDeletionStart);
}
Assert.assertEquals(pe.atEndOfCurrentCigar(), state.getOffsetIntoCurrentCigarElement() == state.getCurrentCigarElement().getLength() - 1, "atEndOfCurrentCigar failed");
Assert.assertEquals(pe.atStartOfCurrentCigar(), state.getOffsetIntoCurrentCigarElement() == 0, "atStartOfCurrentCigar failed");
Assert.assertEquals(pe.getBase(), pe.isDeletion() ? PileupElement.DELETION_BASE : read.getReadBases()[state.getReadOffset()]);
Assert.assertEquals(pe.getQual(), pe.isDeletion() ? PileupElement.DELETION_QUAL : read.getBaseQualities()[state.getReadOffset()]);
Assert.assertEquals(pe.getCurrentCigarElement(), state.getCurrentCigarElement());
Assert.assertEquals(pe.getCurrentCigarOffset(), state.getCurrentCigarElementOffset());
// tested in libs
//pe.getLengthOfImmediatelyFollowingIndel();
//pe.getBasesOfImmediatelyFollowingInsertion();
// Don't test -- pe.getBaseIndex();
if ( pe.atEndOfCurrentCigar() && state.getCurrentCigarElementOffset() < read.getCigarLength() - 1 ) {
final CigarElement nextElement = read.getCigar().getCigarElement(state.getCurrentCigarElementOffset() + 1);
if ( nextElement.getOperator() == CigarOperator.I ) {
Assert.assertTrue(pe.getBetweenNextPosition().size() >= 1);
Assert.assertEquals(pe.getBetweenNextPosition().get(0), nextElement);
}
if ( nextElement.getOperator() == CigarOperator.M ) {
Assert.assertTrue(pe.getBetweenNextPosition().isEmpty());
}
} else {
Assert.assertTrue(pe.getBetweenNextPosition().isEmpty());
}
if ( pe.atStartOfCurrentCigar() && state.getCurrentCigarElementOffset() > 0 ) {
final CigarElement prevElement = read.getCigar().getCigarElement(state.getCurrentCigarElementOffset() - 1);
if ( prevElement.getOperator() == CigarOperator.I ) {
Assert.assertTrue(pe.getBetweenPrevPosition().size() >= 1);
Assert.assertEquals(pe.getBetweenPrevPosition().getLast(), prevElement);
}
if ( prevElement.getOperator() == CigarOperator.M ) {