Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4da6887
chores: basic sandbox script for undestanding the use case
ecarrenolozano Aug 8, 2025
9c302bb
chores: add notebook to explore categories in graph
ecarrenolozano Aug 21, 2025
7db3504
chores: successful creation of ontology skeleton for the swisslipids
ecarrenolozano Aug 22, 2025
c9e1369
feat: produce ontology optimized loop
ecarrenolozano Sep 1, 2025
78dd354
chores: generate ontology with properties (worst case)
ecarrenolozano Sep 1, 2025
127f37e
chores: generalize the process of converting ontologie from a well st…
ecarrenolozano Sep 4, 2025
1d25814
chores: create generic pipeline to generate ontology and mapping file…
ecarrenolozano Sep 8, 2025
29cf1ca
chores: fix yaml name and link in the notebook
ecarrenolozano Sep 8, 2025
12a6ce9
chores: update documentation diagram pipeline
ecarrenolozano Sep 8, 2025
1e815a9
fix: comment path to dummy dataset and improve readability in yaml
ecarrenolozano Sep 8, 2025
4bf5eb1
chores: autoupdate pre-commit hooks
ecarrenolozano Sep 11, 2025
c7b1f99
feat: create functionality to load mapping files for id translation
ecarrenolozano Sep 11, 2025
3bacde6
chores: update notebook to demostrate or experiment with the mapping…
ecarrenolozano Sep 11, 2025
2e83232
chores: remove unnecessary files from branch
ecarrenolozano Sep 11, 2025
71b1893
fix: correct formatting with ruff
ecarrenolozano Sep 11, 2025
79f4e60
chores: add pandas library to the official list of dependencies
ecarrenolozano Sep 11, 2025
53cd8f1
chores: add docstring to the module utils
ecarrenolozano Sep 11, 2025
0e03b90
test: add unit tests for the function _read_mapping_file
ecarrenolozano Sep 11, 2025
a5f910c
fix: fix functionality for _read_mapping_file based on failed tests
ecarrenolozano Sep 11, 2025
2a29506
test: add unit tests for the function _create_reverse_mapping
ecarrenolozano Sep 11, 2025
621337c
fix: correct _create_reverse_mapping based on failing cases in unit t…
ecarrenolozano Sep 11, 2025
b50c630
fix: correct functions based on failing tests
ecarrenolozano Sep 11, 2025
5cc0467
test: add unit tests for the function load_mapping_lut
ecarrenolozano Sep 11, 2025
cf39335
test: add unit tests for the function translate_ids
ecarrenolozano Sep 11, 2025
df52f7d
fix: fix functionality for the function translate_ids based on failin…
ecarrenolozano Sep 11, 2025
ae221ad
test: add unit tests for the class MappingLUT
ecarrenolozano Sep 11, 2025
0af56c9
chores: remove TODOs for the class MappingLUT
ecarrenolozano Sep 11, 2025
fc96dc0
fix: fix type hints for _create_reverse_mapping
ecarrenolozano Sep 12, 2025
75be718
fix: remove redundancy in condition for empty mapping lookup table
ecarrenolozano Sep 12, 2025
85bd8fa
fix: update type hints and docstrings to align with recent changes an…
ecarrenolozano Sep 12, 2025
a7238ab
chores: verify lowest common ancestors case in the notebook
ecarrenolozano Sep 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ default_stages:
repos:
# Fast Python linter and formatter with auto-fix support
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
rev: v0.13.0
hooks:
- id: ruff-check
args: [--fix, --show-fixes]
Expand All @@ -42,7 +42,7 @@ repos:

# Official pre-commit-hooks for general checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0 # Check for updates regularly
rev: v6.0.0 # Check for updates regularly
hooks:
- id: check-added-large-files
stages: [pre-commit, pre-push]
Expand Down Expand Up @@ -71,7 +71,7 @@ repos:

