Skip to content

Commit 34cd647

Browse files
committed
Merge branch 'master' into update/scribe-slf4j-2.7.13
2 parents 1070c1f + 6ca304c commit 34cd647

7 files changed

Lines changed: 62 additions & 66 deletions

File tree

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 2.6.4
1+
version = 2.7.5
22
maxColumn = 140
33
continuationIndent.callSite = 2
44
continuationIndent.defnSite = 2

build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ libraryDependencies ++= {
2424
"dev.zio" %% "zio-streams" % zioVersion,
2525
"dev.zio" %% "zio-interop-monix" % "3.2.2.0-RC2",
2626
"io.monix" %% "monix" % "3.2.2",
27-
"org.geneontology" %% "whelk-owlapi" % "1.0.4",
28-
"com.outr" %% "scribe-slf4j" % "2.7.13",
27+
"org.geneontology" %% "whelk-owlapi" % "1.1",
28+
"com.outr" %% "scribe-slf4j" % "2.7.12",
2929
"com.github.alexarchambault" %% "case-app" % "2.0.6",
30-
"org.apache.jena" % "apache-jena-libs" % "3.16.0" exclude ("org.slf4j", "slf4j-log4j12"),
30+
"org.apache.jena" % "apache-jena-libs" % "3.17.0" exclude ("org.slf4j", "slf4j-log4j12"),
3131
"dev.zio" %% "zio-test" % zioVersion % Test,
3232
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
3333
)

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.7.6")
1+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")

src/main/scala/org/renci/relationgraph/Config.scala

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ final case class Config(ontologyFile: String,
1212
propertiesFile: Option[String],
1313
outputSubclasses: BoolValue = FalseValue,
1414
reflexiveSubclasses: BoolValue = TrueValue,
15-
equivalenceAsSubclass: BoolValue = TrueValue) {
16-
17-
}
15+
equivalenceAsSubclass: BoolValue = TrueValue) {}
1816

1917
object Config {
2018

@@ -30,15 +28,14 @@ object Config {
3028
arg.toLowerCase match {
3129
case "rdf" => Right(RDFMode)
3230
case "owl" => Right(OWLMode)
33-
case _ => Left(MalformedValue("output mode", arg))
31+
case _ => Left(MalformedValue("output mode", arg))
3432
}
3533
}
3634

3735
}
3836

