sparql-examples

A set of SPARQL examples that are used in different SIB resources

https://github.com/sib-swiss/sparql-examples

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

A set of SPARQL examples that are used in different SIB resources

Basic Info
Statistics
  • Stars: 20
  • Watchers: 12
  • Forks: 24
  • Open Issues: 12
  • Releases: 0
Created over 2 years ago · Last pushed 10 months ago
Metadata Files
Readme License Citation

README.md

SPARQL examples

This is a collection of SPARQL examples usable on different SIB related SPARQL endpoints or datasets. The examples are stored one query per file in project specific repositories in the examples folder.

Each SPARQL query is itself in a turtle file. We use the following ontologies for the basic concepts.

  • ShACL for the relation to the text of the Select/Ask queries, and declaring prefixes
  • RDFS for comments and labels as shown in the user interfaces, annotated with a language tag
  • RDF for basic type relations
  • schema.org for the target SPARQL endpoint and tagging relevant keywords

The following illustrates an example to retrieve retrieve human enzymes that metabolize sphingolipids from the UniProt SPARQL endpoint, with a service call to Rhea endpoint.

```turtle @prefix ex: https://sparql.uniprot.org/.well-known/sparql-examples/ . # <!-- change per dataset @prefix rdfs: http://www.w3.org/2000/01/rdf-schema# . @prefix schema: https://schema.org/ . @prefix sh: http://www.w3.org/ns/shacl# . @prefix spex:https://purl.expasy.org/sparql-examples/ontology# .

ex:040 # <!-- UniProt, Rhea and Swiss-Lipids are numbered but this can be anything. a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; rdfs:comment "Retrieve human enzymes that metabolize sphingolipids and are annotated in ChEMBL"@en ; sh:prefixes :sparqlexamplesprefixes ; # <!-- required for the import of the prefix declarations. Note the blank node sh:select """PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI> PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema# PREFIX rh: http://rdf.rhea-db.org/ PREFIX taxon: http://purl.uniprot.org/taxonomy/ PREFIX up: http://purl.uniprot.org/core/

SELECT DISTINCT ?protein ?chemblEntry WHERE { SERVICE https://sparql.rhea-db.org/sparql { ?rhea rdfs:subClassOf rh:Reaction ; rh:side/rh:contains/rh:compound/rh:chebi/rdfs:subClassOf+ CHEBI:26739 . } ?protein up:annotation/up:catalyticActivity/up:catalyzedReaction ?rhea ; up:organism taxon:9606 ; rdfs:seeAlso ?chemblEntry . ?chemblEntry up:database http://purl.uniprot.org/database/ChEMBL . }""" ; schema:keywords "enzyme" ; schema:target https://sparql.uniprot.org/sparql/ ; spex:federatesWith https://sparql.rhea-db.org/sparql . ```

Artifact generation and quality assurance

We use the SIB SPARQL Examples utils for testing and generating artifacts.

First, download the jar file with:

bash wget -O sparql-examples-utils.jar 'https://github.com/sib-swiss/sparql-examples-utils/releases/download/v2.0.19/sparql-examples-utils-2.0.19-uber.jar'

Compile all query files into one file to upload to your endpoint

Compile all query files for a specific example folder, into a local file including the prefixes/namespaces definitions:

bash java -jar sparql-examples-utils.jar convert -i examples/ -p UniProt -f ttl > examples_UniProt.ttl

You can then load this file to this project SPARQL endpoint! We recommend to upload it to a named graph: your endpoint URL + /.well-known/sparql-examples

Or compile for all example folders, as JSON-LD, to the standard output:

bash java -jar sparql-examples-utils.jar convert -i examples/ -p all -f jsonld

Generate RQ files

For easier use by other tools we can also generate rq files. Following the syntax of grlc allowing to use these queries as APIs. bash java -jar sparql-examples-utils.jar convert -i examples/ -p all -r

Generate markdown file

Generate markdown files with the query and a mermaid diagram of the queries, to be used to deploy a static website for the query examples.

bash java -jar sparql-examples-utils.jar convert -i examples/ -m

Testing the queries

The queries are parsed and validated but not executed with junit using the Tester

bash java -jar sparql-examples-utils.jar test --input-directory=./examples

should return no test failures. RDF4j and Jena are both a lot stricter than virtuoso.

The queries can be executed automatically on all endpoints they apply to using an extra argument --also-run-slow-tests:

bash java -jar sparql-examples-utils.jar test --input-directory=./examples/MetaNetX --also-run-slow-tests

This does change the queries to add a LIMIT 1 if no limit was set in the query. Then check if there is a result it is fetched.

Querying for queries

As the SPARQL examples are themselves RDF, they can be queried for as soon as they are loaded in a SPARQL endpoint. ```sparql PREFIX sh: http://www.w3.org/ns/shacl# PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema# PREFIX spex: https://purl.expasy.org/sparql-examples/ontology#

SELECT DISTINCT ?sq ?comment ?query WHERE { ?sq a sh:SPARQLExecutable ; rdfs:comment ?comment ; sh:select|sh:ask|sh:construct|spex:describe ?query . } ORDER BY ?sq ```

Finding queries that run on more than one endpoint

This expects the Jena tools to be available in your $PATH. e.g. export PATH="$JENA_HOME/bin:$PATH"

```bash java -jar sparql-examples-utils.jar convert -i examples/ -p all -f ttl > examples_all.ttl

sparql --data examplesall.ttl "SELECT ?query (GROUPCONCAT(?target ; separator=', ') AS ?targets) WHERE { ?query https://schema.org/target ?target } GROUP BY ?query HAVING (COUNT(DISTINCT ?target) > 1) " ```

How to cite this work

