use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisableToolDefaultFilters.
@Test(dataProvider = "disableToolDefaulFiltersArguments")
public void testDisableToolDefaultFilters(final String[] args, final List<ReadFilter> defaultFilters, final ReadFilter expectedFilter) {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(defaultFilters)));
clp.parseArguments(nullMessageStream, args);
GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
Assert.assertTrue(readFilterPlugin.userArgs.getDisableToolDefaultReadFilters());
// no instances because no readFilter was provided
List<ReadFilter> readFilters = readFilterPlugin.getAllInstances();
Assert.assertEquals(readFilters.size(), (expectedFilter == null) ? 0 : 1);
// all the default filters returns true for isDisabledFilter if it is not the expected
defaultFilters.stream().map(df -> df.getClass().getSimpleName()).filter(df -> expectedFilter == null || expectedFilter.getClass().getSimpleName().equals(df)).forEach(df -> Assert.assertTrue(readFilterPlugin.isDisabledFilter(df.getClass().getSimpleName())));
ReadFilter rf = instantiateFilter(clp, createHeaderWithReadGroups());
Assert.assertEquals(rf.getClass().getSimpleName(), (expectedFilter == null) ? ReadFilterLibrary.ALLOW_ALL_READS.getClass().getSimpleName() : expectedFilter.getClass().getSimpleName());
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testEnableNonExistentFilter.
@Test(expectedExceptions = CommandLineException.class)
public void testEnableNonExistentFilter() {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
clp.parseArguments(nullMessageStream, new String[] { "--RF", "fakeFilter" });
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisableDefaultsAndReenableWithDifferentArgs.
@Test
public void testDisableDefaultsAndReenableWithDifferentArgs() {
GATKReadFilterPluginDescriptor rfDesc = new GATKReadFilterPluginDescriptor(Collections.singletonList(new ReadLengthReadFilter(1, 10)));
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(rfDesc));
clp.parseArguments(nullMessageStream, new String[] { "--disableToolDefaultReadFilters", "--readFilter", ReadLengthReadFilter.class.getSimpleName(), "--maxReadLength", "13" });
List<ReadFilter> allFilters = rfDesc.getAllInstances();
ReadLengthReadFilter rf = (ReadLengthReadFilter) allFilters.get(0);
Assert.assertEquals(rf.maxReadLength.intValue(), 13);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testPreserveToolDefaultFilterOrder.
@Test
public void testPreserveToolDefaultFilterOrder() {
List<ReadFilter> orderedDefaults = new ArrayList<>();
orderedDefaults.add(new WellformedReadFilter());
orderedDefaults.add(ReadFilterLibrary.MAPPED);
orderedDefaults.add(ReadFilterLibrary.HAS_READ_GROUP);
orderedDefaults.add(ReadFilterLibrary.MAPPING_QUALITY_NOT_ZERO);
orderedDefaults.add(ReadFilterLibrary.PAIRED);
orderedDefaults.add(ReadFilterLibrary.NONZERO_FRAGMENT_LENGTH_READ_FILTER);
orderedDefaults.add(ReadFilterLibrary.FIRST_OF_PAIR);
orderedDefaults.add(ReadFilterLibrary.PROPERLY_PAIRED);
orderedDefaults.add(ReadFilterLibrary.NOT_DUPLICATE);
orderedDefaults.add(ReadFilterLibrary.NOT_SECONDARY_ALIGNMENT);
orderedDefaults.add(ReadFilterLibrary.NOT_SUPPLEMENTARY_ALIGNMENT);
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(orderedDefaults)));
clp.parseArguments(nullMessageStream, new String[] { //disable one just to mix things up
"-disableReadFilter", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "-readFilter", ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), "-readFilter", ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName() });
// Now get the final merged read filter and verify the execution order. We need to ensure that
// getMergedReadFilter creates a composite filter that honors the filter test execution
// order rules (tool defaults first, in order, followed by command line-specified, in order
// listed). So reach inside the filter and navigate down the tree.
ReadFilter rf = instantiateFilter(clp, createHeaderWithReadGroups());
String[] expectedOrder = { WellformedReadFilter.class.getSimpleName(), ReadFilterLibrary.HAS_READ_GROUP.getClass().getSimpleName(), ReadFilterLibrary.MAPPING_QUALITY_NOT_ZERO.getClass().getSimpleName(), ReadFilterLibrary.PAIRED.getClass().getSimpleName(), ReadFilterLibrary.NONZERO_FRAGMENT_LENGTH_READ_FILTER.getClass().getSimpleName(), ReadFilterLibrary.FIRST_OF_PAIR.getClass().getSimpleName(), ReadFilterLibrary.PROPERLY_PAIRED.getClass().getSimpleName(), ReadFilterLibrary.NOT_DUPLICATE.getClass().getSimpleName(), ReadFilterLibrary.NOT_SECONDARY_ALIGNMENT.getClass().getSimpleName(), ReadFilterLibrary.NOT_SUPPLEMENTARY_ALIGNMENT.getClass().getSimpleName(), ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName() };
int count = ReadFilterUnitTest.verifyAndFilterOrder(rf, expectedOrder);
Assert.assertEquals(count, 12);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisableOneFilter.
@Test
public void testDisableOneFilter() {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(Collections.singletonList(ReadFilterLibrary.GOOD_CIGAR))));
clp.parseArguments(nullMessageStream, new String[] { "--RF", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "--RF", ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), "-disableReadFilter", ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName() });
// get the command line read filters
GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
List<ReadFilter> readFilters = readFilterPlugin.getAllInstances();
Assert.assertEquals(readFilters.size(), 2);
Assert.assertEquals(readFilters.get(0).getClass().getSimpleName(), ReadFilterLibrary.MAPPED.getClass().getSimpleName());
Assert.assertEquals(readFilters.get(1).getClass().getSimpleName(), ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName());
Assert.assertEquals(readFilterPlugin.userArgs.getUserDisabledReadFilterNames().size(), 1);
Assert.assertTrue(readFilterPlugin.userArgs.getUserDisabledReadFilterNames().contains(ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName()));
Assert.assertTrue(readFilterPlugin.isDisabledFilter(ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName()));
}
Aggregations