Skip to content

Commit

Permalink
Merge pull request #26 from phenoscape/develop
Browse files Browse the repository at this point in the history
Add command line interface to negation hierarchy asserter
  • Loading branch information
balhoff authored Feb 5, 2019
2 parents 7968fa5 + c12ebc9 commit a455264
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
20 changes: 0 additions & 20 deletions src/getscores-genes-corpus.rq

This file was deleted.

25 changes: 23 additions & 2 deletions src/main/scala/org/phenoscape/owl/NegationHierarchyAsserter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@ package org.phenoscape.owl
import scala.collection.JavaConverters._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.model._
import org.semanticweb.owlapi.apibinding.OWLManager
import java.io.File
import java.io.FileOutputStream
import scala.collection.JavaConverters._
import org.semanticweb.owlapi.model.parameters.Imports


object NegationHierarchyAsserter {

val factory = OWLManager.getOWLDataFactory
val Negates = factory.getOWLAnnotationProperty(Vocab.NEGATES)

object NegationHierarchyAsserter extends OWLTask {

def main(args: Array[String]): Unit = {

val manager: OWLOntologyManager = OWLManager.createOWLOntologyManager()
val inputOntology: OWLOntology = manager.loadOntologyFromOntologyDocument(new File(args(0)))
val axioms: Set[OWLAxiom] = inputOntology.getAxioms(Imports.INCLUDED).asScala.toSet
val negationAxioms: Set[OWLAxiom] = assertNegationHierarchy(axioms)
val negationOntology: OWLOntology = manager.createOntology(negationAxioms.asJava)
manager.saveOntology(negationOntology, new FileOutputStream(args(1))) // negation axioms file
}

def assertNegationHierarchy(axioms: Set[OWLAxiom]): Set[OWLAxiom] = {
// create tuples (class expressions, named classes)
Expand Down Expand Up @@ -44,7 +64,7 @@ object NegationHierarchyAsserter extends OWLTask {
} yield Class(negater) SubClassOf Class(superClassOfOntClassIRI)

val equivalentClassAxioms = for {
equivAxiom @ EquivalentClasses(_, _) <- axioms
equivAxiom@EquivalentClasses(_, _) <- axioms
classes = equivAxiom.getNamedClasses.asScala
if classes.size > 1
} yield {
Expand All @@ -59,4 +79,5 @@ object NegationHierarchyAsserter extends OWLTask {

def emptyIndex[A, B]: Map[A, Set[B]] = Map.empty.withDefaultValue(Set.empty)


}
2 changes: 2 additions & 0 deletions src/main/scala/org/phenoscape/owl/build/Command.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.phenoscape.owl.build

import com.bigdata.rdf.store.DataLoader
import org.phenoscape.owl.NegationHierarchyAsserter

object Command extends App {

Expand All @@ -18,6 +19,7 @@ object Command extends App {
case "sparql-construct" => RunSPARQLConstruct.main(commandArgs)
case "sparql-update" => RunSPARQLUpdate.main(commandArgs)
case "convert-nexml" => ConvertNeXML.main(commandArgs)
case "assert-negation-hierarchy" => NegationHierarchyAsserter.main(commandArgs)
case _ => println("""
Valid commands are:
Expand Down
12 changes: 5 additions & 7 deletions src/getscores-taxa-corpus.rq → src/main/sparql/get-scores.rq
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ PREFIX owlet: <http://purl.org/phenoscape/owlet/syntax#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX StandardState: <http://purl.obolibrary.org/obo/CDAO_0000045>

SELECT ?match ?score ?query ?query_label ?corpusprofile ?corpusprofile_label
FROM <http://kb.phenoscape.org/>
FROM <http://kb.phenoscape.org/sim/taxa>
SELECT ?match ?score ?query ?corpusprofile
WHERE
{
?match ps:combined_score ?score .
?match ps:for_query_profile/^ps:has_phenotypic_profile ?query .
?match ps:for_corpus_profile/^ps:has_phenotypic_profile ?corpusprofile .
?query rdfs:label ?query_label .
?corpusprofile rdfs:label ?corpusprofile_label .
?match ps:for_query_profile ?query .
?match ps:for_corpus_profile ?corpusprofile .


}

0 comments on commit a455264

Please sign in to comment.