def test_GO_relation_5(): bp = GO.GO_category({ 'id': ['GO:0008150'], 'name': ['biological_process'], 'def': [''] }) mp = GO.GO_category({ 'id': ['GO:0008152'], 'name': ['metabolic process'], 'def': [''] }) cp = GO.GO_category({ 'id': ['GO:0009987'], 'name': ['cellular process'], 'def': [''] }) m = GO.GO_category({ 'id': ['GO:0032259'], 'name': ['methylation'], 'def': [''] }) is_a = GO.GO_relation({ 'id': ['is_a'], 'name': ['is_a'], 'is_transitive': [True] }) is_a.add_pair(mp, bp) is_a.add_pair(cp, bp) is_a.add_pair(m, mp) is_a.add_pair(bp, m) # Introduce a cycle for testing. is_a_copy = is_a.copy() assert is_a == is_a_copy
def test_GO_relation_4(): bp = GO.GO_category({ 'id': ['GO:0008150'], 'name': ['biological_process'], 'def': [''] }) mp = GO.GO_category({ 'id': ['GO:0008152'], 'name': ['metabolic process'], 'def': [''] }) cp = GO.GO_category({ 'id': ['GO:0009987'], 'name': ['cellular process'], 'def': [''] }) m = GO.GO_category({ 'id': ['GO:0032259'], 'name': ['methylation'], 'def': [''] }) is_a = GO.GO_relation({ 'id': ['is_a'], 'name': ['is_a'], 'is_transitive': [True] }) is_a.add_pair(mp, bp) is_a.add_pair(cp, bp) is_a.add_pair(m, mp) is_a.add_pair(m, bp) # Because the relation is transitive. assert (cp, bp) in is_a assert (m, bp) in is_a assert (m, mp) in is_a assert (mp, bp) in is_a assert not (bp, cp) in is_a assert not (bp, m) in is_a assert not (bp, mp) in is_a assert not (cp, m) in is_a assert not (cp, mp) in is_a assert not (m, cp) in is_a assert not (mp, cp) in is_a assert not (mp, m) in is_a assert is_a[bp] == set() assert is_a[cp] == {bp} assert is_a[m] == {bp, mp} assert is_a[mp] == {bp} assert sorted(is_a) == [(mp, bp), (cp, bp), (m, bp), (m, mp)]
def test_GO_category_1(): category = GO.GO_category({ 'id': ['42'], 'name': ['fortytwo'], 'def': ['answer'] }) assert category.id == '42' assert category.name == 'fortytwo' assert category.defination == 'answer' assert category.others == {} assert str(category) == '42 (fortytwo)'