Skip to content

Commit b6caf74

Browse files
Will-Tylerjeromekelleher
authored andcommitted
Add LPL field unit tests
1 parent 659646d commit b6caf74

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed
8.21 KB
Binary file not shown.

tests/test_vcf_examples.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ def test_call_HQ(self, ds):
233233
]
234234
nt.assert_array_equal(ds["call_HQ"], call_HQ)
235235

236-
def test_call_LAA(self, ds):
236+
def test_no_local_alleles(self, ds):
237237
# The small example VCF does not have a PL field
238-
assert "call_LA" not in ds
238+
assert "call_LAA" not in ds
239+
assert "call_LPL" not in ds
239240

240241
def test_no_genotypes(self, ds, tmp_path):
241242
path = "tests/data/vcf/sample_no_genotypes.vcf.gz"
@@ -451,6 +452,35 @@ def test_call_LAA(self, ds):
451452
]
452453
nt.assert_array_equal(ds.call_LAA.values, call_LAA)
453454

455+
def test_call_LPL(self, ds):
456+
call_LPL = [
457+
[
458+
[100, 0, 105, -2, -2, -2, -2, -2, -2, -2],
459+
[0, 100, 200, -2, -2, -2, -2, -2, -2, -2],
460+
],
461+
[
462+
[0, 100, 200, -2, -2, -2, -2, -2, -2, -2],
463+
[154, 22, 0, -2, -2, -2, -2, -2, -2, -2],
464+
],
465+
[
466+
[1002, 55, 1002, 0, 55, 1002, -2, -2, -2, -2],
467+
[154, 154, 0, 154, 102, 102, -2, -2, -2, -2],
468+
],
469+
[
470+
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
471+
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
472+
],
473+
[
474+
[30, 30, 30, -2, -2, -2, -2, -2, -2, -2],
475+
[30, 60, 0, -2, -2, -2, -2, -2, -2, -2],
476+
],
477+
[
478+
[0, 30, -2, -2, -2, -2, -2, -2, -2, -2],
479+
[0, 0, -2, -2, -2, -2, -2, -2, -2, -2],
480+
],
481+
]
482+
nt.assert_array_equal(ds.call_LPL.values, call_LPL)
483+
454484

455485
class TestTriploidExample:
456486
data_path = "tests/data/vcf/triploid.vcf.gz"
@@ -475,13 +505,18 @@ def test_ok_without_local_alleles(self, ds):
475505

476506
class Test1000G2020Example:
477507
data_path = "tests/data/vcf/1kg_2020_chrM.vcf.gz"
508+
expected_call_lpl_path = "tests/data/numpy/expected_call_LPL.npy"
478509

479510
@pytest.fixture(scope="class")
480511
def ds(self, tmp_path_factory):
481512
out = tmp_path_factory.mktemp("data") / "example.vcf.zarr"
482513
vcf2zarr.convert([self.data_path], out, worker_processes=0)
483514
return sg.load_dataset(out)
484515

516+
@pytest.fixture(scope="class")
517+
def expected_call_lpl(self):
518+
return np.load(self.expected_call_lpl_path)
519+
485520
def test_position(self, ds):
486521
# fmt: off
487522
pos = [
@@ -606,6 +641,9 @@ def test_call_LAA(self, ds):
606641
]
607642
nt.assert_array_equal(ds.call_LAA.values, call_LAA)
608643

644+
def test_call_LPL(self, ds, expected_call_lpl):
645+
nt.assert_array_equal(ds.call_LPL.values, expected_call_lpl)
646+
609647
def test_call_PID(self, ds):
610648
call_PGT = ds["call_PGT"].values
611649
assert np.all(call_PGT == ".")

0 commit comments

Comments
 (0)