Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalizations to benchmarks #94

Merged
merged 6 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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