-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upgrade sphinx. Fixes #512 * doc-refactor * refactor * Update obo_graph_to_fhir_converter.py --------- Co-authored-by: Harshad <[email protected]>
- Loading branch information
Showing
68 changed files
with
263 additions
and
606 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,5 +1,7 @@ | ||
.. _concepts: | ||
|
||
**NOTE** this is largely replaced by the :ref:`guide` | ||
|
||
Ontology Concepts | ||
================= | ||
|
||
|
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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
Introduction | ||
------------ | ||
|
||
Ontology Access Toolkit (OAK) is a Python library for common | ||
:term:`Ontology` operations over a variety of :term:`Adapters<Adapter>`. | ||
|
||
This library provides a collection of different :term:`Interfaces<Interface>` for different | ||
kinds of ontology operations, including: | ||
|
||
- basic features of an :term:`Ontology Element`, such as its :term:`Label`, :term:`Definition`, | ||
:term:`Relationships<Relationship>`, or :term:`Synonyms<Synonym>`. | ||
- :term:`Search` an ontology for a term. | ||
- :term:`Apply` modifications to terms, including adding, deleting, or updating | ||
- numerous specialized operations, such as :term:`Graph Traversal`, or :term:`Axiom` processing, | ||
:term:`Ontology Alignment`, or :term`Text Annotation`. | ||
|
||
These interfaces are *separated* from any particular backend. This means | ||
the same API can be used regardless of whether the ontology: | ||
|
||
- is served by a remote API such as :term:`OLS` or :term:`BioPortal`. | ||
- is present locally on the filesystem in :term:`OWL`, :term:`OBO Format`, | ||
:term:`OBO Graphs`, or :term:`SQLite` formats. | ||
- is to be downloaded from a remote :term:`Ontology Repository` such as the :term:`OBO Library`. | ||
- is queried from a remote database, including :term:`SPARQL` endpoints, A SQL | ||
database, a Solr/ES endpoint. | ||
|
||
Basic Python Example | ||
~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The following code will load an ontology from a :term:`SQLite` database, lookup | ||
basic information on terms matching a search | ||
|
||
.. code:: python | ||
>>> from oaklib import get_adapter | ||
>>> adapter = get_adapter("sqlite:obo:cl") | ||
>>> for curie in adapter.basic_search("T cell"): | ||
... print(f'{curie} ! {si.label(curie)}') | ||
... print(f'Definition: {si.definition(curie)}') | ||
... for rel, fillers in si.outgoing_relationship_map(curie).items(): | ||
... print(f' RELATION: {rel} ! {si.label(rel)}') | ||
... for filler in fillers: | ||
... print(f' * {filler} ! {si.label(filler)}') | ||
Basic Command Line Example | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. code:: bash | ||
$ runoak -i sqlite:obo:obi info "assay" | ||
This does a basic lookup of the term "assay" in :term:`OBI` |
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,83 @@ | ||
.. _best_practice: | ||
|
||
Best Practice | ||
============= | ||
|
||
External Services | ||
----------------- | ||
|
||
Consider making your code robust regardless of whether the ontology implementation is local or a remote service. | ||
|
||
Iterators | ||
^^^^^^^^^ | ||
|
||
Most interface methods that provide more that one result will return :term:`Iterator`s which yield individual elements. | ||
You can iterate over these in exactly the same way you iterate over lists, for example: | ||
.. code:: python | ||
>>> for curie in oi.basic_search("cell"): | ||
>>> ## do something with results | ||
>>> print(f'MATCH: {curie}') | ||
If you like you can directly convert an iterator to a list: | ||
.. code:: python | ||
>>> curies = list(oi.basic_search("cell")) | ||
However, this may be an anti-pattern if the implementation is a remote service and the results include possible thousands of results, | ||
as this will block on waiting for all results. | ||
For more on iterators, see `How to Use Generators and yield in Python <https://realpython.com/introduction-to-python-generators/>`_ | ||
Weaving calls together | ||
^^^^^^^^^^^^^^^^^^^^^^ | ||
A common pattern is to iterate over a result set and issue a separate call for each result: | ||
.. code:: python | ||
>>> for curie in oi.basic_search("cell"): | ||
>>> print(f'MATCH: {curie} ! {oi.label(curie)}') | ||
This is fine if the implementation has a low latency for individual calls, but if the implementation is backed by | ||
a remote service (for example, a SPARQL endpoint like ontobee or ubergraph, or a remote SQL database) then this will | ||
issue one network call for each result, which may be inefficient. | ||
One possibility is to use a dedicated method for retrieving batch results, for example | ||
>>> print(f'MATCH: {curie} ! {oi.get_label_by_curie(curie)}') | ||
A better approach is to *chunk* over iterators: | ||
Chunking | ||
^^^^^^^^ | ||
The :ref:`.chunk` utility function will chunk iterator calls into sizeable amounts: | ||
|
||
.. code:: python | ||
>>> for curie_it in chunk(impl.basic_search(t)): | ||
>>> logging.info('** Next chunk:') | ||
>>> for curie, label in impl.labels(curie_it): | ||
>>> print(f'{curie} ! {label}') | ||
This is slightly more boilerplate code, and may not be necessary for an in-memory implementation like Pronto. However, this | ||
pattern could have considerable advantages for result sets that are potentially large. Even if the external server is | ||
slow to return results, users will see batches or results rather than waiting on the external server to produce | ||
>>> logging.info('** Next chunk:') | ||
>>> for curie, label in impl.get_labels_for_curies(curie_it): | ||
>>> print(f'{curie} ! {label}') | ||
This is slightly more boilerplate code, and may not be necessary for an in-memory implementation like Pronto. However, this | ||
pattern could have considerable advantages for result sets that are potentially large. Even if the external server is | ||
slow to return results, users will see batches or results rather than waiting on the external server to produce *all* results. | ||
Command Line | ||
------------ | ||
If you are extending the CLI module or writing a Python application that uses OAK: | ||
- Use click | ||
- Follow CLIG guidelines | ||
- Ensure that there are tests for the command line using test_click |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,15 @@ | ||
.. _packages: | ||
|
||
Package Documentation | ||
================================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
architecture | ||
interfaces/index | ||
implementations/index | ||
selectors | ||
converters/index | ||
utilities |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
Oops, something went wrong.