|
129 | 129 | "# 1. Standard library imports\n", |
130 | 130 | "import sys\n", |
131 | 131 | "\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", |
133 | 133 | "\n", |
134 | 134 | "from pathlib import Path\n", |
135 | 135 | "\n", |
|
156 | 156 | "metadata": {}, |
157 | 157 | "outputs": [], |
158 | 158 | "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\")" |
160 | 171 | ] |
161 | 172 | }, |
162 | 173 | { |
|
168 | 179 | "We are going to create a registry based on all the metadata that OBO Foundy has." |
169 | 180 | ] |
170 | 181 | }, |
| 182 | + { |
| 183 | + "cell_type": "markdown", |
| 184 | + "metadata": {}, |
| 185 | + "source": [] |
| 186 | + }, |
171 | 187 | { |
172 | 188 | "cell_type": "code", |
173 | 189 | "execution_count": null, |
|
177 | 193 | "onto_registry = OBORegistryAdapter(cache_dir=cache_dir)" |
178 | 194 | ] |
179 | 195 | }, |
| 196 | + { |
| 197 | + "cell_type": "code", |
| 198 | + "execution_count": null, |
| 199 | + "metadata": {}, |
| 200 | + "outputs": [], |
| 201 | + "source": [ |
| 202 | + "onto_registry.cache_dir" |
| 203 | + ] |
| 204 | + }, |
180 | 205 | { |
181 | 206 | "cell_type": "markdown", |
182 | 207 | "metadata": {}, |
|
241 | 266 | "source": [ |
242 | 267 | "# This function looks if the given ontology has a link with a given extension\n", |
243 | 268 | "\n", |
244 | | - "print('Link: {}'.format(onto_registry.get_download_url('chebi', 'obo')))" |
| 269 | + "print(\"Link: {}\".format(onto_registry.get_download_url(\"chebi\", \"obo\")))" |
245 | 270 | ] |
246 | 271 | }, |
247 | 272 | { |
|
257 | 282 | "metadata": {}, |
258 | 283 | "outputs": [], |
259 | 284 | "source": [ |
260 | | - "print(onto_registry.get_available_formats(ontology_id='chebi'))" |
| 285 | + "print(onto_registry.get_available_formats(ontology_id=\"chebi\"))" |
261 | 286 | ] |
262 | 287 | }, |
263 | 288 | { |
|
301 | 326 | "source": [ |
302 | 327 | "# Put the ontologies and their formats as a dictionary\n", |
303 | 328 | "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", |
307 | 332 | "]\n", |
308 | 333 | "\n", |
309 | 334 | "# Use the downloader, it has a cache in case you have already downloaded the ontologies.\n", |
310 | 335 | "batch_results = downloader.fetch_batch(resources)\n", |
311 | 336 | "\n", |
312 | 337 | "# Print all the paths where your ontologies are located\n", |
313 | | - "print('Ontologies in cache:')\n", |
| 338 | + "print(\"Ontologies in cache:\")\n", |
314 | 339 | "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}\")" |
316 | 341 | ] |
317 | 342 | }, |
318 | 343 | { |
|
351 | 376 | "metadata": {}, |
352 | 377 | "outputs": [], |
353 | 378 | "source": [ |
354 | | - "name_id_go = 'go'\n", |
355 | | - "format_go = 'obo'\n", |
| 379 | + "name_id_go = \"go\"\n", |
| 380 | + "format_go = \"obo\"\n", |
356 | 381 | "\n", |
357 | 382 | "gene_ontology = ontology_loader.load(name_id=name_id_go, format=format_go)\n", |
358 | 383 | "\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())}\")" |
361 | 386 | ] |
362 | 387 | }, |
363 | 388 | { |
|
375 | 400 | "source": [ |
376 | 401 | "# term_id = \"GO:0008150\" # biological_process\n", |
377 | 402 | "# 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" |
379 | 404 | ] |
380 | 405 | }, |
381 | 406 | { |
|
387 | 412 | "queries = OntologyQueries(gene_ontology)\n", |
388 | 413 | "\n", |
389 | 414 | "# 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", |
393 | 418 | "\n", |
394 | 419 | "\n", |
395 | 420 | "# print(f\" Ancestors : {queries.ancestors(term_id)}\")\n", |
|
0 commit comments