-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
making optimizations to funcotator #4740
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this method guaranteed to wrap the stream in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
} | ||
|
||
// ============================================================================================================ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't you end up with an empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After discussing in person with @lbergelson, we decided that we don't know enough about the data to add extra safety checks here. If leading whitespace is typical/common rather than an error condition, we don't want to overly-strict extra checks for empty keys. |
||
|
||
// 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; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add javadoc for method args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done