Difference between revisions of "SPARQL BioPortal"

From NCBO Wiki
Jump to: navigation, search
(BioPortal SPARQL Usage Policy)
(Federated SPARQL queries)
 
(32 intermediate revisions by 2 users not shown)
Line 1: Line 1:
lorem ipsu ....
+
NCBO is releasing a free and open SPARQL endpoint to query ontologies hosted in the BioPortal ontology repository. This SPARQL service, that is in BETA status, is stable for testing by our community of users. If you encounter any errors or unexpected behavior please report it to us [mailto:support@bioontology.org support@bioontology.org].  
  
=== Alpha Release ===
+
<div style="margin-top: 10px; background: #F6F9ED; padding: 6px; border: 1px solid #aaaaaa; margin-bottom: 20px;">
 +
Before using the BioPortal SPARQL service please read our [[SPARQL Release Notes And Usage Policy]]
 +
</div>
  
This SPARQL endpoint is currently in alpha release. This alpha release is provided with the following limitations:
+
=== Web Interface and Query Examples ===
  
{| class="wikitable"
+
There is a Web interface to test SPARQL queries at http://sparql.bioontology.org/
|-
+
! style="background:#efefef;" | Item
+
! style="background:#efefef;" | Description
+
! style="background:#efefef;" | Status/Actions
+
|-
+
| Ontology Versions
+
| At the moment only the last version of each ontology is kept in our RDF database.
+
| In the future the data store will keep metadata with links to download old ontology versions. The data store will only contain data for the latest ontology version.
+
|-
+
| RRF/UMLS
+
| Not all the predicates from RRF/UMLS have been transformed into RDF triples. Labels, descriptions and hierarchies are the only predicates that we support for the moment.
+
| Actions to fully transform the UMLS database into RDF are scheduledf for 2012 Q1.
+
|-
+
|NCI Metathesaurus
+
|Currently the process that transforms RRF/UMLS into RDF triples is unable to process NCI Metathesaurus. We are working to fix this issue but meanwhile NCI Metathesaurus cannot be accessed via our SPARQL service.
+
| This issue will be addressed together with the RRF/UMLS conversion (2012 Q1).
+
|-
+
|Ontology Mappings
+
|The ontology mapping data from BioPortal has not been migrated into the SPARQL database yet.
+
|Planned to be implemented in 2012 Q1.
+
|-
+
|Synchronization with BioPortal
+
|The offline process that syncs BioPortal with our RDF database runs once a day (6pm PST). Therefore, new ontology uploads in BioPortal will be reflected in the SPARQL endpoint after that time.
+
|This policy will remain in-place unless other policy is required.
+
|-
+
|Hierarchy Closure
+
|The SPARQL queries in the alpha release do not handle any semantics. The queries only work on the asserted triples and therefore, closures need to be resolve by recursively issuing SPARQL queries.
+
| Planned to be implemented in 2012 Q1.
+
|-
+
|<del>Synonyms</del>
+
|<del>At the moment, synonyms are not handled in SPARQL queries. We are on the mechanism we will use to implement this feature, probably equivalent property reasoning.</del>
+
| Implemented, see ''Preferred Names, Synonyms and other common predicates''
+
|-
+
|}
+
  
<div style="margin-top: 10px; background: #FFEFC6; padding: 6px; border: 1px solid #FFD700; margin-bottom: 20px;">
+
Also, interactive examples can be tested here http://sparql.bioontology.org/examples
We understand that some of these points are limitations to the service as is provided today. The NCBO team is addressing these issues and working on the future SPARQL production infrastructure. Meanwhile, we offer this alpha release. Even though, the service is in alpha we plan to keep high up-time ratios. Please, contact us to provide feedback. Our support mailing list is: [mailto:support@bioontology.org support@bioontology.org]
+
</div>
+
  
=== BioPortal SPARQL Usage Policy ===
+
=== Submitting SPARQL queries programmatically ===
 +
 
 +
A github project contains examples to query our SPARQL service programmatically:
 +
 
 +
https://github.com/ncbo/sparql-code-examples
 +
 
 +
A tarball with these examples is for download here:
 +
 
 +
https://github.com/ncbo/sparql-code-examples/tarball/master
 +
 
 +
This project contains examples in Java, Python, JavaScript and Perl. Some of the examples use just language built-in capabilities and other need third-party libraries like Jena, Sesame or SPARQLWrapper. The github project and the tarball are self-contained, no need to download and install extra libraries.
 +
 
 +