# Format code blocks in documentation files
- repo: https://github.com/asottile/blacken-docs
rev: 1.19.1
rev: 1.20.0
hooks:
- id: blacken-docs
stages: [pre-commit]
Expand Down
254 changes: 254 additions & 0 deletions notebooks/chebi_mix_ontology.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0",
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"\n",
"from ontograph.utils import translate_ids\n",
"from ontograph.client import ClientOntology"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"metadata": {},
"outputs": [],
"source": [
"logging.basicConfig(level=logging.INFO)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"PATH_ONTOLOGY_FILE = '../data/out/swiss_lipids_ontology.obo'\n",
"PATH_MAPPING_FILE = '../data/out/swiss_lipids_mapping_ids.csv'"
]
},
{
"cell_type": "markdown",
"id": "3",
"metadata": {},
"source": [
"## Experimentation"
]
},
{
"cell_type": "markdown",
"id": "4",
"metadata": {},
"source": [
"1. Read an ontology file\n",
"\n",
"2. Read a mapping file:\n",
" - 2.1. Read the mapping file\n",
" - 2.2. Create a LUT.\n",
"\n",
"3. When look for terms do the following:\n",
" - 3.1. If a LUT exist:\n",
" - Translate the term\n",
" - 3.2. Return the terms of interest in the table.\n",
"\n",
"4. Apply the operation in the ontology"
]
},
{
"cell_type": "markdown",
"id": "5",
"metadata": {},
"source": [
"Use cases\n",
"```markdown\n",
"\n",
"SwisslipidsOntology.common_ancestors('HMDB0000232', 'HMDB0000765', 'HMDB0000342')\n",
"['SWL:0000234']\n",
"\n",
"SwisslipidsOntology.terms_for('HMDB0000232')\n",
"['SWL:0000234']\n",
"\n",
"\n",
"SwisslipidsOntology.mappings()\n",
"['hmdb', 'lipidmaps', 'metanetx']\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "6",
"metadata": {},
"source": [
"### Read ontology"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [],
"source": [
"swiss_onto = ClientOntology()"
]
},
{
"cell_type": "markdown",
"id": "8",
"metadata": {},
"source": [
"### Load ontology file"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": [
"swiss_onto.load(file_path_ontology=PATH_ONTOLOGY_FILE)"
]
},
{
"cell_type": "markdown",
"id": "10",
"metadata": {},
"source": [
"### Load mapping file"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"metadata": {},
"outputs": [],
"source": [
"swiss_onto.load_mapping(\n",
" filepath=PATH_MAPPING_FILE,\n",
" delimiter='\\t',\n",
" # target_column=\"chebi_id\",\n",
" target_column='swiss_lipid_id',\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "12",
"metadata": {},
"outputs": [],
"source": [
"test_ids_diverse = [\n",
" 'CHEBI:70995', # chebi\n",
" 'SLM:000508824', # swiss lipids\n",
" 'HMDB00032', # hmdb\n",
" 'LMGP01030010', # lipid maps\n",
" 'MNXM2990', # metanetx\n",
" 'CHEBI:88888', # fake chebi id\n",
"]\n",
"\n",
"test_ids_swiss_lipids = [\n",
" 'SLM:000048885',\n",
" 'SLM:000508824',\n",
" 'SLM:000000042',\n",
" 'SLM:000048885',\n",
" 'SLM:000000288',\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "13",
"metadata": {},
"outputs": [],
"source": [
"terms_translated = translate_ids(\n",
" # mapping_lut=None,\n",
" mapping_lut=swiss_onto.get_mapping_lut(),\n",
" terms_id=test_ids_diverse,\n",
" # terms_id=test_ids_swiss_lipids\n",
")\n",
"\n",
"terms_translated"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14",
"metadata": {},
"outputs": [],
"source": [
"for term in swiss_onto.get_terms(terms_translated):\n",
" print(f'\\n{term}')\n",
" for property in term.annotations:\n",
" print(f'\\t{property.property}: {property.literal}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "15",
"metadata": {},
"outputs": [],
"source": [
"for term in swiss_onto.get_terms(test_ids_diverse):\n",
" print(f'\\n{term}')\n",
" for property in term.annotations:\n",
" print(f'\\t{property.property}: {property.literal}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "16",
"metadata": {},
"outputs": [],
"source": [
"swiss_onto.mappings()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17",
"metadata": {},
"outputs": [],
"source": [
"a = swiss_onto.get_mapping_lut()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ontograph (3.10.18)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.18"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading