Skip to content

Commit 447f003

Browse files
chores: remove example_usage.py script and update Notebook
1 parent bb5d298 commit 447f003

2 files changed

Lines changed: 42 additions & 35 deletions

File tree

example_usage.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

notebooks/quickstart_demo.ipynb

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"# 1. Standard library imports\n",
130130
"import sys\n",
131131
"\n",
132-
"sys.path.append('/home/ecarreno/SSC-Projects/b_REPOSITORIES/ontograph')\n",
132+
"sys.path.append(\"/home/ecarreno/SSC-Projects/b_REPOSITORIES/ontograph\")\n",
133133
"\n",
134134
"from pathlib import Path\n",
135135
"\n",
@@ -156,7 +156,18 @@
156156
"metadata": {},
157157
"outputs": [],
158158
"source": [
159-
"cache_dir = Path('../data/out')"
159+
"import os\n",
160+
"\n",
161+
"os.getcwd()"
162+
]
163+
},
164+
{
165+
"cell_type": "code",
166+
"execution_count": null,
167+
"metadata": {},
168+
"outputs": [],
169+
"source": [
170+
"cache_dir = Path(\"../data/out\")"
160171
]
161172
},
162173
{
@@ -168,6 +179,11 @@
168179
"We are going to create a registry based on all the metadata that OBO Foundy has."
169180
]
170181
},
182+
{
183+
"cell_type": "markdown",
184+
"metadata": {},
185+
"source": []
186+
},
171187
{
172188
"cell_type": "code",
173189
"execution_count": null,
@@ -177,6 +193,15 @@
177193
"onto_registry = OBORegistryAdapter(cache_dir=cache_dir)"
178194
]
179195
},
196+
{
197+
"cell_type": "code",
198+
"execution_count": null,
199+
"metadata": {},
200+
"outputs": [],
201+
"source": [
202+
"onto_registry.cache_dir"
203+
]
204+
},
180205
{
181206
"cell_type": "markdown",
182207
"metadata": {},
@@ -241,7 +266,7 @@
241266
"source": [
242267
"# This function looks if the given ontology has a link with a given extension\n",
243268
"\n",
244-
"print('Link: {}'.format(onto_registry.get_download_url('chebi', 'obo')))"
269+
"print(\"Link: {}\".format(onto_registry.get_download_url(\"chebi\", \"obo\")))"
245270
]
246271
},
247272
{
@@ -257,7 +282,7 @@
257282
"metadata": {},
258283
"outputs": [],
259284
"source": [
260-
"print(onto_registry.get_available_formats(ontology_id='chebi'))"
285+
"print(onto_registry.get_available_formats(ontology_id=\"chebi\"))"
261286
]
262287
},
263288
{
@@ -301,18 +326,18 @@
301326
"source": [
302327
"# Put the ontologies and their formats as a dictionary\n",
303328
"resources = [\n",
304-
" {'name_id': 'chebi', 'format': 'owl'},\n",
305-
" {'name_id': 'go', 'format': 'obo'},\n",
306-
" {'name_id': 'ado', 'format': 'owl'},\n",
329+
" {\"name_id\": \"chebi\", \"format\": \"owl\"},\n",
330+
" {\"name_id\": \"go\", \"format\": \"obo\"},\n",
331+
" {\"name_id\": \"ado\", \"format\": \"owl\"},\n",
307332
"]\n",
308333
"\n",
309334
"# Use the downloader, it has a cache in case you have already downloaded the ontologies.\n",
310335
"batch_results = downloader.fetch_batch(resources)\n",
311336
"\n",
312337
"# Print all the paths where your ontologies are located\n",
313-
"print('Ontologies in cache:')\n",
338+
"print(\"Ontologies in cache:\")\n",
314339
"for ontology_name, ontology_path in batch_results.items():\n",
315-
" print(f'\\t{ontology_name}: {ontology_path}')"
340+
" print(f\"\\t{ontology_name}: {ontology_path}\")"
316341
]
317342
},
318343
{
@@ -351,13 +376,13 @@
351376
"metadata": {},
352377
"outputs": [],
353378
"source": [
354-
"name_id_go = 'go'\n",
355-
"format_go = 'obo'\n",
379+
"name_id_go = \"go\"\n",
380+
"format_go = \"obo\"\n",
356381
"\n",
357382
"gene_ontology = ontology_loader.load(name_id=name_id_go, format=format_go)\n",
358383
"\n",
359-
"print(f'Loaded ontology: {name_id_go}.{format_go}')\n",
360-
"print(f'Number of terms: {len(gene_ontology.terms())}')"
384+
"print(f\"Loaded ontology: {name_id_go}.{format_go}\")\n",
385+
"print(f\"Number of terms: {len(gene_ontology.terms())}\")"
361386
]
362387
},
363388
{
@@ -375,7 +400,7 @@
375400
"source": [
376401
"# term_id = \"GO:0008150\" # biological_process\n",
377402
"# term_id = \"GO:0160266\" # anestrus phase\n",
378-
"term_id = 'GO:0070360' # symbiont-mediated actin polymerization-dependent cell-to-cell migration in host"
403+
"term_id = \"GO:0070360\" # symbiont-mediated actin polymerization-dependent cell-to-cell migration in host"
379404
]
380405
},
381406
{
@@ -387,9 +412,9 @@
387412
"queries = OntologyQueries(gene_ontology)\n",
388413
"\n",
389414
"# Print term relations\n",
390-
"print(f'Term: {term_id}')\n",
391-
"print(f' Parents : {queries.parents(term_id)}')\n",
392-
"print(f' Children : {queries.children(term_id)}')\n",
415+
"print(f\"Term: {term_id}\")\n",
416+
"print(f\" Parents : {queries.parents(term_id)}\")\n",
417+
"print(f\" Children : {queries.children(term_id)}\")\n",
393418
"\n",
394419
"\n",
395420
"# print(f\" Ancestors : {queries.ancestors(term_id)}\")\n",

0 commit comments

Comments
 (0)