Beispiel #1
0
    def test_pack_unpack_diploid(self):
        """Check that genotypes survive pack/unpack round trip."""

        genotypes = np.array([[[0, 0], [0, 1]],
                              [[1, 1], [-1, -1]],
                              [[6, 6], [7, 7]],
                              [[10, 10], [14, 14]]], dtype='i1')
        packed = pack_diploid(genotypes)
        self.assertEqual(BHOM00, packed[0, 0])
        self.assertEqual(BHET01, packed[0, 1])
        self.assertEqual(BHOM11, packed[1, 0])
        self.assertEqual(BMISSING, packed[1, 1])
        actual = unpack_diploid(packed)
        self.assertTrue(np.array_equal(genotypes, actual))
Beispiel #2
0
    def test_pack_diploid_ref_zero(self):
        """Check that hom ref calls are encoded as 0 for sparse matrices."""

        genotypes = np.array([[[0, 0]]], dtype='i1')
        packed = pack_diploid(genotypes)
        self.assertEqual(0, packed[0, 0])