Usage
Client classes for the OLS.
- class Client(base_url)[source]
Wraps the functions to query the Ontology Lookup Service such that alternative base URL’s can be used.
Initialize the client.
- Parameters:
base_url (
str
) – An optional, custom URL for the OLS API.
- get_response(path, params=None, raise_for_status=True, **kwargs)[source]
Send a GET request the given endpoint.
- Parameters:
path (
str
) – The path to query following the base URL, e.g.,/ontologies
. If this starts with the base URL, it gets stripped.params (
Optional
[Dict
[str
,Any
]]) – Parameters to pass through torequests.get()
raise_for_status (
bool
) – If true and the status code isn’t 200, raise an exceptionkwargs – Keyword arguments to pass through to
requests.get()
- Return type:
Response
- Returns:
The response from
requests.get()
- get_paged(path, key=None, size=None, sleep=None)[source]
Iterate over all terms, lazily with paging.
- Parameters:
- Yields:
A terms in an ontology
- Raises:
ValueError – if an invalid size is given
- Return type:
- get_ontology(ontology)[source]
Get the metadata for a given ontology.
- Parameters:
ontology (
str
) – The name of the ontology- Returns:
The dictionary representing the JSON from the OLS
- search(query, query_fields=None, params=None)[source]
Search the OLS with the given term.
- Parameters:
query (
str
) – The query to searchparams – Additional params to pass through to
get_json()
- Returns:
dict
- Returns:
A list of search results
- iter_terms(ontology, size=None, sleep=None)[source]
Iterate over all terms, lazily with paging.
- Parameters:
- Return type:
iter[dict]
- Yields:
Terms in the ontology
- iter_ancestors(ontology, iri, size=None, sleep=None)[source]
Iterate over the ancestors of a given term.
- Parameters:
- Return type:
iter[dict]
- Yields:
the descendants of the given term
- iter_hierarchical_ancestors(ontology, iri, size=None, sleep=None)[source]
Iterate over the hierarchical of a given term.
- Parameters:
- Return type:
iter[dict]
- Yields:
the descendants of the given term
- iter_ancestors_labels(ontology, iri, size=None, sleep=None)[source]
Iterate over the labels for the descendants of a given term.
- Parameters:
- Yields:
labels of the descendants of the given term
- Return type:
- iter_labels(ontology, size=None, sleep=None)[source]
Iterate over the labels of terms in the ontology. Automatically wraps the pager returned by the OLS.
- Parameters:
- Yields:
labels of terms in the ontology
- Return type:
- class TIBClient[source]
The TIB instance of the OLS.
With its new Terminology Service, TIB – Leibniz Information Centre for Science and Technology and University Library provides a single point of access to terminology from domains such as architecture, chemistry, computer science, mathematics and physics.
See also
Initialize the client.
- class MonarchClient[source]
The Monarch Initiative instance of the OLS.
See also
Initialize the client.