use of htsjdk.samtools.CigarOperator in project gatk by broadinstitute.
the class PileupElementUnitTest method testIsImmediatelyAfter_afterFirstD.
@Test
public void testIsImmediatelyAfter_afterFirstD() {
final GATKRead read = ArtificialReadUtils.createArtificialRead("10M10D10M");
final PileupElement pe = PileupElement.createPileupForReadAndOffset(read, 10);
Assert.assertFalse(pe.atEndOfCurrentCigar(), "atEndOfCurrentCigar");
Assert.assertTrue(pe.atStartOfCurrentCigar(), "atStartOfCurrentCigar");
Assert.assertTrue(pe.isImmediatelyAfter(D));
for (final CigarOperator op : CigarOperator.values()) {
if (op != D) {
Assert.assertFalse(pe.isImmediatelyAfter(op), "isImmediatelyAfter " + op);
}
}
for (final CigarOperator op : CigarOperator.values()) {
Assert.assertFalse(pe.isImmediatelyBefore(op));
}
}
use of htsjdk.samtools.CigarOperator in project gatk by broadinstitute.
the class PileupElementUnitTest method testImmediateBeforeAndAfterTest_simple.
@Test(dataProvider = "PrevAndNextTest_simple")
public void testImmediateBeforeAndAfterTest_simple(final GATKRead read, final CigarOperator middleOp) {
final AlignmentStateMachine state = new AlignmentStateMachine(read);
state.stepForwardOnGenome();
//before the 'middleOp'
final PileupElement pe1 = state.makePileupElement();
Assert.assertEquals(pe1.getAdjacentOperator(PileupElement.Direction.PREV), null, "PREV");
Assert.assertEquals(pe1.getAdjacentOperator(PileupElement.Direction.NEXT), middleOp, "NEXT");
for (final CigarOperator op : CigarOperator.values()) {
Assert.assertEquals(pe1.isImmediatelyBefore(op), middleOp == op, op.toString());
Assert.assertFalse(pe1.isImmediatelyAfter(op), op.toString());
}
state.stepForwardOnGenome();
//after the 'middleOp'
final PileupElement pe2 = state.makePileupElement();
Assert.assertEquals(pe2.getAdjacentOperator(PileupElement.Direction.PREV), middleOp, "PREV");
Assert.assertEquals(pe2.getAdjacentOperator(PileupElement.Direction.NEXT), null, "NEXT");
for (final CigarOperator op : CigarOperator.values()) {
Assert.assertFalse(pe2.isImmediatelyBefore(op), op.toString());
Assert.assertEquals(pe2.isImmediatelyAfter(op), op == middleOp, op.toString());
}
}
use of htsjdk.samtools.CigarOperator in project gatk by broadinstitute.
the class PileupElementUnitTest method makePrevAndNextTest.
@DataProvider(name = "PrevAndNextTest")
public Object[][] makePrevAndNextTest() {
final List<Object[]> tests = new LinkedList<>();
final List<CigarOperator> operators = Arrays.asList(CigarOperator.I, CigarOperator.P, CigarOperator.S);
for (final CigarOperator firstOp : Arrays.asList(M)) {
for (final CigarOperator lastOp : Arrays.asList(M, D)) {
for (final int nIntermediate : Arrays.asList(1, 2, 3)) {
for (final List<CigarOperator> combination : Utils.makePermutations(operators, nIntermediate, false)) {
final int readLength = 2 + combination.size();
final GATKRead read = ArtificialReadUtils.createArtificialRead(header, "read", 0, 1, readLength);
read.setBases(Utils.dupBytes((byte) 'A', readLength));
read.setBaseQualities(Utils.dupBytes((byte) 30, readLength));
String cigar = "1" + firstOp;
for (final CigarOperator op : combination) {
cigar += "1" + op;
}
cigar += "1" + lastOp;
read.setCigar(cigar);
tests.add(new Object[] { read, firstOp, lastOp, combination });
}
}
}
}
return tests.toArray(new Object[][] {});
}
use of htsjdk.samtools.CigarOperator in project gatk by broadinstitute.
the class PileupElementUnitTest method testIsImmediatelyAfter_insideMs.
@Test
public void testIsImmediatelyAfter_insideMs() {
final GATKRead read = ArtificialReadUtils.createArtificialRead("10M10D10M");
final PileupElement pe = PileupElement.createPileupForReadAndOffset(read, 5);
Assert.assertFalse(pe.atStartOfCurrentCigar(), "atStartOfCurrentCigar");
Assert.assertFalse(pe.atEndOfCurrentCigar(), "atEndOfCurrentCigar");
for (final CigarOperator op : CigarOperator.values()) {
Assert.assertFalse(pe.isImmediatelyAfter(op), "isImmediatelyAfter " + op);
}
for (final CigarOperator op : CigarOperator.values()) {
Assert.assertFalse(pe.isImmediatelyBefore(op), "isImmediatelyBefore " + op);
}
}
use of htsjdk.samtools.CigarOperator in project gatk by broadinstitute.
the class PileupElementUnitTest method testIsImmediatelyAfter_insideFinalMs.
@Test
public void testIsImmediatelyAfter_insideFinalMs() {
final GATKRead read = ArtificialReadUtils.createArtificialRead("10M10D10M");
final PileupElement pe = PileupElement.createPileupForReadAndOffset(read, 15);
Assert.assertFalse(pe.atStartOfCurrentCigar(), "atStartOfCurrentCigar");
Assert.assertFalse(pe.atEndOfCurrentCigar(), "atEndOfCurrentCigar");
for (final CigarOperator op : CigarOperator.values()) {
Assert.assertFalse(pe.isImmediatelyAfter(op), "isImmediatelyAfter " + op);
}
for (final CigarOperator op : CigarOperator.values()) {
Assert.assertFalse(pe.isImmediatelyBefore(op), "isImmediatelyBefore " + op);
}
}
Aggregations