Search in sources :

Example 6 with ActivityProfileState

use of org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState in project gatk by broadinstitute.

the class ActivityProfileStateUnitTest method testError2.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testError2() {
    final String chr = sequenceDictionary.getSequence(0).getSequenceName();
    new ActivityProfileState(new SimpleInterval(chr, 10, 11), 0.1, null, 1.0);
}
Also used : ActivityProfileState(org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Test(org.testng.annotations.Test)

Example 7 with ActivityProfileState

use of org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState in project gatk by broadinstitute.

the class ActivityProfileStateUnitTest method testError1.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testError1() {
    final String chr = sequenceDictionary.getSequence(0).getSequenceName();
    new ActivityProfileState(new SimpleInterval(chr, 10, 10), 0.1, null, -1.0);
}
Also used : ActivityProfileState(org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Test(org.testng.annotations.Test)

Example 8 with ActivityProfileState

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

the class HaplotypeCallerEngineUnitTest method testIsActive.

@Test
public void testIsActive() throws IOException {
    final File testBam = new File(NA12878_20_21_WGS_bam);
    final File reference = new File(b37_reference_20_21);
    final SimpleInterval shardInterval = new SimpleInterval("20", 10000000, 10001000);
    final SimpleInterval paddedShardInterval = new SimpleInterval(shardInterval.getContig(), shardInterval.getStart() - 100, shardInterval.getEnd() + 100);
    final HaplotypeCallerArgumentCollection hcArgs = new HaplotypeCallerArgumentCollection();
    // We expect isActive() to return 1.0 for the sites below, and 0.0 for all other sites
    final List<SimpleInterval> expectedActiveSites = Arrays.asList(new SimpleInterval("20", 9999996, 9999996), new SimpleInterval("20", 9999997, 9999997), new SimpleInterval("20", 10000117, 10000117), new SimpleInterval("20", 10000211, 10000211), new SimpleInterval("20", 10000439, 10000439), new SimpleInterval("20", 10000598, 10000598), new SimpleInterval("20", 10000694, 10000694), new SimpleInterval("20", 10000758, 10000758), new SimpleInterval("20", 10001019, 10001019));
    try (final ReadsDataSource reads = new ReadsDataSource(testBam.toPath());
        final ReferenceDataSource ref = new ReferenceFileSource(reference);
        final CachingIndexedFastaSequenceFile referenceReader = new CachingIndexedFastaSequenceFile(reference)) {
        final HaplotypeCallerEngine hcEngine = new HaplotypeCallerEngine(hcArgs, reads.getHeader(), referenceReader);
        List<ReadFilter> hcFilters = HaplotypeCallerEngine.makeStandardHCReadFilters();
        hcFilters.forEach(filter -> filter.setHeader(reads.getHeader()));
        ReadFilter hcCombinedFilter = hcFilters.get(0);
        for (int i = 1; i < hcFilters.size(); ++i) {
            hcCombinedFilter = hcCombinedFilter.and(hcFilters.get(i));
        }
        final Iterator<GATKRead> readIter = new ReadFilteringIterator(reads.query(paddedShardInterval), hcCombinedFilter);
        final LocusIteratorByState libs = new LocusIteratorByState(readIter, DownsamplingMethod.NONE, false, ReadUtils.getSamplesFromHeader(reads.getHeader()), reads.getHeader(), false);
        libs.forEachRemaining(pileup -> {
            final SimpleInterval pileupInterval = new SimpleInterval(pileup.getLocation());
            final ReferenceContext pileupRefContext = new ReferenceContext(ref, pileupInterval);
            final ActivityProfileState isActiveResult = hcEngine.isActive(pileup, pileupRefContext, new FeatureContext(null, pileupInterval));
            final double expectedIsActiveValue = expectedActiveSites.contains(pileupInterval) ? 1.0 : 0.0;
            Assert.assertEquals(isActiveResult.isActiveProb(), expectedIsActiveValue, "Wrong isActive probability for site " + pileupInterval);
        });
    }
}
Also used : ReadFilteringIterator(org.broadinstitute.hellbender.utils.iterators.ReadFilteringIterator) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) ActivityProfileState(org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) LocusIteratorByState(org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByState) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 9 with ActivityProfileState

use of org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState in project gatk by broadinstitute.

the class HaplotypeCallerEngineUnitTest method testIsActive.

@Test
public void testIsActive() throws IOException {
    final File testBam = new File(NA12878_20_21_WGS_bam);
    final File reference = new File(b37_reference_20_21);
    final SimpleInterval shardInterval = new SimpleInterval("20", 10000000, 10001000);
    final SimpleInterval paddedShardInterval = new SimpleInterval(shardInterval.getContig(), shardInterval.getStart() - 100, shardInterval.getEnd() + 100);
    final HaplotypeCallerArgumentCollection hcArgs = new HaplotypeCallerArgumentCollection();
    // We expect isActive() to return 1.0 for the sites below, and 0.0 for all other sites
    final List<SimpleInterval> expectedActiveSites = Arrays.asList(new SimpleInterval("20", 9999996, 9999996), new SimpleInterval("20", 9999997, 9999997), new SimpleInterval("20", 10000117, 10000117), new SimpleInterval("20", 10000211, 10000211), new SimpleInterval("20", 10000439, 10000439), new SimpleInterval("20", 10000598, 10000598), new SimpleInterval("20", 10000694, 10000694), new SimpleInterval("20", 10000758, 10000758), new SimpleInterval("20", 10001019, 10001019));
    try (final ReadsDataSource reads = new ReadsDataSource(testBam.toPath());
        final ReferenceDataSource ref = new ReferenceFileSource(reference);
        final CachingIndexedFastaSequenceFile referenceReader = new CachingIndexedFastaSequenceFile(reference)) {
        final HaplotypeCallerEngine hcEngine = new HaplotypeCallerEngine(hcArgs, reads.getHeader(), referenceReader);
        List<ReadFilter> hcFilters = HaplotypeCallerEngine.makeStandardHCReadFilters();
        hcFilters.forEach(filter -> filter.setHeader(reads.getHeader()));
        ReadFilter hcCombinedFilter = hcFilters.get(0);
        for (int i = 1; i < hcFilters.size(); ++i) {
            hcCombinedFilter = hcCombinedFilter.and(hcFilters.get(i));
        }
        final Iterator<GATKRead> readIter = new ReadFilteringIterator(reads.query(paddedShardInterval), hcCombinedFilter);
        final LocusIteratorByState libs = new LocusIteratorByState(readIter, DownsamplingMethod.NONE, false, ReadUtils.getSamplesFromHeader(reads.getHeader()), reads.getHeader(), false);
        libs.forEachRemaining(pileup -> {
            final SimpleInterval pileupInterval = new SimpleInterval(pileup.getLocation());
            final ReferenceContext pileupRefContext = new ReferenceContext(ref, pileupInterval);
            final ActivityProfileState isActiveResult = hcEngine.isActive(pileup, pileupRefContext, new FeatureContext(null, pileupInterval));
            final double expectedIsActiveValue = expectedActiveSites.contains(pileupInterval) ? 1.0 : 0.0;
            Assert.assertEquals(isActiveResult.isActiveProb(), expectedIsActiveValue, "Wrong isActive probability for site " + pileupInterval);
        });
    }
}
Also used : ReadFilteringIterator(org.broadinstitute.hellbender.utils.iterators.ReadFilteringIterator) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) ActivityProfileState(org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) LocusIteratorByState(org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByState) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 10 with ActivityProfileState

