Skip to content

SADI Semantic Web Services framework

timrdf edited this page Aug 16, 2011 · 57 revisions

Semantic Automated Discovery and Integration (SADI) is the coolest web service framework because it requires so little, and it naturally reuses the semantic web to describe what each service does. Their source code is on google code and they offer some training sessions.

SADI's hello world from curl

Find out that http://sadiframework.org/examples/hello is a SADI service.

Get a Turtle description of the service from the service itself (using rapper):

rapper -i rdfxml -o turtle  http://sadiframework.org/examples/hello > service-interface-definition.ttl

See what owl:Class it accepts (NamedIndividual):

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix mygrid: <http://www.mygrid.org.uk/mygrid-moby-service#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://sadiframework.org/examples/hello>
    mygrid:hasOperation [
        mygrid:inputParameter [
            mygrid:objectType <http://sadiframework.org/examples/hello.owl#NamedIndividual> ;
            a mygrid:parameter
        ] ;

Grab the description of NamedIndividual:

rapper -i rdfxml -o turtle http://sadiframework.org/examples/hello.owl#NamedIndividual > hello.owl

and find out that NamedIndividual needs at least one foaf:name:

<http://sadiframework.org/examples/hello.owl#NamedIndividual>
    a owl:Class ;
    owl:equivalentClass [
        a owl:Restriction ;
        owl:minCardinality "1"^^<http://www.w3.org/2001/XMLSchema#int> ;
        owl:onProperty <http://xmlns.com/foaf/0.1/name>
    ] .

Gin up some input to feed the service:

bash-3.2$ cat input.ttl
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<http://tw.rpi.edu/instances/TimLebo> 
   a <http://sadiframework.org/examples/hello.owl#NamedIndividual>; 
   foaf:name "Tim";
.

And send it off with an HTTP POST to get your greeting (to me):

bash-3.2$ curl -H "Content-type: text/rdf+n3" -d @input.ttl http://sadiframework.org/examples/hello
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:hello="http://sadiframework.org/examples/hello.owl#">
  <hello:GreetedIndividual rdf:about="http://tw.rpi.edu/instances/TimLebo">
    <hello:greeting>Hello, Tim!</hello:greeting>
  </hello:GreetedIndividual>
</rdf:RDF>

Notes on SADI for LOBD with Jim McC

Jim McCusker created a python API that can be used to create a SADI service. This adds a third language to the two that already exist (Java and Perl).

Installing Jim's python API:

Some python += rdf references:

protege's SADI plugin or curl to POST an RDF file to it.

To find out what the service does, request the service directly:

curl http://localhost:9090/HomologeneClusterConsistency > HomologeneClusterConsistency.rdf 

It will return an RDF description that cites the owl:Class of instances it inputs, and another for the instances it outputs:

@base <http://localhost:9090/HomologeneClusterConsistency> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ns1: <http://www.mygrid.org.uk/mygrid-moby-service#> .
@prefix ns2: <http://protege.stanford.edu/plugins/owl/dc/protege-dc.owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<>
    ns1:hasOperation <#operation> ;
    ns1:hasServiceDescriptionText "Compute the correlation of gene membership for a particular Homologene" ;
    ns1:hasServiceNameText "Homologene Cluster Consistency Service" ;
    ns1:providedBy <http://tw.rpi.edu> ;
    a ns1:serviceDescription ;
    rdfs:comment "Homologenes" ;
    rdfs:label "Homologene Cluster Consistency" .

<#input>
    ns1:objectType <http://logd.tw.rpi.edu/source/ncbi-nlm-nih-gov/dataset/homologene/vocab/HomologyCluster> ;
    a ns1:parameter .

<#operation>
    ns1:inputParameter <#input> ;
    ns1:outputParameter <#output> ;
    a ns1:operation .

<#output>
    ns1:objectType 
    <http://logd.tw.rpi.edu/source/twc-rpi-edu/dataset/homologene-consistency/vocab/CorrelatedHomologyCluster> ;
    a ns1:parameter .

<http://tw.rpi.edu>
    ns2:creator "l..@rpi.edu" ;
    ns1:authoritative true ;
    a ns1:organisation .

Jim started a collection of services for LOBD in its google code svn.

So stitch together a post-me.ttl.rdf:

@prefix homologene:       <http://logd.tw.rpi.edu/source/ncbi-nlm-nih-gov/dataset/homologene/version/build65/> .
@prefix homologene_vocab: <http://logd.tw.rpi.edu/source/ncbi-nlm-nih-gov/dataset/homologene/vocab/> .

homologene:homologyCluster_3 a homologene_vocab:HomologyCluster .

and HTTP POST it to the service:

curl -F "file=@post-me.ttl.rdf" http://localhost:9090/HomologeneClusterConsistency

Listing of SADI services with a SPARQL endpoint: http://sadiframework.org/registry/ (NOT easy to find from their home page).

Attempt 1: Homologene cluster SADI service

http://localhost:9090/HomologeneClusterConsistency

TODOs

  • wrap prefix.cc?
  • expose PMM

Clone this wiki locally