Visitor traits for horned-owl with overloadable implementations

Overview

horned-visit Star me

Visitor traits for horned-owl with overloadable implementations.

Actions Codecov License Source Crate Documentation Changelog GitHub issues

🗺️ Overview

This library provides visitor traits for the horned-owl object model, which can be used to easily implement algorithms to query or edit an ontology.

🔌 Usage

Add the latest versions of horned-owl and horned-visit to the [dependencies] sections of your Cargo.toml manifest:

[dependencies]
horned-owl = "0.11.0"
horned-visit = "0.1.0"

Then use the horned_visit::Visit or horned_visit::VisitMut traits to implement an algorithm. The horned_visit::visit and horned_visit::visit_mut modules contain default methods implementations.

💡 Example

OWL2 does not require all entities to be declared (see the specification), but it can be required by convention to help catching typos. Here is how an algorithm could be implemented with horned-visit that ensures that all the IRI referencing OWL2 classes are declared in an ontology document:

extern crate horned_owl;
extern crate horned_visit;

use std::collections::HashSet;
use std::fs::File;
use std::io::BufReader;

use horned_owl::model::*;
use horned_visit::Visit;

#[derive(Default, Debug)]
struct ClassDeclarationChecker<'ast> {
    declared: HashSet<&'ast IRI>,
    used: HashSet<&'ast IRI>
}

impl<'ast> Visit<'ast> for ClassDeclarationChecker<'ast> {
    fn visit_declare_class(&mut self, declare_class: &'ast DeclareClass) {
        self.declared.insert(&declare_class.0.0);
        horned_visit::visit::visit_declare_class(self, declare_class);
    }
    fn visit_class(&mut self, class: &'ast Class) {
        self.used.insert(&class.0);
    }
}

pub fn classes_well_declared(ontology: &horned_owl::ontology::set::SetOntology) -> bool {
    let mut checker = ClassDeclarationChecker::default();
    ontology.iter().for_each(|aa| checker.visit_annotated_axiom(aa));
    checker.used.is_subset(&checker.declared)
}

let mut f = File::open("tests/data/bfo.owl").map(BufReader::new).unwrap();
let ontology = horned_owl::io::rdf::reader::read(&mut f).unwrap().0.into();
assert!(classes_well_declared(&ontology));

💭 Feedback

⚠️ Issue Tracker

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker of the project if you need to report or ask something. If you are filling in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

📋 Changelog

This project adheres to Semantic Versioning and provides a changelog in the Keep a Changelog format.

📜 License

This library is provided under the open-source MIT license.

This project was developed by Martin Larralde during his PhD project at the European Molecular Biology Laboratory in the Zeller team.

You might also like...
Various extention traits for providing asynchronous higher-order functions

async-hofs Various extention traits for providing asynchronous higher-order functions. // This won't make any name conflicts since all imports inside

A general solution for commonly used crypt in rust, collection of cryptography-related traits and algorithms.

Crypto-rs A general solution for commonly used crypt in rust, collection of cryptography-related traits and algorithms. This is a Rust implementation

Stdto provides a set of functional traits for conversion between various data representations.

Stdto stdto provides a set of functional traits for conversion between various data representations. | Examples | Docs | Latest Note | stdto = "0.13.0

Expose various non-cryptographic hashing functions with Digest traits

noncrypto-digests Expose various non-cryptographic hashing functions with Digest traits. This allows users to use any hashing function with the same t

Derive conversion traits when items are structurally similar.

structural-convert Derive conversion traits when items are structurally similar. Inspired by serde and struct-convert crates. Features One to one fiel

2D particle system with custom material traits. Works well in wasm webgl2 and mobile
2D particle system with custom material traits. Works well in wasm webgl2 and mobile

Bevy Enoki Enoki - A 2D particle system for the Bevy game engine. Overview The Enoki particle system is a CPU calculate particle system, that uses GPU

The Computer Language Benchmarks Game: Rust implementations

The Computer Language Benchmarks Game: Rust implementations This is the version I propose to the The Computer Language Benchmarks Game. For regex-dna,

Inertia.js implementations for Rust. Currently supports Rocket.

Inertia.rs Inertia.js implementations for Rust. Currently supports Rocket. Why Inertia? From inertiajs.com Inertia is a new approach to building class

asynchronous and synchronous interfaces and persistence implementations for your OOD architecture