use of org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState in project gatk by broadinstitute.

the class AssemblyRegionUnitTest method makePollingData.

@DataProvider(name = "ActionRegionCreationTest")
public Object[][] makePollingData() {
    final List<Object[]> tests = new ArrayList<>();
    for (final int start : Arrays.asList(1, 10, 100, contigLength - 10, contigLength - 1)) {
        for (final int size : Arrays.asList(1, 10, 100, 1000)) {
            for (final int ext : Arrays.asList(0, 1, 10, 100)) {
                for (final boolean isActive : Arrays.asList(true, false)) {
                    for (final boolean addStates : Arrays.asList(true, false)) {
                        List<ActivityProfileState> states = null;
                        if (addStates) {
                            states = new LinkedList<>();
                            for (int i = start; i < start + size; i++) {
                                states.add(new ActivityProfileState(new SimpleInterval(contig, i + start, i + start), isActive ? 1.0 : 0.0));
                            }
                        }
                        final SimpleInterval loc = new SimpleInterval(contig, start, start + size - 1);
                        tests.add(new Object[] { loc, states, isActive, ext });
                    }
                }
            }
        }
    }
    return tests.toArray(new Object[][] {});
}
Also used : ActivityProfileState(org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) DataProvider(org.testng.annotations.DataProvider)

Aggregations

ActivityProfileState (org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState)10 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)9 Test (org.testng.annotations.Test)7 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)4 File (java.io.File)3 CachingIndexedFastaSequenceFile (org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile)3 ReadFilter (org.broadinstitute.hellbender.engine.filters.ReadFilter)2 ReadFilteringIterator (org.broadinstitute.hellbender.utils.iterators.ReadFilteringIterator)2 LocusIteratorByState (org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByState)2 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)2 IndexedFastaSequenceFile (htsjdk.samtools.reference.IndexedFastaSequenceFile)1 Path (java.nio.file.Path)1 Pair (org.apache.commons.lang3.tuple.Pair)1 CountingReadFilter (org.broadinstitute.hellbender.engine.filters.CountingReadFilter)1 MappingQualityReadFilter (org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter)1 WellformedReadFilter (org.broadinstitute.hellbender.engine.filters.WellformedReadFilter)1 ReferenceBases (org.broadinstitute.hellbender.utils.reference.ReferenceBases)1 DataProvider (org.testng.annotations.DataProvider)1