Skip to content
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
25 changes: 24 additions & 1 deletion tests/test_normalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
variant_alleles_are_equivalent,
)

from .utils import compare_vcf_and_vcz, convert_vcf_to_vcz
from .utils import compare_vcf_and_vcz, convert_vcf_to_vcz, convert_vcf_to_vcz_icechunk


# TODO: replace this with make_vcz in vcztools/bio2zarr
Expand Down Expand Up @@ -342,3 +342,26 @@ def test_normalise_and_append(tmp_path):
compare_vcf_and_vcz(
tmp_path, "view --no-version", "sample-part1.vcf.gz", "view --no-version", vcz0
)


def test_normalise_and_append_icechunk(tmp_path):
pytest.importorskip("icechunk")
from vczstore.icechunk_utils import icechunk_transaction

# note that vcz0 is in icechunk, but the others needn't be
vcz0 = convert_vcf_to_vcz_icechunk("sample-variants.vcf.gz", tmp_path, ploidy=2)
vcz1 = convert_vcf_to_vcz("sample-part1.vcf.gz", tmp_path)
vcz1_norm = zarr.storage.MemoryStore()

with icechunk_transaction(vcz0, "main", message="append") as store:
normalise(store, vcz1, vcz1_norm)
append(store, vcz1_norm)

# check equivalence with original VCF
compare_vcf_and_vcz(
tmp_path,
"view --no-version",
"sample-part1.vcf.gz",
"view --no-version --zarr-backend-storage icechunk",
vcz0,
)
12 changes: 10 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,18 @@ def compare_vcf_and_vcz(tmp_path, vcf_args, vcf_file, vcz_args, vcz):
assert_vcfs_close(bcftools_out_file, vcztools_out_file)


def convert_vcf_to_vcz_icechunk(vcf_name, tmp_path):
def convert_vcf_to_vcz_icechunk(
vcf_name, tmp_path, variants_chunk_size=None, samples_chunk_size=None, ploidy=None
):
from vczstore.icechunk_utils import copy_store_to_icechunk

vcz = convert_vcf_to_vcz(vcf_name, tmp_path)
vcz = convert_vcf_to_vcz(
vcf_name,
tmp_path,
variants_chunk_size=variants_chunk_size,
samples_chunk_size=samples_chunk_size,
ploidy=ploidy,
)

ic_tmp_path = tmp_path / "icechunk"
ic_tmp_path.mkdir()
Expand Down
Loading