Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Jul 9, 2024
1 parent 707ef7e commit c7ad572
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions bio2zarr/vcf2zarr/vcz.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,14 @@ def __init__(self, path):
if not (path / ".zmetadata").exists():
raise ValueError("Not in VcfZarr format") # NEEDS TEST
self.path = path
self.root = zarr.open(path, mode="r")
self.root = zarr.open(store=path, mode="r")

def summary_table(self):
data = []
arrays = [(core.du(self.path / a.basename), a) for _, a in self.root.arrays()]
arrays.sort(key=lambda x: x[0])
for stored, array in reversed(arrays):
nbytes = array.size * array.dtype.itemsize
nchunks = array.metadata.chunk_grid.get_nchunks(array.shape)
d = {
"name": array.name,
Expand Down Expand Up @@ -968,7 +969,9 @@ def encode_all_partitions(
total_bytes = 0
for array_spec in self.schema.fields:
# Open the array definition to get the total size
total_bytes += zarr.open(self.arrays_path / array_spec.name).nbytes
arr = zarr.open(store=self.arrays_path / array_spec.name)
nbytes = arr.size * arr.dtype.itemsize
total_bytes += nbytes

progress_config = core.ProgressConfig(
total=total_bytes,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_vcz.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_codec(self, tmp_path, icf_path, cname, clevel, shuffle):
with open(schema_path, "w") as f:
f.write(schema.asjson())
vcf2zarr.encode(icf_path, zarr_path, schema_path=schema_path)
root = zarr.open(zarr_path)
root = zarr.open(store=zarr_path)
for array_spec in schema.fields:
a = root[array_spec.name]
assert a.compressor.cname == cname
Expand All @@ -203,7 +203,7 @@ def test_genotype_dtype(self, tmp_path, icf_path, dtype):
with open(schema_path, "w") as f:
f.write(schema.asjson())
vcf2zarr.encode(icf_path, zarr_path, schema_path=schema_path)
root = zarr.open(zarr_path)
root = zarr.open(store=zarr_path)
assert root["call_genotype"].dtype == dtype


Expand Down

0 comments on commit c7ad572

Please sign in to comment.