Multiple ontology support#1296
Open
cwant wants to merge 6 commits intoElixirTeSS:masterfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR generalizes ontology-term handling so models can accept terms from multiple ontologies instead of only EDAM, while keeping existing single-ontology declarations working the same way in the core codebase.
Changes:
- Extends
has_ontology_termsto accept anontologies:array and adds tests covering single- and multi-ontology assignment by names and URIs. - Adds ontology-level URI matching/lookup helpers so
OntologyTermLinkcan resolve terms from different ontology implementations. - Renames the EDAM-specific synonym concern to a more generic name and updates
Event,Material, andWorkflowto use it.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
test/unit/has_ontology_terms_test.rb |
Adds new unit coverage for custom and multi-ontology term assignment. |
lib/has_ontology_terms.rb |
Extends the macro to support multiple ontologies and changes field registration behavior. |
app/ontologies/ontology.rb |
Adds abstract URI helpers to the base ontology class. |
app/ontologies/edam/ontology.rb |
Adds combined label/synonym lookup for EDAM. |
app/models/workflow.rb |
Switches workflow synonym helper concern to the renamed module. |
app/models/ontology_term_link.rb |
Resolves linked terms by ontology URI prefix instead of assuming EDAM. |
app/models/material.rb |
Switches material synonym helper concern to the renamed module. |
app/models/event.rb |
Switches event synonym helper concern to the renamed module. |
app/models/concerns/has_terms_and_synonyms.rb |
Renames and retains the term/synonym expansion helper used for indexing. |
Comments suppressed due to low confidence (1)
app/models/concerns/has_terms_and_synonyms.rb:16
- This concern is still EDAM-specific:
OntologyTermonly provideslabel/uri, andhas_exact_synonym/has_narrow_synonymare added only byEdam::Term. As soon as a resource contains terms from another ontology, calls likescientific_topics_and_synonymswill raise here during indexing/search.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…iable work better with STI (have not really tested the STI part). Seems to work (in the "test suite passes" sense), and does not suffer from the same inheritance problems that the cattr_accessor code had (the specific problem is that fields added to `ontology_term_fields` would infect the superclass!).
Contributor
Author
|
All (current) Co-pilot suggestions resolved. |
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 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:
(This takes the default of
Edam::Ontology.instancefor theontologyargument.)Now you could allow terms from more than one ontology, like in the tests in
test/unit/has_ontology_terms_test.rb:The
ontologiesargument takes an array of hashes, each hash having keysontologyandbranch(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 renamesEdamControllertoCRDCController.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