39-
/**
40-
* This works around some confusing behavior in case-app boolean parsing
41-
*/
37+
/** This works around some confusing behavior in case-app boolean parsing
38+
*/
4239
sealed trait BoolValue {
4340

4441
def bool: Boolean
@@ -59,11 +56,11 @@ object Config {
5956

6057
implicit val argParser: ArgParser[BoolValue] = SimpleArgParser.from[BoolValue]("boolean value") { arg =>
6158
arg.toLowerCase match {
62-
case "true" => Right(TrueValue)
59+
case "true" => Right(TrueValue)
6360
case "false" => Right(FalseValue)
64-
case "1" => Right(TrueValue)
65-
case "0" => Right(FalseValue)
66-
case _ => Left(MalformedValue("boolean value", arg))
61+
case "1" => Right(TrueValue)
62+
case "0" => Right(FalseValue)
63+
case _ => Left(MalformedValue("boolean value", arg))
6764
}
6865
}
6966

src/main/scala/org/renci/relationgraph/Main.scala

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,37 +49,35 @@ object Main extends ZCaseApp[Config] {
4949
nonredundantRDFWriter <- createStreamRDF(nonredundantOutputStream)
5050
redundantRDFWriter <- createStreamRDF(redundantOutputStream)
5151
} yield (nonredundantRDFWriter, redundantRDFWriter)
52-
val program = streamsManaged.use {
53-
case (nonredundantRDFWriter, redundantRDFWriter) =>
54-
for {
55-
fileProperties <- config.propertiesFile.map(readPropertiesFile).getOrElse(ZIO.succeed(Set.empty[OWLObjectProperty]))
56-
specifiedProperties = fileProperties ++ config.property.map(prop => df.getOWLObjectProperty(IRI.create(prop))).to(Set)
57-
manager <- ZIO.effect(OWLManager.createOWLOntologyManager())
58-
ontology <- ZIO.effect(manager.loadOntologyFromOntologyDocument(ontologyFile))
59-
whelkOntology = Bridge.ontologyToAxioms(ontology)
60-
_ <- ZIO.effectTotal(scribe.info("Running reasoner"))
61-
whelk = Reasoner.assert(whelkOntology)
62-
_ <- ZIO.effectTotal(scribe.info("Done running reasoner"))
63-
_ <- (effectBlockingIO(
64-
nonredundantRDFWriter.triple(Triple.create(NodeFactory.createBlankNode("nonredundant"), RDFType, OWLOntology))) *>
65-
effectBlockingIO(redundantRDFWriter.triple(Triple.create(NodeFactory.createBlankNode("redundant"), RDFType, OWLOntology))))
66-
.when(config.mode == OWLMode)
67-
start <- ZIO.effectTotal(System.currentTimeMillis())
68-
classes = allClasses(ontology)
69-
classesTasks = classes.map(c => Task(processSuperclasses(c, whelk, config)))
70-
restrictions = extractAllRestrictions(ontology, specifiedProperties)
71-
restrictionsTasks = restrictions.map(r => Task(processRestriction(r, whelk, config.mode)))
72-
allTasks = classesTasks ++ restrictionsTasks
73-
processed = allTasks.mapParallelUnordered(JRuntime.getRuntime.availableProcessors)(identity)
74-
monixTask = processed.foreachL {
75-
case TriplesGroup(nonredundant, redundant) =>
76-
nonredundant.foreach(nonredundantRDFWriter.triple)
77-
redundant.foreach(redundantRDFWriter.triple)
78-
}
79-
_ <- IO.fromTask(monixTask)
80-
stop <- ZIO.effectTotal(System.currentTimeMillis())
81-
_ <- ZIO.effectTotal(scribe.info(s"Computed relations in ${(stop - start) / 1000.0}s"))
82-
} yield ()
52+
val program = streamsManaged.use { case (nonredundantRDFWriter, redundantRDFWriter) =>
53+
for {
54+
fileProperties <- config.propertiesFile.map(readPropertiesFile).getOrElse(ZIO.succeed(Set.empty[OWLObjectProperty]))
55+
specifiedProperties = fileProperties ++ config.property.map(prop => df.getOWLObjectProperty(IRI.create(prop))).to(Set)
56+
manager <- ZIO.effect(OWLManager.createOWLOntologyManager())
57+
ontology <- ZIO.effect(manager.loadOntologyFromOntologyDocument(ontologyFile))
58+
whelkOntology = Bridge.ontologyToAxioms(ontology)
59+
_ <- ZIO.effectTotal(scribe.info("Running reasoner"))
60+
whelk = Reasoner.assert(whelkOntology)
61+
_ <- ZIO.effectTotal(scribe.info("Done running reasoner"))
62+
_ <- (effectBlockingIO(
63+
nonredundantRDFWriter.triple(Triple.create(NodeFactory.createBlankNode("nonredundant"), RDFType, OWLOntology))) *>
64+
effectBlockingIO(redundantRDFWriter.triple(Triple.create(NodeFactory.createBlankNode("redundant"), RDFType, OWLOntology))))
65+
.when(config.mode == OWLMode)
66+
start <- ZIO.effectTotal(System.currentTimeMillis())
67+
classes = allClasses(ontology)
68+
classesTasks = classes.map(c => Task(processSuperclasses(c, whelk, config)))
69+
restrictions = extractAllRestrictions(ontology, specifiedProperties)
70+
restrictionsTasks = restrictions.map(r => Task(processRestriction(r, whelk, config.mode)))
71+
allTasks = classesTasks ++ restrictionsTasks
72+
processed = allTasks.mapParallelUnordered(JRuntime.getRuntime.availableProcessors)(identity)
73+
monixTask = processed.foreachL { case TriplesGroup(nonredundant, redundant) =>
74+
nonredundant.foreach(nonredundantRDFWriter.triple)
75+
redundant.foreach(redundantRDFWriter.triple)
76+
}
77+
_ <- IO.fromTask(monixTask)
78+
stop <- ZIO.effectTotal(System.currentTimeMillis())
79+
_ <- ZIO.effectTotal(scribe.info(s"Computed relations in ${(stop - start) / 1000.0}s"))
80+
} yield ()
8381
}
8482
program.exitCode
8583
}
@@ -98,7 +96,8 @@ object Main extends ZCaseApp[Config] {
9896
}
9997
}(stream => ZIO.effectTotal(stream.finish()))
10098

101-
def allClasses(ont: OWLOntology): Observable[OWLClass] = Observable.fromIterable(ont.getClassesInSignature(Imports.INCLUDED).asScala.to(Set) - OWLThing - OWLNothing)
99+
def allClasses(ont: OWLOntology): Observable[OWLClass] =
100+
Observable.fromIterable(ont.getClassesInSignature(Imports.INCLUDED).asScala.to(Set) - OWLThing - OWLNothing)
102101

103102
def processSuperclasses(cls: OWLClass, whelk: ReasonerState, config: Config): TriplesGroup = {
104103
val subject = NodeFactory.createURI(cls.getIRI.toString)
@@ -110,19 +109,21 @@ object Main extends ZCaseApp[Config] {
110109
val (equivs, directSuperclasses) = whelk.directlySubsumedBy(concept)
111110
val adjustedEquivs = if (config.reflexiveSubclasses.bool) equivs + concept else equivs - concept
112111
val directSuperclassTriples = directSuperclasses.map(c => Triple.create(subject, RDFSSubClassOf, NodeFactory.createURI(c.id)))
113-
val equivalentClassTriples = if (config.equivalenceAsSubclass.bool)
114-
adjustedEquivs.map(c => Triple.create(subject, RDFSSubClassOf, NodeFactory.createURI(c.id)))
115-
else
116-
adjustedEquivs.map(c => Triple.create(subject, OWLEquivalentClass, NodeFactory.createURI(c.id)))
112+
val equivalentClassTriples =
113+
if (config.equivalenceAsSubclass.bool)
114+
adjustedEquivs.map(c => Triple.create(subject, RDFSSubClassOf, NodeFactory.createURI(c.id)))
115+
else
116+
adjustedEquivs.map(c => Triple.create(subject, OWLEquivalentClass, NodeFactory.createURI(c.id)))
117117
val nonredundantTriples = directSuperclassTriples ++ equivalentClassTriples
118118
val adjustedSuperclasses = if (config.reflexiveSubclasses.bool) allSuperclasses + concept else allSuperclasses - concept
119-
val redundantTriples = if (config.equivalenceAsSubclass.bool)
120-
adjustedSuperclasses.map(c => Triple.create(subject, RDFSSubClassOf, NodeFactory.createURI(c.id)))
121-
else {
122-
val superclassesMinusEquiv = adjustedSuperclasses -- adjustedEquivs
123-
superclassesMinusEquiv.map(c => Triple.create(subject, RDFSSubClassOf, NodeFactory.createURI(c.id))) ++
124-
equivalentClassTriples
125-
}
119+
val redundantTriples =
120+
if (config.equivalenceAsSubclass.bool)
121+
adjustedSuperclasses.map(c => Triple.create(subject, RDFSSubClassOf, NodeFactory.createURI(c.id)))
122+
else {
123+
val superclassesMinusEquiv = adjustedSuperclasses -- adjustedEquivs
124+
superclassesMinusEquiv.map(c => Triple.create(subject, RDFSSubClassOf, NodeFactory.createURI(c.id))) ++
125+
equivalentClassTriples
126+
}
126127
TriplesGroup(nonredundantTriples, redundantTriples)
127128
}
128129
}

src/main/scala/org/renci/relationgraph/ZCaseApp.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import caseapp.core.{Error, RemainingArgs}
88
import zio._
99
import zio.console.{putStrLn, Console}
1010

11-
/**
12-
* Adapted from caseapp.cats.IOCaseApp
11+
/** Adapted from caseapp.cats.IOCaseApp
1312
*/
1413
abstract class ZCaseApp[T](implicit val parser0: Parser[T], val messages: Help[T]) extends App {
1514

@@ -32,8 +31,7 @@ abstract class ZCaseApp[T](implicit val parser0: Parser[T], val messages: Help[T
3231
private[this] def usageAsked: ZIO[Console, Nothing, ExitCode] =
3332
putStrLn(messages.withHelp.usage).as(ExitCode.success)
3433

35-
/**
36-
* Arguments are expanded then parsed. By default, argument expansion is the identity function.
34+
/** Arguments are expanded then parsed. By default, argument expansion is the identity function.
3735
* Overriding this method allows plugging in an arbitrary argument expansion logic.
3836
*
3937
* One such expansion logic involves replacing each argument of the form '@<file>' with the
@@ -51,8 +49,7 @@ abstract class ZCaseApp[T](implicit val parser0: Parser[T], val messages: Help[T
5149
*/
5250
private[this] def expandArgs(args: List[String]): List[String] = args
5351

54-
/**
55-
* Whether to stop parsing at the first unrecognized argument.
52+
/** Whether to stop parsing at the first unrecognized argument.
5653
*
5754
* That is, stop parsing at the first non option (not starting with "-"), or
5855
* the first unrecognized option. The unparsed arguments are put in the `args`

src/test/scala/org/renci/relationgraph/TestRelationGraph.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ object TestRelationGraph extends DefaultRunnableSpec {
3030
restrictions
3131
.map(Main.processRestriction(_, whelk, Config.RDFMode))
3232
.reduce((left, right) => TriplesGroup(left.nonredundant ++ right.nonredundant, left.redundant ++ right.redundant))
33-
.headL)
33+
.headL
34+
)
3435
TriplesGroup(nonredundant, redundant) = triples
3536
} yield assert(nonredundant)(contains(Triple.create(n(s"$Prefix#A"), P, n(s"$Prefix#D")))) &&
3637
assert(redundant)(contains(Triple.create(n(s"$Prefix#A"), P, n(s"$Prefix#D")))) &&

0 commit comments

Comments
 (0)