Skip to content

Multiple ontology support#1296

Open
cwant wants to merge 3 commits intoElixirTeSS:masterfrom
cwant:cwant/multi_ontology
Open

Multiple ontology support#1296
cwant wants to merge 3 commits intoElixirTeSS:masterfrom
cwant:cwant/multi_ontology

Conversation

@cwant
Copy link
Copy Markdown
Contributor

@cwant cwant commented Apr 29, 2026

Summary of changes

This is a scheme to specify multiple ontologies for a field that is completely backwards compatible with the current single ontology implementation.

As before, we can specify an ontology like we do in the models:

has_ontology_terms(:scientific_topics, branch: EDAM.topics)

(This takes the default of Edam::Ontology.instance for the ontology argument.)

Now you could allow terms from more than one ontology, like in the tests in test/unit/has_ontology_terms_test.rb:

 has_ontology_terms(:test_topics, ontology: DummyOntology.instance)
 has_ontology_terms(:multi_test_topics,
                     ontologies: [{ ontology: Edam::Ontology.instance,
                                    branch: EDAM.topics},
                                  { ontology: DummyOntology.instance}])

The ontologies argument takes an array of hashes, each hash having keys ontology and branch (and if either key is excluded, it takes similar defaults as before).
In the example above, terms come from Edam (topics branch) and from DummyOntology (no branch specified).

Motivation and context

Explora uses multiple ontologies for scientific topics, and this implementation is adapted from that work. In the Explora case, we use a preferred ontology (CRDC from Statistics Canada) that we expose in the user interface (auto-complete), but we also want to be able to ingest Bioschemas that uses Edam.

Out of scope: this work does not address auto-complete in any controllers. The person implementing the ontology has to figure that one out themselves (in the Explora case, we basically did a s/edam/crdc/ and renames EdamController to CRDCController.

Screenshots

Not much to screenshot, since this works at a very abstract level and in fact there are no concrete examples in the code base. The test to look at though is test/unit/has_ontology_terms_test.rb, which has examples of this working in a mocked sense.

Checklist

  • I have read and followed the CONTRIBUTING guide.
  • I confirm that I have the authority necessary to make this contribution on behalf of its copyright owner and agree to license it to the TeSS codebase under the BSD license.

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.

1 participant