Esempio n. 1
0
    def test_remove_child(self):
        a = HOG(id="a")
        b = HOG(id="b")
        c = HOG(id="b")

        self.assertListEqual(a.children, [])

        a.add_child(b)
        a.add_child(c)
        self.assertListEqual(a.children, [b,c])

        a.remove_child(b)
        self.assertListEqual(a.children, [c])
Esempio n. 2
0
 def test_add_score(self):
     a = HOG()
     a.score('testscore', 0.932)
     self.assertAlmostEqual(a.score('testscore'), 0.932)
Esempio n. 3
0
 def test_representation_of_Hog(self):
     a = HOG(id="441.2a", bla="don't know")
     self.assertEqual("{!r}".format(a), "<HOG(441.2a)>")
Esempio n. 4
0
    def test_only_one_genome_possible(self):
        h = HOG()

        # invalid genome
        with self.assertRaises(TypeError):
            h.set_genome("wrong")

        # valid ancestral genome
        a = AncestralGenome()
        h.set_genome(a)

        # invalid extant genome
        hum = ExtantGenome("HUMAN", "1")
        with self.assertRaises(TypeError):
            h.set_genome(hum)

        # cannot reassign a genome is already set
        b = AncestralGenome()
        with self.assertRaises(ECE):
            h.set_genome(b)

        # but same twice should be ok
        h.set_genome(a)
Esempio n. 5
0
 def test_cannot_be_child_of_self(self):
     a = HOG()
     with self.assertRaises(ECE):
         a.add_child(a)
Esempio n. 6
0
 def test_cannot_add_any_type_as_child(self):
     a = HOG()
     with self.assertRaises(TypeError):
         a.add_child("test")
Esempio n. 7
0
 def test_hog_can_be_nested_and_traversed_up_and_down(self):
     a = HOG(id="a")
     b = HOG(id="b")
     a.add_child(b)
     self.assertIn(b, b.parent.children)
Esempio n. 8
0
 def test_unknown_score_raises_keyerror(self):
     a = HOG()
     with self.assertRaises(KeyError):
         a.score('testscore')