def test_GO_relation_1(): relation = GO.GO_relation({'id': ['rel'], 'name': ['relation']}) assert relation.id == 'rel' assert relation.name == 'relation' assert relation.is_transitive == False assert relation.others == {} assert str(relation) == '<rel>'
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)]