Skip to content

Commit

Permalink
Updated readme with info on building and running. Fixes #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
balhoff committed Oct 21, 2016
1 parent 593ae37 commit 5a34f39
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/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 <http://purl.obolibrary.org/obo/RO_0000052> .
?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 <http://purl.obolibrary.org/obo/BFO_0000050> .
?1336ea47488043ecb3149ada5d1102ae owl:someValuesFrom ?location .
FILTER(?entity != ?1336ea47488043ecb3149ada5d1102ae)
FILTER(?attribute != ?589c79cc99244f42aca7ca788c4c5de7)
}
```
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/org/monarchinitiative/dosdp/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/org/monarchinitiative/dosdp/SPARQL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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("-", "")
Expand Down

0 comments on commit 5a34f39

Please sign in to comment.