Skip to main content

Fast OWL 2 profile detection (EL/RL/QL/DL) over pyoxigraph

Project description

pyowl2-profiles

Fast OWL 2 profile detection (EL/RL/QL/DL) over pyoxigraph.

PyPI License: MIT Python versions

Installation

pip install pyowl2-profiles

Quick start

import pyoxigraph
from pyowl2_profiles import detect_profiles, PROFILE_NAMES

# Load your ontology into a pyoxigraph store
store = pyoxigraph.Store()
with open("my-ontology.ttl", "rb") as f:
    store.load(f.read(), pyoxigraph.RdfFormat.TURTLE)

# Run detection
result = detect_profiles(store, graph_iri=None)

# Check verdicts
for profile in PROFILE_NAMES:  # ("el", "rl", "ql", "dl")
    r = result[profile]
    status = "IN" if r["in_profile"] else "OUT"
    print(f"OWL 2 {profile.upper()}: {status}  ({r['total_violations']} violations)")

# Inspect violation samples
for sample in result["el"]["sample_violations"][:3]:
    print(f"  {sample['axiom_type']}: {sample['subject_iri']}")

Why this library

  • No JVM. ROBOT requires Java; pyowl2-profiles runs entirely in Python with no external runtime.
  • No second parse. If you already have data in a pyoxigraph store (e.g., from a pipeline), detection adds only a few lightweight SPARQL queries.
  • Fast. On moderate-sized ontologies (< 1M triples), detection completes in under a second. Cold-start (load + detect) is 10-1400x faster than ROBOT depending on ontology size.
  • Standard Python packaging. pip install, import, done.

CLI usage

Detect profiles for a file

pyowl2-profiles detect my-ontology.ttl
pyowl2-profiles detect my-ontology.ttl --format json
pyowl2-profiles detect my-ontology.ttl --profile EL

Benchmark against ROBOT

# Requires robot on PATH
pyowl2-profiles benchmark onto1.ttl onto2.owl --csv results.csv

# Skip ROBOT, ours only
pyowl2-profiles benchmark onto1.ttl --skip-robot

Validation

Validated against ROBOT 1.9.10 on a 19-ontology biomedical fleet: 19/19 (100%) verdict agreement across all four profiles (EL, RL, QL, DL).

See docs/usage.md for a detailed walkthrough and benchmark methodology.

API reference

detect_profiles(store, graph_iri=None, ontology_id="", version_id="") -> dict

Run all four OWL 2 profile checks against a pyoxigraph.Store.

Parameters:

  • storepyoxigraph.Store containing the ontology triples
  • graph_iri — named graph IRI to query, or None for the default graph
  • ontology_id — optional string identifier (informational only)
  • version_id — optional version string (informational only)

Returns a dict with keys "el", "rl", "ql", "dl", "indexed_at". Each profile value is a dict with:

  • in_profile (bool) — True if no violations found
  • total_violations (int) — total violation count
  • violations_by_axiom_type (dict[str, int]) — per-type counts
  • sample_violations (list[dict]) — up to 50 example violations, each with axiom_type, subject_iri, manchester (rendered tokens), and optionally details

ProfileViolation

Frozen dataclass for a single violation: profile, axiom_type, subject_iri, details, manchester.

PROFILE_NAMES

("el", "rl", "ql", "dl") — the four OWL 2 profiles in subset order.

ProfileName

Type alias: Literal["el", "rl", "ql", "dl"].

Acknowledgement

Originally extracted from OntoExplorer, a FAIR ontology repository at Maastricht University Institute of Data Science.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyowl2_profiles-0.1.0.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyowl2_profiles-0.1.0-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file pyowl2_profiles-0.1.0.tar.gz.

File metadata

  • Download URL: pyowl2_profiles-0.1.0.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pyowl2_profiles-0.1.0.tar.gz
Algorithm Hash digest
SHA256 28c1f123bd3d6e3ab0348e1c707c2e39976ec848bc1de21ed52cc63ec362feb6
MD5 b28b991d3ead8bd9771bfa9e92d73737
BLAKE2b-256 f2bc5f73b455edcfaea1f744b6e2c41c09c59630ead8f9e2b92830d1faeace28

See more details on using hashes here.

File details

Details for the file pyowl2_profiles-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyowl2_profiles-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fd67ca0c1c64582906828e4de290ebc1fe969ae90fd0587ef770cea120813f5
MD5 352e4dfc83bd115f62d77a6fef9d76e2
BLAKE2b-256 349a43dd50de73788f6d664e447b4829ea0e2f259677dc4e4c589e297bd2361f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page