Skip to content

Commit 7653700

Browse files
Will-Tylerjeromekelleher
authored andcommitted
Improve test coverage
1 parent 77ad35c commit 7653700

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed
25 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

tests/data/vcf/triploid2.vcf.gz

363 Bytes
Binary file not shown.
111 Bytes
Binary file not shown.

tests/data/vcf/triploid3.vcf.gz

356 Bytes
Binary file not shown.
111 Bytes
Binary file not shown.

tests/test_vcf_examples.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ def test_call_LAA(self, ds):
452452
[[1, -2, -2], [-1, -2, -2]],
453453
[[2, -2, -2], [2, -2, -2]],
454454
[[1, -2, -2], [-2, -2, -2]],
455+
[[-2, -2, -2], [-2, -2, -2]],
456+
[[1, -2, -2], [1, -2, -2]],
455457
]
456458
nt.assert_array_equal(ds.call_LAA.values, call_LAA)
457459

@@ -493,29 +495,37 @@ def test_call_LPL(self, ds):
493495
[30, 30, 30, -2, -2, -2, -2, -2, -2, -2],
494496
[30, -1, 0, -2, -2, -2, -2, -2, -2, -2],
495497
],
498+
[
499+
[-1, -1, -1, -2, -2, -2, -2, -2, -2, -2],
500+
[-1, -1, -1, -2, -2, -2, -2, -2, -2, -2],
501+
],
502+
[
503+
[-1, -1, -2, -2, -2, -2, -2, -2, -2, -2],
504+
[-1, -1, -2, -2, -2, -2, -2, -2, -2, -2],
505+
],
496506
]
497507
nt.assert_array_equal(ds.call_LPL.values, call_LPL)
498508

499509

500510
class TestTriploidExample:
501-
data_path = "tests/data/vcf/triploid.vcf.gz"
502-
503-
@pytest.fixture(scope="class")
504-
def ds(self, tmp_path_factory):
511+
@pytest.fixture(scope="class", params=["triploid", "triploid2", "triploid3"])
512+
def ds(self, tmp_path_factory, request):
513+
data_path = f"tests/data/vcf/{request.param}.vcf.gz"
505514
out = tmp_path_factory.mktemp("data") / "example.vcf.zarr"
506-
vcf2zarr.convert([self.data_path], out, local_alleles=False)
515+
vcf2zarr.convert([data_path], out, local_alleles=False)
507516
return sg.load_dataset(out)
508517

509-
def test_error_with_local_alleles(self, tmp_path_factory):
510-
icf_path = tmp_path_factory.mktemp("data") / "triploid.icf"
518+
@pytest.mark.parametrize("name", ["triploid", "triploid2", "triploid3"])
519+
def test_error_with_local_alleles(self, tmp_path_factory, name):
520+
data_path = f"tests/data/vcf/{name}.vcf.gz"
521+
icf_path = tmp_path_factory.mktemp("data") / f"{name}.icf"
511522
with pytest.raises(ValueError, match=re.escape("Cannot handle ploidy = 3")):
512523
vcf2zarr.explode(
513-
icf_path, [self.data_path], worker_processes=0, local_alleles=True
524+
icf_path, [data_path], worker_processes=0, local_alleles=True
514525
)
515526

516527
def test_ok_without_local_alleles(self, ds):
517528
nt.assert_array_equal(ds.call_genotype.values, [[[0, 0, 0]]])
518-
nt.assert_array_equal(ds.call_PL.values, [[[0, 0, 0, 0]]])
519529

520530

521531
class Test1000G2020Example:

0 commit comments

Comments
 (0)