def _make_activity_graph(self): self.activity_graph = networkx.DiGraph() for a1, a2 in itertools.combinations(self.activity_types, 2): if bio_ontology.isa('INDRA_ACTIVITIES', a1, 'INDRA_ACTIVITIES', a2): self.activity_graph.add_edge(a2, a1) if bio_ontology.isa('INDRA_ACTIVITIES', a2, 'INDRA_ACTIVITIES', a1): self.activity_graph.add_edge(a1, a2)
def isa_cmp(a, b): """Compare two entries based on isa relationships for sorting.""" if not a.startswith('CHEBI:'): a = 'CHEBI:%s' % a if not b.startswith('CHEBI:'): b = 'CHEBI:%s' % b if bio_ontology.isa('CHEBI', a, 'CHEBI', b): return -1 if bio_ontology.isa('CHEBI', b, 'CHEBI', a): return 1 return 0
def test_erk_isa(): assert bio_ontology.isa('HGNC', '6871', 'FPLX', 'MAPK') assert not bio_ontology.isa('HGNC', '6871', 'FPLX', 'JNK')
def test_isa_activity_not(): assert not bio_ontology.isa('INDRA_ACTIVITIES', 'kinase', 'INDRA_ACTIVITIES', 'phosphatase')
def test_isa_entity(): assert bio_ontology.isa('HGNC', '1097', 'FPLX', 'RAF')
def test_isa_mod_not(): assert not bio_ontology.isa('INDRA_MODS', 'phosphorylation', 'INDRA_MODS', 'ubiquitination')
def test_isa_activity(): assert bio_ontology.isa('INDRA_ACTIVITIES', 'kinase', 'INDRA_ACTIVITIES', 'activity')
def test_isa_mod(): assert bio_ontology.isa('INDRA_MODS', 'phosphorylation', 'INDRA_MODS', 'modification')
def test_isa_entity3(): assert not bio_ontology.isa('FPLX', 'RAF', 'HGNC', '1097')
def test_chebi_isa(): assert bio_ontology.isa('CHEBI', 'CHEBI:87307', 'CHEBI', 'CHEBI:36962')
def test_isa_entity2(): assert not bio_ontology.isa('HGNC', '1097', 'HGNC', '646')
def test_eccode_isa(): parents = set(bio_ontology.get_parents('ECCODE', '1.1.1.1')) assert parents == {('ECCODE', '1.1.1'), ('ECCODE', '1.1'), ('ECCODE', '1')}, parents assert bio_ontology.isa('ECCODE', '1.1.1.1', 'ECCODE', '1.1.1')