Skip to content

Commit

Permalink
Reorganise
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Jun 19, 2023
1 parent d951e76 commit 492a282
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions tests/test_compare_vcfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,21 @@ def test_both_biallelic_same_alleles_different_order():
assert np.array_equal(actual, expected)


def test_biallelic_monoallelic():
def test_both_biallelic_different_alleles():
ds1 = make_test_case()
ds2 = ds1.copy(deep=True)
# At the first site, one allele is shared.
ds2.variant_allele[0] = xr.DataArray([b'C', b'G'])
ds2.call_genotype[0] = xr.DataArray([[0, 1], [1, 0]])
# At the second site, no allele is shared.
for i in np.arange(ds2.variant_contig.size):
ds2.variant_allele[i] = xr.DataArray([b'C', b''])
ds2.call_genotype[i] = xr.DataArray(np.zeros_like(ds2.call_genotype[i]))
ds2.variant_allele[1] = xr.DataArray([b'A', b'C'])
ds2.call_genotype[1] = xr.DataArray([[0, 1], [1, 0]])
# Subtest 1
_, actual = compare_vcfs.remap_genotypes(ds1, ds2)
expected = xr.DataArray(
[
[[1, 1], [1, 1]],
[[2, 2], [2, 2]],
[[1, 2], [2, 1]],
[[2, 3], [3, 2]],
],
dims=["variants", "samples", "ploidy"]
)
Expand All @@ -121,29 +122,28 @@ def test_biallelic_monoallelic():
_, actual = compare_vcfs.remap_genotypes(ds2, ds1)
expected = xr.DataArray(
[
[[1, 0], [0, 1]],
[[2, 1], [1, 2]],
[[2, 0], [0, 2]],
[[3, 2], [2, 3]],
],
dims=["variants", "samples", "ploidy"]
)
assert np.array_equal(actual, expected)


def test_both_biallelic_different_alleles():
def test_biallelic_monoallelic():
ds1 = make_test_case()
ds2 = ds1.copy(deep=True)
# At the first site, one allele is shared.
ds2.variant_allele[0] = xr.DataArray([b'C', b'G'])
ds2.call_genotype[0] = xr.DataArray([[0, 1], [1, 0]])
# At the second site, no allele is shared.
ds2.variant_allele[1] = xr.DataArray([b'A', b'C'])
ds2.call_genotype[1] = xr.DataArray([[0, 1], [1, 0]])
for i in np.arange(ds2.variant_contig.size):
ds2.variant_allele[i] = xr.DataArray([b'C', b''])
ds2.call_genotype[i] = xr.DataArray(np.zeros_like(ds2.call_genotype[i]))
# Subtest 1
_, actual = compare_vcfs.remap_genotypes(ds1, ds2)
expected = xr.DataArray(
[
[[1, 2], [2, 1]],
[[2, 3], [3, 2]],
[[1, 1], [1, 1]],
[[2, 2], [2, 2]],
],
dims=["variants", "samples", "ploidy"]
)
Expand All @@ -152,8 +152,8 @@ def test_both_biallelic_different_alleles():
_, actual = compare_vcfs.remap_genotypes(ds2, ds1)
expected = xr.DataArray(
[
[[2, 0], [0, 2]],
[[3, 2], [2, 3]],
[[1, 0], [0, 1]],
[[2, 1], [1, 2]],
],
dims=["variants", "samples", "ploidy"]
)
Expand Down

0 comments on commit 492a282

Please sign in to comment.