Search in sources :

Example 11 with ReadFilter

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

the class BaseRecalibrator method getStandardBQSRReadFilterList.

/**
     * Return the full list of raw read filters used for BQSR contexts, including WellFormed.
     * @return List of raw read filters not yet primed with a header
     */
public static List<ReadFilter> getStandardBQSRReadFilterList() {
    final List<ReadFilter> bqsrFilters = getBQSRSpecificReadFilterList();
    bqsrFilters.add(new WellformedReadFilter());
    return bqsrFilters;
}
Also used : WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter)

Example 12 with ReadFilter

use of org.broadinstitute.hellbender.engine.filters.ReadFilter 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 13 with ReadFilter

use of org.broadinstitute.hellbender.engine.filters.ReadFilter 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 14 with ReadFilter

use of org.broadinstitute.hellbender.engine.filters.ReadFilter 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 15 with ReadFilter

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

the class GATKReadFilterPluginDescriptor method validateArguments.

/**
     * Validate the list of arguments and reduce the list of read filters to those
     * actually seen on the command line. This is called by the command line parser
     * after all arguments have been parsed.
     */
@Override
public void validateArguments() {
    // throw if a filter is *enabled* more than once by the user
    final Set<String> duplicateUserEnabledFilterNames = Utils.getDuplicatedItems(userArgs.getUserEnabledReadFilterNames());
    if (!duplicateUserEnabledFilterNames.isEmpty()) {
        throw new CommandLineException.BadArgumentValue(String.format("The read filter(s) are enabled more than once: %s", Utils.join(", ", duplicateUserEnabledFilterNames)));
    }
    // throw if a filter is *disabled* more than once by the user
    final Set<String> duplicateDisabledUserFilterNames = Utils.getDuplicatedItems(userArgs.getUserDisabledReadFilterNames());
    if (!duplicateDisabledUserFilterNames.isEmpty()) {
        throw new CommandLineException.BadArgumentValue(String.format("The read filter(s) are disabled more than once: %s", Utils.join(", ", duplicateDisabledUserFilterNames)));
    }
    // throw if a filter is both enabled *and* disabled by the user
    final Set<String> enabledAndDisabled = new HashSet<>(userArgs.getUserEnabledReadFilterNames());
    enabledAndDisabled.retainAll(userArgs.getUserDisabledReadFilterNames());
    if (!enabledAndDisabled.isEmpty()) {
        final String badFiltersList = Utils.join(", ", enabledAndDisabled);
        throw new CommandLineException(String.format("The read filter(s): %s are both enabled and disabled", badFiltersList));
    }
    // throw if a disabled filter doesn't exist; warn if it wasn't enabled by the tool in the first place
    userArgs.getUserDisabledReadFilterNames().forEach(s -> {
        if (!allDiscoveredReadFilters.containsKey(s)) {
            throw new CommandLineException.BadArgumentValue(String.format("Disabled filter (%s) does not exist", s));
        } else if (!toolDefaultReadFilters.containsKey(s)) {
            logger.warn(String.format("Disabled filter (%s) is not enabled by this tool", s));
        }
    });
    // warn if a filter is both default and enabled by the user
    final Set<String> redundant = new HashSet<>(toolDefaultReadFilters.keySet());
    redundant.retainAll(userArgs.getUserEnabledReadFilterNames());
    redundant.forEach(s -> {
        logger.warn(String.format("Redundant enabled filter (%s) is enabled for this tool by default", s));
    });
    // Throw if args were specified for a filter that was also disabled, or that was not enabled by the
    // tool by default.
    //
    // Note that this is also checked during command line argument parsing, but needs to be checked again
    // here. Whenever the command line parser sees a dependent argument on the command line, it delegates
    // back to the descriptor's isDependentArgumentAllowed method to allow it to validate that the predecessor
    // for that dependent argument has been supplied, either by a default read filter, or by an explicitly
    // enabled read filter. However, its possible for the user to subsequently try to disable that
    // predecessor, which is what we want to catch here.
    //
    userArgs.getUserDisabledReadFilterNames().forEach(s -> {
        if (requiredPredecessors.contains(s)) {
            String message = String.format("Values were supplied for (%s) that is also disabled", s);
            if (toolDefaultReadFilters.containsKey(s)) {
                logger.warn(message);
            } else {
                throw new CommandLineException(message);
            }
        }
    });
    // throw if a filter name was specified that has no corresponding instance
    final Map<String, ReadFilter> requestedReadFilters = new HashMap<>();
    userArgs.getUserEnabledReadFilterNames().forEach(s -> {
        ReadFilter trf = allDiscoveredReadFilters.get(s);
        if (null == trf) {
            if (!toolDefaultReadFilters.containsKey(s)) {
                throw new CommandLineException("Unrecognized read filter name: " + s);
            }
        } else {
            requestedReadFilters.put(s, trf);
        }
    });
}
Also used : CountingReadFilter(org.broadinstitute.hellbender.engine.filters.CountingReadFilter) ReadFilter(org.broadinstitute.hellbender.engine.filters.ReadFilter) CommandLineException(org.broadinstitute.barclay.argparser.CommandLineException)

Aggregations

ReadFilter (org.broadinstitute.hellbender.engine.filters.ReadFilter)25 WellformedReadFilter (org.broadinstitute.hellbender.engine.filters.WellformedReadFilter)12 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)10 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)7 File (java.io.File)6 ReadFilterLibrary (org.broadinstitute.hellbender.engine.filters.ReadFilterLibrary)6 CountingReadFilter (org.broadinstitute.hellbender.engine.filters.CountingReadFilter)5 MappingQualityReadFilter (org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter)5 ArrayList (java.util.ArrayList)4 JavaRDD (org.apache.spark.api.java.JavaRDD)4 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)4 SAMFileHeader (htsjdk.samtools.SAMFileHeader)3 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)3 java.util (java.util)3 Argument (org.broadinstitute.barclay.argparser.Argument)3 CommandLineProgramProperties (org.broadinstitute.barclay.argparser.CommandLineProgramProperties)3 DocumentedFeature (org.broadinstitute.barclay.help.DocumentedFeature)3 GATKSparkTool (org.broadinstitute.hellbender.engine.spark.GATKSparkTool)3 UserException (org.broadinstitute.hellbender.exceptions.UserException)3 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)3