Skip to content

Commit

Permalink
Comment and do minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Jun 15, 2023
1 parent 5e1345f commit f188b4c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/test_compare_vcfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,19 @@ def test_both_biallelic_same_alleles_different_order():
def test_biallelic_monoallelic():
ds1 = make_test_case()
ds2 = ds1.copy(deep=True)
# At the first site, one allele is shared.
# 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]))
# Subtest 1
actual = compare_vcfs.remap_genotypes(ds1, ds2)
# At the first site, one allele is shared.
# At the second site, no allele is shared.
expected = [
[[1, 1], [1, 1]],
[[2, 2], [2, 2]],
]
assert np.array_equal(actual, expected)
# Subtest 2
actual = compare_vcfs.remap_genotypes(ds2, ds1)
expected = [
[[1, 0], [0, 1]],
Expand All @@ -121,18 +123,20 @@ 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.variant_allele[1] = xr.DataArray([b'A', b'C'])
ds2.call_genotype[0] = xr.DataArray(data=[[0, 1], [1, 0]])
ds2.call_genotype[1] = xr.DataArray(data=[[0, 1], [1, 0]])
# At the first site, one allele is shared.
# At the second site, no allele is shared.
ds2.variant_allele[1] = xr.DataArray([b'A', b'C'])
ds2.call_genotype[1] = xr.DataArray(data=[[0, 1], [1, 0]])
# Subtest 1
actual = compare_vcfs.remap_genotypes(ds1, ds2)
expected = [
[[1, 2], [2, 1]],
[[2, 3], [3, 2]],
]
assert np.array_equal(actual, expected)
# Subtest 2
actual = compare_vcfs.remap_genotypes(ds2, ds1)
expected = [
[[2, 0], [0, 2]],
Expand Down

0 comments on commit f188b4c

Please sign in to comment.