Skip to content

Commit

Permalink
upgrade sphinx. Fixes #512 (#513)
Browse files Browse the repository at this point in the history
* upgrade sphinx. Fixes #512

* doc-refactor

* refactor

* Update obo_graph_to_fhir_converter.py

---------

Co-authored-by: Harshad <[email protected]>
  • Loading branch information
cmungall and hrshdhgd authored Apr 4, 2023
1 parent 23cf599 commit 32556dc
Show file tree
Hide file tree
Showing 68 changed files with 263 additions and 606 deletions.
441 changes: 0 additions & 441 deletions docs/best-practice.rst

This file was deleted.

2 changes: 2 additions & 0 deletions docs/concepts.rst
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
=================

Expand Down
2 changes: 0 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

All contributions are welcome!

But we warned until [v0.2.0](https://github.com/INCATools/ontology-access-kit/milestone/1) things may be in flux!

## Reporting issues and giving general feedback

Please use the [issue tracker](https://github.com/INCATools/ontology-access-kit/issues) for questions, bugs, enhancements, feature requests, etc
Expand Down
8 changes: 1 addition & 7 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ Ontology Access Kit (OAK) Documentation
introduction
intro/index
guide/index
architecture
interfaces/index
implementations/index
packages/index
cli
selectors
datamodels/index
converters/index
utilities
howtos/index
notebooks
concepts
glossary
faq

Expand Down
44 changes: 0 additions & 44 deletions docs/introduction.md

This file was deleted.

52 changes: 52 additions & 0 deletions docs/introduction.rst
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`
2 changes: 1 addition & 1 deletion docs/architecture.rst → docs/packages/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ you can do on an ontology, mostly simple lookup operations. Here is a simplified

.. mermaid::

classDiagram
classDiagram
class OntologyInterface {
+interfaces_implemented()
}
Expand Down
83 changes: 83 additions & 0 deletions docs/packages/best-practice.rst
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.
15 changes: 15 additions & 0 deletions docs/packages/index.rst
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.
26 changes: 14 additions & 12 deletions docs/selectors.rst → docs/packages/selectors.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _selectors:

Ontology Implementation Selectors
Ontology Adapter Selectors
=================

In the command line interface and in Python code, *descriptors* can be used as a shorthand way to refer to either a local or remote ontology, plus
Expand All @@ -11,8 +11,8 @@ to instantiate an implementation. The descriptors can also be used in the :ref:`

Ontologies are available in a sometimes bewildering range of formats. One thing that constantly
trips people up is the distinction between ontology *language* and *serialization*. OWL is an ontology
language, *not* a syntax. OWL has its own syntaxes such as Manchester, OWL-XML and Functional -- additionally
it can be *mapped* to RDF, which is its *own* datamodel/language, with its *own* serializations (Turtle,
language, *not* a syntax. OWL has its own syntaxes such as :term:`Manchester Syntax`, OWL-XML and :term:`Functional Syntax' -- additionally
it can be *mapped* to RDF, which is its *own* datamodel/language, with its *own* serializations (:term:`Turtle`,
RDF/XML (NOT the same as OWL-XML), JSON-LD, ...). Confusing, huh? We are doing our best in this library
to simplify things for you the user, please be patient!

Expand All @@ -29,10 +29,10 @@ Examples

Examples of scheme-less descriptors, implicit implementation:

- :code:`tests/input/go-nucleus.obo` - local obo format file loaded with pronto
- :code:`tests/input/go-nucleus.json` - local obojson format file loaded with pronto
- :code:`tests/input/go-nucleus.obo` - local :term:`OBO Format` file loaded with pronto
- :code:`tests/input/go-nucleus.json` - local :term:`OBO Graphs` json format file loaded with pronto
- :code:`tests/input/go-nucleus.owl` - local OWL rdf/xml format file (loaded with rdflib at the moment, may change)
- :code:`tests/input/go-nucleus.owl.ttl` - local OWL turtle format file (loaded with rdflib at the moment, may change)
- :code:`tests/input/go-nucleus.owl.ttl` - local OWL :term:`Turtle` file (loaded with rdflib at the moment, may change)
- :code:`tests/input/go-nucleus.db` - local sqlite3 db loaded with SqlImplementation
- :code:`http://purl.obolibrary.org/obo/pato.obo` - NOT IMPLEMENTED; download locally for now
- :code:`http://purl.obolibrary.org/obo/pato.owl` - NOT IMPLEMENTED; download locally for now
Expand All @@ -41,21 +41,23 @@ Examples of explicit schemes:

- :code:`sparql:tests/input/go-nucleus.owl.ttl` - local OWL file in turtle serialization
- :code:`sparql:tests/input/go-nucleus.owl` - local OWL file (RDF/XML assumed unless explicit format option passed)
- :code:`pronto:tests/input/go-nucleus.obo` - local obo format file loaded with pronto
- :code:`pronto:tests/input/go-nucleus.json` - local obojson format file loaded with pronto
- :code:`pronto:tests/input/go-nucleus.obo` - local :term:`OBO Format` file loaded with pronto
- :code:`pronto:tests/input/go-nucleus.json` - local :term:`OBO Graphs` json format file loaded with pronto
- :code:`pronto:tests/input/go-nucleus.owl` - local OWL rdf/xml format file (loaded with pronto at the moment may change)
- :code:`pronto:tests/input/go-nucleus.db` - local sqlite3 db loaded with SqlImplementation
- :code:`prontolib:pato.obo` - remote obo format file loaded from OBO Library with pronto
- :code:`prontolib:pato.obo` - remote :term:`OBO Format` file loaded from OBO Library with pronto
- :code:`prontolib:pato.owl` - remote owl format file loaded from OBO Library with pronto
- :code:`sqlite:tests/input/go-nucleus.db` - local SQLite file
- :code:`sqlite:tests/input/go-nucleus.owl` - convert OWL to SQLite and query using sql_implementation
- :code:`sqlite:obo:go` - pre-made SQLite from :term:`Semantic SQL` registry
- :code:`bioportal:` all of bioportal
- :code:`bioportal:pato` pato in bioportal (NOT IMPLEMENTED)
- :code:`bioportal:pato` pato in bioportal
- :code:`ontobee:` all of ontobee
- :code:`ontobee:pato` pato in ontobee (NOT IMPLEMENTED)
- :code:`ontobee:pato` pato in ontobee
- :code:`ols:` all of OLS
- :code:`ols:pato` pato in OLS (NOT IMPLEMENTED)
- :code:`ubergraph:` all of OLS
- :code:`ubergraph:pato` pato in ubergraph (NOT IMPLEMENTED)
- :code:`ubergraph:pato` pato in ubergraph

See :ref:`cli` for more examples

Expand Down
5 changes: 0 additions & 5 deletions docs/utilities.rst → docs/packages/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ Where possible, this library uses simple standalone python functions organized i
Note: some of these may involve iterated calls on a remote backend, these are candidates for
being turned into :ref:`interfaces`.

.. currentmodule:: oaklib
:toctree: src

selector

.. currentmodule:: oaklib.utilities

.. autosummary::
Expand Down
Loading

0 comments on commit 32556dc

Please sign in to comment.