From aec0a9d6d6eb706faeb3721815e3188f22817d4f Mon Sep 17 00:00:00 2001 From: Tom White Date: Tue, 21 Apr 2026 09:36:55 +0100 Subject: [PATCH] Add normalise test using icechunk --- tests/test_normalise.py | 25 ++++++++++++++++++++++++- tests/utils.py | 12 ++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/tests/test_normalise.py b/tests/test_normalise.py index 582a856..03152d2 100644 --- a/tests/test_normalise.py +++ b/tests/test_normalise.py @@ -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 @@ -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, + ) diff --git a/tests/utils.py b/tests/utils.py index b5c113d..2710c4f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -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()