From f188b4c4496442fcb40d8076e54897d2546c39b4 Mon Sep 17 00:00:00 2001 From: Shing Zhan Date: Thu, 15 Jun 2023 16:11:34 +0100 Subject: [PATCH] Comment and do minor refactor --- tests/test_compare_vcfs.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_compare_vcfs.py b/tests/test_compare_vcfs.py index 723aab2..cdd7d4a 100644 --- a/tests/test_compare_vcfs.py +++ b/tests/test_compare_vcfs.py @@ -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]], @@ -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]],