use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser 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.barclay.argparser.CommandLineArgumentParser 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.barclay.argparser.CommandLineArgumentParser 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.barclay.argparser.CommandLineArgumentParser 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));
}
use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.
the class GATKToolUnitTest method testFeaturesHeader.
@Test
public void testFeaturesHeader() throws Exception {
final TestGATKToolWithFeatures tool = new TestGATKToolWithFeatures();
final CommandLineParser clp = new CommandLineArgumentParser(tool);
final File vcfFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/feature_data_source_test_with_bigHeader.vcf");
final String[] args = { "--mask", vcfFile.getCanonicalPath() };
clp.parseArguments(System.out, args);
tool.onStartup();
final Object headerForFeatures = tool.getHeaderForFeatures(tool.mask);
Assert.assertTrue(headerForFeatures instanceof VCFHeader);
final VCFHeader vcfheaderForFeatures = (VCFHeader) headerForFeatures;
try (final VCFFileReader vcfReader = new VCFFileReader(vcfFile, false)) {
//read the file directly and compare headers
final VCFHeader vcfFileHeader = vcfReader.getFileHeader();
Assert.assertEquals(vcfheaderForFeatures.getGenotypeSamples(), vcfFileHeader.getGenotypeSamples());
Assert.assertEquals(vcfheaderForFeatures.getInfoHeaderLines(), vcfFileHeader.getInfoHeaderLines());
Assert.assertEquals(vcfheaderForFeatures.getFormatHeaderLines(), vcfFileHeader.getFormatHeaderLines());
Assert.assertEquals(vcfheaderForFeatures.getFilterLines(), vcfFileHeader.getFilterLines());
Assert.assertEquals(vcfheaderForFeatures.getContigLines(), vcfFileHeader.getContigLines());
Assert.assertEquals(vcfheaderForFeatures.getOtherHeaderLines(), vcfFileHeader.getOtherHeaderLines());
}
tool.doWork();
tool.onShutdown();
}
Aggregations