Skip to content
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

.vcf.bgz as a valid vcf extension in FileExtensions #1727

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private static <T extends IOPath> Optional<Tuple<String, String>> 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));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/htsjdk/samtools/util/FileExtensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> VCF_LIST = Collections.unmodifiableList(Arrays.asList(VCF, COMPRESSED_VCF, BCF));
public static final List<String> 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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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());
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}
};
}

Expand Down
Loading