Skip to content

Commit

Permalink
Item #1 -- remove instanceof call and let every GATKTool have default
Browse files Browse the repository at this point in the history
GenomicsDB options
  • Loading branch information
ldgauthier committed Aug 2, 2019
1 parent 5fd4d9b commit c41b05d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ public FeatureManager(final CommandLineProgram toolInstance, final int featureQu
* the end of query intervals in anticipation of future queries (>= 0).
* @param cloudPrefetchBuffer MB size of caching/prefetching wrapper for the data, if on Google Cloud (0 to disable).
* @param cloudIndexPrefetchBuffer MB size of caching/prefetching wrapper for the index, if on Google Cloud (0 to disable).
* @param reference reference to use when opening feature files, may be null, currently only used by Genomics DB
* @param gdbOptions settings for GenomicsDB to use when reading from a GenomicsDB workspace
*
*/
public FeatureManager(final CommandLineProgram toolInstance, final int featureQueryLookahead, final int cloudPrefetchBuffer, final int cloudIndexPrefetchBuffer, final Path reference) {
public FeatureManager(final CommandLineProgram toolInstance, final int featureQueryLookahead, final int cloudPrefetchBuffer, final int cloudIndexPrefetchBuffer, final GenomicsDBOptions gdbOptions) {
this.toolInstanceSimpleClassName = toolInstance.getClass().getSimpleName();
this.featureSources = new LinkedHashMap<>();

initializeFeatureSources(featureQueryLookahead, toolInstance, cloudPrefetchBuffer, cloudIndexPrefetchBuffer, reference);
initializeFeatureSources(featureQueryLookahead, toolInstance, cloudPrefetchBuffer, cloudIndexPrefetchBuffer, gdbOptions);
}

/**
Expand Down Expand Up @@ -193,7 +193,7 @@ public FeatureManager(final CommandLineProgram toolInstance, final int featureQu
* @param cloudIndexPrefetchBuffer MB size of caching/prefetching wrapper for the index, if on Google Cloud (0 to disable).
*/
@SuppressWarnings({"unchecked", "rawtypes"})
private void initializeFeatureSources( final int featureQueryLookahead, final CommandLineProgram toolInstance, final int cloudPrefetchBuffer, final int cloudIndexPrefetchBuffer, final Path reference) {
private void initializeFeatureSources( final int featureQueryLookahead, final CommandLineProgram toolInstance, final int cloudPrefetchBuffer, final int cloudIndexPrefetchBuffer, final GenomicsDBOptions gdbOptions) {

// Discover all arguments of type FeatureInput (or Collections thereof) in our tool's class hierarchy
// (and associated ArgumentCollections). Arguments not specified by the user on the command line will
Expand All @@ -208,7 +208,7 @@ private void initializeFeatureSources( final int featureQueryLookahead, final Co
if ( featureInput != null ) {
final Class<? extends Feature> featureType = getFeatureTypeForFeatureInputField(featureArgument.getKey());
addToFeatureSources(featureQueryLookahead, featureInput, featureType, cloudPrefetchBuffer, cloudIndexPrefetchBuffer,
toolInstance instanceof VariantWalker ? ((VariantWalker) toolInstance).getGenomicsDBOptions() : null);
gdbOptions);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/broadinstitute/hellbender/engine/GATKTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ protected List<SimpleInterval> transformTraversalIntervals(final List<SimpleInte
}

/**
*
* @return By default, not every GATK tool can read from a GenomicsDB -- child classes can override
* Get the GenomicsDB read settings for the current tool
* @return By default, just return the vanilla options
*/
protected GenomicsDBOptions getGenomicsDBOptions() {
throw new IllegalArgumentException("This tool does not take a GenomicsDB as a feature input.");
return new GenomicsDBOptions(referenceArguments.getReferencePath());
}

/**
Expand Down Expand Up @@ -481,8 +481,8 @@ private boolean hasCramInput() {
* By default, this method initializes the FeatureManager to use the lookahead cache of {@link FeatureDataSource#DEFAULT_QUERY_LOOKAHEAD_BASES} bases.
*/
void initializeFeatures() {
features = new FeatureManager(this, FeatureDataSource.DEFAULT_QUERY_LOOKAHEAD_BASES, cloudPrefetchBuffer, cloudIndexPrefetchBuffer,
referenceArguments.getReferencePath());
features = new FeatureManager(this, FeatureDataSource.DEFAULT_QUERY_LOOKAHEAD_BASES, cloudPrefetchBuffer,
cloudIndexPrefetchBuffer, getGenomicsDBOptions());
if ( features.isEmpty() ) { // No available sources of Features discovered for this tool
features = null;
}
Expand Down

0 comments on commit c41b05d

Please sign in to comment.