Skip to content

Commit

Permalink
Expand semantic annotation SPARQL query
Browse files Browse the repository at this point in the history
Ref #31

Also adds tests for previously added MOSAiC and ARCRC ontologies
  • Loading branch information
amoeba committed Oct 8, 2021
1 parent 23f92d0 commit 976a812
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT ?annotation_value_uri
WHERE {
<$CONCEPT_URI> rdfs:subClassOf* ?annotation_value_uri .
}
]]>
WHERE
{
<$CONCEPT_URI> (rdf:type|owl:equivalentClass*|(owl:sameAs|^owl:sameAs)*)/rdfs:subClassOf* ?annotation_value_uri .
}
]]>
</value>
</constructor-arg>
</bean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public void testECSOMeasurementTypeExpansion() {
values.add("http://purl.dataone.org/odo/ECSO_00000514");
values.add("http://ecoinformatics.org/oboe/oboe.1.2/oboe-core.owl#MeasurementType");
values.add("http://www.w3.org/2000/01/rdf-schema#Resource");
values.add("http://www.w3.org/2000/01/rdf-schema#Class");
values.add("http://www.w3.org/2002/07/owl#Class");

assertEquals(values, concepts.get("annotation_value_uri"));
} catch (Exception e) {
Expand All @@ -93,4 +95,109 @@ public void testPropertyExpansion() {
fail(e.getMessage());
}
}

@Test
public void testMOSAiCExpansion() {
try {
Map<String, Set<String>> concepts = OntologyModelService.getInstance().expandConcepts("https://purl.dataone.org/odo/MOSAIC_00000865");

Set<String> values = new HashSet<String>();
values.add("https://purl.dataone.org/odo/MOSAIC_00000865");
values.add("https://purl.dataone.org/odo/MOSAIC_00000036");
values.add("https://purl.dataone.org/odo/MOSAIC_00012000");
values.add("http://www.w3.org/2000/01/rdf-schema#Resource");
values.add("http://www.w3.org/2000/01/rdf-schema#Class");
values.add("http://www.w3.org/2002/07/owl#Class");

assertEquals(values, concepts.get("annotation_value_uri"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.getMessage());
}
}

@Test
public void testMOSAiCSameAsExpansion() {
try {
Map<String, Set<String>> concepts = OntologyModelService.getInstance().expandConcepts("https://purl.dataone.org/odo/MOSAIC_00000225");

Set<String> values = new HashSet<String>();
values.add("https://purl.dataone.org/odo/MOSAIC_00000022"); // Project
values.add("https://purl.dataone.org/odo/MOSAIC_00000225"); // MOSAiC
values.add("https://purl.dataone.org/odo/MOSAIC_00000226"); // Multidisciplinary drifting Observatory for the Study of Arctic Climate (sameAs)
values.add("https://purl.dataone.org/odo/MOSAIC_00000023"); // MOSAiC20192020 (sameAs)
values.add("http://www.w3.org/2002/07/owl#NamedIndividual");
values.add("http://www.w3.org/2000/01/rdf-schema#Resource");

assertEquals(values, concepts.get("annotation_value_uri"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.getMessage());
}
}

@Test
public void testARCRCExpansion() {
try {
Map<String, Set<String>> concepts = OntologyModelService.getInstance().expandConcepts("http://purl.dataone.org/odo/ARCRC_00000051");

Set<String> values = new HashSet<String>();
/**
* Add values for ARCRC:SnowDepth and its supertypes:
*
* SnowDepth -> Snow Key Variable Arctic Key Variable -> Arctic Report Card Component
*/
values.add("http://purl.dataone.org/odo/ARCRC_00000051"); // ARCRC:SnowDepth
values.add("http://purl.dataone.org/odo/ARCRC_00000502"); // ARCRC:SnowKeyVariable
values.add("http://purl.dataone.org/odo/ARCRC_00000040"); // ARCRC:KeyVariable
values.add("http://purl.dataone.org/odo/ARCRC_00000500"); // ARCRC:ArcticReportCardComponent


/**
* Add values for ARCRC:SnowDepth's equivalentClass of ECSO:SnowDepth and its supertypes:
*
* SnowDepth -> Water Depth -> Depth -> linearMeasurementType -> Measurement Type
*/
values.add("http://purl.dataone.org/odo/ECSO_00001205"); // ECSO:SnowDepth
values.add("http://purl.dataone.org/odo/ECSO_00000553"); // ECSO:linearMeasurementType
values.add("http://purl.dataone.org/odo/ECSO_00001203"); // ECSO:WaterDepth
values.add("http://purl.dataone.org/odo/ECSO_00001250"); // ECSO:Depth
values.add("http://ecoinformatics.org/oboe/oboe.1.2/oboe-core.owl#MeasurementType");

// Values for high level stuff
values.add("http://www.w3.org/2000/01/rdf-schema#Resource");
values.add("http://www.w3.org/2000/01/rdf-schema#Class");
values.add("http://www.w3.org/2002/07/owl#Class");
values.add("http://www.w3.org/2002/07/owl#NamedIndividual");

assertEquals(values, concepts.get("annotation_value_uri"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.getMessage());
}
}

@Test
public void testNamedIndividualExpansion() {
try {
Map<String, Set<String>> concepts = OntologyModelService.getInstance().expandConcepts("http://purl.dataone.org/odo/ARCRC_00000507");

Set<String> values = new HashSet<String>();
values.add("http://purl.dataone.org/odo/ARCRC_00000507"); // ARCRC:Greenland itself
values.add("http://www.w3.org/2002/07/owl#NamedIndividual"); // the type of ARCRC:Greenland
values.add("http://purl.dataone.org/odo/ARCRC_00000505"); // ARCRC:GeographicNamedPlace (type of ARCRC:Greenland)
values.add("http://purl.dataone.org/odo/ARCRC_00000506"); // ARCRC:Place (supertype of GeographicNamedPlace)
values.add("http://purl.dataone.org/odo/ARCRC_00000500"); // ARCRC:ArcticReportCardComponent
values.add("http://purl.obolibrary.org/obo/GAZ_00001507"); // sameAs

assertEquals(values, concepts.get("annotation_value_uri"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.getMessage());
}
}
}

0 comments on commit 976a812

Please sign in to comment.