Skip to content

Extract class relationships for all properties and axiom shapes - #37

Merged
jvendetti merged 1 commit into
ncbo:masterfrom
matthewhorridge:feature/principled-relationship-extraction
Aug 7, 2026
Merged

Extract class relationships for all properties and axiom shapes#37
jvendetti merged 1 commit into
ncbo:masterfrom
matthewhorridge:feature/principled-relationship-extraction

Conversation

@matthewhorridge

@matthewhorridge matthewhorridge commented Jul 31, 2026

Copy link
Copy Markdown

Fixes #38.

What

Extracts class-to-class (and class-to-individual) relationships for all object properties and from a wider range of axiom shapes, so they surface in a class's property listing (the Details view).

generateGroundTriplesForAxioms only recognises the flat shape SubClassOf(A, someValuesFrom(p, B)), and only for a hard-coded set of OBO properties (part_of, contains, develops_from and their IRIs), gated on the property IRI containing the substring obo. Relationships on any other property — for example EDAM's has_topic / has_output / has_input, or UBERON's many RO/BSPO relations — are silently dropped. This is why some relationships appear on a class and others do not.

Change

Adds generateRelationshipTriples, run alongside the existing method. For every SubClassOf and EquivalentClasses axiom of a named class A, it walks the class expression and emits a relationship A --p--> filler (as an annotation assertion under the property's own IRI) for:

  • someValuesFrom(p, namedClass)
  • hasValue(p, individual)
  • min / exact cardinality (n ≥ 1) on p with a named filler

Recursion descends into ObjectIntersectionOf operands, so relationships nested inside an intersection, and those stated via an equivalence, are extracted too. Unions and complements are not traversed (their operands are not entailed for every instance of A), and allValuesFrom is not emitted (it is a constraint, not an existential relationship).

The change is additive: the existing OBO treeView / metadata/obo/* emission is untouched, so the class hierarchy is unaffected. Only the relationship coverage in the Details view grows.

Testing

  • New RelationshipExtractionTest with a fixture (src/test/resources/repo/input/relations/relations.ttl) covering each extracted shape (bare someValuesFrom, someValuesFrom nested in an intersection, EquivalentClasses + intersection, hasValue, min-cardinality) and the two that must not be extracted (allValuesFrom, union operands).
  • Full suite green (48 tests, previously 47); the OBO hierarchy behaviour is preserved.
  • Verified on real ontologies:
    • EDAM: has_topic (207), has_output (147), has_input (56) now emitted — previously 0.
    • UBERON: relation types exposed go from ~3 (part_of, develops_from, contains) to ~180, adding has part, regulates / positively / negatively regulates, occurs in, in taxon, capable of, the BSPO spatial relations, and UBERON's own connectivity relations. Parse time unchanged (~13s on the 96 MB file).

Follow-ups (not in this PR)

  • The treeView / hierarchy path is still OBO-only and whitelist-based; broadening it changes the class tree and is deferred.
  • The BioPortal Details view should be revisited once this is merged: a sensible ordering for the now-larger relationship set, and de-duplication against the legacy metadata/obo/* remapping (e.g. part_of may now appear both under its own IRI and under obo/part_of).

@matthewhorridge
matthewhorridge force-pushed the feature/principled-relationship-extraction branch from 60e9a9f to f43b0db Compare July 31, 2026 18:00
generateGroundTriplesForAxioms only recognised the flat shape
SubClassOf(A, someValuesFrom(p, B)) and only for a hard-coded set of OBO
properties (part_of, contains, develops_from and their IRIs), gated on the
property IRI containing "obo". Relationships on any other property — e.g.
EDAM's has_topic/has_output/has_input — were silently dropped, which is why
some relationships appear in the class Details view and others do not.

Add generateRelationshipTriples, which visits the class expression of every
SubClassOf and EquivalentClasses axiom of a named class (RelationshipVisitor,
an OWLClassExpressionVisitorAdapter) and emits a relationship triple
(subject --p--> filler, under the property's own IRI) for every
someValuesFrom, hasValue, and min/exact cardinality (n >= 1). Intersection
operands are traversed, both in the superclass expression and in a
restriction's filler, so SubClassOf(A, p some (B and C)) yields A p B and
A p C, and relationships stated via equivalences are extracted too. Unions,
complements and allValuesFrom are not traversed/emitted (not entailed for
every instance).

This is additive: the existing OBO treeView/hierarchy emission is left
unchanged, so the class tree is unaffected; the Details view now shows the
full set of relationships. Verified on EDAM and UBERON, and with a fixture
covering each shape.
@jvendetti

Copy link
Copy Markdown
Member

Noting here that this change passes unit tests (in my local dev env) for ontologies_linked_data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relationship extraction is limited to a hard-coded set of OBO properties in one axiom shape

2 participants