Skip to content

Commit c9d74a4

Browse files
committed
CLASS-112 Add class axiom link of top level properties in OWL conversion.
Create the following axioms during the conversion of stated relationships to OWL: ``` SubClassOf(:762706009 :410662002) SubClassOf(:762705008 :410662002) ```
1 parent c58dc25 commit c9d74a4

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

src/main/java/org/snomed/otf/owltoolkit/ontology/OntologyService.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public Map<Long, Set<OWLAxiom>> createAxiomsFromStatedRelationships(SnomedTaxono
113113
Set<Long> descendants = snomedTaxonomy.getDescendants(conceptModelObjectAttribute);
114114
for (Long objectAttributeId : descendants) {
115115
for (Relationship relationship : snomedTaxonomy.getStatedRelationships(objectAttributeId)) {
116-
if (relationship.getTypeId() == Concepts.IS_A_LONG && (relationship.getDestinationId() != Concepts.CONCEPT_MODEL_ATTRIBUTE_LONG) || !conceptModelObjectAttributePresent) {
116+
if (relationship.getTypeId() == Concepts.IS_A_LONG) {
117117
axiomsMap.computeIfAbsent(objectAttributeId, (id) -> new HashSet<>())
118118
.add(createOwlSubObjectPropertyOfAxiom(objectAttributeId, relationship.getDestinationId()));
119119
}
@@ -133,6 +133,14 @@ public Map<Long, Set<OWLAxiom>> createAxiomsFromStatedRelationships(SnomedTaxono
133133

134134
// Create axioms of all other Snomed concepts
135135
Set<Long> attributeIds = snomedTaxonomy.getDescendants(Concepts.CONCEPT_MODEL_ATTRIBUTE_LONG);
136+
137+
// Link the top object and data property into the class hierarchy.
138+
// The top object and data properties will be represented as an OWL Property and as a Class to ensure that this link comes out in the NNF.
139+
// "The OWL 2 specification allows different entities with the same IRI to co-exist in an ontology" (thanks @apeteri)
140+
// Removing them from the attributeIds here set will ensure Class axioms are created.
141+
attributeIds.remove(Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE_LONG);
142+
attributeIds.remove(Concepts.CONCEPT_MODEL_DATA_ATTRIBUTE_LONG);
143+
136144
for (Long conceptId : snomedTaxonomy.getAllConceptIds()) {
137145

138146
// Convert any stated relationships to axioms

src/test/java/org/snomed/otf/owltoolkit/conversion/RF2ToOWLServiceTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public void convertRF2ArchiveToOWL() throws Exception {
5959
"Declaration(Class(:410662002))\n" +
6060
"Declaration(Class(:723594008))\n" +
6161
"Declaration(Class(:723596005))\n" +
62+
"Declaration(Class(:762705008))\n" +
63+
"Declaration(Class(:762706009))\n" +
6264
"Declaration(Class(:900000000000441003))\n" +
6365
"Declaration(ObjectProperty(:363698007))\n" +
6466
"Declaration(ObjectProperty(:609096000))\n" +
@@ -118,6 +120,14 @@ public void convertRF2ArchiveToOWL() throws Exception {
118120
"AnnotationAssertion(rdfs:label :723596005 \"All SNOMED CT content (foundation metadata concept)\"^^xsd:string)\n" +
119121
"SubClassOf(:723596005 :723594008)\n" +
120122
"\n" +
123+
"# Class: <http://snomed.info/id/762705008> (<http://snomed.info/id/762705008>)\n" +
124+
"\n" +
125+
"SubClassOf(:762705008 :410662002)\n" +
126+
"\n" +
127+
"# Class: <http://snomed.info/id/762706009> (<http://snomed.info/id/762706009>)\n" +
128+
"\n" +
129+
"SubClassOf(:762706009 :410662002)\n" +
130+
"\n" +
121131
"# Class: <http://snomed.info/id/900000000000441003> (SNOMED CT Model Component (metadata))\n" +
122132
"\n" +
123133
"AnnotationAssertion(rdfs:label :900000000000441003 \"SNOMED CT Model Component (metadata)\"^^xsd:string)\n" +
@@ -166,6 +176,8 @@ public void convertRF2ArchiveToOWLIncludingFictitiousDataAttribute() throws Exce
166176
"Declaration(Class(:410662002))\n" +
167177
"Declaration(Class(:723594008))\n" +
168178
"Declaration(Class(:723596005))\n" +
179+
"Declaration(Class(:762705008))\n" +
180+
"Declaration(Class(:762706009))\n" +
169181
"Declaration(Class(:900000000000441003))\n" +
170182
"Declaration(ObjectProperty(:363698007))\n" +
171183
"Declaration(ObjectProperty(:609096000))\n" +
@@ -236,6 +248,14 @@ public void convertRF2ArchiveToOWLIncludingFictitiousDataAttribute() throws Exce
236248
"AnnotationAssertion(rdfs:label :723596005 \"All SNOMED CT content (foundation metadata concept)\"^^xsd:string)\n" +
237249
"SubClassOf(:723596005 :723594008)\n" +
238250
"\n" +
251+
"# Class: <http://snomed.info/id/762705008> (<http://snomed.info/id/762705008>)\n" +
252+
"\n" +
253+
"SubClassOf(:762705008 :410662002)\n" +
254+
"\n" +
255+
"# Class: <http://snomed.info/id/762706009> (<http://snomed.info/id/762706009>)\n" +
256+
"\n" +
257+
"SubClassOf(:762706009 :410662002)\n" +
258+
"\n" +
239259
"# Class: <http://snomed.info/id/900000000000441003> (SNOMED CT Model Component (metadata))\n" +
240260
"\n" +
241261
"AnnotationAssertion(rdfs:label :900000000000441003 \"SNOMED CT Model Component (metadata)\"^^xsd:string)\n" +
@@ -288,6 +308,8 @@ public void convertExtensionRF2ArchivesToOWL() throws Exception {
288308
"Declaration(Class(:723594008))\n" +
289309
"Declaration(Class(:723596005))\n" +
290310
"Declaration(Class(:76145000))\n" +
311+
"Declaration(Class(:762705008))\n" +
312+
"Declaration(Class(:762706009))\n" +
291313
"Declaration(Class(:84301002))\n" +
292314
"Declaration(Class(:900000000000441003))\n" +
293315

@@ -396,6 +418,14 @@ public void convertExtensionRF2ArchivesToOWL() throws Exception {
396418
"AnnotationAssertion(rdfs:label :723596005 \"All SNOMED CT content (foundation metadata concept)\"^^xsd:string)\n" +
397419
"SubClassOf(:723596005 :723594008)\n" +
398420
"\n" +
421+
"# Class: <http://snomed.info/id/762705008> (<http://snomed.info/id/762705008>)\n" +
422+
"\n" +
423+
"SubClassOf(:762705008 :410662002)\n" +
424+
"\n" +
425+
"# Class: <http://snomed.info/id/762706009> (<http://snomed.info/id/762706009>)\n" +
426+
"\n" +
427+
"SubClassOf(:762706009 :410662002)\n" +
428+
"\n" +
399429
"# Class: <http://snomed.info/id/900000000000441003> (SNOMED CT Model Component (metadata))\n" +
400430
"\n" +
401431
"AnnotationAssertion(rdfs:label :900000000000441003 \"SNOMED CT Model Component (metadata)\"^^xsd:string)\n" +

src/test/java/org/snomed/otf/owltoolkit/conversion/StatedRelationshipToOwlRefsetServiceTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,18 @@ public void convertStatedRelationshipsToOwlRefset() throws IOException, OWLOntol
5252
// Sequential identifiers used in this test rather than random UUIDs
5353
assertEquals(
5454
"id\teffectiveTime\tactive\tmoduleId\trefsetId\treferencedComponentId\towlExpression\n" +
55-
"1\t\t1\t900000000000012004\t733073007\t116680003\tSubClassOf(:116680003 :900000000000441003)\n" +
56-
"2\t\t1\t900000000000012004\t733073007\t723594008\tSubClassOf(:723594008 :900000000000441003)\n" +
57-
"3\t\t1\t900000000000012004\t733073007\t410662002\tSubClassOf(:410662002 :900000000000441003)\n" +
58-
"4\t\t1\t900000000000207008\t733073007\t73211009\tSubClassOf(:73211009 :362969004)\n" +
59-
"5\t\t1\t900000000000207008\t733073007\t362969004\tEquivalentClasses(:362969004 ObjectIntersectionOf(:404684003 ObjectSomeValuesFrom(:609096000 ObjectSomeValuesFrom(:363698007 :113331007))))\n" +
60-
"6\t\t1\t900000000000012004\t733073007\t723596005\tSubClassOf(:723596005 :723594008)\n" +
61-
"7\t\t1\t900000000000012004\t733073007\t900000000000441003\tSubClassOf(:900000000000441003 :138875005)\n" +
62-
"8\t\t1\t900000000000207008\t733073007\t404684003\tSubClassOf(:404684003 :138875005)\n" +
63-
"9\t\t1\t900000000000012004\t733073007\t363698007\tSubObjectPropertyOf(:363698007 :762705008)\n" +
64-
"10\t\t1\t900000000000207008\t733073007\t113331007\tSubClassOf(:113331007 :138875005)\n",
55+
"1\t\t1\t900000000000012004\t733073007\t410662002\tSubClassOf(:410662002 :900000000000441003)\n" +
56+
"2\t\t1\t900000000000012004\t733073007\t116680003\tSubClassOf(:116680003 :900000000000441003)\n" +
57+
"3\t\t1\t900000000000012004\t733073007\t723594008\tSubClassOf(:723594008 :900000000000441003)\n" +
58+
"4\t\t1\t900000000000012004\t733073007\t762705008\tSubClassOf(:762705008 :410662002)\n" +
59+
"5\t\t1\t900000000000207008\t733073007\t73211009\tSubClassOf(:73211009 :362969004)\n" +
60+
"6\t\t1\t900000000000012004\t733073007\t900000000000441003\tSubClassOf(:900000000000441003 :138875005)\n" +
61+
"7\t\t1\t900000000000207008\t733073007\t362969004\tEquivalentClasses(:362969004 ObjectIntersectionOf(:404684003 ObjectSomeValuesFrom(:609096000 ObjectSomeValuesFrom(:363698007 :113331007))))\n" +
62+
"8\t\t1\t900000000000012004\t733073007\t723596005\tSubClassOf(:723596005 :723594008)\n" +
63+
"9\t\t1\t900000000000012004\t733073007\t762706009\tSubClassOf(:762706009 :410662002)\n" +
64+
"10\t\t1\t900000000000207008\t733073007\t404684003\tSubClassOf(:404684003 :138875005)\n" +
65+
"11\t\t1\t900000000000012004\t733073007\t363698007\tSubObjectPropertyOf(:363698007 :762705008)\n" +
66+
"12\t\t1\t900000000000207008\t733073007\t113331007\tSubClassOf(:113331007 :138875005)\n",
6567
owlRefset);
6668

6769
assertEquals(
@@ -80,4 +82,5 @@ public void convertStatedRelationshipsToOwlRefset() throws IOException, OWLOntol
8082
"100010001\t\t0\t900000000000207008\t362969004\t113331007\t0\t363698007\t900000000000010007\t900000000000451002\n",
8183
statedRelationships);
8284
}
85+
8386
}

0 commit comments

Comments
 (0)