Search in sources :

Example 1 with UnvalidatingGenomeLoc

use of org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc in project gatk by broadinstitute.

the class HaplotypeUnitTest method testBadTrimLoc.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testBadTrimLoc() {
    final GenomeLoc loc = new UnvalidatingGenomeLoc("20", 0, 10, 20);
    final Haplotype hap = new Haplotype("ACGTAACCGGT".getBytes(), loc);
    hap.trim(new UnvalidatingGenomeLoc("20", 0, 1, 20));
}
Also used : UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 2 with UnvalidatingGenomeLoc

use of org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc in project gatk by broadinstitute.

the class EventMapUnitTest method testBlockSubstitutionsData.

/**
     * Example testng test using MyDataProvider
     */
@Test(dataProvider = "BlockSubstitutionsData")
public void testBlockSubstitutionsData(final String refBases, final String haplotypeBases, final String cigar, final VariantContext expectedBlock) {
    final Haplotype hap = new Haplotype(haplotypeBases.getBytes(), false, 0, TextCigarCodec.decode(cigar));
    final GenomeLoc loc = new UnvalidatingGenomeLoc(CHR, 0, 1, refBases.length());
    final EventMap ee = new EventMap(hap, refBases.getBytes(), loc, NAME);
    ee.replaceClumpedEventsWithBlockSubstitutions();
    Assert.assertEquals(ee.getNumberOfEvents(), 1);
    final VariantContext actual = ee.getVariantContexts().iterator().next();
    Assert.assertTrue(GATKVariantContextUtils.equalSites(actual, expectedBlock), "Failed with " + actual);
}
Also used : UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) VariantContext(htsjdk.variant.variantcontext.VariantContext) GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc) UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 3 with UnvalidatingGenomeLoc

use of org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc in project gatk by broadinstitute.

the class EventMapUnitTest method testAdjacentSNPIndelTest.

/**
     * Example testng test using MyDataProvider
     */
@Test(dataProvider = "AdjacentSNPIndelTest")
public void testAdjacentSNPIndelTest(final String refBases, final String haplotypeBases, final String cigar, final List<List<String>> expectedAlleles) {
    final Haplotype hap = new Haplotype(haplotypeBases.getBytes(), false, 0, TextCigarCodec.decode(cigar));
    final GenomeLoc loc = new UnvalidatingGenomeLoc(CHR, 0, 1, refBases.length());
    final EventMap ee = new EventMap(hap, refBases.getBytes(), loc, NAME);
    ee.replaceClumpedEventsWithBlockSubstitutions();
    Assert.assertEquals(ee.getNumberOfEvents(), expectedAlleles.size());
    final List<VariantContext> actuals = new ArrayList<>(ee.getVariantContexts());
    for (int i = 0; i < ee.getNumberOfEvents(); i++) {
        final VariantContext actual = actuals.get(i);
        Assert.assertEquals(actual.getReference().getDisplayString(), expectedAlleles.get(i).get(0));
        Assert.assertEquals(actual.getAlternateAllele(0).getDisplayString(), expectedAlleles.get(i).get(1));
    }
}
Also used : UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) VariantContext(htsjdk.variant.variantcontext.VariantContext) GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc) UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 4 with UnvalidatingGenomeLoc

use of org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc in project gatk by broadinstitute.

the class HaplotypeUnitTest method makeTrimmingData.

@DataProvider(name = "TrimmingData")
public Object[][] makeTrimmingData() {
    List<Object[]> tests = new ArrayList<>();
    // this functionality can be adapted to provide input data for whatever you might want in your data
    final GenomeLoc loc = new UnvalidatingGenomeLoc("20", 0, 10, 20);
    final String fullBases = "ACGTAACCGGT";
    for (int trimStart = loc.getStart(); trimStart < loc.getStop(); trimStart++) {
        for (int trimStop = trimStart; trimStop <= loc.getStop(); trimStop++) {
            final int start = trimStart - loc.getStart();
            final int stop = start + (trimStop - trimStart) + 1;
            final GenomeLoc trimmedLoc = new UnvalidatingGenomeLoc("20", 0, start + loc.getStart(), stop + loc.getStart() - 1);
            final String expectedBases = fullBases.substring(start, stop);
            final Haplotype full = new Haplotype(fullBases.getBytes(), loc);
            final Haplotype trimmed = new Haplotype(expectedBases.getBytes(), trimmedLoc);
            final int hapStart = 10;
            full.setAlignmentStartHapwrtRef(hapStart);
            full.setCigar(TextCigarCodec.decode(full.length() + "M"));
            trimmed.setAlignmentStartHapwrtRef(hapStart + start);
            trimmed.setCigar(TextCigarCodec.decode(trimmed.length() + "M"));
            tests.add(new Object[] { full, trimmedLoc, trimmed });
        }
    }
    final Haplotype full = new Haplotype("ACT".getBytes(), new UnvalidatingGenomeLoc("20", 0, 10, 14));
    full.setAlignmentStartHapwrtRef(10);
    full.setCigar(TextCigarCodec.decode("1M2D2M"));
    tests.add(new Object[] { full, new UnvalidatingGenomeLoc("20", 0, 11, 12), null });
    tests.add(new Object[] { full, new UnvalidatingGenomeLoc("20", 0, 10, 12), null });
    tests.add(new Object[] { full, new UnvalidatingGenomeLoc("20", 0, 11, 13), null });
    return tests.toArray(new Object[][] {});
}
Also used : ArrayList(java.util.ArrayList) UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc) DataProvider(org.testng.annotations.DataProvider)

Example 5 with UnvalidatingGenomeLoc

use of org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc in project gatk by broadinstitute.

the class HaplotypeUnitTest method testBadTrimNoLoc.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testBadTrimNoLoc() {
    final Haplotype hap = new Haplotype("ACGTAACCGGT".getBytes());
    hap.trim(new UnvalidatingGenomeLoc("20", 0, 1, 20));
}
Also used : UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

UnvalidatingGenomeLoc (org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc)5 GenomeLoc (org.broadinstitute.hellbender.utils.GenomeLoc)4 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)4 Test (org.testng.annotations.Test)4 VariantContext (htsjdk.variant.variantcontext.VariantContext)2 ArrayList (java.util.ArrayList)1 DataProvider (org.testng.annotations.DataProvider)1