Ejemplo n.º 1
0
    def test_singleton_handling(self):
        a = Gene(hgncid=1, symbol='EZH2')
        # When no name is given, ID is used for comparison
        b = Gene(hgncid=1, symbol=None)
        # EZH1 does not exist, but ID is used for comparison
        c = Gene(hgncid=1, symbol='EZH1')
        # EZH2 exists, is used for comparison
        d = Gene(hgncid=2, symbol='EZH2')
        # EZH2 exists, is used for comparison
        e = Gene(hgncid=None, symbol='EZH2')

        # EZH1 does not exist. ID does not exist => New Gene
        f = Gene(hgncid=2, symbol='EZH1')
        # ID is used for comparison
        g = Gene(hgncid=2, symbol='EZH2')
        # EZH1 is used for comparison
        h = Gene(hgncid=1, symbol='EZH1')
        # EZH1 is used for comparison
        i = Gene(hgncid=None, symbol='EZH1')

        self.assertIs(a, b)
        self.assertIs(a, c)
        self.assertIs(a, d)
        self.assertIs(a, e)
        self.assertIsNot(a, f)
        self.assertIs(a, g)
        self.assertIsNot(a, h)
        self.assertIs(f, h)
        self.assertIs(f, i)

        self.assertEqual(a, b)
        self.assertEqual(a, c)
        self.assertEqual(a, d)
        self.assertEqual(a, e)
        self.assertEqual(a, g)
        self.assertEqual(b, c)
        self.assertEqual(b, d)
        self.assertEqual(b, e)
        self.assertEqual(b, g)
        self.assertEqual(c, d)
        self.assertEqual(c, e)
        self.assertEqual(c, g)
        self.assertEqual(d, e)
        self.assertEqual(d, g)
        self.assertEqual(e, g)
        self.assertNotEqual(a, f)
        self.assertNotEqual(a, h)
        self.assertNotEqual(a, i)
        self.assertNotEqual(b, f)
        self.assertNotEqual(b, h)
        self.assertNotEqual(b, i)
        self.assertNotEqual(c, f)
        self.assertNotEqual(c, h)
        self.assertNotEqual(c, i)
        self.assertNotEqual(d, f)
        self.assertNotEqual(d, h)
        self.assertNotEqual(d, i)
        self.assertNotEqual(e, f)
        self.assertNotEqual(e, h)
        self.assertNotEqual(e, i)

        self.assertEqual(f, h)
        self.assertEqual(f, i)
        self.assertEqual(h, i)

        self.assertEqual(
            len(Gene.keys()),
            2
        )
        self.assertEqual(
            len(Gene.values()),
            2
        )
        self.assertEqual(
            len(set(Gene.values())),
            2
        )
Ejemplo n.º 2
0
def all_genes() -> Set['GeneSingleton']:
    return set(Gene.keys())