Search in sources :

Example 1 with GenomeLoc

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

the class OverhangFixingManagerUnitTest method makeOverhangData.

@DataProvider(name = "OverhangTest")
public Object[][] makeOverhangData() {
    final List<Object[]> tests = new ArrayList<>();
    for (int leftRead : Arrays.asList(10, 20, 30, 40)) {
        for (int rightRead : Arrays.asList(20, 30, 40, 50)) {
            if (leftRead >= rightRead)
                continue;
            for (int leftSplice : Arrays.asList(10, 20, 30)) {
                for (int rightSplice : Arrays.asList(20, 30, 40)) {
                    if (leftSplice >= rightSplice)
                        continue;
                    final GenomeLoc readLoc = hg19GenomeLocParser.createGenomeLoc("1", leftRead, rightRead);
                    final GenomeLoc spliceLoc = hg19GenomeLocParser.createGenomeLoc("1", leftSplice, rightSplice);
                    tests.add(new Object[] { readLoc, spliceLoc });
                }
            }
        }
    }
    return tests.toArray(new Object[][] {});
}
Also used : GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc) DataProvider(org.testng.annotations.DataProvider)

Example 2 with GenomeLoc

use of org.broadinstitute.hellbender.utils.GenomeLoc 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 3 with GenomeLoc

use of org.broadinstitute.hellbender.utils.GenomeLoc 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 4 with GenomeLoc

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

the class IntervalArgumentCollectionTest method testExcludeWithNoIncludes.

@Test(dataProvider = "optionalOrNot")
public void testExcludeWithNoIncludes(IntervalArgumentCollection iac) {
    iac.excludeIntervalStrings.addAll(Arrays.asList("1", "2", "3"));
    Assert.assertTrue(iac.intervalsSpecified());
    GenomeLoc chr4GenomeLoc = hg19GenomeLocParser.createOverEntireContig("4");
    Assert.assertEquals(iac.getIntervals(hg19GenomeLocParser.getSequenceDictionary()), Arrays.asList(new SimpleInterval(chr4GenomeLoc)));
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 5 with GenomeLoc

use of org.broadinstitute.hellbender.utils.GenomeLoc in project gatk-protected by broadinstitute.

the class ReferenceConfidenceModelUnitTest method checkReferenceModelResult.

private void checkReferenceModelResult(final RefConfData data, final List<VariantContext> contexts, final List<Integer> expectedDPs, final List<VariantContext> calls) {
    Assert.assertNotNull(contexts);
    final SimpleInterval loc = data.getActiveRegion().getExtendedSpan();
    final List<Boolean> seenBP = new ArrayList<>(Collections.nCopies(data.getActiveRegion().getSpan().size(), false));
    for (int i = 0; i < loc.size(); i++) {
        final GenomeLoc curPos = parser.createGenomeLoc(loc.getContig(), loc.getStart() + i);
        final VariantContext call = model.getOverlappingVariantContext(curPos, calls);
        final VariantContext refModel = model.getOverlappingVariantContext(curPos, contexts);
        if (!data.getActiveRegion().getSpan().contains(curPos)) {
            // part of the extended interval, but not the full interval
            Assert.assertNull(refModel);
            continue;
        }
        if (call != null) {
            if (call.isVariant() && refModel.getType() == VariantContext.Type.SYMBOLIC) {
                //Assert.assertEquals(refModel, call, "Should have found call " + call + " but found " + refModel + " instead");
                // must be a deletion.
                Assert.assertTrue(call.getReference().length() > 1);
                // the deletion must not start at the same position
                Assert.assertTrue(call.getStart() < refModel.getStart());
                Assert.assertEquals(call.getReference().getBaseString().substring(refModel.getStart() - call.getStart(), refModel.getStart() - call.getStart() + 1), refModel.getReference().getBaseString(), // the reference must be the same.
                "" + data.getRefHap());
                // No confidence in the reference hom-ref call across the deletion
                Assert.assertTrue(refModel.getGenotype(0).getGQ() <= 0);
                // the reference and the lonelly <NON_REF>
                Assert.assertEquals(refModel.getAlleles().size(), 2);
                Assert.assertEquals(refModel.getAlleles().get(1), GATKVCFConstants.NON_REF_SYMBOLIC_ALLELE);
            } else {
                Assert.assertEquals(refModel, call, "Should have found call " + call + " but found " + refModel + " instead");
            }
        } else {
            final int expectedDP = expectedDPs.get(curPos.getStart() - data.getActiveRegion().getSpan().getStart());
            Assert.assertEquals(refModel.getStart(), loc.getStart() + i);
            Assert.assertEquals(refModel.getEnd(), loc.getStart() + i);
            Assert.assertFalse(refModel.hasLog10PError());
            Assert.assertEquals(refModel.getAlternateAlleles().size(), 1);
            Assert.assertEquals(refModel.getAlternateAllele(0), GATKVCFConstants.NON_REF_SYMBOLIC_ALLELE);
            Assert.assertTrue(refModel.hasGenotype(sample));
            final Genotype g = refModel.getGenotype(sample);
            Assert.assertTrue(g.hasAD());
            Assert.assertTrue(g.hasDP());
            Assert.assertEquals(g.getDP(), expectedDP);
            Assert.assertTrue(g.hasGQ());
            Assert.assertTrue(g.hasPL());
        }
        final VariantContext vc = call == null ? refModel : call;
        if (curPos.getStart() == vc.getStart()) {
            for (int pos = vc.getStart(); pos <= vc.getEnd(); pos++) {
                final int j = pos - data.getActiveRegion().getSpan().getStart();
                Assert.assertFalse(seenBP.get(j));
                seenBP.set(j, true);
            }
        }
    }
    for (int i = 0; i < seenBP.size(); i++) {
        Assert.assertEquals((boolean) seenBP.get(i), true);
    }
}
Also used : VariantContext(htsjdk.variant.variantcontext.VariantContext) Genotype(htsjdk.variant.variantcontext.Genotype) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc)

Aggregations

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