Skip to content

Commit 74f5dc6

Browse files
tomwhitejeromekelleher
authored andcommitted
Fix named VCF Number dimensions of size 1
1 parent 17db733 commit 74f5dc6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

bio2zarr/vcz.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def from_field(
137137
if array_name is None:
138138
array_name = prefix + vcf_field.name
139139
# TODO make an option to add in the empty extra dimension
140-
if vcf_field.summary.max_number > 1 or vcf_field.full_name == "FORMAT/LAA":
140+
if (
141+
vcf_field.summary.max_number > 0 and vcf_field.vcf_number in ("R", "A", "G")
142+
) or (vcf_field.summary.max_number > 1 or vcf_field.full_name == "FORMAT/LAA"):
141143
shape.append(vcf_field.summary.max_number)
142144
chunks.append(vcf_field.summary.max_number)
143145
# TODO we should really be checking this to see if the named dimensions

tests/test_vcf_examples.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,11 @@ def test_variant_ANN(self, ds):
997997
]
998998
nt.assert_array_equal(ds.variant_ANN.values, variant_ANN)
999999

1000+
def test_variant_MLEAF(self, ds):
1001+
# fixes https://github.com/sgkit-dev/bio2zarr/issues/353
1002+
assert ds.variant_MLEAF.dims == ("variants", "alt_alleles")
1003+
assert ds.variant_MLEAF.shape == (21, 1)
1004+
10001005

10011006
class TestGeneratedFieldsExample:
10021007
data_path = "tests/data/vcf/field_type_combos.vcf.gz"

0 commit comments

Comments
 (0)