sparql-examples

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

View the Project on GitHub sib-swiss/sparql-examples

2

For a given (list of) lipid Species identifier(s) (e.g. SWISSLIPID:000056420 (Phosphatidylcholine (20:2)) SWISSLIPID:000308470 (Triacylglycerol (64:6))), return a list of the corresponding Molecular subspecies (if any), Structural subspecies (if any), and Isomeric subspecies. The query should return the lipid recommended names as well as identifiers. The list should be sorted by level in the hierarchy (Isomeric subspecies last). Future versions of this query should be generic enough to work from any start point (Species, Molecular subspecies, Structural subspecies). Recapitulates the “browse lipid analytes” function of the website (in batch).

Use at

PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

# Example 2
SELECT ?startId ?startName ?rank ?id ?name
WHERE
{
  # query: list of SwissLipids Species identifiers
  VALUES ?startId { SWISSLIPID:000056420 SWISSLIPID:000308470 }
  ?startId SWISSLIPID:rank SWISSLIPID:Species .
  # SwissLipids Species name
  ?startId rdfs:label ?startName .  
  # Hierarchical search
  ?id rdfs:subClassOf+ ?startId .
  ?id SWISSLIPID:rank ?rank .
  VALUES ?rank { SWISSLIPID:Isomeric_Subspecies SWISSLIPID:Molecular_Subspecies SWISSLIPID:Structural_Subspecies}
  ?id rdfs:label ?name .
} 
ORDER BY DESC(?rank) ?startId
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?id"):::projected 
  v5("?name"):::projected 
  v5("?rank"):::projected 
  v3("?startId"):::projected 
  v3("?startName"):::projected 
  c2(["SWISSLIPID:Species"]):::iri 
  bind0[/VALUES ?startId/]
  bind0-->v3
  bind00(["SWISSLIPID:000056420"])
  bind00 --> bind0
  bind01(["SWISSLIPID:000308470"])
  bind01 --> bind0
  v3 --"SWISSLIPID:rank"-->  c2
  v3 --"rdfs:label"-->  v3
  v4 --"rdfs:subClassOf"-->  v3
  v4 --"SWISSLIPID:rank"-->  v5
  bind1[/VALUES ?rank/]
  bind1-->v5
  bind10(["SWISSLIPID:Isomeric_Subspecies"])
  bind10 --> bind1
  bind11(["SWISSLIPID:Molecular_Subspecies"])
  bind11 --> bind1
  bind12(["SWISSLIPID:Structural_Subspecies"])
  bind12 --> bind1
  v4 --"rdfs:label"-->  v5