|
| 1 | +"""Generate mappings using Gilda from UBERON to MeSH.""" |
| 2 | + |
| 3 | +import gilda |
| 4 | +import obonet |
| 5 | +from indra.databases import mesh_client |
| 6 | + |
| 7 | +from biomappings.resources import PredictionTuple, append_prediction_tuples |
| 8 | + |
| 9 | +g = obonet.read_obo("/Users/ben/src/uberon/src/ontology/uberon-edit.obo") |
| 10 | + |
| 11 | +mappings = {} |
| 12 | +for node, data in g.nodes(data=True): |
| 13 | + if not node.startswith("UBERON"): |
| 14 | + continue |
| 15 | + mesh_refs = [xref for xref in data.get("xref", []) if xref.startswith("MESH")] |
| 16 | + if mesh_refs: |
| 17 | + continue |
| 18 | + matches = gilda.ground(data["name"]) |
| 19 | + if matches and matches[0].term.db == "MESH": |
| 20 | + mappings[node] = matches[0].term.id |
| 21 | + |
| 22 | +print("Found %d UBERON->MESH mappings." % len(mappings)) |
| 23 | + |
| 24 | +predictions = [] |
| 25 | +for uberon_id, mesh_id in mappings.items(): |
| 26 | + pred = PredictionTuple( |
| 27 | + source_prefix="uberon", |
| 28 | + source_id=uberon_id, |
| 29 | + source_name=g.nodes[uberon_id]["name"], |
| 30 | + relation="skos:exactMatch", |
| 31 | + target_prefix="mesh", |
| 32 | + target_identifier=mesh_id, |
| 33 | + target_name=mesh_client.get_mesh_name(mesh_id), |
| 34 | + type="lexical", |
| 35 | + confidence=0.9, |
| 36 | + source="generate_uberon_mesh_mappings.py", |
| 37 | + ) |
| 38 | + predictions.append(pred) |
| 39 | + |
| 40 | +append_prediction_tuples(predictions, deduplicate=True, sort=True) |
0 commit comments