fetch_salmon_ontology

fetch_salmon_ontology(
    url='https://dfo-pacific-science.github.io/dfo-salmon-ontology/ontology/dfo-salmon.ttl',
    accept='text/turtle, application/rdf+xml;q=0.8',
    cache_dir=None,
    fallback_urls=None,
)

Fetch the DFO Salmon Ontology with HTTP caching.

Downloads the DFO Salmon Ontology using HTTP content negotiation and caches the response using ETag/Last-Modified headers when available. Supports fallback URLs if the primary URL fails.

Parameters

Name Type Description Default
url str Primary ontology URL "https://dfo-pacific-science.github.io/dfo-salmon-ontology/ontology/dfo-salmon.ttl"
accept str Accept header for content negotiation "text/turtle, application/rdf+xml;q=0.8"
cache_dir str Directory to store cached ontology and headers. Defaults to /metasalmonpy-ontology-cache None
fallback_urls List[str] List of fallback URLs to try if primary fails. Defaults to [“https://w3id.org/gcdfo/salmon”] None

Returns

Name Type Description
str Path to the cached ontology file

Raises

Name Type Description
RuntimeError If all URLs fail to fetch the ontology

Examples

>>> from metasalmonpy import fetch_salmon_ontology
>>> ttl_path = fetch_salmon_ontology()
>>> print(f"Ontology cached at: {ttl_path}")
>>> # Read the ontology with rdflib or similar
>>> with open(ttl_path, 'r') as f:
...     ontology_content = f.read()
Back to top