From 5a34f39a6d2c59eae5a3749c4d22d8b6ea9786c1 Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Thu, 20 Oct 2016 22:20:12 -0500 Subject: [PATCH] Updated readme with info on building and running. Fixes #2. --- README.md | 54 +++++++++++++++++++ build.sbt | 2 + .../org/monarchinitiative/dosdp/Main.scala | 4 +- .../org/monarchinitiative/dosdp/SPARQL.scala | 4 ++ 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 191b852..7e7c80d 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,57 @@ Given a YAML design pattern following the [DOSDP spec](https://github.com/dosumi For context, see: https://github.com/dosumis/dead_simple_owl_design_patterns/issues/9 + +## Releases +dosdp-scala is still somewhat experimental, but pre-packaged releases can be downloaded from [here](https://github.com/balhoff/dosdp-scala/releases). + +## Building + +Install `sbt` on your system. For Mac OS X, it is easily done using [Homebrew](http://brew.sh): `brew install sbt` + +To compile and build the executable package, run: + +`sbt stage` + +You will find executables for Unix and Windows in `target/universal/stage/bin/`. These depend on the libraries in `target/universal/stage/lib`. + +## Usage + +``` +Usage + + dosdp-scala [options] : query an ontology for terms matching a Dead Simple OWL Design Pattern + +Options + + --ontology : OWL ontology to query + --print-query : Print generated query without running against ontology + --reasoner : Reasoner to use for expanding variable constraints (currently only valid option is `elk`) + --template : DOSDP file (YAML) +``` + +Example: `dosdp-scala --template=entity_attribute_location.yaml --print-query` + +Output: +```sparql +PREFIX rdf: +PREFIX rdfs: +PREFIX owl: + +SELECT DISTINCT ?attribute ?entity ?entity_attribute_location ?location +WHERE { +?entity_attribute_location owl:equivalentClass ?935f1722f77e4a5d83a952bd05468061 . +?935f1722f77e4a5d83a952bd05468061 owl:intersectionOf/rdf:rest*/rdf:first ?589c79cc99244f42aca7ca788c4c5de7 . +?935f1722f77e4a5d83a952bd05468061 owl:intersectionOf/rdf:rest*/rdf:first ?attribute . +?935f1722f77e4a5d83a952bd05468061 owl:intersectionOf/rdf:rest/rdf:rest rdf:nil . +?589c79cc99244f42aca7ca788c4c5de7 owl:onProperty . +?589c79cc99244f42aca7ca788c4c5de7 owl:someValuesFrom ?c3ce064ef0e54bb580fd6e78c53646b2 . +?c3ce064ef0e54bb580fd6e78c53646b2 owl:intersectionOf/rdf:rest*/rdf:first ?entity . +?c3ce064ef0e54bb580fd6e78c53646b2 owl:intersectionOf/rdf:rest*/rdf:first ?1336ea47488043ecb3149ada5d1102ae . +?c3ce064ef0e54bb580fd6e78c53646b2 owl:intersectionOf/rdf:rest/rdf:rest rdf:nil . +?1336ea47488043ecb3149ada5d1102ae owl:onProperty . +?1336ea47488043ecb3149ada5d1102ae owl:someValuesFrom ?location . +FILTER(?entity != ?1336ea47488043ecb3149ada5d1102ae) +FILTER(?attribute != ?589c79cc99244f42aca7ca788c4c5de7) +} +``` \ No newline at end of file diff --git a/build.sbt b/build.sbt index 7a121e7..0b1413b 100644 --- a/build.sbt +++ b/build.sbt @@ -12,6 +12,8 @@ scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8") scalacOptions in Test ++= Seq("-Yrangepos") +mainClass in Compile := Some("org.monarchinitiative.dosdp.Main") + resolvers += Resolver.bintrayRepo("jeremyrsmith", "maven") resolvers += "Phenoscape Maven repository" at "http://phenoscape.svn.sourceforge.net/svnroot/phenoscape/trunk/maven/repository" diff --git a/src/main/scala/org/monarchinitiative/dosdp/Main.scala b/src/main/scala/org/monarchinitiative/dosdp/Main.scala index c5023e2..7e591e0 100644 --- a/src/main/scala/org/monarchinitiative/dosdp/Main.scala +++ b/src/main/scala/org/monarchinitiative/dosdp/Main.scala @@ -20,12 +20,12 @@ import com.hp.hpl.jena.query.QueryExecutionFactory import com.hp.hpl.jena.query.ResultSetFormatter object Main extends CliMain[Unit]( - name = "dosdp-query", + name = "dosdp-scala", description = "query an ontology for terms matching a Dead Simple OWL Design Pattern") { var ontOpt = opt[Option[String]](name = "ontology", description = "OWL ontology to query") var templateFile = opt[File](name = "template", default = new File("dosdp.yaml"), description = "DOSDP file (YAML)") - var reasonerNameOpt = opt[Option[String]](name = "reasoner", description = "Reasoner to use for expanding variable constraints (currently any reasoner as long as it is `elk`") + var reasonerNameOpt = opt[Option[String]](name = "reasoner", description = "Reasoner to use for expanding variable constraints (currently only valid option is `elk`)") var printQuery = opt[Boolean](name = "print-query", default = false, description = "Print generated query without running against ontology") def run: Unit = { diff --git a/src/main/scala/org/monarchinitiative/dosdp/SPARQL.scala b/src/main/scala/org/monarchinitiative/dosdp/SPARQL.scala index e997d63..b60ffc3 100644 --- a/src/main/scala/org/monarchinitiative/dosdp/SPARQL.scala +++ b/src/main/scala/org/monarchinitiative/dosdp/SPARQL.scala @@ -17,6 +17,8 @@ import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom import org.semanticweb.owlapi.model.OWLSubClassOfAxiom import com.typesafe.scalalogging.LazyLogging +import org.semanticweb.owlapi.model.OWLObjectUnionOf +import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom object SPARQL extends LazyLogging { @@ -115,6 +117,8 @@ ${triplesFor(dosdp).mkString("\n")} val listLengthTriple = s"$node owl:intersectionOf/${and.getOperands.toSeq.map(_ => "rdf:rest").mkString("/")} rdf:nil ." (node, (intersectionTriples.toSeq :+ listLengthTriple) ++ operandTriplesList.toSeq.flatten ++ filters) } + case or: OWLObjectUnionOf => ??? + case only: OWLObjectAllValuesFrom => ??? } private def genVar: String = "?" + UUID.randomUUID.toString.replaceAllLiterally("-", "")