Skip to content

Commit d35707a

Browse files
Remove unused dimensions attr in Schema
Closes #98
1 parent 754bb07 commit d35707a

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

bio2zarr/vcf.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,6 @@ class VcfZarrSchema:
14131413
format_version: str
14141414
samples_chunk_size: int
14151415
variants_chunk_size: int
1416-
dimensions: list
14171416
samples: list
14181417
contigs: list
14191418
filters: list
@@ -1575,7 +1574,6 @@ def fixed_field_spec(
15751574
samples_chunk_size=samples_chunk_size,
15761575
variants_chunk_size=variants_chunk_size,
15771576
fields=colspecs,
1578-
dimensions=["variants", "samples", "ploidy", "alleles", "filters"],
15791577
samples=icf.metadata.samples,
15801578
contigs=icf.metadata.contigs,
15811579
filters=icf.metadata.filters,
@@ -1786,9 +1784,7 @@ def init(
17861784

17871785
def encode_samples(self, root):
17881786
if self.schema.samples != self.icf.metadata.samples:
1789-
raise ValueError(
1790-
"Subsetting or reordering samples not supported currently"
1791-
) # NEEDS TEST
1787+
raise ValueError("Subsetting or reordering samples not supported currently")
17921788
array = root.array(
17931789
"sample_id",
17941790
[sample.id for sample in self.schema.samples],

tests/test_vcf.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,6 @@ def test_chunk_size(self, schema):
218218
assert schema.samples_chunk_size == 1000
219219
assert schema.variants_chunk_size == 10000
220220

221-
def test_dimensions(self, schema):
222-
assert schema.dimensions == [
223-
"variants",
224-
"samples",
225-
"ploidy",
226-
"alleles",
227-
"filters",
228-
]
229-
230221
def test_samples(self, schema):
231222
assert schema.asdict()["samples"] == [
232223
{"id": s} for s in ["NA00001", "NA00002", "NA00003"]
@@ -569,3 +560,30 @@ def test_call_fields(self, tmp_path, field):
569560
self.generate_vcf(vcf_file, format_field=field)
570561
with pytest.raises(ValueError, match=f"FORMAT field name.*{field}"):
571562
vcf.explode(tmp_path / "x.icf", [tmp_path / "test.vcf.gz"])
563+
564+
565+
class TestBadSchemaChanges:
566+
# [{'id': 'NA00001'}, {'id': 'NA00002'}, {'id': 'NA00003'}],
567+
@pytest.mark.parametrize(
568+
"samples",
569+
[
570+
[],
571+
[{"id": "NA00001"}, {"id": "NA00003"}],
572+
[{"id": "NA00001"}, {"id": "NA00002"}, {"id": "NA00004"}],
573+
[
574+
{"id": "NA00001"},
575+
{"id": "NA00002"},
576+
{"id": "NA00003"},
577+
{"id": "NA00004"},
578+
],
579+
[{"id": "NA00001"}, {"id": "NA00003"}, {"id": "NA00002"}],
580+
],
581+
)
582+
def test_removed_samples(self, tmp_path, schema, icf_path, samples):
583+
d = schema.asdict()
584+
d["samples"] = samples
585+
schema_path = tmp_path / "schema.json"
586+
with open(schema_path, "w") as f:
587+
json.dump(d, f)
588+
with pytest.raises(ValueError, match="Subsetting or reordering samples"):
589+
vcf.encode(icf_path, tmp_path / "z", schema_path=schema_path)

0 commit comments

Comments
 (0)