use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.
the class VariantWalkerIntegrationTest method testBestSequenceDictionary_FromVariantIndex.
@Test
public void testBestSequenceDictionary_FromVariantIndex() throws Exception {
final GATKTool tool = new TestGATKToolWithFeatures();
final CommandLineParser clp = new CommandLineArgumentParser(tool);
final File vcfFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/example_variants_noSequenceDict.vcf");
final String[] args = { "--variant", vcfFile.getCanonicalPath() };
clp.parseArguments(System.out, args);
tool.onStartup();
// make sure we get the seq dict from the index when there isn't one in the VCF and there is no reference available
final SAMSequenceDictionary toolDict = tool.getBestAvailableSequenceDictionary();
Assert.assertTrue(toolDict.getSequences().stream().allMatch(seqRec -> seqRec.getSequenceLength() == 0));
}
use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser 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.barclay.argparser.CommandLineArgumentParser 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.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.
the class GATKToolUnitTest method testDisallowLexicographicallySortedVariantHeader_ifClashWithReference.
@Test(expectedExceptions = UserException.IncompatibleSequenceDictionaries.class)
public void testDisallowLexicographicallySortedVariantHeader_ifClashWithReference() throws Exception {
final GATKTool tool = new TestGATKToolWithFeatures();
final CommandLineParser clp = new CommandLineArgumentParser(tool);
final File vcfFile = new File(publicTestDir + "org/broadinstitute/hellbender/engine/lexicographically_sorted_dict.vcf");
final String[] args = { "--mask", vcfFile.getCanonicalPath(), "--reference", hg19MiniReference };
clp.parseArguments(System.out, args);
// This method throws despite the lexicographically-sorted sequence dictionary in the vcf.
//This is because the reference sequence dictionary clashes with the one from the VCF.
tool.onStartup();
}
use of org.broadinstitute.barclay.argparser.CommandLineArgumentParser in project gatk by broadinstitute.
the class FeatureInputArgumentCollectionTest method testOptionalIsOptional.
@Test
public void testOptionalIsOptional() {
Object req = new Object() {
@ArgumentCollection
private OptionalFeatureInputArgumentCollection ric = new OptionalFeatureInputArgumentCollection();
};
CommandLineParser clp = new CommandLineArgumentParser(req);
String[] args = {};
clp.parseArguments(System.out, args);
}
Aggregations