use of org.broadinstitute.barclay.argparser.CommandLineParser 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.barclay.argparser.CommandLineParser 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.barclay.argparser.CommandLineParser 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.barclay.argparser.CommandLineParser 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()));
}
use of org.broadinstitute.barclay.argparser.CommandLineParser in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisableDefaultsAndReorderWithUserEnabledFirts.
@Test
public void testDisableDefaultsAndReorderWithUserEnabledFirts() {
final ReadLengthReadFilter rlrf = new ReadLengthReadFilter(2, 10);
GATKReadFilterPluginDescriptor rfDesc = new GATKReadFilterPluginDescriptor(Arrays.asList(rlrf, ReadFilterLibrary.MAPPED));
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(rfDesc));
clp.parseArguments(nullMessageStream, new String[] { "--disableToolDefaultReadFilters", "--readFilter", ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName(), "--readFilter", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "--readFilter", ReadLengthReadFilter.class.getSimpleName() });
List<ReadFilter> allFilters = rfDesc.getAllInstances();
// User filter is first according to the command line
Assert.assertSame(allFilters.get(0).getClass(), ReadFilterLibrary.GOOD_CIGAR.getClass());
// default filters are exactly the same object
Assert.assertSame(allFilters.get(1), ReadFilterLibrary.MAPPED);
ReadLengthReadFilter rf = (ReadLengthReadFilter) allFilters.get(2);
Assert.assertSame(rf, rlrf);
// and the state is the same as in the provided default
Assert.assertEquals(rf.minReadLength, 2);
Assert.assertEquals(rf.maxReadLength.intValue(), 10);
}
Aggregations