The primary slide deck for the SADI tutorial. We explain the motivation, simple SADI services, more complex SADI services, and then do a detailed walk-through of building a service, including the Perl service code and examples of service invocation at the command line, and using the SHARE client. You will want to look at the sample data/queries in this slide deck: http://www.slideshare.net/markmoby/sample-data-and-other-ur-ls-55737183 and the example service code in this slide deck: http://www.slideshare.net/markmoby/example-code-for-the-sadi-bmi-calculator-web-service?related=1
6. Semantic Web Technologies
?TO ME: If you are using RDF or even OWL, without reasoning, then you
are ‘doing’ Linked Data. When you start using a reasoner (or reasoning of
some type) you are ‘doing’ Semantic Web
7. Semantic Web Technologies
?I will be showing how SADI can be used both as a straightforward
Linked Data resource, and/or as a Semantic Web resource.
11. In My Opinion, this is the critical bit!
causally related to
The link is explicitly labeled!
???
12. http://semanticscience.org/resource/SIO_000243
SIO_000243:
<owl:ObjectProperty rdf:about="&resource;SIO_000243">
<rdfs:label xml: lang="en"> is causally related with</rdfs:label>
<rdf:type rdf:resource="&owl;SymmetricProperty"/>
<rdf:type rdf:resource="&owl;TransitiveProperty"/>
<dc:description xml:lang="en"> A transitive, symmetric, temporal relation
in which one entity is causally related with another non-identical entity.
</dc:description>
<rdfs:subPropertyOf rdf:resource="&resource;SIO_000322"/>
</owl:ObjectProperty>
causally related with
13. A lot of important information cannot be represented
on the Semantic Web
For example, all of the data that results from
analytical algorithms and statistical analyses
14.
15.
16. Varying estimates
put the size of the
Deep Web
between
500 and 800 times
larger than the
surface Web
18. There are many suggestions for how to bring the Deep Web
into the Semantic Web using Semantic Web Services (SWS)
19. There are many suggestions for how to bring the Deep Web
into the Semantic Web using Semantic Web Services (SWS)
Describe input data
Describe output data
Describe how the system manipulates the data
Describe how the world changes as a result
20. There are many suggestions for how to bring the Deep Web
into the Semantic Web using Semantic Web Services (SWS)
Describe input data
Describe output data
Describe how the system manipulates the data
Describe how the world changes as a result
None, so far, has proven to be wildly successful
(in my opinion)
21. There are many suggestions for how to bring the Deep Web
into the Semantic Web using Semantic Web Services (SWS)
Describe input data
Describe output data
Describe how the system manipulates the data
Describe how the world changes as a result
None, so far, has proven to be wildly successful
(in my opinion)
…because describing what a Service does is HARD!
25. Scientific Web Services are DIFFERENT!
They’re simpler!
So perhaps we can solve the Semantic Web Service problem
as it pertains to this (important!) domain
26. With respect to the Semantic Web
What is missing from this list?
Describe input data
Describe output data
Describe how the system manipulates the data
Describe how the world changes as a result
29. Relationships are not on this list…
and that seemed to me to be a huge oversight!
Describe input data
Describe output data
Describe how the system manipulates the data
Describe how the world changes as a result
38. If SADI produces Linked Data, can we interact with it
like any other Linked Data resource?
39. “Semantic Health And Research Environment”
SPARQL + SADI + Workflows + OWL Reasoning
40. The SHARE registry
indexes all of the input/output/relationship
triples that can be generated by all known SADI services
SHARE is then able to discover Services
that will generate the data that it needs
to answer the SPARQL query
41.
42. What is the phenotype of every allele of the
Antirrhinum majus DEFICIENS gene
SELECT ?allele ?image ?desc
WHERE {
locus:DEF genetics:hasVariant ?allele .
?allele info:visualizedByImage ?image .
?image info:hasDescription ?desc
}
43. What is the phenotype of every allele of the
Antirrhinum majus DEFICIENS gene
SELECT ?allele ?image ?desc
WHERE {
locus:DEF genetics:hasVariant ?allele .
?allele info:visualizedByImage ?image .
?image info:hasDescription ?desc
}
Note that there is no “FROM” clause!
We don’t tell it where it should get the information,
The machine has to figure that out by itself...
44. What is the phenotype of every allele of the
Antirrhinum majus DEFICIENS gene
SELECT ?allele ?image ?desc
WHERE {
locus:DEF genetics:hasVariant ?allele .
?allele info:visualizedByImage ?image .
?image info:hasDescription ?desc
}
Starting data: the locus “DEF” (Deficiens)
(the “bound” variable in the query)
45. What is the phenotype of every allele of the
Antirrhinum majus DEFICIENS gene
SELECT ?allele ?image ?desc
WHERE {
locus:DEF genetics:hasVariant ?allele .
?allele info:visualizedByImage ?image .
?image info:hasDescription ?desc
}
Query: A series of relationships v.v. DEF
48. ...and in a few seconds you get your answer.
Based on the relationships in your query, SHARE queried its registry
to automatically discover SADI Services capable of generating those triples
50. What pathways does UniProt protein P47989 belong to?
PREFIX pred: <http://sadiframework.org/ontologies/predicates.owl#>
PREFIX ont: <http://ontology.dumontierlab.com/>
PREFIX uniprot: <http://lsrn.org/UniProt:>
SELECT ?gene ?pathway
WHERE {
uniprot:P47989 pred:isEncodedBy ?gene .
?gene ont:isParticipantIn ?pathway .
}
51. What pathways does UniProt protein P47989 belong to?
PREFIX pred: <http://sadiframework.org/ontologies/predicates.owl#>
PREFIX ont: <http://ontology.dumontierlab.com/>
PREFIX uniprot: <http://lsrn.org/UniProt:>
SELECT ?gene ?pathway
WHERE {
uniprot:P47989 pred:isEncodedBy ?gene .
?gene ont:isParticipantIn ?pathway .
}
52. What pathways does UniProt protein P47989 belong to?
PREFIX pred: <http://sadiframework.org/ontologies/predicates.owl#>
PREFIX ont: <http://ontology.dumontierlab.com/>
PREFIX uniprot: <http://lsrn.org/UniProt:>
SELECT ?gene ?pathway
WHERE {
uniprot:P47989 pred:isEncodedBy ?gene .
?gene ont:isParticipantIn ?pathway .
}
Note again that there is no “From” clause…
I have not told SHARE where to look for the answer, I
am simply asking my question
56. Two different
providers of gene
information
(KEGG & NCBI);
were found &
accessed
Two different
providers of
pathway
information
(KEGG and
GO);
were found &
accessed
58. These were examples where SADI/SHARE was used
for “simple” Linked Data exploration
What does it look like when we start pushing Semantics?
Please be assured - you DO NOT have to understand
this next piece in order to use SADI. This is just
“the icing on the cake”
“c'est la cerise sur le gâteau”
“la guinda del pastel”
“die Krönung des Ganzen”
59. Show me the latest Blood Urea Nitrogen and Creatinine levels
of patients who appear to be rejecting their transplants
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX patient: <http://sadiframework.org/ontologies/patients.owl#>
PREFIX l: <http://sadiframework.org/ontologies/predicates.owl#>
SELECT ?patient ?bun ?creat
FROM <http://sadiframework.org/ontologies/patients.rdf>
WHERE {
?patient rdf:type patient:LikelyRejecter .
?patient l:latestBUN ?bun .
?patient l:latestCreatinine ?creat .
}
60. Show me the latest Blood Urea Nitrogen (BUN) and
Creatinine levels of patients who appear to be
rejecting their transplants
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX patient: <http://sadiframework.org/ontologies/patients.owl#>
PREFIX l: <http://sadiframework.org/ontologies/predicates.owl#>
SELECT ?patient ?bun ?creat
FROM <http://sadiframework.org/ontologies/patients.rdf>
WHERE {
?patient rdf:type patient:LikelyRejecter .
?patient l:latestBUN ?bun .
?patient l:latestCreatinine ?creat .
}
61. Likely Rejecter:
A patient who has creatinine levels
that are increasing over time
- - Mark D Wilkinson’s definition
62. Likely Rejecter:
…but there is no “likely rejecter”
column or table in our database…
only blood chemistry measurements
at various time-points
64. My definition of a Likely Rejecter is encoded in
a machine-readable document written in the OWL Ontology language
Basically:
“the regression line over creatinine measurements should have an increasing slope”
65. Our ontology refers to other ontologies (possibly published by other people)
to learn about what the properties of “regression models” are
e.g. that regression models have slopes and intercepts
and that slopes and intercepts have decimal values
71. The conversation between SHARE and the registry
reveals the use of “Deep Semantics”
Q: Is there a SADI service that will consume instances of Patient and give
me instances of LikelyRejector
A: No
Q: Okay... LikelyRejectors need a regression model of increasing slope
over their BloodCreatinine, so... Is there a SADI service that will consume
BloodCreatinine over time and give me its linear regression model?
A: No
Q: Okay... Blood Creatinine over time is a subclass of data of type
X/Y coordinate, so is there a service that consumes X/Y data and
returns its regression model?
A: Yes → here’s the Service URL.
72. The SHARE system utilizes DL Reasoning over SADI interface
definitions to discover analytical services
that do linear regression analysis
→ sends the data to be analyzed
73. This happens iteratively
(e.g. SHARE also has to examine the slope of the regression line
using another service, find the “latest” in a series of time measurements, etc.)
There is reasoning after every Service invocation
(i.e. after every clause in the query)
Once it is able to find instances (OWL Individuals)
of the LikelyRejector class, it continues with the
rest of the query
75. The way SHARE “interprets” data varies
depending on the context of the query
(i.e. which ontologies it reads – Mine? Yours?)
and on what part of the query
it is trying to answer at any given moment
(which ontological concept is relevant to that clause)
77. Example?
The data had the ‘qualities/properties’ that
allowed one machine to interpret
that they were Blood Creatinine measurements
(e.g. to determine which patients were rejecting)
78. Example?
But the data also had the ‘qualities/properties’ that
allowed another machine to interpret them as
Simple X/Y coordinate data
(e.g. the Linear Regression calculation tool)
81. We will examine SADI
mainly as a source of Linked Data
We will not spend much time
thinking about the Semantics
of our services or their interfaces
82. 2 Contents
1. Introduction to Semantic Web Services
2. Introduction to SADI services
3. SADI service ontologies
4. SADI service generator
5. SADI and SAWSDL
6. SADI clients
83. 2.1.3 Motivation for SADI
▪▪ simple
“perfection is finally attained not when there is no
longer anything to add, but when there is no longer
anything to take away”
▪▪ powerful
“everything should be as simple as it can be, but not
simpler”
▪▪ flexible
“SADI: there’s nothing to it”
84. 2.2 Introduction to SADI Services
2. Introduction to SADI Services
1. What is a SADI service?
2. Why use SADI services?
3. Requirements for SADI compliance
4. Calling a SADI service
5. Advanced SADI features
6. The SADI registry
85. 2.2.1 What is a SADI service?
● SADI services
○ use simple HTTP operations
■ (no project-specific protocol)
○ consume and produce RDF data
■ (no project-specific message scaffolding)
○ use OWL to describe service interface
(use existing ontologies
and especially existing properties)
86. 2.2.1 What is a SADI service?
● input is an RDF graph
○ rooted at a particular node
○ described by an OWL class
● output is an RDF graph
○ rooted at the same node
○ described by another OWL class
87. 2.2.1 What is a SADI service?
● explicit relationship between input and output
○ transparent service operation semantics
● machine-understandable description of the
service interface
○ easy service discovery and integration
88. 2.2.2 Why use SADI services?
Input
height weight
SADI
Service
Output
BMI
ID Name Height Weight Age
24601
7474505B
6
Jean Valjean
Jake Blues
—
...
1.8m
1.73m
1.88m
...
84kg
101kg
75kg
...
45
31
39
...
Client
BMI
89. 2.2.2 Why use SADI services?
Input
height weight
SADI
Service
Output
BMI
ID Name Height Weight Age
24601
7474505B
6
Jean Valjean
Jake Blues
—
...
1.8m
1.73m
1.88m
...
84kg
101kg
75kg
...
45
31
39
...
Client
BMI
#24601
1.8m 84kg
height weight
90. 2.2.2 Why use SADI services?
Input
height weight
SADI
Service
Output
BMI
ID Name Height Weight Age
24601
7474505B
6
Jean Valjean
Jake Blues
—
...
1.8m
1.73m
1.88m
...
84kg
101kg
75kg
...
45
31
39
...
Client
BMI
#24601
25.9
BMI
25.9
92. 2.2.2 Why use SADI services?
sadi: <http://sadiframework.org/ontologies/predicates.owl#> sadi: <http:
//sadiframework.org/ontologies/predicates.owl#> dumontier:
<http://ontology.dumontierlab.com/>
kegg: <http://lsrn.org/KEGG_PATHWAY:>
?gene ?protein ?seq
PREFIX
PREFIX
PREFIX
SELECT
WHERE {
kegg:hsa00232 dumontier:hasParticipant ?gene .
?gene sadi:encodes ?protein .
?protein sadi:hasSequence ?seq
}
Service
Service
Servic
e
Similar to “Federated Queries”… but are actually Web Service Workflows
93. 2.2.3 Requirements for SADI compliance
● Identified by an HTTP URL
○ used to identify the service
■ (service URI)
○ used to invoke the service
■ (service URL)
http://sadiframework.org/examples/hello
94. 2.2.3 Requirements for SADI compliance
•Responds to HTTP GET with service interface def.
•RDF document
•Service definition instance identified by service URI
•(see §2.3.1 for specifics)
•Indicates input OWL class and output OWL class
• (among other things)
http://sadiframework.org/examples/hello
95. http://sadiframework.org/examples/hello
input OWL class is
http://sadiframework.org/examples/hello.owl#NamedIndividual
output OWL class is
http://sadiframework.org/examples/hello.owl#GreetedIndividual
2.2.3 Requirements for SADI compliance
96. 2.2.3 Requirements for SADI compliance
● Responds to HTTP POST by invoking service
○ input is an RDF document
■ contains input OWL class instances
○ output is an RDF document
■ contains output OWL class instances
● one for each input instance
● Input/output instance share same URI
http://sadiframework.org/examples/hello
97. http://sadiframework.org/examples/hello
input:
@prefix hello: <http://sadiframework.org/examples/hello.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://sadiframework.org/examples/hello-input.rdf#1> a hello:NamedIndividual ;
foaf:name "Guy Incognito" .
output:
@prefix hello: <http://sadiframework.org/examples/hello.owl#> .
<http://sadiframework.org/examples/hello-input.rdf#1> a hello:GreetedIndividual ;
hello:greeting "Hello, Guy Incognito!" .
2.2.3 Requirements for SADI compliance
98. 2.2.3 Requirements for SADI compliance
● Indicates error with appropriate HTTP status
○ usually 500 Internal Service Error
○ may return RDF describing the error
99. 2.2.4 Calling a SADI service
1. Client sends POST request to service URL
● POST body is an RDF document
○ contains input OWL class instances
○ input serialization specified in
Content-type HTTP header
application/rdf+xml text/rdf+n3
○ output serialization requested in
Accept HTTP header
100. POST /examples/hello HTTP/1.1 Host: sadiframework.org Content-type:
text/rdf+n3 Accept: text/rdf+n3
@prefix hello: <http://sadiframework.org/examples/hello.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://sadiframework.org/examples/hello-input.rdf#1> a hello:NamedIndividual ;
foaf:name "Guy Incognito" .
2.2.4 Calling a SADI service
101. POST /examples/hello HTTP/1.1 Host: sadiframework.org Content-type:
text/rdf+n3 Accept: text/rdf+n3
@prefix hello: <http://sadiframework.org/examples/hello.owl#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://sadiframework.org/examples/hello-input.rdf#1> a hello:NamedIndividual ;
foaf:name "Guy Incognito" .
2.2.4 Calling a SADI service
Note that there is NO special message structure! This is not like SOAP!
102. 2.2.4 Calling a SADI service
2. Service responds with output
● response body is an RDF document
○ contains output OWL class instances
● serialization specified in
○ Content-type HTTP header
application/rdf+xml text/rdf+n3
103. HTTP/1.1 200 OK
Content-type: text/rdf+n3
@prefix hello: <http://sadiframework.org/examples/hello.owl#> .
<http://sadiframework.org/examples/hello-input.rdf#1> a hello:GreetedIndividual ;
hello:greeting "Hello, Guy Incognito!" .
2.2.4 Calling a SADI service
104. 2.2.5 Advanced SADI features
5. Advanced SADI features
a. Asynchronous SADI services
b. Parameterized SADI services
105. 2.2.5.a Asynchronous SADI services
● Problem
○ HTTP timeout if a service takes too long to
respond
● Solution
○ service returns stub immediately; client polls
for complete response
106. 2.2.5.a Asynchronous SADI services
1. Client sends POST request to service URL
● POST body is an RDF document
○ contains input OWL class instances
● input serialization specified in
Content-type HTTP header
application/rdf+xml text/rdf+n3
● output serialization requested in
Accept HTTP header
(Exactly the same as before….)
110. 2.2.5.a Asynchronous SADI services
3. Client fetches asynchronous data
● fetch the object URL of each
rdfs:isDefinedBy statement
GET /examples/hello?poll=1 HTTP/1.1 Host: sadiframework.org
111. 2.2.5.a Asynchronous SADI services
4. Until output is ready
● service sends an HTTP 302 redirect
Retry-after HTTP header suggests how long the client
should wait (in seconds)
HTTP/1.1 302 Moved Temporarily Retry-After: 30
Location: http://sadiframework.org/examples/hello?poll=1
112. 2.2.5.a Asynchronous SADI services
5. Client follows redirect
● after waiting as suggested by
Retry-after HTTP header
GET /examples/hello?poll=1 HTTP/1.1 Host: sadiframework.org
113. 2.2.5.a Asynchronous SADI services
6. When output is ready
● response body is an RDF document
should be combined with original response
HTTP/1.1 200 OK
Content-type: text/rdf+n3
@prefix hello: <http://sadiframework.org/examples/hello.owl#> .
<http://sadiframework.org/examples/hello-input.rdf#1> a hello:GreetedIndividual ;
hello:greeting "Hello, Guy Incognito!" .
114. 2.2.6 The SADI registry
● clients need to find SADI services
○ ideally just search the Web for instances of the
SADI service description class
■ current technology isn’t quite there
● use the SADI registry
○ SPARQL endpoint, Java and REST APIs
○ anyone can register a service
○ services are indexed by the properties they
attach
115. 2.2.6 The SADI registry
SADI registry
http://sadiframework.org/registry/
SPARQL endpoint
http://sadiframework.org/registry/sparql
REST API
http://sadiframework.org/registry/api/
116. 2.3.2 Input and output OWL classes
2. Input and output OWL classes
a. Input OWL classes
b. Output OWL classes
117. 2.3.2 Input and output OWL classes
2. Input and output OWL classes
a. Input OWL classes
b. Output OWL classes
Remember the OWL2 presentation yesterday
by Frédéric Bestian…
The dangers of OWL reasoning!
118. 2.3.2 Input and output OWL classes
2. Input and output OWL classes
a. Input OWL classes
b. Output OWL classes
Human equivalent to (leg minimum cardinality 2)
→ you not human if you lose a leg
119. 2.3.2 Input and output OWL classes
2. Input and output OWL classes
a. Input OWL classes
b. Output OWL classes
Do SADI Services suffer this problem?
120. 2.3.2 Input and output OWL classes
2. Input and output OWL classes
a. Input OWL classes
b. Output OWL classes
Do SADI Services suffer this problem?
NO!
We are not trying to “understand” the world!
121. 2.3.2 Input and output OWL classes
2. Input and output OWL classes
a. Input OWL classes
b. Output OWL classes
Do SADI Services suffer this problem?
NO!
We are only trying to discover acceptable input
122. 2.3.2 Input and output OWL classes
2. Input and output OWL classes
a. Input OWL classes
b. Output OWL classes
If my analysis requires that you have 2 legs
and you have only one leg...
YOU ARE NOT A CANDIDATE
FOR MY ANALYSIS. PERIOD.
123. 2.3.2 Input and output OWL classes
2. Input and output OWL classes
a. Input OWL classes
b. Output OWL classes
If my analysis requires that you have 2 legs
and you have only one leg...
...my service isn’t interested in whether or not
you are human… it only wants your legs!
124.
125. 2.4.1 Exercise
Create a SADI service that takes
height and weight as input
and attaches BMI.
126. SADI Services in Perl
The Perl module in CPAN is:
SADI::Simple
Example Service Code:
https://docs.google.com/document/d/1HrFNxG2-eZhiaCaBjNLcAtHPY_-MLCw9BwFmnw4BHKQ/edit?usp=sharing
Example Data and other information:
https://docs.google.com/document/d/1DdWux6w3RzMGexFHf9roRuJnCiDaxWJScECK4POg6RQ/edit?usp=sharing