Disallow tabix indices for non-BGZIP inputs - #1101
Conversation
| */ | ||
| public WFIterator() throws IOException { | ||
| final InputStream inputStream = ParsingUtils.openInputStream(path, wrapper); | ||
| final InputStream inputStream = new BufferedInputStream(ParsingUtils.openInputStream(path, wrapper), 512000); |
There was a problem hiding this comment.
what's this magic number? can it be named as a constant?
| Assert.assertEquals(featureReader.query("2", 190, 210).toList().size(), 1); | ||
| Function<SeekableByteChannel, SeekableByteChannel> indexWrapper, | ||
| boolean useTribbleReader) throws IOException, URISyntaxException { | ||
| if (index!=null) { |
| // Test for tabix index | ||
| if (methods.isTabix(featureResource, indexResource)) { | ||
| // Test for BGZF formatted file | ||
| if (methods.isTabix(featureResource, SeekableStreamFactory.getInstance().getBufferedStream(SeekableStreamFactory.getInstance().getStreamFor(featureResource, wrapper)), indexResource)) { |
There was a problem hiding this comment.
lets extract this stream creation and put it in the try () if possible
| return hasBlockCompressedExtension(resourcePath) && ParsingUtils.resourceExists(indexPath); | ||
| boolean isBGZF = isBGZFFile(inputStream); | ||
| boolean hasIndex = ParsingUtils.resourceExists(indexPath); | ||
| if (hasIndex && !isBGZF && indexPath.endsWith(TabixUtils.STANDARD_INDEX_EXTENSION)) { |
There was a problem hiding this comment.
this seems wrong to throw in the isTabix method
| Assert.assertEquals(count, 12218); | ||
| } | ||
| } | ||
|
|
|
could you use a non-compressed VCF input and compress it in the different ways you want as part of the tests? |
|
|
||
| public static boolean isTabix(String resourcePath, String indexPath) throws IOException { | ||
| if(indexPath == null){ | ||
| try (SeekableStream inputStream = SeekableStreamFactory.getInstance().getStreamFor(resourcePath)) { |
There was a problem hiding this comment.
if this throws IOException it's better to just propagate it rather than suppress it to false I think.
|
bump |
|
split out the buffered index part so that we can think harder about the exception throwing... |
| public static boolean isTabix(String resourcePath, String indexPath) throws IOException { | ||
| if(indexPath == null){ | ||
| try (SeekableStream inputStream = SeekableStreamFactory.getInstance().getStreamFor(resourcePath)) { | ||
| return isTabix(resourcePath, inputStream,indexPath); |
There was a problem hiding this comment.
| return isTabix(resourcePath, inputStream,indexPath); | |
| return isTabix(resourcePath, inputStream, indexPath); |
| boolean isBGZF = isBGZFFile(inputStream); | ||
| boolean hasIndex = ParsingUtils.resourceExists(indexPath); | ||
| if (hasIndex && !isBGZF && indexPath.endsWith(TabixUtils.STANDARD_INDEX_EXTENSION)) { | ||
| throw new TribbleException(String.format("Detected Tabix index for file %s, but the file does not appear to be compressed in BGZF format", resourcePath)); |
There was a problem hiding this comment.
How about you return false here and log a warning explaining the situation?
|
what's going on with this PR? it has conflicts and no responses to review comments. |
Description
rebased copy of #1079