use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisabledNonDefaultFilterWithArgsProvided.
@Test(expectedExceptions = CommandLineException.class)
public void testDisabledNonDefaultFilterWithArgsProvided() {
// test for arguments provided for a non-default filter that is also disabled
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(Collections.emptyList())));
clp.parseArguments(nullMessageStream, new String[] { "--disableReadFilter", SampleReadFilter.class.getSimpleName(), "--sample", "fred" });
// get the command line read filters
clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
}
use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisableDuplicateFilter.
@Test(dataProvider = "duplicateDisabledFilters", expectedExceptions = CommandLineException.BadArgumentValue.class)
public void testDisableDuplicateFilter(final List<ReadFilter> defaults, final String[] arguments) {
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(defaults)));
clp.parseArguments(nullMessageStream, arguments);
}
use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testEnableMultipleFilters.
@Test
public void testEnableMultipleFilters() {
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", "102", "--readFilter", ReadNameReadFilter.class.getSimpleName(), "--readName", "fred" };
clp.parseArguments(nullMessageStream, args);
ReadFilter rf = instantiateFilter(clp, header);
// default read name is rejected by the readName filter
Assert.assertFalse(rf.test(read));
String readName = read.getName();
read.setName("fred");
// accepted
Assert.assertTrue(rf.test(read));
// trigger the read length filter to reject
read.setBases(new byte[150]);
Assert.assertFalse(rf.test(read));
}
use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.
the class ReadFilterPluginUnitTest method testDisableMultipleFilters.
@Test
public void testDisableMultipleFilters() {
List<ReadFilter> defaultFilters = new ArrayList<>();
defaultFilters.add(ReadFilterLibrary.GOOD_CIGAR);
defaultFilters.add(ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS);
CommandLineParser clp = new CommandLineArgumentParser(new Object(), Collections.singletonList(new GATKReadFilterPluginDescriptor(defaultFilters)));
clp.parseArguments(nullMessageStream, new String[] { "--RF", ReadFilterLibrary.MAPPED.getClass().getSimpleName(), "-disableReadFilter", ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName(), "-disableReadFilter", ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName() });
// get the command line read filters
GATKReadFilterPluginDescriptor readFilterPlugin = clp.getPluginDescriptor(GATKReadFilterPluginDescriptor.class);
List<ReadFilter> readFilters = readFilterPlugin.getAllInstances();
Assert.assertEquals(readFilters.size(), 1);
Assert.assertEquals(readFilters.get(0).getClass().getSimpleName(), ReadFilterLibrary.MAPPED.getClass().getSimpleName());
Assert.assertEquals(readFilterPlugin.userArgs.getUserDisabledReadFilterNames().size(), 2);
Assert.assertTrue(readFilterPlugin.userArgs.getUserDisabledReadFilterNames().contains(ReadFilterLibrary.GOOD_CIGAR.getClass().getSimpleName()));
Assert.assertTrue(readFilterPlugin.userArgs.getUserDisabledReadFilterNames().contains(ReadFilterLibrary.HAS_MATCHING_BASES_AND_QUALS.getClass().getSimpleName()));
ReadFilter rf = instantiateFilter(clp, createHeaderWithReadGroups());
Assert.assertEquals(rf.getClass().getSimpleName(), ReadFilterLibrary.MAPPED.getClass().getSimpleName());
}
use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser 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);
}
Aggregations