Skip to content

Commit

Permalink
PrintBGZFBlockInformation: remove file extension check so that we can…
Browse files Browse the repository at this point in the history
… accept, eg., bams

The file extension check in this tool was redundant, since there is a subsequent check
that the input file is in BGZF format.

Resolves #5800
  • Loading branch information
droazen committed Mar 15, 2019
1 parent 811e72a commit 6161839
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ protected void onStartup() {
throw new UserException.CouldNotReadInputFile("File " + bgzfPathString + " does not exist");
}

if ( ! IOUtil.hasBlockCompressedExtension(bgzfPathString) ) {
throw new UserException.CouldNotReadInputFile("File " + bgzfPathString + " does not end in a recognized BGZF file extension (" +
StringUtils.join(IOUtil.BLOCK_COMPRESSED_EXTENSIONS, ",") + ")");
}

try {
// Check that the file is in BGZF format. This catches the "regular GZIP" case as well:
if ( ! IOUtil.isBlockCompressed(bgzfPath) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,20 @@ public void testRegularGzipFile() throws IOException {
};
runCommandLine(args);
}

/* Make sure that we can handle a standard BAM file */
@Test
public void testBamFile() throws IOException {
final File input = new File(packageRootTestDir + "engine/reads_data_source_test1.bam");
final File actualOutput = createTempFile("PrintBGZFBlockInformationIntegrationTest_testBamFile", ".out");
final File expectedOutput = new File(toolsTestDir + "PrintBGZFBlockInformation/expected_PrintBGZFBlockInformationIntegrationTest_testBamFile.out");

final String[] args = {
"--bgzf-file", input.getAbsolutePath(),
"--" + StandardArgumentDefinitions.OUTPUT_LONG_NAME, actualOutput.getAbsolutePath()
};
runCommandLine(args);

IntegrationTestSpec.assertEqualTextFiles(actualOutput, expectedOutput);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BGZF block information for file: reads_data_source_test1.bam

Block #1 at file offset 0
- compressed size: 380
- uncompressed size: 1971

Block #2 at file offset 380
- compressed size: 28
- uncompressed size: 0

***************************************************************************
Final BGZF 0-byte terminator block FOUND as expected at block number 2
***************************************************************************

0 comments on commit 6161839

Please sign in to comment.