Skip to content

Commit 9a78fbf

Browse files
committed
Backward and forward-compatible changes to support zarr-python v3
1 parent 97578d1 commit 9a78fbf

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

dev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def main(root):
5656
# we avoid retrieving stuff we don't need.
5757
format_fields = {}
5858
info_fields = {}
59-
for name, array in root.items():
59+
for name, array in root.arrays():
6060
if name.startswith("call_") and not name.startswith("call_genotype"):
6161
vcf_name = name[len("call_") :]
6262
format_fields[vcf_name] = array.blocks[v_chunk]

vcztools/filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _compose_comparison_evaluator(self, parse_results: pp.ParseResults) -> Calla
113113

114114
def evaluator(root, variant_chunk_index: int) -> np.ndarray:
115115
vcf_name = parse_results[0]
116-
vcz_names = set(name for name, _array in root.items())
116+
vcz_names = set(root.keys())
117117
vcz_name = vcf_name_to_vcz_name(vcz_names, vcf_name)
118118
zarray = root[vcz_name]
119119
variant_chunk_len = zarray.chunks[0]

vcztools/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def _compose_tag_generator(
141141
return self._compose_sample_ids_generator()
142142

143143
def generate(root):
144-
vcz_names = set(name for name, _zarray in root.items())
144+
vcz_names = set(root.keys())
145145
vcz_name = vcf_name_to_vcz_name(vcz_names, tag)
146146
zarray = root[vcz_name]
147147
contig_ids = root["contig_id"][:] if tag == "CHROM" else None

vcztools/vcf_writer.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ def c_chunk_to_vcf(
309309
no_update,
310310
preceding_future: concurrent.futures.Future | None = None,
311311
):
312-
chrom = contigs[get_vchunk_array(root.variant_contig, v_chunk, v_mask_chunk)]
312+
chrom = contigs[get_vchunk_array(root["variant_contig"], v_chunk, v_mask_chunk)]
313313
# TODO check we don't truncate silently by doing this
314-
pos = get_vchunk_array(root.variant_position, v_chunk, v_mask_chunk).astype(
314+
pos = get_vchunk_array(root["variant_position"], v_chunk, v_mask_chunk).astype(
315315
np.int32
316316
)
317-
id = get_vchunk_array(root.variant_id, v_chunk, v_mask_chunk).astype("S")
318-
alleles = get_vchunk_array(root.variant_allele, v_chunk, v_mask_chunk)
319-
qual = get_vchunk_array(root.variant_quality, v_chunk, v_mask_chunk)
320-
filter_ = get_vchunk_array(root.variant_filter, v_chunk, v_mask_chunk)
317+
id = get_vchunk_array(root["variant_id"], v_chunk, v_mask_chunk).astype("S")
318+
alleles = get_vchunk_array(root["variant_allele"], v_chunk, v_mask_chunk)
319+
qual = get_vchunk_array(root["variant_quality"], v_chunk, v_mask_chunk)
320+
filter_ = get_vchunk_array(root["variant_filter"], v_chunk, v_mask_chunk)
321321
format_fields = {}
322322
info_fields = {}
323323
num_samples = len(samples_selection) if samples_selection is not None else None
@@ -346,7 +346,7 @@ def c_chunk_to_vcf(
346346
else:
347347
gt_phased = np.zeros_like(gt, dtype=bool)
348348

349-
for name, zarray in root.items():
349+
for name, zarray in root.arrays():
350350
if (
351351
name.startswith("call_")
352352
and not name.startswith("call_genotype")
@@ -442,7 +442,8 @@ def _generate_header(ds, original_header, sample_ids, *, no_version: bool = Fals
442442
# GT must be the first field if present, per the spec (section 1.6.2)
443443
format_fields.append("GT")
444444

445-
for var, arr in ds.items():
445+
for var in sorted(ds.keys()):
446+
arr = ds[var]
446447
if (
447448
var.startswith("variant_")
448449
and not var.endswith("_fill")

0 commit comments

Comments
 (0)