Search in sources :

Example 1 with MappingQualityReadFilter

use of org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter in project gatk by broadinstitute.

the class AssemblyRegionUnitTest method testCreateFromReadShard.

@Test
public void testCreateFromReadShard() {
    final Path testBam = IOUtils.getPath(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);
    // Traversal settings to match the GATK 3/4 HaplotypeCaller settings when the expected output was generated:
    final int minRegionSize = 50;
    final int maxRegionSize = 300;
    final int regionPadding = 100;
    final double activeProbThreshold = 0.002;
    final int maxProbPropagationDistance = 50;
    // This mock evaluator returns exactly the values that the GATK 4 HaplotypeCallerEngine's isActive()
    // method returns for this region. We don't have direct access to the HaplotypeCallerEngine since
    // we're in public, so we need to use a mock.
    final AssemblyRegionEvaluator mockEvaluator = new AssemblyRegionEvaluator() {

        private final List<SimpleInterval> activeSites = 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));

        @Override
        public ActivityProfileState isActive(AlignmentContext locusPileup, ReferenceContext referenceContext, FeatureContext featureContext) {
            final SimpleInterval pileupInterval = new SimpleInterval(locusPileup);
            return activeSites.contains(pileupInterval) ? new ActivityProfileState(pileupInterval, 1.0) : new ActivityProfileState(pileupInterval, 0.0);
        }
    };
    final List<Pair<SimpleInterval, Boolean>> expectedResults = Arrays.asList(// GATK 3.4's results).
    Pair.of(new SimpleInterval("20", 9999902, 9999953), false), Pair.of(new SimpleInterval("20", 9999954, 10000039), true), Pair.of(new SimpleInterval("20", 10000040, 10000079), false), Pair.of(new SimpleInterval("20", 10000080, 10000154), true), Pair.of(new SimpleInterval("20", 10000155, 10000173), false), Pair.of(new SimpleInterval("20", 10000174, 10000248), true), Pair.of(new SimpleInterval("20", 10000249, 10000401), false), Pair.of(new SimpleInterval("20", 10000402, 10000476), true), Pair.of(new SimpleInterval("20", 10000477, 10000560), false), Pair.of(new SimpleInterval("20", 10000561, 10000635), true), Pair.of(new SimpleInterval("20", 10000636, 10000656), false), Pair.of(new SimpleInterval("20", 10000657, 10000795), true), Pair.of(new SimpleInterval("20", 10000796, 10000981), false), Pair.of(new SimpleInterval("20", 10000982, 10001056), true), Pair.of(new SimpleInterval("20", 10001057, 10001100), false));
    try (final ReadsDataSource readsSource = new ReadsDataSource(testBam);
        final ReferenceDataSource refSource = new ReferenceFileSource(reference)) {
        // Set the shard's read filter to match the GATK 3/4 HaplotypeCaller settings when the expected output was generated:
        final LocalReadShard shard = new LocalReadShard(shardInterval, paddedShardInterval, readsSource);
        shard.setReadFilter(new CountingReadFilter(new MappingQualityReadFilter(20)).and(new CountingReadFilter(ReadFilterLibrary.MAPPING_QUALITY_AVAILABLE)).and(new CountingReadFilter(ReadFilterLibrary.MAPPED)).and(new CountingReadFilter(ReadFilterLibrary.PRIMARY_ALIGNMENT)).and(new CountingReadFilter(ReadFilterLibrary.NOT_DUPLICATE)).and(new CountingReadFilter(ReadFilterLibrary.PASSES_VENDOR_QUALITY_CHECK)).and(new CountingReadFilter(ReadFilterLibrary.GOOD_CIGAR)).and(new CountingReadFilter(new WellformedReadFilter(readsSource.getHeader()))));
        final Iterable<AssemblyRegion> assemblyRegions = AssemblyRegion.createFromReadShard(shard, readsSource.getHeader(), new ReferenceContext(refSource, paddedShardInterval), new FeatureContext(null, paddedShardInterval), mockEvaluator, minRegionSize, maxRegionSize, regionPadding, activeProbThreshold, maxProbPropagationDistance);
        int regionCount = 0;
        for (final AssemblyRegion region : assemblyRegions) {
            Assert.assertTrue(regionCount < expectedResults.size(), "Too many regions returned from AssemblyRegion.createFromReadShard()");
            Assert.assertEquals(region.getSpan(), expectedResults.get(regionCount).getLeft(), "Wrong interval for region");
            Assert.assertEquals(region.isActive(), expectedResults.get(regionCount).getRight().booleanValue(), "Region incorrectly marked as active/inactive");
            ++regionCount;
        }
        Assert.assertEquals(regionCount, expectedResults.size(), "Too few regions returned from AssemblyRegion.createFromReadShard()");
    }
}
Also used : Path(java.nio.file.Path) WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) ActivityProfileState(org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState) CountingReadFilter(org.broadinstitute.hellbender.engine.filters.CountingReadFilter) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) Pair(org.apache.commons.lang3.tuple.Pair) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 2 with MappingQualityReadFilter

use of org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter in project gatk by broadinstitute.

the class InsertSizeMetricsCollector method getDefaultReadFilters.

/**
     * Return the read filter for InsertSizeMetrics collector.
     * @return ReadFilter to be used to filter records
     */
