Skip to content

Commit

Permalink
.vcf.bgz as a valid vcf extension
Browse files Browse the repository at this point in the history
  • Loading branch information
lindenb committed Oct 29, 2024
1 parent a37ffa6 commit 5bd0287
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
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 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

0 comments on commit 5bd0287

Please sign in to comment.