Giter Club home page Giter Club logo

py-horned-owl's Introduction

py-horned-owl

An experimental bridge from horned-owl to python using PyO3.

Installation

Published version

To install the published library:

pip install py_horned_owl

From sources

To build locally from sources, you will need Rust, PyO3 and Maturin.

Check out this repository: git clone https://github.com/jannahastings/py-horned-owl/

In the directory py-horned-owl, create and activate a virtual Python environment:

virtualenv py-horned-owl

source bin/activate

Then you can get maturin to build the library and install it into the virtual Python environment with:

maturin develop

Usage

The library supports loading ontologies from .owl (RDF-XML) and .owx (OWL-XML) files via horned-owl's parsing functionality. ROBOT can transform ontologies that are in other OWL flavours into one of these formats using robot convert.

Example of simple usage:

import pyhornedowl

ontoname = "family.owx"

onto = pyhornedowl.open_ontology(ontoname)

print (f"Loaded ontology has {len(onto.get_classes())} classes.")
print (f"Loaded ontology has {len(onto.get_axioms())} axioms.")

for c in onto.get_classes():
    print(onto.get_axioms_for_iri(c))


For more information please visit the documentation.

py-horned-owl's People

Contributors

areleu avatar b-gehrke avatar eugenio2192 avatar jannahastings avatar web-flow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

py-horned-owl's Issues

Provide a sdist (or git tag), in-tree LICENSE for py-horned-owl 0.2.1

Hello! This looks like an interesting tool, and I would like to take a shot at providing it (and all its platform-specific builds) on conda-forge. We'd be able to support building the "big three" x86-64 platforms, as well as some additional ones, for modern pythons (e.g. 3.8+).

Like a lot of "system-style" package managers, conda-forge prefer to use a "canonical" source distribution (such as a .tar.gz uploaded to PyPI). Lacking that, a GitHub release tarball is usually fine, but the cryptography sums can change over time. So the big request here is either:

  • upload an sdist to go with the .whl
  • add a tag for when 0.2.1 was shipped

And:

  • add an explicit LICENSE to the repo (and probably as-released metadata)

If broader distribution is interesting to the maintainers of this package, we always love to have upstream maintainers join the maintainer team, but certainly not required! Once everything "works," it's mostly a matter of pressing "merge" on automated PRs that update version numbers and crypto hashes when new upstream releases come out.

Thanks again!

AxiomAnnotations not included

It looks like axiom annotations are not included.

it would be good to decide in advance how this should be stored with the current pseudo-lisp datastructures. Functional syntax and owlx place annotations as the first argument which is IMHO weird and may be particularly hard to work with using the current untyped structures.

I think the best options are:

  • break with s-expressions and use a mixed dict/list structure
  • place axiom annotations as the last argument, and ALWAYS include them, even if [], that way the s-expressions can be evaluated unambiguously

Disjointness axioms are not parsed properly

I tried to load a number of disjointness axioms using py-horned-owl, but the resulting disjointness axioms do not contain the target class:

>>> onto_dis = pyhornedowl.open_ontology("chebi-disjoints.owl")
>>> onto_dis.get_axioms_for_iri("http://purl.obolibrary.org/obo/CHEBI_15356")
['AxiomKind::DisjointClasses']

what I would expect is something like

['AxiomKind::DisjointClasses', 'http://purl.obolibrary.org/obo/CHEBI_23509']

Provide equivalent to OWL Reasoner API

Motivation: I would like to use the Rust version of @balhoff's Whelk, whelk.rs

Previously I was thinking the way to go would be to write a pyo3 wrapper onto whelk.rs. However, it may make more sense to have a generic wrapper for reasoners, with py-horned-owl providing the interface, just as there is one reasoner API for the OWLAPI

(it might be nice to have some features the owlapi ones lack though, that give access to some of the neater features of whelk)

Adding windows wheels

Hello @jannahastings,

I built some windows wheels using github actions. One can find them here: https://github.com/Eugenio2192/py-horned-owl/releases
I did them using a branch of your latest release and the development version of https://github.com/phillord/horned-owl
I have been using them and so far they have been working properly.

I could adapt this github action: https://github.com/Eugenio2192/py-horned-owl/blob/build/.github/workflows/build.yml to what you consider apropiate for release.

Datatype not included for literals

AFAICT there is no datatype info on literals, and no way to determine if the value is a node or a literal when it stringifies as a URL

E.g. in GO:

['AxiomKind::AnnotationAssertion', 'http://purl.obolibrary.org/obo/GO_0019098', 'http://purl.obolibrary.org/obo/IAO_0000233', 'https://github.com/geneontology/go-ontology/issues/23491']

is the last argument a node, a plain literal, a string, an xsd:anyURI...?

Looks like it is intentionally conflating these:

py-horned-owl/src/lib.rs

Lines 431 to 438 in 6c5ed6c

Axiom::AnnotationAssertion(AnnotationAssertion{subject,ann:Annotation{ap,av}}) => {
pyax.elements.push( subject.to_string().into() );
pyax.elements.push( ap.0.to_string().into() );
let av: String = match av {
AnnotationValue::Literal(lit) => lit.literal().to_string(),
AnnotationValue::IRI(iri) => iri.to_string(),
};
pyax.elements.push( av.into() );

I suggest an additional argument for literals

owx rendering differences with OWL API

This probably belongs to the horned-owl itself but I discovered it here so I write it here first in case you find a root cause in this library.

So I have been using this in parallel with ROBOT to try out some automatic checks and I noticed that if I read a owx file written by ROBOT(OWLAPI) and then read it in into py-horned-owl and then save it without altering it I get an inconsistency that makes the file not undestandable by OWLAPI. The xml Namespaces are not appearing. See this example:

This is the header of the output of OWLAPI:

<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
     xml:base="http://openenergy-platform.org/ontology/oeo/oeo-physical/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     ontologyIRI="http://openenergy-platform.org/ontology/oeo/oeo-physical/"
     versionIRI="http://openenergy-platform.org/ontology/oeo/dev/oeo-physical.omn">
    <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
    <Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
    <Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
    <Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
    <Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>

This is the output of horned-owl:

<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2002/07/owl#">
    <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
    <Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
    <Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
    <Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
    <Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>

When I try to convert this last version to something else using OWLAPI I get an empty file.

I don't see the generation of these Namespaces happening anywhere here:

https://github.com/phillord/horned-owl/blob/e33ea9e98df83773ddead0bbe438955690b6b73c/src/io/owx/writer.rs#L228

So the root cause may be there. If you think the same I can just bring this issue to @phillord

Add parsers and serializers for other OWL serialization formats

https://jannahastings.github.io/py-horned-owl/generated/pyhornedowl.open_ontology.html#pyhornedowl.open_ontology

Says "Only .owl and .owx files are currently supported."

.owl could be any syntax, but it looks like this means OWL layered as RDF/XML.

Are there any plans to support other syntaxes? I believe these are supported in the rust layer.

https://github.com/phillord/horned-owl/tree/main/src/io/ofn

For saving, only .owx is supprted:

https://jannahastings.github.io/py-horned-owl/generated/pyhornedowl.PyIndexedOntology.html#pyhornedowl.PyIndexedOntology.save_to_file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.