use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor 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);
}
use of org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor 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.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor 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.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor 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.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor 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());
}
Aggregations