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
18 changes: 18 additions & 0 deletions tests/test_normalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import zarr
from numpy.testing import assert_array_equal

from vczstore.append import append
from vczstore.normalise import (
index_variants,
normalise,
remap_genotypes,
variant_alleles_are_equivalent,
)

from .utils import compare_vcf_and_vcz, convert_vcf_to_vcz


# TODO: replace this with make_vcz in vcztools/bio2zarr
# see https://github.com/sgkit-dev/vczstore/issues/37
Expand Down Expand Up @@ -324,3 +327,18 @@ def test_normalise__other_call_fields_not_implemented():

with pytest.raises(NotImplementedError):
normalise(vcz1, vcz2, vcz2_norm)


def test_normalise_and_append(tmp_path):
vcz0 = convert_vcf_to_vcz("sample-variants.vcf.gz", tmp_path, ploidy=2)
vcz1 = convert_vcf_to_vcz("sample-part1.vcf.gz", tmp_path)
vcz1_norm = zarr.storage.MemoryStore()

normalise(vcz0, vcz1, vcz1_norm)

append(vcz0, vcz1_norm)

# check equivalence with original VCF
compare_vcf_and_vcz(
tmp_path, "view --no-version", "sample-part1.vcf.gz", "view --no-version", vcz0
)
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vczstore/normalise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import zarr
from bio2zarr.zarr_utils import create_empty_group_array, get_compressor
from bio2zarr.zarr_utils import create_empty_group_array, get_compressor_config
from more_itertools import peekable
from vcztools.constants import STR_FILL, STR_MISSING
from vcztools.retrieval import VczReader
Expand Down Expand Up @@ -51,7 +51,7 @@ def normalise(vcz1, vcz2, vcz2_norm):
shape=shape,
dtype=arr.dtype,
chunks=chunks,
compressor=get_compressor(arr),
compressor=get_compressor_config(arr),
dimension_names=array_dims(arr),
)
else:
Expand All @@ -66,7 +66,7 @@ def normalise(vcz1, vcz2, vcz2_norm):
shape=arr.shape,
dtype=arr.dtype,
chunks=arr.chunks,
compressor=get_compressor(arr),
compressor=get_compressor_config(arr),
dimension_names=array_dims(arr),
)

Expand Down
Loading