use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDanglingFilterArguments.
// fail if a filter's arguments are passed but the filter itself is not enabled
@Test(dataProvider = "filtersWithRequiredArguments", expectedExceptions = CommandLineException.class)
public void testDanglingFilterArguments(final String filter, final String argName, final String argValue) {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
// no read filter set
String[] args = { argName, argValue };
// no need to instantiate the filters - dependency errors are caught by the command line parser
clp.parseArguments(nullMessageStream, args);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testPreserveCommandLineOrder.
@Test
public void testPreserveCommandLineOrder() {
List<ReadFilter> orderedDefaults = new ArrayList<>();
orderedDefaults.add(new WellformedReadFilter());
orderedDefaults.add(ReadFilterLibrary.HAS_READ_GROUP);
orderedDefaults.add(ReadFilterLibrary.MAPPING_QUALITY_NOT_ZERO);
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(orderedDefaults)));
clp.parseArguments(nullMessageStream, new String[] { "-readFilter", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "-readFilter", ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), "-readFilter", ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName() });
GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
// get and verify the list of filters enabled on the command line (not including defaults)
List<ReadFilter> orderedFilters = readFilterPlugin.getAllInstances();
Assert.assertEquals(orderedFilters.size(), 3);
Assert.assertEquals(orderedFilters.get(0).getClass().getSimpleName(), ReadFilterLibrary.MAPPED.getClass().getSimpleName());
Assert.assertEquals(orderedFilters.get(1).getClass().getSimpleName(), ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName());
Assert.assertEquals(orderedFilters.get(2).getClass().getSimpleName(), 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 validate by reaching inside the filter and navigating 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.MAPPED.getClass().getSimpleName(), ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName(), ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName() };
int count = ReadFilterUnitTest.verifyAndFilterOrder(rf, expectedOrder);
Assert.assertEquals(count, 6);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisabledDefaultWithArgsProvided.
// Disabled due to https://github.com/broadinstitute/barclay/issues/23
// For now this will just generate a warning, but it should throw
@Test(expectedExceptions = CommandLineException.class, enabled = false)
public void testDisabledDefaultWithArgsProvided() {
// test for arguments provided for a default filter that is also disabled
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(Collections.singletonList(new SampleReadFilter()))));
clp.parseArguments(nullMessageStream, new String[] { "--sample", "fred", "-disableReadFilter", SampleReadFilter.class.getSimpleName() });
// get the command line read filters
clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testEnableDuplicateFilter.
@Test(dataProvider = "duplicateFilters", expectedExceptions = CommandLineException.BadArgumentValue.class)
public void testEnableDuplicateFilter(final String[] arguments) {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
clp.parseArguments(nullMessageStream, arguments);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testReadLengthFilter.
@Test
public void testReadLengthFilter() {
final SAMFileHeader header = createHeaderWithReadGroups();
final GATKRead read = simpleGoodRead(header);
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(null)));
String[] args = { "--readFilter", ReadLengthReadFilter.class.getSimpleName(), "--minReadLength", "10", "--maxReadLength", "20" };
clp.parseArguments(nullMessageStream, args);
ReadFilter rf = instantiateFilter(clp, header);
read.setBases(new byte[5]);
Assert.assertFalse(rf.test(read));
read.setBases(new byte[25]);
Assert.assertFalse(rf.test(read));
read.setBases(new byte[15]);
Assert.assertTrue(rf.test(read));
}
Aggregations