diff --git a/docs/examples/hubcap.owl b/docs/examples/hubcap.owl new file mode 100644 index 000000000..21f53ed24 --- /dev/null +++ b/docs/examples/hubcap.owl @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/robot-command/src/main/java/org/obolibrary/robot/MaterializeCommand.java b/robot-command/src/main/java/org/obolibrary/robot/MaterializeCommand.java index f177a7cf9..6ad020f00 100644 --- a/robot-command/src/main/java/org/obolibrary/robot/MaterializeCommand.java +++ b/robot-command/src/main/java/org/obolibrary/robot/MaterializeCommand.java @@ -44,6 +44,8 @@ public MaterializeCommand() { o.addOption("o", "output", true, "save reasoned ontology to a file"); o.addOption("t", "term", true, "a property to materialize"); o.addOption("T", "term-file", true, "load properties from a file"); + o.addOption( + "c", "include-indirect", true, "if true include redundant existential restrictions"); options = o; } @@ -131,6 +133,8 @@ public CommandState execute(CommandState state, String[] args) throws Exception } } + boolean includeIndirect = CommandLineHelper.getBooleanValue(line, "include-indirect", false); + Set terms = CommandLineHelper.getTerms(ioHelper, line, true); Set properties = new HashSet<>(); for (IRI term : terms) { diff --git a/robot-core/src/main/java/org/obolibrary/robot/MaterializeOperation.java b/robot-core/src/main/java/org/obolibrary/robot/MaterializeOperation.java index 71d5a5621..4bd228ba2 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/MaterializeOperation.java +++ b/robot-core/src/main/java/org/obolibrary/robot/MaterializeOperation.java @@ -77,6 +77,7 @@ public static void materialize( * @param options A map of options for the operation * @param reasonOverImportsClosure if true will first perform materialization over all ontologies * in the import closure + * @param includeIndirect if true include redundant existential restrictions * @throws OWLOntologyCreationException on ontology problem * @throws OntologyLogicException on logic problem */ @@ -87,12 +88,37 @@ public static void materialize( Map options, boolean reasonOverImportsClosure) throws OntologyLogicException, OWLOntologyCreationException { + materialize(ontology, reasonerFactory, properties, options, reasonOverImportsClosure, false); + } + + /** + * Replace EquivalentClass axioms with weaker SubClassOf axioms. + * + * @param ontology The OWLOntology to relax + * @param reasonerFactory reasoner factory for the reasoner that is to be wrapped + * @param properties object properties whose existentials are to be materialized (null + * materializes all) + * @param options A map of options for the operation + * @param reasonOverImportsClosure if true will first perform materialization over all ontologies + * in the import closure + * @throws OWLOntologyCreationException on ontology problem + * @throws OntologyLogicException on logic problem + */ + public static void materialize( + OWLOntology ontology, + OWLReasonerFactory reasonerFactory, + Set properties, + Map options, + boolean reasonOverImportsClosure, + boolean includeIndirect) + throws OntologyLogicException, OWLOntologyCreationException { if (reasonOverImportsClosure) { logger.info("Materializing imported ontologies..."); for (OWLOntology importedOntology : ontology.getImportsClosure()) { if (!importedOntology.equals(ontology)) { - materialize(importedOntology, reasonerFactory, properties, options, false); + materialize( + importedOntology, reasonerFactory, properties, options, false, includeIndirect); } } } @@ -143,7 +169,7 @@ public static void materialize( logger.debug("Excluding classes not in main ontology: " + c); continue; } - Set sces = emr.getSuperClassExpressions(c, true); + Set sces = emr.getSuperClassExpressions(c, !includeIndirect); if (!emr.isSatisfiable(c)) { logger.error("Ontology is not coherent! Unsatisfiable: " + c); throw new IncoherentTBoxException(Collections.singleton(c));