use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDependentFilterArguments.
// fail if a filter with required arguments is specified without corresponding arguments
@Test(dataProvider = "filtersWithRequiredArguments", expectedExceptions = CommandLineException.MissingArgument.class)
public void testDependentFilterArguments(final String filter, //unused
final String argName, //unused
final String argValue) {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
String[] args = { // no args, just enable filters
"--readFilter", // no args, just enable filters
filter };
clp.parseArguments(nullMessageStream, args);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testGetAllowedValuesForDescriptorArgument.
@Test(dataProvider = "defaultFiltersForAllowedValues")
public void testGetAllowedValuesForDescriptorArgument(final List<ReadFilter> defaultFilters) {
final CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(defaultFilters)));
clp.parseArguments(nullMessageStream, new String[] {});
final GATKReadFilterPluginDescriptor pluginDescriptor = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
// the help for disableReadFilter should point out to the default filters in the order provided
Assert.assertEquals(pluginDescriptor.getAllowedValuesForDescriptorArgument("disableReadFilter"), defaultFilters.stream().map(rf -> rf.getClass().getSimpleName()).collect(Collectors.toSet()));
// test if the help for readFilter is not empty after parsing: if custom validation throws, the help should print the readFilter available
// the complete set could not checked because that requires to discover all the implemented filters
Assert.assertFalse(pluginDescriptor.getAllowedValuesForDescriptorArgument("readFilter").isEmpty());
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testFilterArguments.
@Test(dataProvider = "filtersWithFilteringArguments")
public void testFilterArguments(final String filter, final Consumer<SetupTest> setup, final String argName, final String argValue) {
final SAMFileHeader header = createHeaderWithReadGroups();
final GATKRead read = simpleGoodRead(header);
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
String[] args = { "--readFilter", filter, argName, argValue };
clp.parseArguments(nullMessageStream, args);
ReadFilter rf = instantiateFilter(clp, header);
// to ensure that the filter is actually working, verify that the test record
// we're using fails the filter test *before* we set it up to pass the filter
Assert.assertFalse(rf.test(read));
// setup the header and read for the test
setup.accept(new SetupTest(header, read, argValue));
Assert.assertTrue(rf.test(read));
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testNoFiltersSpecified.
@Test
public void testNoFiltersSpecified() {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
clp.parseArguments(nullMessageStream, new String[] {});
// get the command line read filters
final GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
final List<ReadFilter> readFilters = readFilterPlugin.getAllInstances();
Assert.assertEquals(readFilters.size(), 0);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisableNotEnabledFilter.
@Test
public void testDisableNotEnabledFilter() {
GATKReadFilterPluginDescriptor rfDesc = new GATKReadFilterPluginDescriptor(null);
final CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(rfDesc));
final String filterName = ReadFilterLibrary.MAPPED.getClass().getSimpleName();
clp.parseArguments(nullMessageStream, new String[] { "-disableReadFilter", filterName });
// Make sure mapped filter got disabled with no exception
Assert.assertTrue(rfDesc.userArgs.getUserDisabledReadFilterNames().contains(filterName));
Assert.assertTrue(rfDesc.isDisabledFilter(filterName));
}
Aggregations