diff --git a/src/main/java/org/broadinstitute/hellbender/engine/GATKTool.java b/src/main/java/org/broadinstitute/hellbender/engine/GATKTool.java index b60cef34843..559125c58c5 100644 --- a/src/main/java/org/broadinstitute/hellbender/engine/GATKTool.java +++ b/src/main/java/org/broadinstitute/hellbender/engine/GATKTool.java @@ -805,18 +805,24 @@ record = header.getProgramRecord(pgID); /** * A method to allow a user to inject data sources after initialization that were not specified as command-line * arguments. + * + * @param filePath path to the Feature file to register + * @param name what to call the Feature input + * @param featureType class of features + * @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. */ protected FeatureInput addFeatureInputsAfterInitialization(final String filePath, final String name, - final Class featureType) { + final Class featureType, + final int featureQueryLookahead) { - final FeatureInput featureInput = new FeatureInput<>(name + FeatureInput.FEATURE_ARGUMENT_TAG_DELIMITER + filePath); + final FeatureInput featureInput = new FeatureInput<>(filePath, name); //Add datasource to the feature manager too so that it can be queried. Setting lookahead to 0 to avoid caching. //Note: we are disabling lookahead here because of windowed queries that need to "look behind" as well. features.addToFeatureSources( - 0, + featureQueryLookahead, featureInput, featureType, cloudPrefetchBuffer, diff --git a/src/main/java/org/broadinstitute/hellbender/tools/funcotator/Funcotator.java b/src/main/java/org/broadinstitute/hellbender/tools/funcotator/Funcotator.java index 3fb50d3acf2..604040c8f60 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/funcotator/Funcotator.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/funcotator/Funcotator.java @@ -211,7 +211,7 @@ public class Funcotator extends VariantWalker { /** * The current version of {@link Funcotator}. */ - public static final String VERSION = "0.0.2"; + public static final String VERSION = "0.0.3"; //================================================================================================================== // Arguments: @@ -568,9 +568,9 @@ private void initializeManualFeaturesForLocatableDataSources(final Map featureClazz ) { + private void addFeaturesForLocatableDataSource(final Path dataSourceFile, + final Properties dataSourceProperties, + final Class featureClazz) { final String name = dataSourceProperties.getProperty(DataSourceUtils.CONFIG_FILE_FIELD_NAME_NAME); @@ -580,7 +580,8 @@ private void addFeaturesForLocatableDataSource( final Path dataSourceFile, IOUtils.getPath( dataSourceProperties.getProperty(DataSourceUtils.CONFIG_FILE_FIELD_NAME_SRC_FILE) ) ).toUri().toString(), name, - featureClazz + featureClazz, + VariantWalkerBase.FEATURE_CACHE_LOOKAHEAD ); // Add our feature input to our list of manual inputs: diff --git a/src/main/java/org/broadinstitute/hellbender/utils/codecs/gencode/GencodeGtfCodec.java b/src/main/java/org/broadinstitute/hellbender/utils/codecs/gencode/GencodeGtfCodec.java index 49de36cc383..1bffc29e8e9 100644 --- a/src/main/java/org/broadinstitute/hellbender/utils/codecs/gencode/GencodeGtfCodec.java +++ b/src/main/java/org/broadinstitute/hellbender/utils/codecs/gencode/GencodeGtfCodec.java @@ -139,16 +139,9 @@ public FeatureCodecHeader readHeader(final LineIterator lineIterator) throws IOE return new FeatureCodecHeader(readActualHeader(lineIterator), FeatureCodecHeader.NO_HEADER_END); } - @SuppressWarnings( "deprecation" ) @Override public LocationAware makeIndexableSourceFromStream(final InputStream bufferedInputStream) { - final PositionalBufferedStream pbs; - if (bufferedInputStream instanceof PositionalBufferedStream) { - pbs = (PositionalBufferedStream) bufferedInputStream; - } else { - pbs = new PositionalBufferedStream(bufferedInputStream); - } - return new AsciiLineReaderIterator(new AsciiLineReader(pbs)); + return new AsciiLineReaderIterator(AsciiLineReader.from(bufferedInputStream)); } // ============================================================================================================ diff --git a/src/main/java/org/broadinstitute/hellbender/utils/codecs/gencode/GencodeGtfFeature.java b/src/main/java/org/broadinstitute/hellbender/utils/codecs/gencode/GencodeGtfFeature.java index 3436f6f5348..b5cb43eee06 100644 --- a/src/main/java/org/broadinstitute/hellbender/utils/codecs/gencode/GencodeGtfFeature.java +++ b/src/main/java/org/broadinstitute/hellbender/utils/codecs/gencode/GencodeGtfFeature.java @@ -4,6 +4,7 @@ import htsjdk.samtools.util.Locatable; import htsjdk.tribble.Feature; import htsjdk.tribble.annotation.Strand; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.broadinstitute.hellbender.exceptions.UserException; @@ -108,23 +109,26 @@ protected GencodeGtfFeature(final String[] gtfFields) { // But we need to match up the field names to the fields themselves: for ( final String extraField : extraFields ) { - final String[] fieldParts = extraField.trim().split(EXTRA_FIELD_KEY_VALUE_SPLITTER); + final String trimmedExtraField = extraField.trim(); + if (trimmedExtraField.isEmpty()) { + continue; + } - if ( fieldParts.length == 1 ){ - if ( fieldParts[EXTRA_FIELD_KEY_INDEX].isEmpty() ){ - continue; - } - else { - throw new UserException.MalformedFile("Extraneous optional field data - not in a key/value pair: " + extraField); - } + final int splitPoint = trimmedExtraField.indexOf(EXTRA_FIELD_KEY_VALUE_SPLITTER); + if( splitPoint == -1 ) { + throw new UserException.MalformedFile("Extraneous optional field data - not in a key/value pair: " + extraField); } - // Each optional field is in a key/value pair: - final String fieldName = fieldParts[EXTRA_FIELD_KEY_INDEX].trim(); + final String fieldName = trimmedExtraField.substring(0, splitPoint).trim(); // The value of the field may be between two quotes. // We remove them here. - final String fieldValue = fieldParts[EXTRA_FIELD_VALUE_INDEX].trim().replaceAll("\"", ""); + final String rawFieldValue = trimmedExtraField.substring(splitPoint + 1, trimmedExtraField.length()); + final String fieldValue = StringUtils.remove(rawFieldValue.trim(), '"'); + + if( fieldValue.contains(EXTRA_FIELD_KEY_VALUE_SPLITTER) ){ + throw new UserException("Expected a key/value pair but found several values " + fieldName + "/" + fieldValue); + } OptionalField optionalField = null;