-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: prototype to support multiple prefixes #225
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e35148d
prototype to support multiple suffixes
Bento007 563093e
prototype to support multiple suffixes
Bento007 cdf8692
prototype to support multiple suffixes
Bento007 7aa656d
update _get_ancestors to support allowed_ontologies
Bento007 c0ce9b0
update ontology_term_id_schema.json with AfPO
Bento007 777bb0e
fix ontology builder unit tests + add multi-ontology unit test
nayib-jose-gloria e78dd34
lint
nayib-jose-gloria 1a8f886
fix codecov
nayib-jose-gloria aae57a7
revert HANCESTRO test bump
nayib-jose-gloria 3949116
revert AfPo term inclusion
nayib-jose-gloria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,4 +148,4 @@ | |
}, | ||
"deprecated_on": "2024-05-10" | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import pytest | ||
from all_ontology_generator import ( | ||
_download_ontologies, | ||
_extract_ontology_term_metadata, | ||
_parse_ontologies, | ||
deprecate_previous_cellxgene_schema_versions, | ||
get_ontology_info_file, | ||
|
@@ -45,6 +46,16 @@ | |
return str(sub_dir) | ||
|
||
|
||
@pytest.fixture | ||
def mock_owl(tmpdir): | ||
import owlready2 | ||
|
||
onto = owlready2.get_ontology("http://example.com/ontology_name.owl") | ||
onto.name = "FAKE" | ||
|
||
return onto | ||
|
||
|
||
def test_get_ontology_info_file_default(mock_ontology_info_file): | ||
# Call the function | ||
ontology_info = get_ontology_info_file(ontology_info_file=mock_ontology_info_file) | ||
|
@@ -224,3 +235,121 @@ | |
deprecate_previous_cellxgene_schema_versions(ontology_info, "v1") | ||
|
||
assert ontology_info == expected_ontology_info | ||
|
||
|
||
@pytest.fixture | ||
def sample_ontology(tmp_path): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nayib-jose-gloria thank you for fixing. |
||
# Create a new ontology | ||
import owlready2 | ||
|
||
onto = owlready2.get_ontology("http://test.org/onto.owl") | ||
onto.name = "FOO" | ||
|
||
with onto: | ||
|
||
class FOO_000001(owlready2.Thing): | ||
label = ["Test Root Term"] | ||
|
||
class FOO_000002(FOO_000001): | ||
label = ["Test Deprecated Descendant Term"] | ||
IAO_0000115 = ["Test description"] | ||
hasExactSynonym = ["Test synonym"] | ||
deprecated = [True] | ||
comment = ["Deprecated term", "See Links for more details"] | ||
IAO_0000233 = ["http://example.org/term_tracker"] | ||
IAO_0100001 = ["http://ontology.org/FOO_000003"] | ||
|
||
class FOO_000003(FOO_000001): | ||
label = ["Test Non-Deprecated Descendant Term"] | ||
|
||
class OOF_000001(owlready2.Thing): | ||
label = ["Test Unrelated Different Ontology Term"] | ||
|
||
class OOF_000002(FOO_000001): | ||
label = ["Test Descendant Different Ontology Term"] | ||
|
||
class FOO_000004(OOF_000002, FOO_000003): | ||
label = ["Test Ontology Term With Different Ontology Ancestors"] | ||
|
||
onto.save(file=str(tmp_path.joinpath("test_ontology.owl"))) | ||
return onto | ||
|
||
|
||
def test_extract_ontology_term_metadata(sample_ontology): | ||
allowed_ontologies = ["FOO"] | ||
nayib-jose-gloria marked this conversation as resolved.
Show resolved
Hide resolved
|
||
result = _extract_ontology_term_metadata(sample_ontology, allowed_ontologies) | ||
|
||
expected_result = { | ||
"FOO:000001": { | ||
"ancestors": {}, | ||
"label": "Test Root Term", | ||
"deprecated": False, | ||
}, | ||
"FOO:000002": { | ||
"ancestors": {"FOO:000001": 1}, | ||
"label": "Test Deprecated Descendant Term", | ||
"description": "Test description", | ||
"synonyms": ["Test synonym"], | ||
"deprecated": True, | ||
"comments": ["Deprecated term", "See Links for more details"], | ||
"term_tracker": "http://example.org/term_tracker", | ||
"replaced_by": "FOO:000003", | ||
}, | ||
"FOO:000003": { | ||
"ancestors": {"FOO:000001": 1}, | ||
"label": "Test Non-Deprecated Descendant Term", | ||
"deprecated": False, | ||
}, | ||
"FOO:000004": { | ||
"ancestors": {"FOO:000001": 2, "FOO:000003": 1}, | ||
"label": "Test Ontology Term With Different Ontology Ancestors", | ||
"deprecated": False, | ||
}, | ||
} | ||
|
||
assert result == expected_result | ||
|
||
|
||
def test_extract_ontology_term_metadata_multiple_allowed_ontologies(sample_ontology): | ||
allowed_ontologies = ["FOO", "OOF"] | ||
result = _extract_ontology_term_metadata(sample_ontology, allowed_ontologies) | ||
|
||
expected_result = { | ||
"FOO:000001": { | ||
"ancestors": {}, | ||
"label": "Test Root Term", | ||
"deprecated": False, | ||
}, | ||
"FOO:000002": { | ||
"ancestors": {"FOO:000001": 1}, | ||
"label": "Test Deprecated Descendant Term", | ||
"description": "Test description", | ||
"synonyms": ["Test synonym"], | ||
"deprecated": True, | ||
"comments": ["Deprecated term", "See Links for more details"], | ||
"term_tracker": "http://example.org/term_tracker", | ||
"replaced_by": "FOO:000003", | ||
}, | ||
"FOO:000003": { | ||
"ancestors": {"FOO:000001": 1}, | ||
"label": "Test Non-Deprecated Descendant Term", | ||
"deprecated": False, | ||
}, | ||
"FOO:000004": { | ||
"ancestors": {"FOO:000001": 2, "FOO:000003": 1, "OOF:000002": 1}, | ||
"label": "Test Ontology Term With Different Ontology Ancestors", | ||
"deprecated": False, | ||
}, | ||
"OOF:000001": { | ||
"ancestors": {}, | ||
"label": "Test Unrelated Different Ontology Term", | ||
"deprecated": False, | ||
}, | ||
"OOF:000002": { | ||
"ancestors": {"FOO:000001": 1}, | ||
"label": "Test Descendant Different Ontology Term", | ||
"deprecated": False, | ||
}, | ||
} | ||
|
||
assert result == expected_result |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
allowed_ontologies
agree withadditional_ontologies
in the schema?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think allowed_ontologies == main ontology + additional ontologies makes intuitive sense as-is