Skip to content

Commit

Permalink
Addressing @droazen comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonn-smith committed Sep 13, 2018
1 parent 76f87ec commit cbed1ec
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 101 deletions.
34 changes: 2 additions & 32 deletions src/main/java/org/broadinstitute/hellbender/engine/GATKTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -862,20 +862,6 @@ record = header.getProgramRecord(pgID);
return pgID;
}

/**
* Call {@link GATKTool#addFeatureInputsAfterInitialization(String, String, Class, int)} with no caching.
*
* @param filePath See {@link #addFeatureInputsAfterInitialization(String, String, Class, int)}
* @param name See {@link #addFeatureInputsAfterInitialization(String, String, Class, int)}
* @param featureType See {@link #addFeatureInputsAfterInitialization(String, String, Class, int)}
* @return The {@link FeatureInput} used as the key for this data source.
*/
public FeatureInput<? extends Feature> addFeatureInputsAfterInitialization(final String filePath, final String name,
final Class<? extends Feature> featureType) {

return addFeatureInputsAfterInitialization(filePath, name, featureType, 0);
}

/**
* A method to allow a user to inject data sources after initialization that were not specified as command-line
* arguments.
Expand All @@ -893,24 +879,6 @@ public FeatureInput<? extends Feature> addFeatureInputsAfterInitialization(final

final FeatureInput<? extends Feature> featureInput = new FeatureInput<>(filePath, name);

//Add datasource to the feature manager too so that it can be queried. Setting lookahead to user's requested value.
addFeatureInputsAfterInitialization(featureInput, featureType, featureQueryLookahead);

return featureInput;
}

/**
* A method to allow a user to inject data sources after initialization that were not specified as command-line
* arguments.
*
* @param featureInput
* @param featureType class of feature in the feature input
* @param featureQueryLookahead look ahead this many bases during queries that produce cache misses
* @return The {@link FeatureInput} used as the key for this data source.
*/
public void addFeatureInputsAfterInitialization(final FeatureInput<? extends Feature> featureInput,
final Class<? extends Feature> featureType,
final int featureQueryLookahead) {
// Add datasource to the feature manager too so that it can be queried.
// Setting lookahead to user-requested value:
features.addToFeatureSources(
Expand All @@ -921,6 +889,8 @@ public void addFeatureInputsAfterInitialization(final FeatureInput<? extends Fea
cloudIndexPrefetchBuffer,
referenceArguments.getReferencePath()
);

return featureInput;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,25 @@ public void onTraversalStart() {
funcotatorArgs.dataSourceDirectories.sort(Comparator.naturalOrder());
final Map<Path, Properties> configData = DataSourceUtils.getAndValidateDataSourcesFromPaths(funcotatorArgs.referenceVersion, funcotatorArgs.dataSourceDirectories);

// Create the metadata directly from the input.
funcotatorEngine = new FuncotatorEngine(VcfFuncotationMetadata.create(new ArrayList<>(getHeaderForVariants().getInfoHeaderLines())),
DataSourceUtils.createDataSourceFuncotationFactoriesForDataSources(configData, annotationOverridesMap,
funcotatorArgs.transcriptSelectionMode, finalUserTranscriptIdSet));

// Note that the next line has the effect of registering the FeatureInputs with the engine (via addFeatureInputsAfterInitialization).
// If a funcotation factory feature input (i.e. the source file as a feature input) is null, then the funcotation
// factory is not locatable.
funcotatorEngine.getFuncotationFactories().stream()
.filter(ff -> ff.getMainSourceFileAsFeatureInput() != null)
.forEach(ff -> addFeatureInputsAfterInitialization(ff.getMainSourceFileAsFeatureInput(), ff.getAnnotationFeatureClass(), funcotatorArgs.lookaheadFeatureCachingInBp));
// Create the data sources from the input:
// This will also create and register the FeatureInputs (created by the Data Sources)
// with the GATK Engine, so we do not have to plumb them in after the fact.
final List<DataSourceFuncotationFactory> dataSourceFuncotationFactories = DataSourceUtils.createDataSourceFuncotationFactoriesForDataSources(
configData,
annotationOverridesMap,
funcotatorArgs.transcriptSelectionMode,
finalUserTranscriptIdSet,
this,
funcotatorArgs.lookaheadFeatureCachingInBp
);

// Create our engine to do our work and drive this Funcotation train!
funcotatorEngine = new FuncotatorEngine(
VcfFuncotationMetadata.create(
new ArrayList<>(getHeaderForVariants().getInfoHeaderLines())
),
dataSourceFuncotationFactories
);

// Determine which annotations are accounted for (by the funcotation factories) and which are not.
final LinkedHashMap<String, String> unaccountedForDefaultAnnotations = getUnaccountedForAnnotations( funcotatorEngine.getFuncotationFactories(), annotationDefaultsMap );
Expand Down
Loading

0 comments on commit cbed1ec

Please sign in to comment.