Skip to content

Commit 69621cc

Browse files
committed
Revert "Reformat with scalafmt 2.7.5"
This reverts commit b21bdab.
1 parent 9e4ddb5 commit 69621cc

4 files changed

Lines changed: 61 additions & 57 deletions

File tree

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

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

1719
object Config {
1820

@@ -28,14 +30,15 @@ object Config {
2830
arg.toLowerCase match {
2931
case "rdf" => Right(RDFMode)
3032
case "owl" => Right(OWLMode)
31-
case _ => Left(MalformedValue("output mode", arg))
33+
case _ => Left(MalformedValue("output mode", arg))
3234
}
3335
}
3436

3537
}
3638

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

4144
def bool: Boolean
@@ -56,11 +59,11 @@ object Config {
5659

5760
implicit val argParser: ArgParser[BoolValue] = SimpleArgParser.from[BoolValue]("boolean value") { arg =>
5861
arg.toLowerCase match {
59-
case "true" => Right(TrueValue)
62+
case "true" => Right(TrueValue)
6063
case "false" => Right(FalseValue)
61-
case "1" => Right(TrueValue)
62-
case "0" => Right(FalseValue)
63-
case _ => Left(MalformedValue("boolean value", arg))
64+
case "1" => Right(TrueValue)
65+
case "0" => Right(FalseValue)
66+
case _ => Left(MalformedValue("boolean value", arg))
6467
}
6568
}
6669

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

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,37 @@ object Main extends ZCaseApp[Config] {
4949
nonredundantRDFWriter <- createStreamRDF(nonredundantOutputStream)
5050
redundantRDFWriter <- createStreamRDF(redundantOutputStream)
5151
} yield (nonredundantRDFWriter, redundantRDFWriter)
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 ()
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 ()
8183
}
8284
program.exitCode
8385
}
@@ -96,8 +98,7 @@ object Main extends ZCaseApp[Config] {
9698
}
9799
}(stream => ZIO.effectTotal(stream.finish()))
98100

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

102103
def processSuperclasses(cls: OWLClass, whelk: ReasonerState, config: Config): TriplesGroup = {
103104
val subject = NodeFactory.createURI(cls.getIRI.toString)
@@ -109,21 +110,19 @@ object Main extends ZCaseApp[Config] {
109110
val (equivs, directSuperclasses) = whelk.directlySubsumedBy(concept)
110111
val adjustedEquivs = if (config.reflexiveSubclasses.bool) equivs + concept else equivs - concept
111112
val directSuperclassTriples = directSuperclasses.map(c => Triple.create(subject, RDFSSubClassOf, 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)))
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)))
117117
val nonredundantTriples = directSuperclassTriples ++ equivalentClassTriples
118118
val adjustedSuperclasses = if (config.reflexiveSubclasses.bool) allSuperclasses + concept else allSuperclasses - concept
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-
}
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+
}
127126
TriplesGroup(nonredundantTriples, redundantTriples)
128127
}
129128
}

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

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

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

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

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

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ 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
34-
)
33+
.headL)
3534
TriplesGroup(nonredundant, redundant) = triples
3635
} yield assert(nonredundant)(contains(Triple.create(n(s"$Prefix#A"), P, n(s"$Prefix#D")))) &&
3736
assert(redundant)(contains(Triple.create(n(s"$Prefix#A"), P, n(s"$Prefix#D")))) &&

0 commit comments

Comments
 (0)