Skip to content

Commit

Permalink
Merge branch 'master' into shalsh-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Shalsh23 authored Sep 6, 2019
2 parents ce84e7b + 70aa8c1 commit 19ac4ad
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 125 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: scala
scala:
- "2.11.11"
- "2.12.4"
- "2.12.8"
jdk:
- openjdk8
33 changes: 17 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mainClass in Compile := Some("org.phenoscape.owl.build.Command")

scalaVersion := "2.12.8"

crossScalaVersions := Seq("2.11.8", "2.12.8")
crossScalaVersions := Seq("2.12.8")

scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8")

Expand All @@ -28,21 +28,22 @@ testFrameworks += new TestFramework("utest.runner.Framework")

libraryDependencies ++= {
Seq(
"org.apache.commons" % "commons-lang3" % "3.1",
"commons-io" % "commons-io" % "2.4",
"org.jdom" % "jdom" % "2.0.2",
"net.sourceforge.owlapi" % "owlapi-distribution" % "4.5.8",
"org.semanticweb.elk" % "elk-owlapi" % "0.4.3",
"com.blazegraph" % "bigdata-core" % "2.1.2",
"org.openrdf.sesame" % "sesame-rio" % "2.7.12",
"org.phenoscape" %% "scowl" % "1.3",
"org.phenoscape" %% "owlet" % "1.6",
"org.phenoscape" %% "phenoscape-kb-ingest" % "1.6.1",
"log4j" % "log4j" % "1.2.17",
"org.apache.directory.studio" % "org.apache.commons.codec" % "1.8",
"com.github.pathikrit" %% "better-files" % "3.4.0",
"com.lihaoyi" %% "utest" % "0.6.3" % Test,
"org.phenoscape" %% "sparql-interpolator" % "1.0"
"org.apache.commons" % "commons-lang3" % "3.1",
"commons-io" % "commons-io" % "2.4",
"org.jdom" % "jdom" % "2.0.2",
"net.sourceforge.owlapi" % "owlapi-distribution" % "4.5.8",
"org.semanticweb.elk" % "elk-owlapi" % "0.4.3",
"com.blazegraph" % "bigdata-core" % "2.1.2",
"org.openrdf.sesame" % "sesame-rio" % "2.7.12",
"org.phenoscape" %% "scowl" % "1.3.4",
"org.phenoscape" %% "owlet" % "1.6",
"org.phenoscape" %% "phenoscape-kb-ingest" % "1.6.2",
"log4j" % "log4j" % "1.2.17",
"org.apache.directory.studio" % "org.apache.commons.codec" % "1.8",
"com.github.pathikrit" %% "better-files" % "3.4.0",
"com.lihaoyi" %% "utest" % "0.6.9" % Test,
"org.phenoscape" %% "sparql-interpolator" % "1.0",
"io.monix" %% "monix" % "3.0.0-RC2"

)
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package org.phenoscape.owl

import java.io.File
import scala.collection.JavaConverters._
import scala.io.Source
import org.phenoscape.kb.ingest.util.OBOUtil
import java.io.{File, FileOutputStream}

import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.{OBOUtil, PostCompositionParser}
import org.phenoscape.owl.Vocab._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.AddOntologyAnnotation
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom
import org.semanticweb.owlapi.model.OWLOntology
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat
import org.semanticweb.owlapi.model.{AddOntologyAnnotation, IRI, OWLAxiom, OWLOntology}
import org.semanticweb.owlapi.vocab.DublinCoreVocabulary

import Vocab._
import org.phenoscape.kb.ingest.util.PostCompositionParser
import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.lang3.StringUtils
import scala.collection.JavaConverters._
import scala.io.Source

object HomologyTableDemoRolification extends App {

Expand Down Expand Up @@ -63,13 +61,13 @@ object HomologyTableDemoRolification extends App {
val evidence = Individual(s"$uniquePrefix#evidence")
val pub = factory.getOWLLiteral(items(13).trim)
if (!negated) {
axioms += ((structure1 and (in_taxon some taxon1)) SubClassOf (role1.Self)) Annotation (axiom_has_evidence, evidence)
axioms += ((structure2 and (in_taxon some taxon2)) SubClassOf (role2.Self)) Annotation (axiom_has_evidence, evidence)
axioms += (property SubPropertyChain (role1 o factory.getOWLTopObjectProperty o role2)) Annotation (axiom_has_evidence, evidence)
axioms += ((structure1 and (in_taxon some taxon1)) SubClassOf (role1.Self)) Annotation(axiom_has_evidence, evidence)
axioms += ((structure2 and (in_taxon some taxon2)) SubClassOf (role2.Self)) Annotation(axiom_has_evidence, evidence)
axioms += (property SubPropertyChain (role1 o factory.getOWLTopObjectProperty o role2)) Annotation(axiom_has_evidence, evidence)
}
axioms += evidence Type evidenceCode
axioms += evidence Annotation (source, pub)
case None =>
axioms += evidence Annotation(source, pub)
case None =>
if (!negated) {
axioms += ((structure1 and (in_taxon some taxon1)) SubClassOf (role1.Self))
axioms += ((structure2 and (in_taxon some taxon2)) SubClassOf (role2.Self))
Expand All @@ -80,6 +78,6 @@ object HomologyTableDemoRolification extends App {
}

val output = convertFile(input)
manager.saveOntology(output, IRI.create(new File(args(1))))
manager.saveOntology(output, new FunctionalSyntaxDocumentFormat(), new FileOutputStream(new File(args(1))))

}
30 changes: 13 additions & 17 deletions src/main/scala/org/phenoscape/owl/HomologyTableToOWLVAHM.scala
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
package org.phenoscape.owl

import java.io.File

import scala.collection.JavaConverters._
import scala.io.Source
import java.io.{File, FileOutputStream}

import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.OBOUtil
import org.phenoscape.kb.ingest.util.PostCompositionParser
import org.phenoscape.kb.ingest.util.{OBOUtil, PostCompositionParser}
import org.phenoscape.owl.Vocab._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.AddOntologyAnnotation
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom
import org.semanticweb.owlapi.model.OWLOntology
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat
import org.semanticweb.owlapi.model.{AddOntologyAnnotation, IRI, OWLAxiom, OWLOntology}
import org.semanticweb.owlapi.vocab.DublinCoreVocabulary

import Vocab._
import scala.collection.JavaConverters._
import scala.io.Source

/**
* This corresponds to the AVA homology model in the Phenoscape homology paper.
*/
* This corresponds to the AVA homology model in the Phenoscape homology paper.
*/
object HomologyTableToOWLVAHM extends App {

val factory = OWLManager.getOWLDataFactory
Expand All @@ -40,7 +36,7 @@ object HomologyTableToOWLVAHM extends App {
def convertFile(file: Source): OWLOntology = {
val axioms = (file.getLines.drop(1).flatMap(processEntry)).toSet.asJava
val ontology = manager.createOntology(axioms, IRI.create("http://purl.org/phenoscape/demo/phenoscape_homology.owl"))
manager.applyChange(new AddOntologyAnnotation(ontology, factory.getOWLAnnotation(description, factory.getOWLLiteral("Homology Assertions using the VAHM model"))))
manager.applyChange(new AddOntologyAnnotation(ontology, factory.getOWLAnnotation(description, factory.getOWLLiteral("Homology Assertions using the AVA model"))))
manager.addAxiom(ontology, HistoricalHomologyMemberof InverseOf HasHistoricalHomologyMember)
manager.addAxiom(ontology, SerialHomologyMemberOf InverseOf HasSerialHomologyMember)
manager.addAxiom(ontology, InHistoricalHomologyRelationshipWith SubPropertyChain (HistoricalHomologyMemberof o HasHistoricalHomologyMember))
Expand Down Expand Up @@ -81,14 +77,14 @@ object HomologyTableToOWLVAHM extends App {
val evidence = Individual(s"$uniquePrefix#evidence")
val pub = factory.getOWLLiteral(items(13).trim)
axioms += evidence Type evidenceCode
axioms += evidence Annotation (source, pub)
axioms += ancestor Fact (has_evidence, evidence)
axioms += evidence Annotation(source, pub)
axioms += ancestor Fact(has_evidence, evidence)
}
}
axioms
}

val output = convertFile(input)
manager.saveOntology(output, IRI.create(new File(args(1))))
manager.saveOntology(output, new FunctionalSyntaxDocumentFormat(), new FileOutputStream(new File(args(1))))

}
52 changes: 22 additions & 30 deletions src/main/scala/org/phenoscape/owl/HomologyTableWithTaxa.scala
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
package org.phenoscape.owl

import java.io.File
import java.util.UUID
import java.io.{File, FileOutputStream}

import scala.collection.JavaConverters._
import scala.io.Source
import org.phenoscape.kb.ingest.util.OBOUtil
import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.lang3.StringUtils
import org.phenoscape.kb.ingest.util.{OBOUtil, PostCompositionParser}
import org.phenoscape.owl.Vocab._
import org.phenoscape.scowl._
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.AddImport
import org.semanticweb.owlapi.model.AddOntologyAnnotation
import org.semanticweb.owlapi.model.IRI
import org.semanticweb.owlapi.model.OWLAxiom
import org.semanticweb.owlapi.model.OWLOntology
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat
import org.semanticweb.owlapi.model.{AddOntologyAnnotation, IRI, OWLAxiom, OWLOntology}
import org.semanticweb.owlapi.vocab.DublinCoreVocabulary

import Vocab._
import org.phenoscape.kb.ingest.util.PostCompositionParser
import org.semanticweb.owlapi.model.OWLClassExpression
import org.semanticweb.owlapi.model.OWLNamedIndividual
import org.semanticweb.owlapi.model.OWLIndividual
import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.lang3.StringUtils
import scala.collection.JavaConverters._
import scala.io.Source

/**
* This corresponds to the REA homology model in the Phenoscape homology paper.
*/
* This corresponds to the REA homology model in the Phenoscape homology paper.
*/
object HomologyTableWithTaxa extends App {

val factory = OWLManager.getOWLDataFactory
Expand All @@ -45,7 +37,7 @@ object HomologyTableWithTaxa extends App {
def convertFile(file: Source): OWLOntology = {
val axioms = (file.getLines.drop(1).flatMap(processEntry)).toSet.asJava
val ontology = manager.createOntology(axioms, IRI.create("http://purl.org/phenoscape/demo/phenoscape_homology.owl"))
manager.applyChange(new AddOntologyAnnotation(ontology, factory.getOWLAnnotation(description, factory.getOWLLiteral("Homology Assertions using the REAHM model"))))
manager.applyChange(new AddOntologyAnnotation(ontology, factory.getOWLAnnotation(description, factory.getOWLLiteral("Homology Assertions using the REA model"))))
ontology
}

Expand Down Expand Up @@ -75,23 +67,23 @@ object HomologyTableWithTaxa extends App {
val evidence = Individual(s"$uniquePrefix#evidence")
val pub = factory.getOWLLiteral(items(13).trim)
if (!negated) {
axioms += ((structure1 and (in_taxon some taxon1)) SubClassOf (property some (structure2 and (in_taxon some taxon2)))) Annotation (axiom_has_evidence, evidence)
axioms += ((structure2 and (in_taxon some taxon2)) SubClassOf (property some (structure1 and (in_taxon some taxon1)))) Annotation (axiom_has_evidence, evidence)
axioms += ((structure1 and (in_taxon some taxon1)) SubClassOf (property some (structure2 and (in_taxon some taxon2)))) Annotation(axiom_has_evidence, evidence)
axioms += ((structure2 and (in_taxon some taxon2)) SubClassOf (property some (structure1 and (in_taxon some taxon1)))) Annotation(axiom_has_evidence, evidence)
}
val association = Individual(uniquePrefix)
axioms += association Type Association
axioms += association Fact (has_evidence, evidence)
axioms += association Fact (IsNegated, negated)
axioms += association Fact(has_evidence, evidence)
axioms += association Fact(IsNegated, negated)
val structure1Ind = Individual(s"$uniquePrefix#structure1")
val structure2Ind = Individual(s"$uniquePrefix#structure2")
axioms += structure1Ind Type (structure1 and (in_taxon some taxon1))
axioms += structure2Ind Type (structure2 and (in_taxon some taxon2))
axioms += association Fact (HasSubject, structure1Ind)
axioms += association Fact (HasObject, structure2Ind)
axioms += association Fact (HasPredicate, Individual(property.getIRI))
axioms += association Fact(HasSubject, structure1Ind)
axioms += association Fact(HasObject, structure2Ind)
axioms += association Fact(HasPredicate, Individual(property.getIRI))
axioms += evidence Type evidenceCode
axioms += evidence Annotation (source, pub)
case None =>
axioms += evidence Annotation(source, pub)
case None =>
if (!negated) {
axioms += ((structure1 and (in_taxon some taxon1)) SubClassOf (property some (structure2 and (in_taxon some taxon2))))
axioms += ((structure2 and (in_taxon some taxon2)) SubClassOf (property some (structure1 and (in_taxon some taxon1))))
Expand All @@ -101,6 +93,6 @@ object HomologyTableWithTaxa extends App {
}

val output = convertFile(input)
manager.saveOntology(output, IRI.create(new File(args(1))))
manager.saveOntology(output, new FunctionalSyntaxDocumentFormat(), new FileOutputStream(new File(args(1))))

}
39 changes: 23 additions & 16 deletions src/main/scala/org/phenoscape/owl/build/Command.scala
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
package org.phenoscape.owl.build

import com.bigdata.rdf.store.DataLoader
import org.phenoscape.owl.{EvolutionaryProfiles, NegationHierarchyAsserter, TaxonNode}
import org.semanticweb.owlapi.model.OWLOntology
import org.phenoscape.owl._

object Command extends App {

val commandArgs = args.drop(1)
args(0) match {
case "build-kb" => PhenoscapeKB.main(commandArgs)
case "pairwise-sim" => RunPairwiseOWLSim.main(commandArgs)
case "load-triples" => DataLoader.main(commandArgs)
case "output-ics" => ComputeICs.main(commandArgs)
case "output-profile-sizes" => PrintTaxonAndGeneProfileSizes.main(commandArgs)
case "expects-to-triples" => ConvertScoresToTriples.main(commandArgs)
case "sparql-select" => RunSPARQLQuery.main(commandArgs)
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 "build-kb" => PhenoscapeKB.main(commandArgs)
case "pairwise-sim" => RunPairwiseOWLSim.main(commandArgs)
case "load-triples" => DataLoader.main(commandArgs)
case "output-ics" => ComputeICs.main(commandArgs)
case "output-profile-sizes" => PrintTaxonAndGeneProfileSizes.main(commandArgs)
case "expects-to-triples" => ConvertScoresToTriples.main(commandArgs)
case "sparql-select" => RunSPARQLQuery.main(commandArgs)
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 "output-evolutionary-profiles" => EvolutionaryProfiles.main(commandArgs)
case _ => {
println(
"""

case "homology-table-to-owl" =>
val homologyArgs = commandArgs.drop(1)
commandArgs(0).toLowerCase match {
case "rea" => HomologyTableWithTaxa.main(homologyArgs)
case "ava" => HomologyTableToOWLVAHM.main(homologyArgs)
case "rolification" => HomologyTableDemoRolification.main(homologyArgs)
}
case _ => { println(
"""
Valid commands are:
build-kb
Expand All @@ -37,6 +43,7 @@ sparql-update
convert-nexml
assert-negation-hierarchy
output-evolutionary-profiles
homology-table-to-owl
Consult the source code for required parameters.
""")
Expand Down
20 changes: 5 additions & 15 deletions src/main/scala/org/phenoscape/owl/build/RunPairwiseOWLSim.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package org.phenoscape.owl.build

import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.util.Date
import scala.collection.JavaConverters._
import org.openrdf.rio.RDFFormat
import org.openrdf.rio.Rio
import org.phenoscape.owl.sim.OWLsim

import org.phenoscape.kb.ingest.util.OntUtil
import org.phenoscape.owl.sim.OWLsim
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.OWLNamedIndividual

import scala.collection.JavaConverters._

object RunPairwiseOWLSim extends App {

val taskCount = args(0).toInt
Expand Down Expand Up @@ -41,14 +39,6 @@ object RunPairwiseOWLSim extends App {
val startIndex = (taskNum - 1) * groupSize
val group = orderedProfiles.drop(startIndex).take(groupSize)
println("Computing similarity matrix")
val similarityMatrix = owlSim.computeAllSimilarityToCorpus(group.toSet)
println("Writing results to file")
val triplesOutput = new BufferedOutputStream(new FileOutputStream(new File(outfile)))
val writer = Rio.createWriter(RDFFormat.TURTLE, triplesOutput)
writer.startRDF()
similarityMatrix.foreach(writer.handleStatement)
writer.endRDF()
triplesOutput.close()
owlSim.computeAllSimilarityToCorpusDirectOutput(group.toSet, new File(outfile))
println("Done: " + new Date())

}
Loading

0 comments on commit 19ac4ad

Please sign in to comment.