Search in sources :

Example 11 with CigarOperator

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));
    }
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) CigarOperator(htsjdk.samtools.CigarOperator) LocusIteratorByStateBaseTest(org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByStateBaseTest) Test(org.testng.annotations.Test) LIBSTest(org.broadinstitute.hellbender.utils.locusiterator.LIBSTest)

Example 12 with CigarOperator

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());
    }
}
Also used : CigarOperator(htsjdk.samtools.CigarOperator) AlignmentStateMachine(org.broadinstitute.hellbender.utils.locusiterator.AlignmentStateMachine) LocusIteratorByStateBaseTest(org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByStateBaseTest) Test(org.testng.annotations.Test) LIBSTest(org.broadinstitute.hellbender.utils.locusiterator.LIBSTest)

Example 13 with CigarOperator

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[][] {});
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) CigarOperator(htsjdk.samtools.CigarOperator) DataProvider(org.testng.annotations.DataProvider)

Example 14 with CigarOperator

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);
    }
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) CigarOperator(htsjdk.samtools.CigarOperator) LocusIteratorByStateBaseTest(org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByStateBaseTest) Test(org.testng.annotations.Test) LIBSTest(org.broadinstitute.hellbender.utils.locusiterator.LIBSTest)

Example 15 with CigarOperator

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);
    }
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) CigarOperator(htsjdk.samtools.CigarOperator) LocusIteratorByStateBaseTest(org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByStateBaseTest) Test(org.testng.annotations.Test) LIBSTest(org.broadinstitute.hellbender.utils.locusiterator.LIBSTest)

Aggregations

CigarOperator (htsjdk.samtools.CigarOperator)18 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)8 LIBSTest (org.broadinstitute.hellbender.utils.locusiterator.LIBSTest)7 LocusIteratorByStateBaseTest (org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByStateBaseTest)7 Test (org.testng.annotations.Test)7 CigarElement (htsjdk.samtools.CigarElement)5 DataProvider (org.testng.annotations.DataProvider)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Cigar (htsjdk.samtools.Cigar)2 AlignmentStateMachine (org.broadinstitute.hellbender.utils.locusiterator.AlignmentStateMachine)2 Locatable (htsjdk.samtools.util.Locatable)1 ArrayList (java.util.ArrayList)1 AlignmentContext (org.broadinstitute.hellbender.engine.AlignmentContext)1 GATKException (org.broadinstitute.hellbender.exceptions.GATKException)1 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)1 PileupElement (org.broadinstitute.hellbender.utils.pileup.PileupElement)1 ReadPileup (org.broadinstitute.hellbender.utils.pileup.ReadPileup)1