From d0c424252d8f5197dcf1c21040b48a972cdadab0 Mon Sep 17 00:00:00 2001 From: Chris Norman Date: Thu, 31 Oct 2019 11:36:16 -0400 Subject: [PATCH 1/3] Cloud-enable IndexFeatureFile. --- .../hellbender/engine/FeatureManager.java | 27 ++-------- .../hellbender/engine/FeatureWalker.java | 2 +- .../hellbender/exceptions/UserException.java | 4 +- .../hellbender/tools/IndexFeatureFile.java | 52 ++++++++++--------- .../engine/FeatureInputUnitTest.java | 2 +- .../engine/FeatureManagerUnitTest.java | 8 +-- .../IndexFeatureFileIntegrationTest.java | 32 ++++++++++-- .../GATKVariantContextUtilsUnitTest.java | 2 +- 8 files changed, 68 insertions(+), 61 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/engine/FeatureManager.java b/src/main/java/org/broadinstitute/hellbender/engine/FeatureManager.java index 57416ca2d48..785c73e5cc5 100644 --- a/src/main/java/org/broadinstitute/hellbender/engine/FeatureManager.java +++ b/src/main/java/org/broadinstitute/hellbender/engine/FeatureManager.java @@ -421,32 +421,11 @@ private FeatureDataSource lookupDataSource( final Feature * an unsupported format), or if more than one codec claims to be able to decode the file (this is * a configuration error on the codec authors' part). * - * @param featureFile file for which to find the right codec + * @param featurePath path for which to find the right codec * @return the codec suitable for decoding the provided file */ - public static FeatureCodec getCodecForFile( final File featureFile ) { - return getCodecForFile(featureFile.toPath(), null); - } - - /** - * Utility method that determines the correct codec to use to read Features from the provided file, - * optionally considering only codecs that produce a particular type of Feature. - * - * Codecs MUST correctly implement the {@link FeatureCodec#canDecode(String)} method - * in order to be considered as candidates for decoding the file, and must produce - * Features of the specified type if featureType is non-null. - * - * Throws an exception if no suitable codecs are found (this is a user error, since the file is of - * an unsupported format), or if more than one codec claims to be able to decode the file (this is - * a configuration error on the codec authors' part). - * - * @param featureFile file for which to find the right codec - * @param featureType If specified, consider only codecs that produce Features of this type. May be null, - * in which case all codecs are considered. - * @return the codec suitable for decoding the provided file - */ - public static FeatureCodec getCodecForFile( final File featureFile, final Class featureType ) { - return getCodecForFile(featureFile.toPath(), featureType); + public static FeatureCodec getCodecForFile( final Path featurePath ) { + return getCodecForFile(featurePath, null); } /** diff --git a/src/main/java/org/broadinstitute/hellbender/engine/FeatureWalker.java b/src/main/java/org/broadinstitute/hellbender/engine/FeatureWalker.java index 6aab39207df..1d82ef22c9b 100644 --- a/src/main/java/org/broadinstitute/hellbender/engine/FeatureWalker.java +++ b/src/main/java/org/broadinstitute/hellbender/engine/FeatureWalker.java @@ -56,7 +56,7 @@ protected final void onStartup() { @SuppressWarnings("unchecked") private void initializeDrivingFeatures() { final File drivingFile = getDrivingFeatureFile(); - final FeatureCodec codec = FeatureManager.getCodecForFile(drivingFile); + final FeatureCodec codec = FeatureManager.getCodecForFile(drivingFile.toPath()); if (isAcceptableFeatureType(codec.getFeatureType())) { drivingFeatures = new FeatureDataSource<>(new FeatureInput<>(drivingFile.getAbsolutePath()), FeatureDataSource.DEFAULT_QUERY_LOOKAHEAD_BASES, null, cloudPrefetchBuffer, cloudIndexPrefetchBuffer, referenceArguments.getReferencePath()); diff --git a/src/main/java/org/broadinstitute/hellbender/exceptions/UserException.java b/src/main/java/org/broadinstitute/hellbender/exceptions/UserException.java index 4ebba13fb17..c43ccd8cc3d 100644 --- a/src/main/java/org/broadinstitute/hellbender/exceptions/UserException.java +++ b/src/main/java/org/broadinstitute/hellbender/exceptions/UserException.java @@ -444,9 +444,9 @@ public HardwareFeatureException(String message, Exception e){ public static final class CouldNotIndexFile extends UserException { private static final long serialVersionUID = 0L; - public CouldNotIndexFile(final File file, final Exception e) { + public CouldNotIndexFile(final Path path, final Exception e) { super(String.format("Error while trying to create index for %s. Error was: %s: %s", - file.getAbsolutePath(), e.getClass().getCanonicalName(), e.getMessage()), e); + path.toString(), e.getClass().getCanonicalName(), e.getMessage()), e); } } diff --git a/src/main/java/org/broadinstitute/hellbender/tools/IndexFeatureFile.java b/src/main/java/org/broadinstitute/hellbender/tools/IndexFeatureFile.java index 2d130b15162..95840cfa3d8 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/IndexFeatureFile.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/IndexFeatureFile.java @@ -14,14 +14,16 @@ import org.broadinstitute.barclay.help.DocumentedFeature; import org.broadinstitute.hellbender.cmdline.CommandLineProgram; import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; +import org.broadinstitute.hellbender.engine.GATKPathSpecifier; import picard.cmdline.programgroups.OtherProgramGroup; import org.broadinstitute.hellbender.engine.FeatureManager; import org.broadinstitute.hellbender.engine.ProgressMeter; import org.broadinstitute.hellbender.exceptions.UserException; import org.broadinstitute.hellbender.utils.codecs.ProgressReportingDelegatingCodec; -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; /** * This tool creates an index file for the various kinds of feature-containing files supported by GATK (such as VCF @@ -47,78 +49,78 @@ public final class IndexFeatureFile extends CommandLineProgram { @Argument(shortName = "F", fullName = "feature-file", doc = "Feature file (eg., VCF or BED file) to index. Must be in a tribble-supported format") - public File featureFile; + public GATKPathSpecifier featurePath; @Argument(shortName = StandardArgumentDefinitions.OUTPUT_SHORT_NAME, fullName = StandardArgumentDefinitions.OUTPUT_LONG_NAME, doc = "The output index file. If missing, the tool will create an index file in the same directory " + "as the input file.", optional = true) - public File outputFile; + public GATKPathSpecifier outputPath; public static final int OPTIMAL_GVCF_INDEX_BIN_SIZE = 128000; public static final String GVCF_FILE_EXTENSION = ".g.vcf"; @Override protected Object doWork() { - if (!featureFile.canRead()) { - throw new UserException.CouldNotReadInputFile(featureFile); + if (!Files.isReadable(featurePath.toPath()) ) { + throw new UserException.CouldNotReadInputFile(featurePath.toPath()); } // Get the right codec for the file to be indexed. This call will throw an appropriate exception // if featureFile is not in a supported format or is unreadable. - final FeatureCodec codec = new ProgressReportingDelegatingCodec<>(FeatureManager.getCodecForFile(featureFile), ProgressMeter.DEFAULT_SECONDS_BETWEEN_UPDATES); + final FeatureCodec codec = new ProgressReportingDelegatingCodec<>( + FeatureManager.getCodecForFile(featurePath.toPath()), ProgressMeter.DEFAULT_SECONDS_BETWEEN_UPDATES); final Index index = createAppropriateIndexInMemory(codec); - final File indexFile = determineFileName(index); + final Path indexPath = determineFileName(index); try { - index.write(indexFile); + index.write(indexPath); } catch (final IOException e) { - throw new UserException.CouldNotCreateOutputFile("Could not write index to file " + indexFile.getAbsolutePath(), e); + throw new UserException.CouldNotCreateOutputFile("Could not write index to file " + indexPath.toAbsolutePath(), e); } - logger.info("Successfully wrote index to " + indexFile.getAbsolutePath()); - return indexFile.getAbsolutePath(); + logger.info("Successfully wrote index to " + indexPath.toAbsolutePath()); + return indexPath.toAbsolutePath().toString(); } - private File determineFileName(final Index index) { - if (outputFile != null) { - return outputFile; + private Path determineFileName(final Index index) { + if (outputPath != null) { + return outputPath.toPath(); } else if (index instanceof TabixIndex) { - return Tribble.tabixIndexFile(featureFile); + return Tribble.tabixIndexPath(featurePath.toPath()); } else { - return Tribble.indexFile(featureFile); + return Tribble.indexPath(featurePath.toPath()); } } private Index createAppropriateIndexInMemory(final FeatureCodec codec) { try { // For block-compression files, write a Tabix index - if (IOUtil.hasBlockCompressedExtension(featureFile)) { + if (IOUtil.hasBlockCompressedExtension(featurePath.toPath())) { // Creating tabix indices with a non standard extensions can cause problems so we disable it - if (outputFile != null && !outputFile.getAbsolutePath().endsWith(FileExtensions.TABIX_INDEX)) { - throw new UserException("The index for " + featureFile + " must be written to a file with a \"" + FileExtensions.TABIX_INDEX + "\" extension"); + if (outputPath != null && !outputPath.getURIString().endsWith(FileExtensions.TABIX_INDEX)) { + throw new UserException("The index for " + featurePath + " must be written to a file with a \"" + FileExtensions.TABIX_INDEX + "\" extension"); } // TODO: this could benefit from provided sequence dictionary from reference // TODO: this can be an optional parameter for the tool - return IndexFactory.createIndex(featureFile, codec, IndexFactory.IndexType.TABIX, null); - + return IndexFactory.createIndex(featurePath.toPath(), codec, IndexFactory.IndexType.TABIX, null); } // TODO: detection of GVCF files should not be file-extension-based. Need to come up with canonical // TODO: way of detecting GVCFs based on the contents (may require changes to the spec!) - else if (featureFile.getName().endsWith(GVCF_FILE_EXTENSION)) { + else if (featurePath.getURIString().endsWith(GVCF_FILE_EXTENSION)) { // Optimize GVCF indices for the use case of having a large number of GVCFs open simultaneously - return IndexFactory.createLinearIndex(featureFile, codec, OPTIMAL_GVCF_INDEX_BIN_SIZE); + return IndexFactory.createLinearIndex(featurePath.toPath(), codec, OPTIMAL_GVCF_INDEX_BIN_SIZE); } else { // Optimize indices for other kinds of files for seek time / querying - return IndexFactory.createDynamicIndex(featureFile, codec, IndexFactory.IndexBalanceApproach.FOR_SEEK_TIME); + return IndexFactory.createDynamicIndex(featurePath.toPath(), codec, IndexFactory.IndexBalanceApproach.FOR_SEEK_TIME); } } catch (TribbleException e) { // Underlying cause here is usually a malformed file, but can also be things like // "codec does not support tabix" - throw new UserException.CouldNotIndexFile(featureFile, e); + throw new UserException.CouldNotIndexFile(featurePath.toPath(), e); } } } diff --git a/src/test/java/org/broadinstitute/hellbender/engine/FeatureInputUnitTest.java b/src/test/java/org/broadinstitute/hellbender/engine/FeatureInputUnitTest.java index 678d69f637f..d2fe8e677da 100644 --- a/src/test/java/org/broadinstitute/hellbender/engine/FeatureInputUnitTest.java +++ b/src/test/java/org/broadinstitute/hellbender/engine/FeatureInputUnitTest.java @@ -255,7 +255,7 @@ private FeatureInput getVariantFeatureInputWithCachedCodec() { final FeatureInput featureInput = new FeatureInput<>(inputVCFFile.getAbsolutePath()); Assert.assertNull(featureInput.getFeatureCodecClass()); - final FeatureCodec codec = FeatureManager.getCodecForFile(new File(featureInput.getFeaturePath())); + final FeatureCodec codec = FeatureManager.getCodecForFile(featureInput.toPath()); featureInput.setFeatureCodecClass((Class>)codec.getClass()); return featureInput; diff --git a/src/test/java/org/broadinstitute/hellbender/engine/FeatureManagerUnitTest.java b/src/test/java/org/broadinstitute/hellbender/engine/FeatureManagerUnitTest.java index eba10f08fb5..972e65537ad 100644 --- a/src/test/java/org/broadinstitute/hellbender/engine/FeatureManagerUnitTest.java +++ b/src/test/java/org/broadinstitute/hellbender/engine/FeatureManagerUnitTest.java @@ -44,13 +44,13 @@ public Object[][] getDetectCorrectFileFormatTestData() { @Test(dataProvider = "DetectCorrectFileFormatTestData") public void testDetectCorrectFileFormat( final File file, final Class> expectedCodecClass ) throws Exception { - Assert.assertEquals(FeatureManager.getCodecForFile(file).getClass(), expectedCodecClass, + Assert.assertEquals(FeatureManager.getCodecForFile(file.toPath()).getClass(), expectedCodecClass, "Wrong codec selected for file " + file.getAbsolutePath()); // We should also get the correct codec if we pass in the explicit expected Feature type to getCodecForFile() @SuppressWarnings("unchecked") final Class expectedCodecFeatureType = expectedCodecClass.getDeclaredConstructor().newInstance().getFeatureType(); - Assert.assertEquals(FeatureManager.getCodecForFile(file, expectedCodecFeatureType).getClass(), expectedCodecClass, + Assert.assertEquals(FeatureManager.getCodecForFile(file.toPath(), expectedCodecFeatureType).getClass(), expectedCodecClass, "Wrong codec selected for file " + file.getAbsolutePath() + " after subsetting to the expected Feature type"); } @@ -62,7 +62,7 @@ public void testDetectUnsupportedFileFormat() { Assert.assertTrue(unsupportedFile.canRead(), "Cannot test detection of unsupported file formats on an unreadable file"); // Should throw, since the file exists and is readable, but is in an unsupported format - FeatureManager.getCodecForFile(unsupportedFile); + FeatureManager.getCodecForFile(unsupportedFile.toPath()); } @Test(expectedExceptions = UserException.WrongFeatureType.class) @@ -70,7 +70,7 @@ public void testRestrictCodecSelectionToWrongFeatureType() { final File vcf = new File(FEATURE_MANAGER_TEST_DIRECTORY + "minimal_vcf4_file.vcf"); // If we require BED Features from this vcf file, we should get a type mismatch exception - FeatureManager.getCodecForFile(vcf, BEDFeature.class); + FeatureManager.getCodecForFile(vcf.toPath(), BEDFeature.class); } @DataProvider(name = "IsFeatureFileTestData") diff --git a/src/test/java/org/broadinstitute/hellbender/tools/IndexFeatureFileIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/IndexFeatureFileIntegrationTest.java index 72bac8277b7..c312d6ef355 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/IndexFeatureFileIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/IndexFeatureFileIntegrationTest.java @@ -8,15 +8,18 @@ import htsjdk.tribble.index.tabix.TabixIndex; import htsjdk.variant.variantcontext.VariantContext; import org.broadinstitute.hellbender.CommandLineProgramTest; +import org.broadinstitute.hellbender.Main; import org.broadinstitute.hellbender.engine.FeatureDataSource; import org.broadinstitute.hellbender.exceptions.UserException; import org.broadinstitute.hellbender.utils.SimpleInterval; +import org.broadinstitute.hellbender.utils.gcs.BucketUtils; import org.testng.Assert; import org.testng.annotations.Test; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -32,6 +35,7 @@ public void testVCFIndex() { "--feature-file" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; + final Object res = this.runCommandLine(args); Assert.assertEquals(res, outName.getAbsolutePath()); @@ -42,6 +46,27 @@ public void testVCFIndex() { checkIndex(index, Arrays.asList("1", "2", "3", "4")); } + @Test(groups={"bucket"}) + public void testVCFIndexOnCloud() throws IOException { + final File testFile = getTestFile("test_variants_for_index.vcf"); + final String vcfOnGCS = BucketUtils.getTempFilePath( + getGCPTestStaging() +"testIndexOnCloud", ".vcf"); + BucketUtils.copyFile(testFile.getAbsolutePath(), vcfOnGCS); + + final String[] args = new String[] { + "IndexFeatureFile", "--feature-file", vcfOnGCS + }; + + new Main().instanceMain(args); + + Assert.assertTrue(BucketUtils.fileExists(vcfOnGCS + ".idx")); + + final Index index = IndexFactory.loadIndex(vcfOnGCS + ".idx"); + Assert.assertTrue(index instanceof LinearIndex); + Assert.assertEquals(index.getSequenceNames(), Arrays.asList("1", "2", "3", "4")); + checkIndex(index, Arrays.asList("1", "2", "3", "4")); + } + @Test public void testVCFIndex_inferredName() { final File ORIG_FILE = getTestFile("test_variants_for_index.vcf"); @@ -50,9 +75,9 @@ public void testVCFIndex_inferredName() { "--feature-file" , ORIG_FILE.getAbsolutePath(), }; final Object res = this.runCommandLine(args); - final File tribbleIndex = Tribble.indexFile(ORIG_FILE); - Assert.assertEquals(res, tribbleIndex.getAbsolutePath()); - tribbleIndex.deleteOnExit(); + final Path tribbleIndex = Tribble.indexPath(ORIG_FILE.toPath()); + Assert.assertEquals(res, tribbleIndex.toAbsolutePath().toString()); + tribbleIndex.toFile().deleteOnExit(); final Index index = IndexFactory.loadIndex(res.toString()); Assert.assertTrue(index instanceof LinearIndex); @@ -382,4 +407,5 @@ public void testVCFWithNoRecords() { Assert.assertTrue(output.exists()); Assert.assertTrue(output.length() > 0); } + } diff --git a/src/test/java/org/broadinstitute/hellbender/utils/variant/GATKVariantContextUtilsUnitTest.java b/src/test/java/org/broadinstitute/hellbender/utils/variant/GATKVariantContextUtilsUnitTest.java index a0d148d68c9..41554c0d3ee 100644 --- a/src/test/java/org/broadinstitute/hellbender/utils/variant/GATKVariantContextUtilsUnitTest.java +++ b/src/test/java/org/broadinstitute/hellbender/utils/variant/GATKVariantContextUtilsUnitTest.java @@ -1660,7 +1660,7 @@ public void testCreateVCFWriterWithOptions( private void verifyFileType( final File resultVCFFile, final String outputExtension) { - final FeatureCodec featureCodec = FeatureManager.getCodecForFile(resultVCFFile); + final FeatureCodec featureCodec = FeatureManager.getCodecForFile(resultVCFFile.toPath()); if (outputExtension.equals(".vcf") || outputExtension.equals(".vcf.bgz") || From 95a15d3b2a2d9db4c7488b8fb22166f0e02d3d6f Mon Sep 17 00:00:00 2001 From: Chris Norman Date: Thu, 31 Oct 2019 11:43:14 -0400 Subject: [PATCH 2/3] Change IndexFeatureFile to use -I instead of -F. --- .../hellbender/tools/IndexFeatureFile.java | 6 +-- .../IndexFeatureFileIntegrationTest.java | 44 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/IndexFeatureFile.java b/src/main/java/org/broadinstitute/hellbender/tools/IndexFeatureFile.java index 95840cfa3d8..86a0e5ecd6a 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/IndexFeatureFile.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/IndexFeatureFile.java @@ -32,7 +32,7 @@ *

Usage example

*
  * gatk IndexFeatureFile \
- *     -F cohort.vcf.gz
+ *     -I cohort.vcf.gz
  * 
* This produces the corresponding index, cohort.vcf.gz.tbi. */ @@ -46,8 +46,8 @@ public final class IndexFeatureFile extends CommandLineProgram { private static final Logger logger = LogManager.getLogger(IndexFeatureFile.class); - @Argument(shortName = "F", - fullName = "feature-file", + @Argument(shortName =StandardArgumentDefinitions.INPUT_SHORT_NAME, + fullName = StandardArgumentDefinitions.INPUT_LONG_NAME, doc = "Feature file (eg., VCF or BED file) to index. Must be in a tribble-supported format") public GATKPathSpecifier featurePath; diff --git a/src/test/java/org/broadinstitute/hellbender/tools/IndexFeatureFileIntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/IndexFeatureFileIntegrationTest.java index c312d6ef355..51d9e47e749 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/IndexFeatureFileIntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/IndexFeatureFileIntegrationTest.java @@ -9,8 +9,10 @@ import htsjdk.variant.variantcontext.VariantContext; import org.broadinstitute.hellbender.CommandLineProgramTest; import org.broadinstitute.hellbender.Main; +import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions; import org.broadinstitute.hellbender.engine.FeatureDataSource; import org.broadinstitute.hellbender.exceptions.UserException; +import org.broadinstitute.hellbender.testutils.ArgumentsBuilder; import org.broadinstitute.hellbender.utils.SimpleInterval; import org.broadinstitute.hellbender.utils.gcs.BucketUtils; import org.testng.Assert; @@ -32,7 +34,7 @@ public void testVCFIndex() { final File outName = createTempFile("test_variants_for_index.vcf", ".idx"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I", ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; @@ -54,7 +56,7 @@ public void testVCFIndexOnCloud() throws IOException { BucketUtils.copyFile(testFile.getAbsolutePath(), vcfOnGCS); final String[] args = new String[] { - "IndexFeatureFile", "--feature-file", vcfOnGCS + "IndexFeatureFile", "-I", vcfOnGCS }; new Main().instanceMain(args); @@ -72,7 +74,7 @@ public void testVCFIndex_inferredName() { final File ORIG_FILE = getTestFile("test_variants_for_index.vcf"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), }; final Object res = this.runCommandLine(args); final Path tribbleIndex = Tribble.indexPath(ORIG_FILE.toPath()); @@ -91,7 +93,7 @@ public void testIndexNonFeatureFileGZ() { final File outName = createTempFile("test_nonFeature_file.txt.blockgz.gz.", ".tbi"); final String[] args = { - "--feature-file", ORIG_FILE.getAbsolutePath(), + "-I", ORIG_FILE.getAbsolutePath(), "-O", outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -103,7 +105,7 @@ public void testIndexBCFFileGZ() { final File outName = createTempFile("test_variants_for_index.bcf.blockgz.gz.", ".tbi"); final String[] args = { - "--feature-file", ORIG_FILE.getAbsolutePath(), + "-I", ORIG_FILE.getAbsolutePath(), "-O", outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -115,7 +117,7 @@ public void testVCFGZIndex_tabixRequires_tbi_name() { final File outName = createTempFile("test_variants_for_index.blockgz.gz.", ".idx"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; this.runCommandLine(args); @@ -128,7 +130,7 @@ public void testVCFGZIndex_tabix() { FileExtensions.TABIX_INDEX); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -151,7 +153,7 @@ public void testVCFGZLargeHeaderIndex_tabix() throws IOException { final File outIndexFile = new File(tempDir, inputCopy.getName() + FileExtensions.TABIX_INDEX); final String[] args = { - "--feature-file" , inputCopy.getAbsolutePath(), + "-I" , inputCopy.getAbsolutePath(), "-O" , outIndexFile.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -178,7 +180,7 @@ public void testVCFGZLargeHeaderIndex_tabix() throws IOException { public void testVCFGZIndex_inferredName(){ final File ORIG_FILE = getTestFile("test_variants_for_index.vcf.blockgz.gz"); //made by bgzip final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), }; final Object res = this.runCommandLine(args); final File tabixIndex = new File(ORIG_FILE.getAbsolutePath() + FileExtensions.TABIX_INDEX); @@ -199,7 +201,7 @@ public void testVCFGZIPIndex() throws IOException { final File ORIG_FILE = getTestFile("test_variants_for_index.vcf.gzip.gz"); //made by gzip final File outName = createTempFile("test_variants_for_index.gzip.gz.", ".tbi"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -210,7 +212,7 @@ public void testVCFGZIPIndex_inferredName() throws IOException { //This tests blows up because the input file is not blocked gzipped final File ORIG_FILE = getTestFile("test_variants_for_index.vcf.gzip.gz"); //made by gzip final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), }; final Object res = this.runCommandLine(args); } @@ -221,7 +223,7 @@ public void testBCFIndex() { final File outName = createTempFile("test_variants_for_index.bcf.", ".idx"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -240,7 +242,7 @@ public void testUncompressedBCF2_2Index() { final File outName = createTempFile("test_variants_for_index.BCF22uncompressed.bcf", ".idx"); final String[] args = { - "--feature-file", ORIG_FILE.getAbsolutePath(), + "-I", ORIG_FILE.getAbsolutePath(), "-O", outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -252,7 +254,7 @@ public void testCompressedBCF2_2Index() { final File outName = createTempFile("test_variants_for_index.BCF22compressed.bcf.blockgz.gz", ".idx"); final String[] args = { - "--feature-file", ORIG_FILE.getAbsolutePath(), + "-I", ORIG_FILE.getAbsolutePath(), "-O", outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -266,7 +268,7 @@ public void testGVCFTreatedAsVCFIndex() { final File outName = createTempFile("test_variants_for_index.gvcf_treated_as_vcf.vcf.", ".idx"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -284,7 +286,7 @@ public void testGVCFIndex() { final File outName = createTempFile("test_variants_for_index.g.vcf.", ".idx"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -306,7 +308,7 @@ private void testBedIndex(final File ORIG_FILE, final Class ind final File outName = createTempFile(ORIG_FILE.getName(), (indexClass == TabixIndex.class) ? FileExtensions.TABIX_INDEX : ".idx"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -344,7 +346,7 @@ public void testSAMPileupGZIndex() { final File outName = createTempFile(ORIG_FILE.getName(), FileExtensions.TABIX_INDEX); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -371,7 +373,7 @@ public void testVCFIndex_missingFile() { final File outName = createTempFile("test_variants_for_index.vcf.", ".idx"); final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -386,7 +388,7 @@ public void testVCFIndex_cannotWrite() { final File outName = new File(doesNotExist, "joe.txt"); //we can't write to this because parent does not exist final String[] args = { - "--feature-file" , ORIG_FILE.getAbsolutePath(), + "-I" , ORIG_FILE.getAbsolutePath(), "-O" , outName.getAbsolutePath() }; final Object res = this.runCommandLine(args); @@ -399,7 +401,7 @@ public void testVCFWithNoRecords() { final File output = createTempFile("header_only.vcf", ".idx"); final String[] args = { - "--feature-file", emptyVCF.getAbsolutePath(), + "-I", emptyVCF.getAbsolutePath(), "-O", output.getAbsolutePath() }; runCommandLine(args); From afbe00744793d8e41b5d20abc2853884bef55d70 Mon Sep 17 00:00:00 2001 From: Chris Norman Date: Thu, 7 Nov 2019 12:35:17 -0500 Subject: [PATCH 3/3] Update VariantsSparkSinkUnitTest arg names. --- .../engine/spark/datasources/VariantsSparkSinkUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/broadinstitute/hellbender/engine/spark/datasources/VariantsSparkSinkUnitTest.java b/src/test/java/org/broadinstitute/hellbender/engine/spark/datasources/VariantsSparkSinkUnitTest.java index 7a6f032dc3a..6dfc1bb3b8d 100644 --- a/src/test/java/org/broadinstitute/hellbender/engine/spark/datasources/VariantsSparkSinkUnitTest.java +++ b/src/test/java/org/broadinstitute/hellbender/engine/spark/datasources/VariantsSparkSinkUnitTest.java @@ -150,7 +150,7 @@ public void testEnableDisableGVCFWriting(boolean writeGvcf, String extension) th public String getTestedToolName(){ return IndexFeatureFile.class.getSimpleName(); } - }.runCommandLine(new String[]{"-F", output.getAbsolutePath()}); + }.runCommandLine(new String[]{"-I", output.getAbsolutePath()}); final List writtenVcs = readVariants(output.toString()); //if we are actually writing a gvcf, all the variant blocks will be merged into a single homref block with