diff --git a/CHANGELOG.md b/CHANGELOG.md
index 955f1cf4b..c333e4d54 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- '--annotate-with-source true' does not work with extract --method subset [#1160]
- Fix how Template adds entities to the QuotedEntityChecker [#1104]
+- [`merge`] and 'annotate' operations '--annotate-defined-by' excludes reserved OWL 2 vocabularies [#1171]
- Handle IRIs that are not entities in export [#1168]
## [1.9.5] - 2023-09-20
@@ -381,6 +382,7 @@ First official release of ROBOT!
[`template`]: http://robot.obolibrary.org/template
[`validate`]: http://robot.obolibrary.org/validate
+[#1171]: https://github.com/ontodev/robot/pull/1171
[#1168]: https://github.com/ontodev/robot/pull/1168
[#1160]: https://github.com/ontodev/robot/pull/1160
[#1148]: https://github.com/ontodev/robot/pull/1148
diff --git a/docs/examples/example2_defined_by.owl b/docs/examples/example2_defined_by.owl
index d15c175ac..82bb72339 100644
--- a/docs/examples/example2_defined_by.owl
+++ b/docs/examples/example2_defined_by.owl
@@ -78,62 +78,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -284,18 +234,6 @@
dummy individal 5
-
-
-
-
-
-
diff --git a/docs/examples/merged_defined_by.owl b/docs/examples/merged_defined_by.owl
index d988d4fa2..e71912c17 100644
--- a/docs/examples/merged_defined_by.owl
+++ b/docs/examples/merged_defined_by.owl
@@ -78,54 +78,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/merge.md b/docs/merge.md
index b8d1a80c8..d74f96ea8 100644
--- a/docs/merge.md
+++ b/docs/merge.md
@@ -46,3 +46,5 @@ It’s also possible to annotate the imported or merged ontology axioms with the
robot merge --input example2.owl --input merge.owl \
--annotate-defined-by true \
--output results/merged_defined_by.owl
+
+`--annotate-defined-by` excludes entities from the reserved OWL 2 vocabularies (RDF, RDFS, XSD and OWL).
diff --git a/robot-command/src/main/java/org/obolibrary/robot/AnnotateCommand.java b/robot-command/src/main/java/org/obolibrary/robot/AnnotateCommand.java
index 8a9d3499b..e35fc36b0 100644
--- a/robot-command/src/main/java/org/obolibrary/robot/AnnotateCommand.java
+++ b/robot-command/src/main/java/org/obolibrary/robot/AnnotateCommand.java
@@ -318,7 +318,9 @@ public CommandState execute(CommandState state, String[] args) throws Exception
OWLAnnotationProperty rdfsIsDefinedBy =
ontology.getOWLOntologyManager().getOWLDataFactory().getRDFSIsDefinedBy();
for (OWLEntity owlEntity : ontology.getSignature()) {
- OntologyHelper.addEntityAnnotation(ontology, owlEntity, rdfsIsDefinedBy, ontIRI, false);
+ if (!owlEntity.getIRI().isReservedVocabulary()) {
+ OntologyHelper.addEntityAnnotation(ontology, owlEntity, rdfsIsDefinedBy, ontIRI, false);
+ }
}
}
}
diff --git a/robot-core/src/main/java/org/obolibrary/robot/MergeOperation.java b/robot-core/src/main/java/org/obolibrary/robot/MergeOperation.java
index 92d1a13a4..6e5efa25d 100644
--- a/robot-core/src/main/java/org/obolibrary/robot/MergeOperation.java
+++ b/robot-core/src/main/java/org/obolibrary/robot/MergeOperation.java
@@ -363,8 +363,10 @@ private static void annotateWithOntologyIRI(
OWLAnnotationProperty rdfsIsDefinedBy =
targetOntology.getOWLOntologyManager().getOWLDataFactory().getRDFSIsDefinedBy();
for (OWLEntity owlEntity : sourceOntology.getSignature(includeImportsClosure)) {
- OntologyHelper.addEntityAnnotation(
- targetOntology, owlEntity, rdfsIsDefinedBy, ontIRI, false);
+ if (!owlEntity.getIRI().isReservedVocabulary()) {
+ OntologyHelper.addEntityAnnotation(
+ targetOntology, owlEntity, rdfsIsDefinedBy, ontIRI, false);
+ }
}
}
}
diff --git a/robot-core/src/test/java/org/obolibrary/robot/MergeOperationTest.java b/robot-core/src/test/java/org/obolibrary/robot/MergeOperationTest.java
index 6bf104b2f..386a4319c 100644
--- a/robot-core/src/test/java/org/obolibrary/robot/MergeOperationTest.java
+++ b/robot-core/src/test/java/org/obolibrary/robot/MergeOperationTest.java
@@ -101,9 +101,9 @@ public void testMergeDefinedBy() throws IOException {
assertEquals(5, simple.getAxiomCount());
OWLOntology merged = MergeOperation.merge(ontologies, false, false, true, false);
- assertEquals(9, merged.getAxiomCount());
+ assertEquals(7, merged.getAxiomCount());
OWLOntology expected = loadOntology("/simple_defined_by.owl");
- assertEquals(9, expected.getAxiomCount());
+ assertEquals(7, expected.getAxiomCount());
assertIdentical(expected, merged);
}
}
diff --git a/robot-core/src/test/resources/simple_defined_by.owl b/robot-core/src/test/resources/simple_defined_by.owl
index 890c1075d..06c23107a 100644
--- a/robot-core/src/test/resources/simple_defined_by.owl
+++ b/robot-core/src/test/resources/simple_defined_by.owl
@@ -8,43 +8,6 @@
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-