public List<ReadFilter> getDefaultReadFilters() {
    List<ReadFilter> readFilters = new ArrayList<>();
    readFilters.add(new WellformedReadFilter());
    readFilters.add(ReadFilterLibrary.MAPPED);
    readFilters.add(ReadFilterLibrary.PAIRED);
    readFilters.add(ReadFilterLibrary.NONZERO_FRAGMENT_LENGTH_READ_FILTER);
    readFilters.add(ReadFilterLibrary.FIRST_OF_PAIR);
    readFilters.add(ReadFilterLibrary.PROPERLY_PAIRED);
    readFilters.add(ReadFilterLibrary.NOT_DUPLICATE);
    readFilters.add(ReadFilterLibrary.NOT_SECONDARY_ALIGNMENT);
    readFilters.add(ReadFilterLibrary.NOT_SUPPLEMENTARY_ALIGNMENT);
    readFilters.add(new MappingQualityReadFilter(0));
    return readFilters;
}
Also used : WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) ArrayList(java.util.ArrayList) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter)

Example 3 with MappingQualityReadFilter

use of org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter in project gatk-protected by broadinstitute.

the class HaplotypeCallerEngine method makeStandardHCReadFilters.

/**
     * @return the default set of read filters for use with the HaplotypeCaller
     */
public static List<ReadFilter> makeStandardHCReadFilters() {
    List<ReadFilter> filters = new ArrayList<>();
    filters.add(new MappingQualityReadFilter(READ_QUALITY_FILTER_THRESHOLD));
    filters.add(ReadFilterLibrary.MAPPING_QUALITY_AVAILABLE);
    filters.add(ReadFilterLibrary.MAPPED);
    filters.add(ReadFilterLibrary.PRIMARY_ALIGNMENT);
    filters.add(ReadFilterLibrary.NOT_DUPLICATE);
    filters.add(ReadFilterLibrary.PASSES_VENDOR_QUALITY_CHECK);
    filters.add(ReadFilterLibrary.NON_ZERO_REFERENCE_LENGTH_ALIGNMENT);
    filters.add(ReadFilterLibrary.GOOD_CIGAR);
    filters.add(new WellformedReadFilter());
    return filters;
}
Also used : WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter)

Example 4 with MappingQualityReadFilter

use of org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter in project gatk-protected by broadinstitute.

the class Mutect2Engine method makeStandardMutect2ReadFilters.

/**
     * @return the default set of read filters for use with Mutect2
     */
public static List<ReadFilter> makeStandardMutect2ReadFilters() {
    // The order in which we apply filters is important. Cheap filters come first so we fail fast
    List<ReadFilter> filters = new ArrayList<>();
    filters.add(new MappingQualityReadFilter(READ_QUALITY_FILTER_THRESHOLD));
    filters.add(ReadFilterLibrary.MAPPING_QUALITY_AVAILABLE);
    filters.add(ReadFilterLibrary.MAPPING_QUALITY_NOT_ZERO);
    filters.add(ReadFilterLibrary.MAPPED);
    filters.add(ReadFilterLibrary.PRIMARY_ALIGNMENT);
    filters.add(ReadFilterLibrary.NOT_DUPLICATE);
    filters.add(ReadFilterLibrary.PASSES_VENDOR_QUALITY_CHECK);
    filters.add(ReadFilterLibrary.NON_ZERO_REFERENCE_LENGTH_ALIGNMENT);
    filters.add(GOOD_READ_LENGTH_FILTER);
    filters.add(ReadFilterLibrary.MATE_ON_SAME_CONTIG_OR_NO_MAPPED_MATE);
    filters.add(ReadFilterLibrary.GOOD_CIGAR);
    filters.add(new WellformedReadFilter());
    return filters;
}
Also used : WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter)

Example 5 with MappingQualityReadFilter

use of org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter in project gatk by broadinstitute.

the class Mutect2Engine method makeStandardMutect2ReadFilters.

/**
     * @return the default set of read filters for use with Mutect2
     */
public static List<ReadFilter> makeStandardMutect2ReadFilters() {
    // The order in which we apply filters is important. Cheap filters come first so we fail fast
    List<ReadFilter> filters = new ArrayList<>();
    filters.add(new MappingQualityReadFilter(READ_QUALITY_FILTER_THRESHOLD));
    filters.add(ReadFilterLibrary.MAPPING_QUALITY_AVAILABLE);
    filters.add(ReadFilterLibrary.MAPPING_QUALITY_NOT_ZERO);
    filters.add(ReadFilterLibrary.MAPPED);
    filters.add(ReadFilterLibrary.PRIMARY_ALIGNMENT);
    filters.add(ReadFilterLibrary.NOT_DUPLICATE);
    filters.add(ReadFilterLibrary.PASSES_VENDOR_QUALITY_CHECK);
    filters.add(ReadFilterLibrary.NON_ZERO_REFERENCE_LENGTH_ALIGNMENT);
    filters.add(GOOD_READ_LENGTH_FILTER);
    filters.add(ReadFilterLibrary.MATE_ON_SAME_CONTIG_OR_NO_MAPPED_MATE);
    filters.add(ReadFilterLibrary.GOOD_CIGAR);
    filters.add(new WellformedReadFilter());
    return filters;
}
Also used : WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) MappingQualityReadFilter(org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter)

Aggregations

MappingQualityReadFilter (org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter)6 WellformedReadFilter (org.broadinstitute.hellbender.engine.filters.WellformedReadFilter)6 ReadFilter (org.broadinstitute.hellbender.engine.filters.ReadFilter)5 IndexedFastaSequenceFile (htsjdk.samtools.reference.IndexedFastaSequenceFile)1 File (java.io.File)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Pair (org.apache.commons.lang3.tuple.Pair)1 CountingReadFilter (org.broadinstitute.hellbender.engine.filters.CountingReadFilter)1 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)1 ActivityProfileState (org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState)1 CachingIndexedFastaSequenceFile (org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile)1 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1 Test (org.testng.annotations.Test)1