diff --git a/src/main/java/htsjdk/beta/codecs/variants/vcf/VCFCodec.java b/src/main/java/htsjdk/beta/codecs/variants/vcf/VCFCodec.java index 0162364848..c18a60b34e 100644 --- a/src/main/java/htsjdk/beta/codecs/variants/vcf/VCFCodec.java +++ b/src/main/java/htsjdk/beta/codecs/variants/vcf/VCFCodec.java @@ -32,7 +32,7 @@ public abstract class VCFCodec implements VariantsCodec { { add(FileExtensions.VCF); add(FileExtensions.COMPRESSED_VCF); - add(".vcf.bgz"); + add(FileExtensions.COMPRESSED_VCF_BGZ); } }; diff --git a/src/main/java/htsjdk/beta/plugin/variants/VariantsBundle.java b/src/main/java/htsjdk/beta/plugin/variants/VariantsBundle.java index a8bce40cc5..75c6b73971 100644 --- a/src/main/java/htsjdk/beta/plugin/variants/VariantsBundle.java +++ b/src/main/java/htsjdk/beta/plugin/variants/VariantsBundle.java @@ -206,7 +206,7 @@ private static Optional> getInferredCon final String ext = extension.get(); if (ext.equals(FileExtensions.VCF)) { return Optional.of(new Tuple<>(BundleResourceType.CT_VARIANT_CONTEXTS, BundleResourceType.FMT_VARIANTS_VCF)); - } else if (ext.equals(FileExtensions.COMPRESSED_VCF)) { + } else if (ext.equals(FileExtensions.COMPRESSED_VCF) || ext.equals(FileExtensions.COMPRESSED_VCF_BGZ)) { return Optional.of(new Tuple<>(BundleResourceType.CT_VARIANT_CONTEXTS, BundleResourceType.FMT_VARIANTS_VCF)); } } diff --git a/src/main/java/htsjdk/samtools/util/FileExtensions.java b/src/main/java/htsjdk/samtools/util/FileExtensions.java index b67154a629..63e2cf4de6 100755 --- a/src/main/java/htsjdk/samtools/util/FileExtensions.java +++ b/src/main/java/htsjdk/samtools/util/FileExtensions.java @@ -65,9 +65,10 @@ public final class FileExtensions { public static final String VCF = ".vcf"; public static final String VCF_INDEX = TRIBBLE_INDEX; public static final String BCF = ".bcf"; + public static final String COMPRESSED_VCF_BGZ = ".vcf.bgz"; // suffix used by gnomad see https://gnomad.broadinstitute.org/data#v4 public static final String COMPRESSED_VCF = ".vcf.gz"; public static final String COMPRESSED_VCF_INDEX = ".tbi"; - public static final List VCF_LIST = Collections.unmodifiableList(Arrays.asList(VCF, COMPRESSED_VCF, BCF)); + public static final List VCF_LIST = Collections.unmodifiableList(Arrays.asList(VCF, COMPRESSED_VCF, COMPRESSED_VCF_BGZ, BCF)); public static final String INTERVAL_LIST = ".interval_list"; public static final String COMPRESSED_INTERVAL_LIST = ".interval_list.gz"; diff --git a/src/test/java/htsjdk/variant/variantcontext/writer/VCFWriterUnitTest.java b/src/test/java/htsjdk/variant/variantcontext/writer/VCFWriterUnitTest.java index ca2afcbec0..d6bfb5a9a9 100644 --- a/src/test/java/htsjdk/variant/variantcontext/writer/VCFWriterUnitTest.java +++ b/src/test/java/htsjdk/variant/variantcontext/writer/VCFWriterUnitTest.java @@ -90,7 +90,7 @@ private void createTemporaryDirectory() { public void testBasicWriteAndRead(final String extension) throws IOException { final File fakeVCFFile = File.createTempFile("testBasicWriteAndRead.", extension, tempDir); fakeVCFFile.deleteOnExit(); - if (FileExtensions.COMPRESSED_VCF.equals(extension)) { + if (FileExtensions.COMPRESSED_VCF.equals(extension) || FileExtensions.COMPRESSED_VCF_BGZ.equals(extension)) { new File(fakeVCFFile.getAbsolutePath() + FileExtensions.VCF_INDEX); } else { Tribble.indexFile(fakeVCFFile).deleteOnExit(); @@ -136,7 +136,7 @@ public void testBasicWriteAndRead(final String extension) throws IOException { public void testWriteAndReadVCFHeaderless(final String extension) throws IOException { final File fakeVCFFile = File.createTempFile("testWriteAndReadVCFHeaderless.", extension, tempDir); fakeVCFFile.deleteOnExit(); - if (FileExtensions.COMPRESSED_VCF.equals(extension)) { + if (FileExtensions.COMPRESSED_VCF.equals(extension) || FileExtensions.COMPRESSED_VCF_BGZ.equals(extension)) { new File(fakeVCFFile.getAbsolutePath() + ".tbi"); } else { Tribble.indexFile(fakeVCFFile).deleteOnExit(); @@ -159,7 +159,7 @@ public void testWriteAndReadVCFHeaderless(final String extension) throws IOExcep try (BlockCompressedInputStream bcis = new BlockCompressedInputStream(fakeVCFFile); FileInputStream fis = new FileInputStream(fakeVCFFile)) { AsciiLineReaderIterator iterator = - new AsciiLineReaderIterator(new AsciiLineReader(".vcf.gz".equals(extension) ? bcis : fis)); + new AsciiLineReaderIterator(new AsciiLineReader(FileExtensions.COMPRESSED_VCF.equals(extension) || FileExtensions.COMPRESSED_VCF_BGZ.equals(extension) ? bcis : fis)); int counter = 0; while (iterator.hasNext()) { VariantContext context = codec.decode(iterator.next()); @@ -300,7 +300,7 @@ public void TestWritingLargeVCF(final String extension) throws FileNotFoundExcep final File vcf = new File(tempDir, "test" + extension); final String indexExtension; - if (extension.equals(FileExtensions.COMPRESSED_VCF)) { + if (extension.equals(FileExtensions.COMPRESSED_VCF) || extension.equals(FileExtensions.COMPRESSED_VCF_BGZ)) { indexExtension = FileExtensions.TABIX_INDEX; } else { indexExtension = FileExtensions.TRIBBLE_INDEX; @@ -333,7 +333,8 @@ public void TestWritingLargeVCF(final String extension) throws FileNotFoundExcep // TODO: BCF doesn't work because header is not properly constructed. // {".bcf"}, {FileExtensions.VCF}, - {FileExtensions.COMPRESSED_VCF} + {FileExtensions.COMPRESSED_VCF}, + {FileExtensions.COMPRESSED_VCF_BGZ} }; }