def test_get_single(self): lateral_map = MapLateral(self.ham_analysis) map_human_euarc = HOGsMap(self.ham_analysis, self.human, self.euarchontoglires) self.assertTrue(map_human_euarc.consistent) lateral_map.add_map(map_human_euarc) map_rat_euarc = HOGsMap(self.ham_analysis, self.rat, self.euarchontoglires) self.assertTrue(map_rat_euarc.consistent) lateral_map.add_map(map_rat_euarc) single = lateral_map.get_retained() for hog in single.keys(): if str(hog) == "<HOG(3.E.1)>": H3_E_1 = hog elif str(hog) == "<HOG(1.M.E)>": H1_M_E = hog elif str(hog) == "<HOG(2.E)>": H2_E = hog self.assertDictEqual({str(self.human): "Gene(3)"}, _str_dict_one_value(single[H3_E_1])) self.assertDictEqual( { str(self.human): "Gene(1)", str(self.rat): "Gene(41)" }, _str_dict_one_value(single[H1_M_E])) self.assertDictEqual({str(self.human): "Gene(2)"}, _str_dict_one_value(single[H2_E]))
def test_get_lost(self): lateral_map = MapLateral(self.ham_analysis) map_human_euarc = HOGsMap(self.ham_analysis, self.human, self.euarchontoglires) self.assertTrue(map_human_euarc.consistent) lateral_map.add_map(map_human_euarc) map_rat_euarc = HOGsMap(self.ham_analysis, self.rat, self.euarchontoglires) self.assertTrue(map_rat_euarc.consistent) lateral_map.add_map(map_rat_euarc) loss = lateral_map.get_lost() for hog in loss.keys(): if str(hog) == "<HOG(3.E.2)>": H3_E_2 = hog elif str(hog) == "<HOG(3.E.1)>": H3_E_1 = hog elif str(hog) == "<HOG(2.E)>": H2_E = hog self.assertEqual({self.rat}, set(loss[H2_E])) self.assertEqual({self.rat}, set(loss[H3_E_1])) self.assertEqual({self.rat, self.human}, set(loss[H3_E_2])) # trying if lazy property work loss2 = lateral_map.get_lost() self.assertEqual({self.rat}, set(loss2[H2_E])) self.assertEqual({self.rat}, set(loss2[H3_E_1])) self.assertEqual({self.rat, self.human}, set(loss2[H3_E_2]))
def test_can_only_add_HOGMAP_as_map(self): lateral_map = MapLateral(self.ham_analysis) with self.assertRaises(TypeError): lateral_map.add_map("111") with self.assertRaises(TypeError): lateral_map.add_map("")
def test_cannot_add_map_with_different_ancestor(self): lateral_map = MapLateral(self.ham_analysis) map = HOGsMap(self.ham_analysis, self.human, self.euarchontoglires) self.assertTrue(map.consistent) lateral_map.add_map(map) map2 = HOGsMap(self.ham_analysis, self.human, self.vertebrates) self.assertTrue(map2.consistent) with self.assertRaises(TypeError): lateral_map.add_map(map2)
def test_create_correctly_lateral_map(self): lateral_map = MapLateral(self.ham_analysis) map = HOGsMap(self.ham_analysis, self.human, self.euarchontoglires) self.assertTrue(map.consistent) lateral_map.add_map(map) map2 = HOGsMap(self.ham_analysis, self.rodents, self.euarchontoglires) self.assertTrue(map2.consistent) lateral_map.add_map(map2) self.assertEqual(self.euarchontoglires, lateral_map.ancestor) self.assertEqual([self.human, self.rodents], lateral_map.descendants) self.assertEqual(self.ham_analysis, lateral_map.HAM)
def test_get_gained(self): lateral_map = MapLateral(self.ham_analysis) map_frog_vertebrate = HOGsMap(self.ham_analysis, self.frog, self.vertebrates) self.assertTrue(map_frog_vertebrate.consistent) lateral_map.add_map(map_frog_vertebrate) map_human_euarc = HOGsMap(self.ham_analysis, self.human, self.vertebrates) self.assertTrue(map_human_euarc.consistent) lateral_map.add_map(map_human_euarc) gain = lateral_map.get_gained() self.assertEqual(set(), set(_str_array(gain[self.frog]))) self.assertEqual({"Gene(2)", "Gene(5)"}, set(_str_array(gain[self.human])))
def test_get_duplicated(self): lateral_map = MapLateral(self.ham_analysis) map_human_vert = HOGsMap(self.ham_analysis, self.human, self.vertebrates) self.assertTrue(map_human_vert.consistent) lateral_map.add_map(map_human_vert) map_mouse_vert = HOGsMap(self.ham_analysis, self.mouse, self.vertebrates) self.assertTrue(map_mouse_vert.consistent) lateral_map.add_map(map_mouse_vert) duplicate = lateral_map.get_duplicated() for hog in duplicate.keys(): if str(hog) == "<HOG(3)>": H = hog self.assertDictEqual( { str(self.human): {"Gene(3)"}, str(self.mouse): {'Gene(33)', 'Gene(34)'} }, _str_dict_array_value(duplicate[H]))