Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Will-Tyler authored and jeromekelleher committed Oct 25, 2024
1 parent 65c6963 commit d52069b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 115 deletions.
1 change: 1 addition & 0 deletions bio2zarr/vcf2zarr/icf.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ def compute_lpl_field(variant, laa_val: np.ndarray) -> np.ndarray:
pl_val = np.broadcast_to(pl_val, n.shape)
row_index = np.arange(pl_val.shape[0]).reshape(-1, 1)
lpl_val = pl_val[row_index, n]
lpl_val[b == constants.INT_FILL] = constants.INT_FILL

return lpl_val

Expand Down
135 changes: 20 additions & 115 deletions tests/test_vcf_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,41 +446,41 @@ def ds(self, tmp_path_factory):

def test_call_LAA(self, ds):
call_LAA = [
[[1, -2, -2], [1, -2, -2]],
[[1, -2, -2], [1, -2, -2]],
[[1, 2, -2], [1, 2, -2]],
[[1, -2, -2], [-2, -2, -2]],
[[-2, -2, -2], [1, -2, -2]],
[[1, -2, -2], [2, -2, -2]],
[[1, 2, 3], [2, 3, -2]],
[[1, -2, -2], [1, -2, -2]],
[[2, -2, -2], [1, -2, -2]],
[[-2, -2, -2], [-2, -2, -2]],
[[-2, -2, -2], [1, -2, -2]],
[[1, -2, -2], [-1, -2, -2]],
[[2, -2, -2], [2, -2, -2]],
[[1, -2, -2], [-2, -2, -2]],
[[-2, -2, -2], [-2, -2, -2]],
[[1, -2, -2], [1, -2, -2]],
[[-2, -2, -2], [-2, -2, -2]],
[[-2, -2, -2], [1, -2, -2]],
]
nt.assert_array_equal(ds.call_LAA.values, call_LAA)

def test_call_LPL(self, ds):
call_LPL = [
[
[100, 0, 105, -2, -2, -2, -2, -2, -2, -2],
[0, 100, 200, -2, -2, -2, -2, -2, -2, -2],
[0, -2, -2, -2, -2, -2, -2, -2, -2, -2],
],
[
[0, 100, 200, -2, -2, -2, -2, -2, -2, -2],
[0, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[154, 22, 0, -2, -2, -2, -2, -2, -2, -2],
],
[
[1002, 55, 1002, 0, 55, 1002, -2, -2, -2, -2],
[154, 154, 0, 154, 102, 102, -2, -2, -2, -2],
[1002, 55, 1002, -2, -2, -2, -2, -2, -2, -2],
[154, 154, 102, -2, -2, -2, -2, -2, -2, -2],
],
[
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
],
[
[30, 30, 30, -2, -2, -2, -2, -2, -2, -2],
[30, 60, 0, -2, -2, -2, -2, -2, -2, -2],
[30, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[30, -2, -2, -2, -2, -2, -2, -2, -2, -2],
],
[
[0, 30, -2, -2, -2, -2, -2, -2, -2, -2],
Expand All @@ -495,12 +495,12 @@ def test_call_LPL(self, ds):
[10, 40, 60, -2, -2, -2, -2, -2, -2, -2],
],
[
[30, 30, 30, -2, -2, -2, -2, -2, -2, -2],
[30, -1, 0, -2, -2, -2, -2, -2, -2, -2],
[30, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[30, -2, -2, -2, -2, -2, -2, -2, -2, -2],
],
[
[-1, -1, -1, -2, -2, -2, -2, -2, -2, -2],
[-1, -1, -1, -2, -2, -2, -2, -2, -2, -2],
[-1, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[-1, -2, -2, -2, -2, -2, -2, -2, -2, -2],
],
[
[-1, -1, -2, -2, -2, -2, -2, -2, -2, -2],
Expand Down Expand Up @@ -637,107 +637,12 @@ def test_call_AD(self, ds):
nt.assert_array_equal(ds.call_AD.values, call_AD)

def test_call_LAA(self, ds):
call_LAA = [
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, 2, -2, -2], [1, 2, -2, -2], [1, 2, -2, -2]],
[[1, 2, 3, -2], [1, 2, 3, -2], [1, 2, 3, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]],
[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]],
[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]],
[[1, 2, 3, -2], [1, 2, 3, -2], [1, 2, 3, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, 2, -2, -2], [1, 2, -2, -2], [1, 2, -2, -2]],
[[1, -2, -2, -2], [1, -2, -2, -2], [1, -2, -2, -2]],
[[1, 2, -2, -2], [1, 2, -2, -2], [1, 2, -2, -2]],
[[1, 2, 3, -2], [1, 2, 3, -2], [1, 2, 3, -2]],
[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]],
[[1, 2, 3, -2], [1, 2, 3, -2], [1, 2, 3, -2]],
]
# All the genotypes are 0/0
call_LAA = np.full((23, 3, 1), -2)
nt.assert_array_equal(ds.call_LAA.values, call_LAA)

def test_call_LPL(self, ds):
# fmt: off
call_LPL = [
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2]], # noqa: E501
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800], # noqa: E501
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800], # noqa: E501
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800]], # noqa: E501
[[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800], # noqa: E501
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800], # noqa: E501
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800]], # noqa: E501
[[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800], # noqa: E501
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800], # noqa: E501
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800]], # noqa: E501
[[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2]], # noqa: E501
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, -2, -2, -2, -2, -2, -2, -2, -2, -2]],
[[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2]], # noqa: E501
[[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800], # noqa: E501
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800], # noqa: E501
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, 120, 1800, 1800, 1800, 1800]], # noqa: E501
[[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2],
[0, 120, 1800, 120, 1800, 1800, 120, 1800, 1800, 1800, -2, -2, -2, -2, -2]]
]
# fmt: on
call_LPL = np.tile([0, -2, -2], (23, 3, 1))
nt.assert_array_equal(ds.call_LPL.values, call_LPL)

def test_call_PID(self, ds):
Expand Down

0 comments on commit d52069b

Please sign in to comment.