Skip to content

Commit

Permalink
Merge pull request #94 from indralab/benchmark_improve
Browse files Browse the repository at this point in the history
Generalizations to benchmarks
  • Loading branch information
bgyori authored Apr 26, 2022
2 parents 3d34600 + b9048af commit 78478eb
Show file tree
Hide file tree
Showing 3 changed files with 19,598 additions and 13 deletions.
36 changes: 35 additions & 1 deletion benchmarks/bioid_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def _get_equivalent_entities(self, curie: str) -> Set[str]:
if prefix == 'PubChem':
chebi_id = get_chebi_id_from_pubchem(identifier)
if chebi_id is not None:
output.add(f'CHEBI:CHEBI:{chebi_id}')
output.add(f'CHEBI:{chebi_id}')
return output

@staticmethod
Expand Down Expand Up @@ -739,6 +739,40 @@ def get_famplex_members():
fplx_members = get_famplex_members()


# NOTE: these mappings are already integrated into equivalences.json
def get_uberon_mesh_mappings():
import obonet
from indra.databases import mesh_client
g = obonet.read_obo('/Users/ben/src/uberon/src/ontology/uberon-edit.obo')
mappings = {}
for node, data in g.nodes(data=True):
xrefs = [x[5:] for x in data.get('xref', []) if x.startswith('MESH')]
if len(xrefs) != 1:
continue
xref = xrefs[0]
if mesh_client.get_mesh_name(xref, offline=True):
mappings[node] = 'MESH:%s' % xref
return mappings


# NOTE: these mappings are already integrated into equivalences.json
def get_cl_mesh_mappings():
import re
classdef_prefix = "# Class: obo:"
mesh_id_pattern = re.compile(r'MESH:[CD][0-9]+')
mappings = {}
with open('/Users/ben/src/cell-ontology/src/ontology/cl-edit.owl', 'r') as fh:
node = None
for line in fh:
if line.startswith(classdef_prefix):
node_owl = line[len(classdef_prefix):len(classdef_prefix) + 10]
node = node_owl.replace('_', ':')
mesh_ids = set(mesh_id_pattern.findall(line))
if node and len(mesh_ids) == 1:
mappings[node] = list(mesh_ids)[0]
return mappings


def get_display_name(ns: str) -> str:
"""Gets row/column name associated to a namespace"""
return nmspace_displaynames[ns] if ns in nmspace_displaynames else ns
Expand Down
Loading

0 comments on commit 78478eb

Please sign in to comment.