Repository navigation
Fix obograph_source prefix-map destruction and predicate mapping - #548
Merged
Merged
Conversation
Two related bugs in the obograph TSV pipeline that together caused obojson
IRIs to land as URIs (instead of CURIEs) in TSV output and well-mapped RO
relations like RO:0002162 (in_taxon) to be demoted to biolink:related_to.
- TsvSource and SssomSource set_prefix_map now use update_prefix_map
(additive) rather than set_prefix_map (destructive). The base
PrefixManager loads ~600 default JSON-LD prefix mappings in __init__;
the transformer's source.set_prefix_map({}) call was wiping them.
- ObographSource.read_edge passes the already-computed CURIE (not the IRI)
to bmt's get_element_by_mapping, so RO:* relations with biolink slot
mappings resolve correctly instead of falling through to related_to.
Adjusted test_read_obograph1/test_read_jsonl2 expected edge count from 205
to 206: previously, two distinct relations between the same node pair
(BFO:0000050 and RO:0002211) were both demoted to biolink:related_to and
produced colliding deterministic edge ids that conflated in the test's dict.
With BFO:0000050 now mapped correctly to biolink:part_of, all three edges
are kept distinct.
Closes #546.
Closes #547.
kevinschaper
added a commit
to Knowledge-Graph-Hub/kg-phenio
that referenced
this pull request
May 9, 2026
Three small follow-ups surfaced when running the new gene-taxon materializer against a real phenio.json with a kgx checkout that has biolink/kgx#548 applied (the prefix-map fix that finally lets identifiers.org/{hgnc,ncbigene}/ URIs contract to CURIEs through ObographSource): - sources.py: add NCBIGene to EDGE_SOURCES and NODE_SOURCES with ("ncbi-gene", "Gene"). Previously NCBIGene URIs were always dropped by BAD_PREFIXES on the subject side, so the maps never had to know about them. With kgx contracting them now, phenio_node_sources.py's category_sources/infores_sources lookups would KeyError otherwise. - phenio_node_sources.py: switch the category_sources / infores_sources lookups to .get() with safe defaults. The kgx fix lets several previously- filtered prefixes flow through (e.g. MAXO, dct, prov, GOREL, UBERON_CORE); unknown ones now keep whatever category kgx assigned and fall back to a lower-cased prefix as the infores name rather than crashing the whole transform. - phenio_transform.py: the gene-taxon materializer's subject filter accepts both CURIE and URI form (HGNC:, NCBIGene:, http://identifiers.org/{hgnc, ncbigene}/) so it works whether the upstream kgx has the contraction fix or not. Also always emit in_taxon / in_taxon_label columns even when no rows have a value, since phenio_node_sources.yaml declares them and Koza checks the header on every run. Verified end-to-end: PhenioTransform on the current phenio.json plus this materializer attaches in_taxon to 753 of 769 NCBIGene nodes, with NCBIGene:698782 (macaque MLH1) coming through as "biolink:Gene | MLH1 | infores:ncbi-gene | NCBITaxon:9544 | Macaca mulatta". HGNC nodes pass through cleanly but without taxon (they need the SPARQL update from monarch-initiative/phenio#130 to ship in a phenio rebuild before the materializer has anything to fold for them).
With the get_element_by_mapping(curie) fix, BFO:0000050 maps to biolink:part_of instead of falling through to biolink:related_to. The recovered predicate distinguishes an edge that previously collided on edge-id with another related_to edge between the same nodes, so the post-fix graph correctly preserves one more edge.
This was referenced Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related bugs in the obograph TSV pipeline that together caused obojson IRIs to land as URIs (instead of CURIEs) in TSV output and well-mapped RO relations like
RO:0002162(in_taxon) to be demoted tobiolink:related_to.TsvSource.set_prefix_mapandSssomSource.set_prefix_mapnow useupdate_prefix_map(additive) rather thanset_prefix_map(destructive). The basePrefixManagerloads ~600 default JSON-LD prefix mappings in__init__; the transformer'ssource.set_prefix_map({})call was wiping them, leaving only the three hardcodedbiolink/owlstar/MONARCHentries thatset_prefix_mapre-adds.ObographSource.read_edgepasses the already-computed CURIE (not the IRI) tobmt'sget_element_by_mapping.bmtonly recognizes CURIE form, so the IRI lookup silently returnedNoneand edges fell through to the catch-allbiolink:related_to. Six commonRO:*relations get proper biolink slots after this fix (in_taxon,causes,has_participant,disrupts,caused_by,expresses).Closes #546.
Closes #547.
Test plan
tests/unit/test_source/test_obograph_source.py(one per bug), backed by a small obograph fixture (tests/resources/obograph_curie_and_predicate.json).test_read_obograph1/test_read_jsonl2expected edge count from 205 to 206. Previously, two distinct relations between the same node pair (BFO:0000050andRO:0002211both betweenGO:0007165andGO:0008150) were silently demoted tobiolink:related_toand produced colliding deterministic edge ids ({sub}-{predicate}-{obj}) that conflated in the test's dict. WithBFO:0000050now correctly mapped tobiolink:part_of, all three edges are kept distinct. A code comment in the test explains this.