Semantic Astronomy SeRQL? Notes
SeRQL Examples for Practical Semantic Astronomy Workshop Hack-a-thon
Elizabeth Auden, AstroGrid / VOTech
11 February 2008
Semantic Astronomy Sesame Knowledge Base
All queries can be performed as user "anonymous" without being logged in.
In the top menu bar next to "Read actions", click "SeRQL-S" and try out the following queries.
Example SeRQL? queries
Queries about ontology classes
- See all class names included with uploaded ontologies
select C from {C} rdf:type {rdfs:Class}
- Select all subclasses of "galaxy":
SELECT * FROM {sub} rdfs:subClassOf {<http://www.ivoa.net/ontology/astronomy.owl#galaxy>}
- Select all direct subclasses of "galaxy":
SELECT * FROM {directSub} serql:directSubClassOf {<http://www.ivoa.net/ontology/astronomy.owl#galaxy>}
Basic data queries
- Select all entries for a certain event type (e.g., supernova remnants)
SELECT DISTINCT * FROM {C} ast:supernovaRemnant {} USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
- Click the entry (e.g. http://msslxx.mssl.ucl.ac.uk:8080/sesame/m100.rdf) to see its statements in the format subject | predicate | object.
- Other event types to query in place of ast:supernovaRemnant:
- ast:activeGalacticNucleus
- ast:galacticCluster
- ast:galaxy
- ast:globularCluster
- ast:HeIiIonizationZone
- ast:interactingGalaxy
- ast:linerGalaxy
- ast:openStarCluster
- ast:planetaryNebula
- ast:reflectionNebula
- ast:SeyfertGalaxy
- ast:starburstGalaxy
- ast:starCluster
- Select all properties and values from the RDF entry for M23:
select * from {<http://msslxx.mssl.ucl.ac.uk:8080/sesame/m23.rdf>} p {value}
- Select entries for all globularClusters:
select globularCluster from {globularCluster} ast:globularCluster {} USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>, ivoao = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/IVOAO.owl>
- Select Messier object ID, right ascension, and declination from all entries:
select ID, RA, Dec from {C} ivoao:identification {ID}; ast:RightAscension {RA}; ast:Declination {Dec} using namespace ivoao = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/IVOAO.owl>, ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
- Select the Messier object ID and spectral classification of all globular clusters:
select ID, spectralClass, GlC? from {C} ivoao:identification {ID};ast:SpectralClassification {spectralClass}; ast:globularCluster {GlC} using namespace ivoao = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/IVOAO.owl>, ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
- Select entry URIs plus ID and spectral classification for all globular clusters:
select globularCluster, ID, spectralClass from {globularCluster} ast:globularCluster {}; [ivoao:identification {ID}]; [ast:SpectralClassification {spectralClass}] USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>, ivoao = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/IVOAO.owl>
- Select object entry, ID, RA, Dec for all entries:
select object, ID, RA, Dec from {object} ivoao:identification {ID}; ast:RightAscension {RA}; ast:Declination {Dec} using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>, ivoao = <http://www.ivoa.net/ontology/IVOAO.owl#>, phys = <http://www.ivoa.net/ontology/physics.owl#>
- Select object entry, ID, spectral classification, and object type where ID equals "M 61":
select object, ID, SpecClass, objectType from {object} ivoao:identification {ID}; ast:SpectralClassification {SpecClass}; serql:directType {objectType} where ID = "M 61" using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>, ivoao = <http://www.ivoa.net/ontology/IVOAO.owl#>, phys = <http://www.ivoa.net/ontology/physics.owl#>
- Select object entry, ID, spectral classification, and object type for any object with an "F" type spectral classification:
select object, ID, SpecClass, objectType from {object} ivoao:identification {ID}; ast:SpectralClassification {SpecClass}; serql:directType {objectType} where SpecClass like "F*" using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>, ivoao = <http://www.ivoa.net/ontology/IVOAO.owl#>, phys = <http://www.ivoa.net/ontology/physics.owl#>
More interesting data queries
- Select all entries that are subclasses of ast:starCluster:
select distinct * from {C} rdf:type {} rdfs:subClassOf {ast:starCluster} using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>
- Select ID, RA, Dec, flux, and spectral class of all entries that are subclasses of ast:starCluster:
select ID, RA, Dec, Flux, SpecClass from {C} rdf:type {} rdfs:subClassOf {ast:starCluster}; ivoao:identification {ID}; ast:RightAscension {RA}; ast:Declination {Dec}; phys:flux {Flux}; ast:SpectralClassification {SpecClass} using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>, ivoao = <http://www.ivoa.net/ontology/IVOAO.owl#>, phys = <http://www.ivoa.net/ontology/physics.owl#>
- Box query: select all objects plus their ID, RA, Dec, and object type that fall into a box defined by 180.0 < RA < 190.0 and +11.0< Dec < +14.0 :
select object, ID, RA, Dec, objectType from {object} ivoao:identification {ID}; ast:RightAscension {RA}; ast:Declination {Dec}; serql:directType {objectType} where RA > "180.0"^^xsd:float and Dec < "14.0"^^xsd:float and RA < "190.0"^^xsd:float and Dec > "11.0"^^xsd:float using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>, ivoao = <http://www.ivoa.net/ontology/IVOAO.owl#>, phys = <http://www.ivoa.net/ontology/physics.owl#>
- More specific box query: select all galaxies (and subclasses of galaxies) plus their ID, RA, Dec, and object type that fall into a box defined by 180.0 < RA < 190.0 and +11.0< Dec < +14.0
select object, ID, RA, Dec, objectType from {object} ivoao:identification {ID}; ast:RightAscension {RA}; ast:Declination {Dec}; serql:directType {objectType} rdfs:subClassOf {ast:galaxy} where RA > "180.0"^^xsd:float and Dec < "14.0"^^xsd:float and RA < "190.0"^^xsd:float and Dec > "11.0"^^xsd:float using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>, ivoao = <http://www.ivoa.net/ontology/IVOAO.owl#>, phys = <http://www.ivoa.net/ontology/physics.owl#>
- Put it all together: select all types of star cluster (including globular clusters and open star clusters) with "F" or "A" type spectral classifications that fall into a box defined by 244.0 < RA < 276.0 and -30.0 < Dec < -10.0 (warning: the "OR" query takes a while to process):
select object, ID, RA, Dec, SpecClass, objectType from {object} ivoao:identification {ID}; ast:RightAscension {RA}; ast:Declination {Dec}; ast:SpectralClassification {SpecClass}; serql:directType {objectType} rdfs:subClassOf {ast:starCluster} where SpecClass like "A" or SpecClass like "F*" and Dec < "-10.0"^^xsd:float and RA < "276.0"^^xsd:float and Dec > "-30.0"^^xsd:float and RA > "244.0"^^xsd:float using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>, ivoao = <http://www.ivoa.net/ontology/IVOAO.owl#>, phys = <http://www.ivoa.net/ontology/physics.owl#>
serql:directSubClassOf {ast:galaxy} using namespace ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
select SUB from {SUB} rdfs:subClassOf {ast:galaxy} using namespace
ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
select C from {C} rdfs:subClassOf {ast:starCluster} using namespace ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
- Select all direct subclasses of "galaxy":SELECT * FROM {directSub} serql:directSubClassOf {directSuper} rdfs:subClassOf {<http://www.ivoa.net/ontology/astronomy.owl#galaxy>}
- Select all subclasses of "galaxy". Compare this with results from the above query; a class is considered a subclass of itself, but not a direct subclass of itself:SELECT * FROM {directSub} rdfs:subClassOf {directSuper} rdfs:subClassOf {<http://www.ivoa.net/ontology/astronomy.owl#galaxy>}
Well-formatted but empty subclass query:
select SUB, ID, spectralClass from {SUB} rdfs:subClassOf {ast:starCluster}; [ivoao:identification {ID}]; [ast:SpectralClassification {spectralClass}] USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>, ivoao = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/IVOAO.owl>
Ditto:
select clusters from {clusters} rdfs:subClassOf {ast:starCluster}
USING NAMESPACE
ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
Well-formatted, but returns class names instead of entries:
select clusters from {clusters} rdfs:subClassOf {<http://www.ivoa.net/ontology/astronomy.owl#starCluster>}
USING NAMESPACE
ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
Well-formatted, but empty:
select ID from {} rdfs:subClassOf {<http://www.ivoa.net/ontology/astronomy.owl#starCluster>} ivoao:identification {ID}
USING NAMESPACE
ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>, ivoao = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/IVOAO.owl>
Returns subclasses of starCluster:
select C
from {C} rdf:type {rdfs:Class};
rdfs:subClassOf {<http://www.ivoa.net/ontology/astronomy.owl#starCluster>}
USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
Select all classes to which M62.rdf belongs (returns only "Resource", so try using that):#SELECT X FROM {<http://msslxx.mssl.ucl.ac.uk:8080/sesame/m62.rdf>} rdf:type {X}
USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
Select all rdf:Resources (returns all classes and all entries for Messier objects):
SELECT Resource
FROM {Resource} rdf:type {<http://www.w3.org/2000/01/rdf-schema#Resource>}
USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
As above, but returns only classes that are subclasses of starCluster. Want
instances of starCluster subclasses (select all resources that are also subclasses of starCluster).
FROM {Resource}
rdf:type {<http://www.w3.org/2000/01/rdf-schema#Resource>};
rdfs:subClassOf {<http://www.ivoa.net/ontology/astronomy.owl#starCluster>}
USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
Select all entries containing Right Ascension:
SELECT DISTINCT *
FROM {C}
ast:RightAscension {}
USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl
Empty (also with rdf:predicate, rdf:subject):
SELECT DISTINCT *
FROM {C}
rdf:object {}
USING NAMESPACE ast = <http://archive.astro.umd.edu/ivoa-onto/src/main/resources/astronomy.owl>
NOTE: need to regenerate RDF data. Set
rdf:type to a celestial object type, ensure that
ast namespace points to
http://www.ivoa.net/ontology/astronomy.owl#, don't forget "#" after namespaces. New subclass queries:
- Select entries which are subclasses of galaxy:
select distinct * from {C}
rdf:type {} rdfs:subClassOf {ast:galaxy} using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>
- Select entries which are direct subclasses of galaxy (i.e., does not include galaxy itself):
select distinct * from {C} rdf:type {} serql:directSubClassOf {ast:galaxy} using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>
- Select names of subclasses of galaxy:
SELECT * FROM {sub} rdfs:subClassOf {<http://www.ivoa.net/ontology/astronomy.owl#galaxy>}
- Select names of direct subclasses of galaxy:
SELECT * FROM {sub} serql:directSubClassOf {<http://www.ivoa.net/ontology/astronomy.owl#galaxy>}
- Select all properties and their values for M10:
select * from {<http://msslxx.mssl.ucl.ac.uk:8080/sesame/#m10>} p {Y} using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>
- Select ID, RA, Dec, flux, spectral classification from all subclasses of starCluster:
select ID, RA, Dec, Flux, SpecClass? from {C} rdf:type {} rdfs:subClassOf {ast:starCluster}; ivoao:identification {ID}; ast:RightAscension {RA}; ast:Declination {Dec}; phys:flux {Flux}; ast:SpectralClassification {SpecClass} using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>, ivoao = <http://www.ivoa.net/ontology/IVOAO.owl#>, phys = <http://www.ivoa.net/ontology/physics.owl#>
select distinct * from {C} rdf:type {} rdfs:subClassOf {ast:galaxy}; ast:RightAscension {RA}; ast:Declination {Dec} where RA > "10.0"^^xsd:float and Dec < "41.0"^^xsd:float and RA < "11.0"^^xsd:float and Dec > "42.0"^^xsd:float using namespace ast = <http://www.ivoa.net/ontology/astronomy.owl#>
--
ElizabethAuden - 11 Feb 2008