If you reuse any part of this work, please cite the GigaScience paper:

@misc{largecollectionsparqlquestionquery, author = {Bolleman, Jerven and Emonet, Vincent and Altenhoff, Adrian and Bairoch, Amos and Blatter, Marie-Claude and Bridge, Alan and Duvaud, Severine and Gasteiger, Elisabeth and Kuznetsov, Dmitry and Moretti, Sebastien and Michel, Pierre-Andre and Morgat, Anne and Pagni, Marco and Redaschi, Nicole and Zahn-Zabal, Monique and Mendes de Farias, Tarcisio and Sima, Ana Claudia}, doi = {10.1093/gigascience/giaf045}, month = {10}, title = {A large collection of bioinformatics question-query pairs over federated knowledge graphs: methodology and applications}, url = {https://github.com/sib-swiss/sparql-examples-utils}, year = {2024} }

Owner

  • Name: SIB Swiss Institute of Bioinformatics
  • Login: sib-swiss
  • Kind: organization
  • Location: Switzerland

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: "A large collection of bioinformatics question-query pairs over federated knowledge graphs: methodology and applications"
repository-code: https://github.com/sib-swiss/sparql-examples-utils
date-released: 2024-10-08
doi: 10.1093/gigascience/giaf045
license: MIT
authors:
  - given-names: Jerven
    family-names: Bolleman
    orcid: https://orcid.org/0000-0002-7449-1266,
    email: Jerven.Bolleman@sib.swiss
    affiliation: SIB Swiss Institute of Bioinformatics
  - given-names: Vincent
    family-names: Emonet
    orcid: https://orcid.org/0000-0002-1501-1082
    affiliation: SIB Swiss Institute of Bioinformatics
  - given-names: Adrian
    family-names: Altenhoff
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0001-7492-1273
  - given-names: Amos
    family-names: Bairoch
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0003-2826-6444
  - given-names: Marie-Claude
    family-names: Blatter
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0002-7474-1499 
  - given-names: Alan
    family-names: Bridge
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0003-2148-9135 
  - given-names: Severine
    family-names: Duvaud
    orcid: https://orcid.org/0000-0001-7892-9678
    affiliation: SIB Swiss Institute of Bioinformatics
  - given-names: Elisabeth
    family-names: Gasteiger
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0003-1829-162X 
  - given-names: Dmitry
    family-names: Kuznetsov
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0002-9972-947X
  - given-names: Sebastien
    family-names: Moretti
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0003-3947-488X
  - given-names: Pierre-Andre
    family-names: Michel
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0002-7023-1045 
  - given-names: Anne
    family-names: Morgat
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0002-1216-2969 
  - given-names: Marco
    family-names: Pagni
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0001-9292-9463 
  - given-names: Nicole
    family-names: Redaschi
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0001-8890-2268 
  - given-names: Monique
    family-names: Zahn-Zabal
    affiliation: SIB Swiss Institute of Bioinformatics
    orcid: https://orcid.org/0000-0001-7961-6091 
  - given-names: Tarcisio
    family-names: Mendes de Farias
    orcid: https://orcid.org/0000-0002-3175-5372
    affiliation: SIB Swiss Institute of Bioinformatics
  - given-names: Ana Claudia
    family-names: Sima
    orcid: https://orcid.org/0000-0003-3213-4495
    affiliation: SIB Swiss Institute of Bioinformatics

GitHub Events

Total
  • Issues event: 9
  • Watch event: 12
  • Delete event: 110
  • Issue comment event: 32
  • Push event: 232
  • Pull request review comment event: 2
  • Pull request review event: 4
  • Pull request event: 268
  • Fork event: 14
  • Create event: 120
Last Year
  • Issues event: 9
  • Watch event: 12
  • Delete event: 110
  • Issue comment event: 32
  • Push event: 232
  • Pull request review comment event: 2
  • Pull request review event: 4
  • Pull request event: 268
  • Fork event: 14
  • Create event: 120

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 15
  • Total pull requests: 163
  • Average time to close issues: 18 days
  • Average time to close pull requests: 1 day
  • Total issue authors: 8
  • Total pull request authors: 13
  • Average comments per issue: 1.07
  • Average comments per pull request: 0.22
  • Merged pull requests: 133
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 6
  • Pull requests: 140
  • Average time to close issues: about 1 hour
  • Average time to close pull requests: about 15 hours
  • Issue authors: 6
  • Pull request authors: 10
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.09
  • Merged pull requests: 118
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • JervenBolleman (5)
  • dssib (5)
  • tarcisiotmf (2)
  • vemonet (2)
  • WolfgangFahl (1)
  • smoretti (1)
  • egonw (1)
  • ecrum19 (1)
  • Adafede (1)
Pull Request Authors
  • JervenBolleman (115)
  • mcblatter (110)
  • vemonet (12)
  • tarcisiotmf (9)
  • mdrishti (9)
  • pamichel (8)
  • andrawaag (4)
  • smoretti (3)
  • ecrum19 (3)
  • gmicklem (3)
  • redaschi (2)
  • alpae (1)
  • Caloyko (1)
Top Labels
Issue Labels
enhancement (5) documentation (1) good first issue (1)
Pull Request Labels
uniprot (2) enzyme (2) enhancement (1)

Dependencies

.github/workflows/check.yml actions
  • actions/checkout v4 composite
  • actions/setup-java v4 composite
.github/workflows/publish_github_pages.yaml actions
  • actions/checkout v4 composite
  • actions/configure-pages v5 composite
  • actions/deploy-pages v4 composite
  • actions/jekyll-build-pages v1 composite
  • actions/setup-java v4 composite
  • actions/upload-pages-artifact v3 composite