Exemplo n.º 1
0
 def add_obo_hierarchies(self):
     from indra.databases import obo_client
     namespaces = ['go', 'efo', 'hp', 'doid', 'chebi']
     edges = []
     rel_mappings = {
         'xref': 'xref',
         'isa': 'isa',
         'partof': 'partof',
         'is_a': 'isa',
         'part_of': 'partof',
         # These are for ChEBI: identical to the old behavior but it might
         # make sense to add other relations here too
         'is_conjugate_acid_of': 'isa',
         'has_functional_parent': 'isa',
         'has_parent_hydride': 'isa',
         'has_role': 'isa'
     }
     for ns in namespaces:
         oc = obo_client.OboClient(prefix=ns)
         for db_id, entry in oc.entries.items():
             for rel, targets in entry.get('relations', {}).items():
                 # Skip unknown relation types
                 mapped_rel = rel_mappings.get(rel)
                 if not mapped_rel:
                     continue
                 for target in targets:
                     edges.append((self.label(ns.upper(), db_id),
                                   self.label(ns.upper(), target),
                                   {'type': mapped_rel}))
     self.add_edges_from(edges)
Exemplo n.º 2
0
 def add_obo_nodes(self):
     from indra.databases import obo_client
     namespaces = ['go', 'efo', 'hp', 'doid', 'chebi']
     nodes = []
     for ns in namespaces:
         oc = obo_client.OboClient(prefix=ns)
         for db_id, entry in oc.entries.items():
             nodes.append((self.label(ns.upper(), db_id),
                           {'name': entry['name']}))
     self.add_nodes_from(nodes)