From 01e977f68ffe6d526d90eeaae7f9d16c433fdca2 Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Thu, 29 Dec 2016 18:40:23 -0500 Subject: [PATCH] Added missing property axiom types. --- build.sbt | 4 +- project/build.properties | 2 +- .../phenoscape/scowl/ofn/PropertyAxioms.scala | 79 ++++++++++++++++++- .../scala/org/phenoscape/scowl/package.scala | 15 +++- 4 files changed, 94 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index b05497e..8cc7602 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ organization := "org.phenoscape" name := "scowl" -version := "1.1" +version := "1.2-SNAPSHOT" crossScalaVersions := Seq("2.10.6", "2.11.7") @@ -13,7 +13,7 @@ javaOptions += "-Xmx8G" libraryDependencies ++= { Seq( - "net.sourceforge.owlapi" % "owlapi-distribution" % "4.2.1", + "net.sourceforge.owlapi" % "owlapi-distribution" % "4.2.7", "org.scalatest" %% "scalatest" % "2.2.6" % Test, "org.scalaz" %% "scalaz-core" % "7.2.1" % Test ) diff --git a/project/build.properties b/project/build.properties index 817bc38..27e88aa 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.9 +sbt.version=0.13.13 diff --git a/src/main/scala/org/phenoscape/scowl/ofn/PropertyAxioms.scala b/src/main/scala/org/phenoscape/scowl/ofn/PropertyAxioms.scala index bbd5f39..17ac0d5 100644 --- a/src/main/scala/org/phenoscape/scowl/ofn/PropertyAxioms.scala +++ b/src/main/scala/org/phenoscape/scowl/ofn/PropertyAxioms.scala @@ -1,6 +1,8 @@ package org.phenoscape.scowl.ofn import scala.collection.JavaConversions._ + +import org.semanticweb.owlapi.apibinding.OWLManager import org.semanticweb.owlapi.model.OWLAnnotation import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom import org.semanticweb.owlapi.model.OWLClassExpression @@ -8,7 +10,10 @@ import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom import org.semanticweb.owlapi.model.OWLDataPropertyExpression import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom import org.semanticweb.owlapi.model.OWLDataRange +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom @@ -19,15 +24,15 @@ import org.semanticweb.owlapi.model.OWLObjectPropertyExpression import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom import org.semanticweb.owlapi.model.OWLPropertyExpression import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom import org.semanticweb.owlapi.model.OWLUnaryPropertyAxiom -import org.semanticweb.owlapi.apibinding.OWLManager trait PropertyAxioms { - + private val factory = OWLManager.getOWLDataFactory object SubObjectPropertyOf { @@ -56,6 +61,57 @@ trait PropertyAxioms { } + object SubDataPropertyOf { + + def apply(annotations: Set[OWLAnnotation], subProperty: OWLDataPropertyExpression, superProperty: OWLDataPropertyExpression): OWLSubDataPropertyOfAxiom = + factory.getOWLSubDataPropertyOfAxiom(subProperty, superProperty) + + def apply(subProperty: OWLDataPropertyExpression, superProperty: OWLDataPropertyExpression): OWLSubDataPropertyOfAxiom = + apply(Set.empty, subProperty, superProperty) + + def unapply(axiom: OWLSubDataPropertyOfAxiom): Option[(Set[OWLAnnotation], OWLDataPropertyExpression, OWLDataPropertyExpression)] = + Option(axiom.getAnnotations.toSet, axiom.getSubProperty, axiom.getSuperProperty) + + } + + object EquivalentObjectProperties { + + def apply(annotations: Set[OWLAnnotation], propertyExpressions: Set[OWLObjectPropertyExpression]): OWLEquivalentObjectPropertiesAxiom = + factory.getOWLEquivalentObjectPropertiesAxiom(propertyExpressions, annotations) + + def apply(properties: OWLObjectPropertyExpression*): OWLEquivalentObjectPropertiesAxiom = + apply(Set.empty[OWLAnnotation], properties.toSet) + + def apply(properties: Set[OWLObjectPropertyExpression]): OWLEquivalentObjectPropertiesAxiom = + apply(Set.empty[OWLAnnotation], properties) + + def apply(annotations: OWLAnnotation*)(properties: OWLObjectPropertyExpression*): OWLEquivalentObjectPropertiesAxiom = + apply(annotations.toSet, properties.toSet) + + def unapply(axiom: OWLEquivalentObjectPropertiesAxiom): Option[(Set[OWLAnnotation], Set[OWLObjectPropertyExpression])] = + Option(axiom.getAnnotations.toSet, axiom.getProperties.toSet) + + } + + object EquivalentDataProperties { + + def apply(annotations: Set[OWLAnnotation], propertyExpressions: Set[OWLDataPropertyExpression]): OWLEquivalentDataPropertiesAxiom = + factory.getOWLEquivalentDataPropertiesAxiom(propertyExpressions, annotations) + + def apply(properties: OWLDataPropertyExpression*): OWLEquivalentDataPropertiesAxiom = + apply(Set.empty[OWLAnnotation], properties.toSet) + + def apply(properties: Set[OWLDataPropertyExpression]): OWLEquivalentDataPropertiesAxiom = + apply(Set.empty[OWLAnnotation], properties) + + def apply(annotations: OWLAnnotation*)(properties: OWLDataPropertyExpression*): OWLEquivalentDataPropertiesAxiom = + apply(annotations.toSet, properties.toSet) + + def unapply(axiom: OWLEquivalentDataPropertiesAxiom): Option[(Set[OWLAnnotation], Set[OWLDataPropertyExpression])] = + Option(axiom.getAnnotations.toSet, axiom.getProperties.toSet) + + } + object ObjectPropertyDomain { def apply(annotations: Set[OWLAnnotation], property: OWLObjectPropertyExpression, domain: OWLClassExpression): OWLObjectPropertyDomainAxiom = @@ -140,6 +196,25 @@ trait PropertyAxioms { } + object DisjointDataProperties { + + def apply(annotations: Set[OWLAnnotation], properties: Set[OWLDataPropertyExpression]): OWLDisjointDataPropertiesAxiom = + factory.getOWLDisjointDataPropertiesAxiom(properties, annotations) + + def apply(properties: OWLDataPropertyExpression*): OWLDisjointDataPropertiesAxiom = + apply(Set.empty[OWLAnnotation], properties.toSet) + + def apply(properties: Set[OWLDataPropertyExpression]): OWLDisjointDataPropertiesAxiom = + apply(Set.empty[OWLAnnotation], properties) + + def apply(annotations: OWLAnnotation*)(properties: OWLDataPropertyExpression*): OWLDisjointDataPropertiesAxiom = + apply(annotations.toSet, properties.toSet) + + def unapply(axiom: OWLDisjointDataPropertiesAxiom): Option[(Set[OWLAnnotation], Set[OWLDataPropertyExpression])] = + Option(axiom.getAnnotations.toSet, axiom.getProperties.toSet) + + } + object SymmetricObjectProperty extends UnaryObjectPropertyAxiom[OWLSymmetricObjectPropertyAxiom, OWLObjectPropertyExpression] { val constructor = factory.getOWLSymmetricObjectPropertyAxiom(_: OWLObjectPropertyExpression, _: Set[OWLAnnotation]) diff --git a/src/main/scala/org/phenoscape/scowl/package.scala b/src/main/scala/org/phenoscape/scowl/package.scala index 2eb71b9..4ddfb4e 100644 --- a/src/main/scala/org/phenoscape/scowl/package.scala +++ b/src/main/scala/org/phenoscape/scowl/package.scala @@ -1,6 +1,7 @@ package org.phenoscape import scala.collection.JavaConversions._ + import org.phenoscape.scowl.converters.AnnotationValuer import org.phenoscape.scowl.converters.Literalable import org.phenoscape.scowl.converters.SWRLDArgish @@ -40,8 +41,11 @@ import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom import org.semanticweb.owlapi.model.OWLDatatypeRestriction import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom +import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom +import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom +import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom import org.semanticweb.owlapi.model.OWLFacetRestriction import org.semanticweb.owlapi.model.OWLHasKeyAxiom import org.semanticweb.owlapi.model.OWLIndividual @@ -68,14 +72,15 @@ import org.semanticweb.owlapi.model.OWLObjectUnionOf import org.semanticweb.owlapi.model.OWLPropertyExpression import org.semanticweb.owlapi.model.OWLSameIndividualAxiom import org.semanticweb.owlapi.model.OWLSubClassOfAxiom +import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom import org.semanticweb.owlapi.model.SWRLAtom import org.semanticweb.owlapi.model.SWRLClassAtom import org.semanticweb.owlapi.model.SWRLDataPropertyAtom +import org.semanticweb.owlapi.model.SWRLDataRangeAtom import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom import org.semanticweb.owlapi.model.SWRLRule -import org.semanticweb.owlapi.model.SWRLDataRangeAtom package object scowl extends Vocab with ofn.Entities @@ -205,6 +210,8 @@ package object scowl extends Vocab def value(individual: OWLIndividual): OWLObjectHasValue = factory.getOWLObjectHasValue(self, individual) + def EquivalentTo(other: OWLObjectPropertyExpression): OWLEquivalentObjectPropertiesAxiom = factory.getOWLEquivalentObjectPropertiesAxiom(self, other) + def SubPropertyOf(other: OWLObjectPropertyExpression): OWLSubObjectPropertyOfAxiom = factory.getOWLSubObjectPropertyOfAxiom(self, other) def o(property: OWLObjectPropertyExpression): ScowlPropertyChain = new ScowlPropertyChain(self, property) @@ -254,10 +261,16 @@ package object scowl extends Vocab factory.getOWLDataHasValue(self, literalable.toLiteral(value)) } + def EquivalentTo(other: OWLDataPropertyExpression): OWLEquivalentDataPropertiesAxiom = factory.getOWLEquivalentDataPropertiesAxiom(self, other) + + def SubPropertyOf(other: OWLDataPropertyExpression): OWLSubDataPropertyOfAxiom = factory.getOWLSubDataPropertyOfAxiom(self, other) + def Domain(domain: OWLClassExpression): OWLDataPropertyDomainAxiom = factory.getOWLDataPropertyDomainAxiom(self, domain) def Range(range: OWLDataRange): OWLDataPropertyRangeAxiom = factory.getOWLDataPropertyRangeAxiom(self, range) + def DisjointWith(other: OWLDataPropertyExpression): OWLDisjointDataPropertiesAxiom = factory.getOWLDisjointDataPropertiesAxiom(self, other) + def Characteristic[T <: OWLDataPropertyCharacteristicAxiom](characteristic: PropertyCharacteristic[_, T]): T = characteristic.axiom(self) def apply[S: SWRLIArgish, V: SWRLDArgish](subj: S, value: V): SWRLDataPropertyAtom = {