-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add API ontology querying module
- Loading branch information
1 parent
2179ebb
commit 68f3168
Showing
9 changed files
with
34 additions
and
7 deletions.
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import os | ||
|
||
PACKAGE_ROOT = os.path.dirname(os.path.realpath(__file__)) | ||
ALL_ONTOLOGY_JSON = os.path.join(PACKAGE_ROOT, "fixtures/all_ontology.json.gz") | ||
ONTOLOGY_INFO_YML = os.path.join(PACKAGE_ROOT, "fixtures/ontology_info.yml") |
Binary file renamed
BIN
+14.1 MB
.../ontology-references/all_ontology.json.gz → ...ology_guide/fixtures/all_ontology.json.gz
Binary file not shown.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from typing import List | ||
|
||
import env | ||
import gzip | ||
import json | ||
|
||
with gzip.open(env.ALL_ONTOLOGY_JSON, "rt") as f: | ||
ONTOLOGY_DICT = json.load(f) | ||
|
||
|
||
def get_ancestors(term_id: str) -> List[str]: | ||
# TODO: Support List input, Dict return? | ||
# TODO: Regex input validation? | ||
# TODO: docstring | ||
ontology_name = term_id.split(":")[0] | ||
return ONTOLOGY_DICT[ontology_name][term_id]["ancestors"] |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from cellxgene_ontology_guide import query | ||
|
||
|
||
def test_get_ancestors(): | ||
ancestors = query.get_ancestors("UBERON:0000966") | ||
assert len(ancestors) == 39 |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import os | ||
|
||
PACKAGE_ROOT = os.path.dirname(os.path.realpath(__file__)) | ||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(PACKAGE_ROOT))) | ||
FIXTURES_ROOT = os.path.join(ROOT_DIR, "api/python/src/cellxgene_ontology_guide/fixtures") | ||
ONTOLOGY_REF_DIR = os.path.join(PACKAGE_ROOT, "ontology-references") | ||
RAW_ONTOLOGY_DIR = os.path.join(ONTOLOGY_REF_DIR, "raw-files") | ||
ONTO_INFO_YAML = os.path.join(ONTOLOGY_REF_DIR, "ontology_info.yml") | ||
PARSED_ONTOLOGIES_FILE = os.path.join(ONTOLOGY_REF_DIR, "all_ontology.json.gz") | ||
ONTO_INFO_YAML = os.path.join(FIXTURES_ROOT, "ontology_info.yml") | ||
PARSED_ONTOLOGIES_FILE = os.path.join(FIXTURES_ROOT, "all_ontology.json.gz") |