<div style="margin-top: 10px; background: #F6F9ED; padding: 6px; border: 1px solid #aaaaaa; margin-bottom: 20px;">
 +
To run these examples or any other SPARQL queries programmatically an API key from BioPortal is required. If you do not have a BioPortal account go to [[http://bioportal.bioontology.org/accounts/new New Account]]  and create one. Once you have the BioPortal account, login in BioPortal and go to your account details. You should see your API Key as part of your account profile.
 +
</div>
  
The NCBO team is designing and implementing the infraestructure that will ensure a fair usage of our SPARQL service.
+
=== Database Named Graph Structure ===
  
While in ALPHA, the only queries that the service does not accept are the ones with triple patterns containing unbound subject, predicate and object; and unbound graph. For instance, the following are not acceptable queries:  
+
Each ontology is asserted into a single graph. The graph is named with an acronym based URI. For example, the graph:
  
 
<pre>
 
<pre>
SELECT * WHERE { ?s ?p ?o }
+
http://bioportal.bioontology.org/ontologies/HP
 
</pre>
 
</pre>
 +
 +
contains the Human Phenotype Ontology ontology. And the graph:
  
 
<pre>
 
<pre>
SELECT * WHERE { GRAPH ?g { ?s ?p ?o } }
+
http://bioportal.bioontology.org/ontologies/SNOMEDCT
 
</pre>
 
</pre>
  
The two queries above are not accepted by the service because they try to retrieve all the triples in the store. Their use is considered problematic in open SPARQL endpoints. On the other side, the following query will be accepted:
+
contains the SNOMEDCT ontology.
 +
 
 +
The following query would return all version IDs with the graph IDs where ontologies are located:
  
 
<pre>
 
<pre>
SELECT * WHERE { ?s rdf:type ?o }
+
PREFIX meta: <http://bioportal.bioontology.org/metadata/def/>
 +
 
 +
SELECT DISTINCT ?version ?graph
 +
WHERE {  
 +
    ?version meta:hasDataGraph ?graph
 +
}
 
</pre>
 
</pre>
  
Any combination of triple patterns that enclose any of the two first cases these will be rejected and not processed. For example:  
+
=== BioPortal Preferred Label ===
 +
 
 +
There are problematic cases of label definition. In order to provide a consistent mechanism to query by label across different ontologies we generate labels for the following cases. These label are attached to terms using the predicate '''http://bioportal.bioontology.org/metadata/def/prefLabel''' (bp:prefLabel)
 +
 
 +
* '''Missing labels''': for every owl:Class that is missing a label we generate a label based on the latest fragment of URI.
 +
 
 +
* '''Terms that use rdfs:label as preferred name''': BioPortal uses skos:prefLabel and skos:altLabel for preferred names and synonyms respectively. Both skos:prefLabel and skos:altLabel are subproperties of rdfs:label in the SKOS ontology. If someone uses rdfs:label to record preferred names, in the SKOS context, he would be saying that that name can be a preferred name or a synonym. To avoid this confusion we  generate bp:prefLabel(s) for every rdfs:label used as preferred name.
 +
 
 +
=== Preferred Label, Synonyms and other common predicates ===
 +
 
 +
When ontologies are submitted to BioPortal the user can select which predicates that ontology uses for:
 +
 
 +
* Preferred Names.
 +
* Synonyms or alternative names.
 +
* Author.
 +
* Description.
 +
 
 +
The BioPortal SPARQL endpoint supports rdfs:subPropertyOf reasoning to enable cross querying across all these configurable predicates. In the triple store, the following URI:
 +
 
 +
http://bioportal.bioontology.org/ontologies/globals
 +
 
 +
is used as identifier for the named graph that contains all the sub-property of statements that have been configured by users when uploading their ontologies. The root properties to be used  to trigger the reasoning are the following:
 +
 
 +
* '''skos:prefLabel''' for Preferred name.
 +
* '''skos:altLabel''' for Synonyms or alternative names.
 +
* '''dc:author''' for Author.
 +
* '''skos:definition''' for Description.
 +
 
 +
When using named graphs if you want to use this reasoning then you should include the globals graph that contains the subproperty statements, i.e:
  
 
<pre>
 
<pre>
SELECT * WHERE {
+
PREFIX owl:  <http://www.w3.org/2002/07/owl#>
    GRAPH ?g {
+
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
        ?s ?p ?o .  
+
SELECT DISTINCT ?termURI ?prefLabel
        ?s rdf:type ?c
+
FROM <http://bioportal.bioontology.org/ontologies/EHDA>
    } }
+
FROM <http://bioportal.bioontology.org/ontologies/globals>
 +
WHERE {
 +
      ?termURI a owl:Class;
 +
      skos:prefLabel ?prefLabel .
 +
}  
 
</pre>
 
</pre>
  
Queries with variables in subjects, predicates and objects but with bound graphs will be accepted. The following query retrieves all triples from a single graph (ontology):  
+
Otherwise the subproperty statements that take part in the query processor will not be taken into account.
 +
 
 +
=== Mappings ===
 +
 
 +
<div style="margin-top: 10px; background: #F6F9ED; padding: 6px; border: 1px solid #aaaaaa; margin-bottom: 20px;">
 +
Notice that as of January 30th (2013) we are hosting the mappings in a separate endpoint. This eases our regular mapping updates. Programmatic queries that target mapping data need to use the following endpoint: http://sparql.bioontology.org/mappings/sparql
 +
</div>
 +
 
 +
The mapping data in the triple store is stored in the following graphs:
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Graph Name!! Description
 +
|-
 +
|  http://purl.bioontology.org/mapping/loom || Loom: lexical mappings.
 +
|-
 +
| http://purl.bioontology.org/mapping/rest || REST: User submitted by users via the REST API.
 +
|-
 +
| http://purl.bioontology.org/mapping/umls_cui || UMLS-CUI: CUI based mappings
 +
|-
 +
| http://purl.bioontology.org/mapping/cuinonumls || NOUMLS-CUI: Terms with same CUIs but for ontologies that are not part of UMLS.
 +
|-
 +
| http://purl.bioontology.org/mapping/obo_xref || OBO-XREF: Mappings for terms with same xref attribute.
 +
|-
 +
| http://purl.bioontology.org/mapping/uri_match || URI-MATCH: Mappings that for terms that in different ontologies are represented by the same URI.
 +
|}
 +
 
 +
The following query returns the list of the graphs where mappings are located:
 +
 
 
<pre>
 
<pre>
PREFIX bio: <http://bioportal.bioontology.org/ontologies/>
+
SELECT DISTINCT ?g WHERE {
SELECT * WHERE {
+
GRAPH ?g {
    GRAPH bio:1422 {
+
?s a <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#One_To_One_Mapping> . }}
        ?s ?p ?o .
+
    }
+
}
+
 
</pre>
 
</pre>
  
 +
The following RDF/Turtle sample shows an example of a mapping instance:
 
<pre>
 
<pre>
PREFIX bio: <http://bioportal.bioontology.org/ontologies/>
+
@prefix maps: <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#> .
SELECT * WHERE {
+
 
     GRAPH bio:1422 {
+
<http://purl.bioontology.org/mapping/2767e8e0-001b-012e-749f-005056bd0010>
        ?s ?p ?o .  
+
    maps:has_process_info <.../procinfo/2008-04-23-38138> ;
        ?s rdf:type ?c
+
     maps:comment "Manual mappings between Mouse anatomy and NCIT." ;
     } }
+
    maps:relation skos:closeMatch ;
 +
    maps:target <http://purl.org/obo/owl/MA#MA_0001096> ;
 +
    maps:source <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#Olfactory_Nerve> ;
 +
     maps:source_ontology_id <http://bioportal.bioontology.org/ontologies/1032> ;
 +
    maps:target_ontology_id <http://bioportal.bioontology.org/ontologies/1000> ;
 +
    a maps:One_To_One_Mapping .
 
</pre>
 
</pre>
  
We accept two exceptions of queries that use unbound G, S, P and O. Our backend storage is optimized to resolve them and they are considered important SPARQL exploratory queries. These are the queries that list all distinct graphs or properties in the database:  
+
The predicates we use to represent a mapping record both the target and source terms and target and source ontologies. A SPARQL query to return all the target terms for a giving source term would look like the following:
  
 
<pre>
 
<pre>
SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }
+
PREFIX map: <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#>
 +
SELECT DISTINCT ?target WHERE {
 +
  ?s map:source <http://purl.obolibrary.org/obo/DOID_8545>;
 +
    map:target ?target .
 +
}
 
</pre>
 
</pre>
 +
 +
If one wants to count at all the mappings for two given ontologies then the SPARQL would use the ''target_ontology'' and ''source_ontology'' predicates:
  
 
<pre>
 
<pre>
SELECT DISTINCT ?p WHERE { ?s ?p ?o }
+
PREFIX map: <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#>
 +
SELECT (count(?m) as ?c) WHERE {
 +
  ?m map:source_ontology <http://bioportal.bioontology.org/ontologies/1032> ;
 +
      map:target_ontology  <http://bioportal.bioontology.org/ontologies/1000> .
 +
}
 
</pre>
 
</pre>
  
 +
In this case this query returns a count of 4393 solutions.
 +
It is important to notice that for mappings we use version based ontology URIs and not the ones that are based on acronyms.
  
If you have any questions about the usage policy or if you have any problems using our SPARQL Service then email our [[mailto:support@bioontology.org support email list]] or visit our [[http://alphasparql.bioontology.org/examples examples]] and code sections.
+
=== Federated SPARQL queries ===
  
=== Submitting SPARQL queries programmatically ===
+
SPARQL Federation can be used with the Jena ARQ library. The Jena ARQ library handles the SERVICE SPARQL construct and directs sets of triple patterns to different endpoint and handles the joins.
 +
 
 +
BioPortal offers two different SPARQL endpoints one for ontologies (metadata and terms) and a second one for mappings. There are use cases that require queries with joins from both endpoints. This can be achieved by using SPARQL federation and the SERVICE feature (SPARQL 1.1). The following example looks at the CSP term 'Neck' and retrieves the sources for all the mappings for that term (from the mapping endpoint). For each of those sources then gets the parents (from the ontologies endpoint). Notice the change in the SERVICE endpoints from 'mappings' in the first block to 'ontologies' in the second one.
 +
 
 +
<pre>
 +
PREFIX map: <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#>
 +
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 +
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
 +
SELECT DISTINCT ?mappedParent WHERE {
 +
    SERVICE <http://sparql.bioontology.org/mappings/sparql/?apikey=YOUR API KEY HERE> {
 +
        ?mapping map:target <http://purl.bioontology.org/ontology/CSP/0468-5952> .
 +
        ?mapping map:source ?source .
 +
    }
 +
    SERVICE <http://sparql.bioontology.org/ontologies/sparql/?apikey=YOUR API KEY HERE> {
 +
        ?source rdfs:subClassOf ?mappedParent .
 +
    }
 +
}
 +
</pre>
 +
 
 +
Full example: https://github.com/ncbo/sparql-code-examples/blob/master/java/src/org/ncbo/stanford/sparql/examples/JenaARQFederationExample.java
 +
 
 +
<div style="margin-top: 10px; background: #F6F9ED; padding: 6px; border: 1px solid #aaaaaa; margin-bottom: 20px;">
 +
<b>Note</b> SPARQL Federation can be used programmatically only. Our web front-end at http://sparql.bioontology.org/ does not support mediation for the SERVICE clause. Our tests for SPARQL federation use Jena ARQ 2.9.4, this version is able to correctly submit the BioPortal API keys.
 +
</div>
  
yyyyyyyyyyy
+
=== Partial or Incomplete Results ===
  
 +
sparql.bioontology.org uses 4store's soft-limit internal mechanism to limit resources for expensive queries. Our setup is configured to bind 8K elements per triple pattern. If you hit these limits a warning message will be appended to the query response. This message says something like: "hit complexity limit 8 times". If you see this warning it means that the results are incomplete, and probably there is a more efficient way to write that query.
  
=== Preferred Names, Synonyms and other common predicates ===
+
Contact our support mail list if you need help to rewrite your query in a more efficient way and avoid incomplete results.
  
yyyyyyyyyyy
+
=== Slides ===
 +
* '''''BioPortal SPARQL presentation at ISWC 2012''''' http://www.slideshare.net/manuelso/using-sparql-to-query-bioportal-ontologies-and-metadata
 +
* '''''BioPortal SPARQL tutorial from SWAT4LS 2011''''' http://www.bioontology.org/wiki/index.php/File:Whetzel_SPARQL.pdf
 +
* '''''NCBO Hackathon slides for the SPARQL tutorial''''' http://www.stanford.edu/~manuelso/ncbohack/index.html

Latest revision as of 12:00, 25 January 2013

NCBO is releasing a free and open SPARQL endpoint to query ontologies hosted in the BioPortal ontology repository. This SPARQL service, that is in BETA status, is stable for testing by our community of users. If you encounter any errors or unexpected behavior please report it to us support@bioontology.org.

Before using the BioPortal SPARQL service please read our SPARQL Release Notes And Usage Policy

Contents

[edit] Web Interface and Query Examples

There is a Web interface to test SPARQL queries at http://sparql.bioontology.org/

Also, interactive examples can be tested here http://sparql.bioontology.org/examples

[edit] Submitting SPARQL queries programmatically

A github project contains examples to query our SPARQL service programmatically:

https://github.com/ncbo/sparql-code-examples

A tarball with these examples is for download here:

https://github.com/ncbo/sparql-code-examples/tarball/master

This project contains examples in Java, Python, JavaScript and Perl. Some of the examples use just language built-in capabilities and other need third-party libraries like Jena, Sesame or SPARQLWrapper. The github project and the tarball are self-contained, no need to download and install extra libraries.

To run these examples or any other SPARQL queries programmatically an API key from BioPortal is required. If you do not have a BioPortal account go to [New Account] and create one. Once you have the BioPortal account, login in BioPortal and go to your account details. You should see your API Key as part of your account profile.

[edit] Database Named Graph Structure

Each ontology is asserted into a single graph. The graph is named with an acronym based URI. For example, the graph:

http://bioportal.bioontology.org/ontologies/HP

contains the Human Phenotype Ontology ontology. And the graph:

http://bioportal.bioontology.org/ontologies/SNOMEDCT

contains the SNOMEDCT ontology.

The following query would return all version IDs with the graph IDs where ontologies are located:

PREFIX meta: <http://bioportal.bioontology.org/metadata/def/> 

SELECT DISTINCT ?version ?graph
WHERE { 
    ?version meta:hasDataGraph ?graph
}

[edit] BioPortal Preferred Label

There are problematic cases of label definition. In order to provide a consistent mechanism to query by label across different ontologies we generate labels for the following cases. These label are attached to terms using the predicate http://bioportal.bioontology.org/metadata/def/prefLabel (bp:prefLabel)

  • Missing labels: for every owl:Class that is missing a label we generate a label based on the latest fragment of URI.
  • Terms that use rdfs:label as preferred name: BioPortal uses skos:prefLabel and skos:altLabel for preferred names and synonyms respectively. Both skos:prefLabel and skos:altLabel are subproperties of rdfs:label in the SKOS ontology. If someone uses rdfs:label to record preferred names, in the SKOS context, he would be saying that that name can be a preferred name or a synonym. To avoid this confusion we generate bp:prefLabel(s) for every rdfs:label used as preferred name.

[edit] Preferred Label, Synonyms and other common predicates

When ontologies are submitted to BioPortal the user can select which predicates that ontology uses for:

  • Preferred Names.
  • Synonyms or alternative names.
  • Author.
  • Description.

The BioPortal SPARQL endpoint supports rdfs:subPropertyOf reasoning to enable cross querying across all these configurable predicates. In the triple store, the following URI:

http://bioportal.bioontology.org/ontologies/globals

is used as identifier for the named graph that contains all the sub-property of statements that have been configured by users when uploading their ontologies. The root properties to be used to trigger the reasoning are the following:

  • skos:prefLabel for Preferred name.
  • skos:altLabel for Synonyms or alternative names.
  • dc:author for Author.
  • skos:definition for Description.

When using named graphs if you want to use this reasoning then you should include the globals graph that contains the subproperty statements, i.e:

PREFIX owl:  <http://www.w3.org/2002/07/owl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?termURI ?prefLabel
 FROM <http://bioportal.bioontology.org/ontologies/EHDA>
 FROM <http://bioportal.bioontology.org/ontologies/globals> 
WHERE {
      ?termURI a owl:Class;
      skos:prefLabel ?prefLabel .
} 

Otherwise the subproperty statements that take part in the query processor will not be taken into account.

[edit] Mappings

Notice that as of January 30th (2013) we are hosting the mappings in a separate endpoint. This eases our regular mapping updates. Programmatic queries that target mapping data need to use the following endpoint: http://sparql.bioontology.org/mappings/sparql

The mapping data in the triple store is stored in the following graphs:

Graph Name Description
http://purl.bioontology.org/mapping/loom Loom: lexical mappings.
http://purl.bioontology.org/mapping/rest REST: User submitted by users via the REST API.
http://purl.bioontology.org/mapping/umls_cui UMLS-CUI: CUI based mappings
http://purl.bioontology.org/mapping/cuinonumls NOUMLS-CUI: Terms with same CUIs but for ontologies that are not part of UMLS.
http://purl.bioontology.org/mapping/obo_xref OBO-XREF: Mappings for terms with same xref attribute.
http://purl.bioontology.org/mapping/uri_match URI-MATCH: Mappings that for terms that in different ontologies are represented by the same URI.

The following query returns the list of the graphs where mappings are located:

SELECT DISTINCT ?g WHERE { 
GRAPH ?g { 
?s a <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#One_To_One_Mapping> . }}

The following RDF/Turtle sample shows an example of a mapping instance:

@prefix maps: <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#> .

<http://purl.bioontology.org/mapping/2767e8e0-001b-012e-749f-005056bd0010>
    maps:has_process_info <.../procinfo/2008-04-23-38138> ;
    maps:comment "Manual mappings between Mouse anatomy and NCIT." ;
    maps:relation skos:closeMatch ;
    maps:target <http://purl.org/obo/owl/MA#MA_0001096> ;
    maps:source <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#Olfactory_Nerve> ;
    maps:source_ontology_id <http://bioportal.bioontology.org/ontologies/1032> ;
    maps:target_ontology_id <http://bioportal.bioontology.org/ontologies/1000> ;
    a maps:One_To_One_Mapping .

The predicates we use to represent a mapping record both the target and source terms and target and source ontologies. A SPARQL query to return all the target terms for a giving source term would look like the following:

PREFIX map: <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#>
SELECT DISTINCT ?target WHERE {
  ?s map:source <http://purl.obolibrary.org/obo/DOID_8545>;
     map:target ?target .
}

If one wants to count at all the mappings for two given ontologies then the SPARQL would use the target_ontology and source_ontology predicates:

PREFIX map: <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#>
SELECT (count(?m) as ?c) WHERE {
  ?m map:source_ontology <http://bioportal.bioontology.org/ontologies/1032> ;
      map:target_ontology  <http://bioportal.bioontology.org/ontologies/1000> .
}

In this case this query returns a count of 4393 solutions. It is important to notice that for mappings we use version based ontology URIs and not the ones that are based on acronyms.

[edit] Federated SPARQL queries

SPARQL Federation can be used with the Jena ARQ library. The Jena ARQ library handles the SERVICE SPARQL construct and directs sets of triple patterns to different endpoint and handles the joins.

BioPortal offers two different SPARQL endpoints one for ontologies (metadata and terms) and a second one for mappings. There are use cases that require queries with joins from both endpoints. This can be achieved by using SPARQL federation and the SERVICE feature (SPARQL 1.1). The following example looks at the CSP term 'Neck' and retrieves the sources for all the mappings for that term (from the mapping endpoint). For each of those sources then gets the parents (from the ontologies endpoint). Notice the change in the SERVICE endpoints from 'mappings' in the first block to 'ontologies' in the second one.

PREFIX map: <http://protege.stanford.edu/ontologies/mappings/mappings.rdfs#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?mappedParent WHERE {
    SERVICE <http://sparql.bioontology.org/mappings/sparql/?apikey=YOUR API KEY HERE> {
        ?mapping map:target <http://purl.bioontology.org/ontology/CSP/0468-5952> .
        ?mapping map:source ?source .
    }
    SERVICE <http://sparql.bioontology.org/ontologies/sparql/?apikey=YOUR API KEY HERE> {
        ?source rdfs:subClassOf ?mappedParent .
    }
}

Full example: https://github.com/ncbo/sparql-code-examples/blob/master/java/src/org/ncbo/stanford/sparql/examples/JenaARQFederationExample.java

Note SPARQL Federation can be used programmatically only. Our web front-end at http://sparql.bioontology.org/ does not support mediation for the SERVICE clause. Our tests for SPARQL federation use Jena ARQ 2.9.4, this version is able to correctly submit the BioPortal API keys.

[edit] Partial or Incomplete Results

sparql.bioontology.org uses 4store's soft-limit internal mechanism to limit resources for expensive queries. Our setup is configured to bind 8K elements per triple pattern. If you hit these limits a warning message will be appended to the query response. This message says something like: "hit complexity limit 8 times". If you see this warning it means that the results are incomplete, and probably there is a more efficient way to write that query.

Contact our support mail list if you need help to rewrite your query in a more efficient way and avoid incomplete results.

[edit] Slides

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox