Skip to content

Commit 650224e

Browse files
authored
Properly handle nonexistent input relations; add documentation on default relations (#157)
* Don’t fail when processing a requested but undeclared property. * Add documentation about default properties. * Add test file to git.
1 parent 93d4543 commit 650224e

4 files changed

Lines changed: 128228 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ final case class Config(
1818
@HelpMessage("Configure style of triples to be output. RDF mode is the default; each existential relation is collapsed to a single direct triple.")
1919
@ValueDescription("RDF|OWL")
2020
mode: OutputMode = RDFMode,
21-
@HelpMessage("Property to restrict output relations to. Provide option multiple times for multiple properties.")
21+
@HelpMessage("Property to restrict output relations to. Provide option multiple times for multiple properties. If no properties are provided (via CLI or file), then all properties found in the ontology will be used.")
2222
@ValueDescription("IRI")
2323
property: List[String] = Nil,
24-
@HelpMessage("File containing line-separated property IRIs to restrict output relations to.")
24+
@HelpMessage("File containing line-separated property IRIs to restrict output relations to. If no properties are provided (via CLI or file), then all properties found in the ontology will be used.")
2525
@ValueDescription("filename")
2626
propertiesFile: Option[String],
2727
@HelpMessage("Include entailed rdfs:subClassOf or owl:equivalentClass relations in output (default false)")

core/src/main/scala/org/renci/relationgraph/RelationGraph.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ object RelationGraph extends StrictLogging {
5858
val indexedWhelk = IndexedReasonerState(whelk)
5959
logger.info("Done running reasoner")
6060
val classes = classHierarchy(indexedWhelk.state)
61-
val properties = propertyHierarchy(ontology)
61+
val properties = propertyHierarchy(ontology, specifiedProperties)
6262
val allProperties = properties.subclasses.keySet.map(c => Role(c.id))
6363
val ontologyDeclarationStream = ZStream.succeed(ZIO.succeed(TriplesGroup(Set(Triple.create(NodeFactory.createBlankNode("redundant"), RDFType, OWLOntology)))))
6464
.when(outputConfig.mode == OWLMode)
@@ -181,7 +181,7 @@ object RelationGraph extends StrictLogging {
181181
Hierarchy(equivMap, subclassTaxonomy)
182182
}
183183

184-
def propertyHierarchy(ont: OWLOntology): Hierarchy = {
184+
def propertyHierarchy(ont: OWLOntology, requestedProperties: Set[AtomicConcept]): Hierarchy = {
185185
val subPropAxioms = ont.getAxioms(AxiomType.SUB_OBJECT_PROPERTY).asScala.to(Set).collect {
186186
case ax if ax.getSubProperty.isNamed && ax.getSuperProperty.isNamed && !ax.getSuperProperty.isOWLTopObjectProperty => ConceptInclusion(
187187
AtomicConcept(ax.getSubProperty.asOWLObjectProperty.getIRI.toString),
@@ -191,7 +191,10 @@ object RelationGraph extends StrictLogging {
191191
.filterNot(_.isOWLTopObjectProperty)
192192
.map(prop =>
193193
ConceptInclusion(AtomicConcept(prop.getIRI.toString), AtomicConcept(prop.getIRI.toString)))
194-
val allAxioms = (subPropAxioms ++ allProps).toSet[Axiom]
194+
val requestedProps = requestedProperties
195+
.filterNot(_ == BuiltIn.Top)
196+
.map(prop => ConceptInclusion(prop, prop))
197+
val allAxioms = (subPropAxioms ++ allProps ++ requestedProps).toSet[Axiom]
195198
val whelk = Reasoner.assert(allAxioms)
196199
classHierarchy(whelk)
197200
}

0 commit comments

Comments
 (0)