Skip to content

Commit ada71fa

Browse files
committed
Make chunks have the same number of dimensions as shape
1 parent 69ee0e8 commit ada71fa

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

bio2zarr/vcf2zarr/vcz.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def from_field(
9898
# TODO make an option to add in the empty extra dimension
9999
if vcf_field.summary.max_number > 1:
100100
shape.append(vcf_field.summary.max_number)
101+
chunks.append(vcf_field.summary.max_number)
101102
# TODO we should really be checking this to see if the named dimensions
102103
# are actually correct.
103104
if vcf_field.vcf_number == "R":
@@ -251,7 +252,12 @@ def spec_from_field(field, array_name=None):
251252
)
252253

253254
def fixed_field_spec(
254-
name, dtype, vcf_field=None, shape=(m,), dimensions=("variants",)
255+
name,
256+
dtype,
257+
vcf_field=None,
258+
shape=(m,),
259+
dimensions=("variants",),
260+
chunks=None,
255261
):
256262
return ZarrArraySpec.new(
257263
vcf_field=vcf_field,
@@ -260,7 +266,7 @@ def fixed_field_spec(
260266
shape=shape,
261267
description="",
262268
dimensions=dimensions,
263-
chunks=[variants_chunk_size],
269+
chunks=chunks or [variants_chunk_size],
264270
)
265271

266272
alt_field = icf.fields["ALT"]
@@ -276,12 +282,14 @@ def fixed_field_spec(
276282
dtype="bool",
277283
shape=(m, icf.metadata.num_filters),
278284
dimensions=["variants", "filters"],
285+
chunks=(variants_chunk_size, icf.metadata.num_filters),
279286
),
280287
fixed_field_spec(
281288
name="variant_allele",
282289
dtype="O",
283290
shape=(m, max_alleles),
284291
dimensions=["variants", "alleles"],
292+
chunks=(variants_chunk_size, max_alleles),
285293
),
286294
fixed_field_spec(
287295
name="variant_id",
@@ -329,6 +337,7 @@ def fixed_field_spec(
329337
)
330338
)
331339
shape += [ploidy]
340+
chunks += [ploidy]
332341
dimensions += ["ploidy"]
333342
array_specs.append(
334343
ZarrArraySpec.new(

tests/test_vcz.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def test_call_genotype(self, schema):
313313
"name": "call_genotype",
314314
"dtype": "i1",
315315
"shape": (9, 3, 2),
316-
"chunks": (10000, 1000),
316+
"chunks": (10000, 1000, 2),
317317
"dimensions": ("variants", "samples", "ploidy"),
318318
"description": "",
319319
"vcf_field": None,
@@ -332,7 +332,7 @@ def test_call_genotype_mask(self, schema):
332332
"name": "call_genotype_mask",
333333
"dtype": "bool",
334334
"shape": (9, 3, 2),
335-
"chunks": (10000, 1000),
335+
"chunks": (10000, 1000, 2),
336336
"dimensions": ("variants", "samples", "ploidy"),
337337
"description": "",
338338
"vcf_field": None,
@@ -351,7 +351,7 @@ def test_call_genotype_phased(self, schema):
351351
"name": "call_genotype_mask",
352352
"dtype": "bool",
353353
"shape": (9, 3, 2),
354-
"chunks": (10000, 1000),
354+
"chunks": (10000, 1000, 2),
355355
"dimensions": ("variants", "samples", "ploidy"),
356356
"description": "",
357357
"vcf_field": None,

0 commit comments

Comments
 (0)