From f6c8f43c2f0784a21270d5fbba2eeadcdab15f54 Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Mon, 10 Jun 2019 14:16:49 -0400 Subject: [PATCH 1/5] Update dependencies. --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index c53b43c..2a2ff8b 100644 --- a/build.sbt +++ b/build.sbt @@ -35,13 +35,13 @@ libraryDependencies ++= { "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" %% "scowl" % "1.3.4", "org.phenoscape" %% "owlet" % "1.6", - "org.phenoscape" %% "phenoscape-kb-ingest" % "1.6.1", + "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.3" % Test, + "com.lihaoyi" %% "utest" % "0.6.9" % Test, "org.phenoscape" %% "sparql-interpolator" % "1.0", "io.monix" %% "monix" % "3.0.0-RC2" From 635a70b2ca4b4d47d3173cd6a5b3ab258c617d77 Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Fri, 26 Jul 2019 12:15:42 -0400 Subject: [PATCH 2/5] Add command to run homology converters. --- .../owl/HomologyTableDemoRolification.scala | 34 ++++++------ .../owl/HomologyTableToOWLVAHM.scala | 30 +++++------ .../owl/HomologyTableWithTaxa.scala | 52 ++++++++----------- .../org/phenoscape/owl/build/Command.scala | 35 ++++++++----- 4 files changed, 72 insertions(+), 79 deletions(-) diff --git a/src/main/scala/org/phenoscape/owl/HomologyTableDemoRolification.scala b/src/main/scala/org/phenoscape/owl/HomologyTableDemoRolification.scala index 7c0f02c..87266a3 100644 --- a/src/main/scala/org/phenoscape/owl/HomologyTableDemoRolification.scala +++ b/src/main/scala/org/phenoscape/owl/HomologyTableDemoRolification.scala @@ -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 { @@ -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)) @@ -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)))) } \ No newline at end of file diff --git a/src/main/scala/org/phenoscape/owl/HomologyTableToOWLVAHM.scala b/src/main/scala/org/phenoscape/owl/HomologyTableToOWLVAHM.scala index 6be2d0f..218693c 100644 --- a/src/main/scala/org/phenoscape/owl/HomologyTableToOWLVAHM.scala +++ b/src/main/scala/org/phenoscape/owl/HomologyTableToOWLVAHM.scala @@ -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 @@ -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)) @@ -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)))) } \ No newline at end of file diff --git a/src/main/scala/org/phenoscape/owl/HomologyTableWithTaxa.scala b/src/main/scala/org/phenoscape/owl/HomologyTableWithTaxa.scala index 62b48c1..15ad020 100644 --- a/src/main/scala/org/phenoscape/owl/HomologyTableWithTaxa.scala +++ b/src/main/scala/org/phenoscape/owl/HomologyTableWithTaxa.scala @@ -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 @@ -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 } @@ -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)))) @@ -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)))) } \ No newline at end of file diff --git a/src/main/scala/org/phenoscape/owl/build/Command.scala b/src/main/scala/org/phenoscape/owl/build/Command.scala index 38e32b4..ebb2fde 100644 --- a/src/main/scala/org/phenoscape/owl/build/Command.scala +++ b/src/main/scala/org/phenoscape/owl/build/Command.scala @@ -1,26 +1,32 @@ 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: @@ -36,6 +42,7 @@ sparql-update convert-nexml assert-negation-hierarchy output-evolutionary-profiles +homology-table-to-owl Consult the source code for required parameters. """) From 21b1bdda20a266e3fb935b3d4202b9032d895b9a Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Fri, 26 Jul 2019 12:18:23 -0400 Subject: [PATCH 3/5] Change travis to openjdk. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 292dee1..95e8726 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ scala: - "2.11.11" - "2.12.4" jdk: - - oraclejdk8 + - openjdk8 From d9bd933c7018341d3338901acee8d7bebe8faf12 Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Fri, 26 Jul 2019 12:38:32 -0400 Subject: [PATCH 4/5] Drop support for Scala 2.11. --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 2a2ff8b..c0d17be 100644 --- a/build.sbt +++ b/build.sbt @@ -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") From d700be90dbfd8ea970c4e794ea2f8b5998ae1af0 Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Fri, 26 Jul 2019 12:40:33 -0400 Subject: [PATCH 5/5] Update travis config. --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95e8726..d8f89de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: scala scala: - - "2.11.11" - - "2.12.4" + - "2.12.8" jdk: - openjdk8