OOD Persistence Asynchronous and synchronous interfaces and persistence implementations for your OOD architecture Installation Add ood_persistence = {

Cryptography-oriented big integer library with constant-time, stack-allocated (no_std-friendly) implementations of modern formulas

RustCrypto: Cryptographic Big Integers Pure Rust implementation of a big integer library which has been designed from the ground-up for use in cryptog

Making composability with the Zeta DEX a breeze, FuZe provides CPI interfaces and sample implementations for on-chain program integration.
Making composability with the Zeta DEX a breeze, FuZe provides CPI interfaces and sample implementations for on-chain program integration.

Zeta FuZe 🧬 Zeta FuZe FuZe is Zeta's cross-program integration ecosystem. This repository contains the Zeta Cross Program Invocation (CPI) interface

the official Rust and C implementations of the BLAKE3 cryptographic hash function

BLAKE3 is a cryptographic hash function that is: Much faster than MD5, SHA-1, SHA-2, SHA-3, and BLAKE2. Secure, unlike MD5 and SHA-1. And secure again

Experimenting with Rust implementations of IP address lookup algorithms.

This repository contains some very rough experimentation with Rust implementations of IP address lookup algorithms, both my own and comparison with th

Elliptic-curves - Collection of pure Rust elliptic curve implementations (e.g. P-256, P-384, secp256k1)

RustCrypto: Elliptic Curves General purpose Elliptic Curve Cryptography (ECC) support, including types and traits for representing various elliptic cu

This library provides implementations of many algorithms and data structures that are useful for bioinformatics.

This library provides implementations of many algorithms and data structures that are useful for bioinformatics. All provided implementations are rigorously tested via continuous integration.

OpenZKP - pure Rust implementations of Zero-Knowledge Proof systems.

OpenZKP OpenZKP - pure Rust implementations of Zero-Knowledge Proof systems. Overview Project current implements 🐺 the Stark protocol (see its readme

Library containing implementations of various sequential data-structures.

Library containing implementations of various sequential data-structures.

Recursive & Iterative Binary Search Tree Implementations within Rust

bst-rs Recursive & Iterative Binary Search Tree Implementations within Rust Table of Contents Personal Goals About Quick Start License Contributing In

A bridge between different serde implementations.

serde-bridge   Bridge between serde types Quick Start use anyhow::Result; use serde_bridge::{from_value, into_value, FromValue, IntoValue, Value}; fn

Comments
  • Update horned-owl requirement from 0.11.0 to 0.12.0

    Update horned-owl requirement from 0.11.0 to 0.12.0

    Updates the requirements on horned-owl to permit the latest version.

    Changelog

    Sourced from horned-owl's changelog.

    Version 0.12.0

    The core data model has been updated to make IRI generic. This resolves a long standing problem that Horned-OWL was a single threaded library. This has also meant that SetOntology has now been rewritten to use SetIndex.

    A general purpose visitor library has been added. At some point, we should use them for rendering, but for now, an IRIMappedIndex has been written.

    A closure parser has been added for RDF, as it is often necessary to parse the whole import closure to make a complete RDF parse.

    Updated error handling to use a single unified hierarchy.

    Many type aliases are now new types meaning that defaults work better.

    Parsing of GCIs has now been fixed for RDF/XML.

    Version 0.11.0

    This release includes a new command horned which multiplexes all the other commands. Thanks for Filippo De Bortoli for this addition.

    There has been one model change with the introduction of AnnotationSubject.

    There has been a significant refactoring and updating of dependencies, particularly the removal of the failure crate dependency.

    There have been a number of performance updates thanks to Martin Larralde.

    Version 0.10.0

    The major change is to move the RDF parser to RIO. RDF parsing now has preliminary support for ontologies which require knowledge from outside the current one to parse fully.

    An RDF writer has been added.

    Version 0.9.0

    A variety of advances and fixes, including an IRI resolver and a horned-materialize command.

    ... (truncated)

    Commits
    • 2c3a881 (cargo-release) version 0.12.0
    • 202973b Update for release
    • e91df3d Update release documentation and cosmetic changes
    • 27f36c9 Refactor object property expression parsing
    • e03cfde Fix for complex classes as subjects of various axioms
    • 74c9804 Clean up last error handling
    • df62071 Type aliases to reduce type complexity
    • e8538ff Update method names to obey self convention
    • e7ca224 Apply many clippy updates
    • bbe5138 Run rustfmt
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
Releases(v0.1.0)
Owner
FastOBO
The faultless Rust stack for Open Biomedical Ontologies.
FastOBO
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
Traits - Collection of cryptography-related traits

RustCrypto: Traits Collection of traits which describe functionality of cryptographic primitives. Crates Name Algorithm Crates.io Docs MSRV aead Authe

Rust Crypto 401 Dec 27, 2022
Pure-Rust traits and utilities for constant-time cryptographic implementations.

subtle Pure-Rust traits and utilities for constant-time cryptographic implementations. It consists of a Choice type, and a collection of traits using

dalek cryptography 196 Dec 13, 2022
Decode SCALE bytes into custom types using a scale-info type registry and a custom Visitor impl.

scale-decode This crate attempts to simplify the process of decoding SCALE encoded bytes into a custom data structure given a type registry (from scal

Parity Technologies 6 Sep 20, 2022
miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

Kat Marchán 1.2k Jan 1, 2023
Traits for inspecting memory usage of Rust types

memuse This crate contains traits for measuring the dynamic memory usage of Rust types. About Memory-tracking is a common activity in large applicatio

null 13 Dec 23, 2022
Annotation to easily define ad-hoc / one-shot extension traits

Annotation to easily define ad-hoc / one-shot extension traits

Daniel Henry-Mantilla 2 Apr 19, 2022
A collection of numeric types and traits for Rust.

num A collection of numeric types and traits for Rust. This includes new types for big integers, rationals (aka fractions), and complex numbers, new t

null 813 Dec 27, 2022
A typemap for a set of known types optionally without heap allocation, and supporting iterating by traits

fixed_typemap docs.rs GitHub Sponsors Implements typemaps that support a lot of extra funcctionality using procedural macros. docs.rs has a lot more t

Austin Hicks 2 Dec 27, 2021
Async `TryFrom/TryInto` traits

async-convert Async TryFrom/TryInto traits API Docs | Releases | Contributing Installation $ cargo add async-convert Safety This crate uses #![deny(un

Yosh 4 Mar 4, 2022