SPARQL example query
1: Select the SwissLipids categories and their labels.
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 1 SELECT ?category ?label WHERE { ?category SWISSLIPID:rank SWISSLIPID:Category . ?category rdfs:label ?label . }Use2: 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).
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) ?startIdUse3: For a given (list of) lipid Species identifiers (e.g. SWISSLIPID:000056493, Phosphatidylcholine (32:0)), return a list of the corresponding Molecular subspecies (if any), Structural subspecies (if any), and Isomeric subspecies (if any) which are associated with at least one citation (PMID: PubMed id). The query should return the lipid identifiers (?id), recommended names (?name), and PMIDs (?citation). Future versions of this query should be generic enough to work from any start point (Species, Molecular subspecies, Structural subspecies).
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 3 SELECT ?startId ?startLabel ?rank ?id ?name ?citation WHERE { # Queried lipid species VALUES ?startId { SWISSLIPID:000056493 } ?startId rdfs:label ?startLabel . ?id rdfs:subClassOf+ ?startId . VALUES ?rank { SWISSLIPID:Isomeric_Subspecie SWISSLIPID:Molecular_Subspecies SWISSLIPID:Structural_Subspecies} ?id SWISSLIPID:rank ?rank ; rdfs:label ?name ; SWISSLIPID:citation ?citation . } ORDER BY ?startId ?id DESC(?rank)Use4: For a given (list of) lipid classes (e.g. SWISSLIPID:000399814 (Ceramide) SWISSLIPID:000000007 (Sphingomyelin (iso-d17:1(4E))), return a list of the corresponding Isomeric subspecies. The query should return the lipid recommended names (?name) as well as identifiers (?id). Recapitulates the “browse lipid classes” function of the website (in batch).
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 4 SELECT ?startId ?startName ?id ?name WHERE { VALUES ?startId { SWISSLIPID:000399814 SWISSLIPID:000000567} ?startId SWISSLIPID:rank SWISSLIPID:Class . ?startId rdfs:label ?startName . ?id rdfs:subClassOf+ ?startId . ?id SWISSLIPID:rank SWISSLIPID:Isomeric_Subspecies ; rdfs:label ?name . } ORDER BY ?startIdUse5: For a given lipid (SWISSLIPID:000399814, Ceramide), return a list of all corresponding reactions (Rhea IDs and equation). This query does consider the hierarchy: it looks for reactions involving the specified lipid and/or its more specific forms.
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> # Example 5 SELECT ?startId ?startName ?id ?name ?chebi ?rhea ?rheaEquation WHERE { # SwissLipids query (list of) identifier(s) VALUES ?startId { SWISSLIPID:000399814 } # name ?startId rdfs:label ?startName . # Retrieve children lipids ?id rdfs:subClassOf* ?startId . ?id rdfs:label ?name . # ChEBI x-ref ?id owl:equivalentClass ?chebi . # federated query to Rhea SERVICE <https://sparql.rhea-db.org/sparql> { ?rhea rh:equation ?rheaEquation . ?rhea rh:side/rh:contains/rh:compound/rh:chebi ?chebi . } } ORDER BY ?startId ?idUse6: For a given lipid (SWISSLIPID:000399814, Ceramide), return a list of all corresponding reactions (Rhea IDs and equation), as well as their enzymes as annotated in UniProtKB/Swiss-Prot) enzymes themselves (ID and protein name). This query does not consider the hierarchy: it looks for reactions and enzymes only for the specified lipid.
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> PREFIX up: <http://purl.uniprot.org/core/> # Example 6 SELECT ?startId ?startName ?chebi ?rhea ?rheaEquation ?uniprot ?uniprotName WHERE { # SwissLipids query (list of) identifier(s) VALUES ?startId { SWISSLIPID:000399814 } # name ?startId rdfs:label ?startName . # ChEBI x-ref ?startId owl:equivalentClass ?chebi . # federated query to Rhea SERVICE <https://sparql.rhea-db.org/sparql> { ?rhea rh:equation ?rheaEquation . ?rhea rh:side/rh:contains/rh:compound/rh:chebi ?chebi . } # federated query to UniProt SERVICE <https://sparql.uniprot.org/sparql> { ?uniprot up:reviewed true . ?uniprot up:recommendedName/up:fullName ?uniprotName . ?uniprot up:annotation/up:catalyticActivity/up:catalyzedReaction ?rhea . } } ORDER BY ?startIdUse7: For a given list of lipid Species, return a list of the corresponding Isomeric subspecies for that particular lipid that are linked to an enzyme as annotated in UniProtKB (UniProt AC and recommended name). This question would allow a user with (a list of) very high level MS identifications to immediately narrow them to the most likely potential lipid structures and protein targets as in this example: SWISSLIPID:000056871 / PC(O-36:4) (target species of interest) -> SWISSLIPID:000028143 / PC(O-16:0/20:4(5Z,8Z,11Z,14Z)) -> LPCAT4, PLA2G4A, PLA2G4C, PLA2G4F (target proteins)
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> PREFIX up: <http://purl.uniprot.org/core/> # Example 7 SELECT ?startId ?startLabel ?id ?name WHERE { # Queried lipid species VALUES ?startId { SWISSLIPID:000056871 } ?startId rdfs:label ?startLabel . # Corresponding Isomeric subspecies ?id rdfs:subClassOf+ ?startId . ?id SWISSLIPID:rank SWISSLIPID:Isomeric_Subspecie ; rdfs:label ?name . # Mapped ChEBI ?id owl:equivalentClass ?chebi . # federated query to Rhea SERVICE <https://sparql.rhea-db.org/sparql> { ?rhea rh:equation ?rheaEquation . ?rhea rh:side/rh:contains/rh:compound/rh:chebi ?chebi . } # federated query to UniProt SERVICE <https://sparql.uniprot.org/sparql> { ?uniprot up:reviewed true . ?uniprot up:recommendedName/up:fullName ?uniprotName . ?uniprot up:annotation/up:catalyticActivity/up:catalyzedReaction ?rhea . } }Use8: Retrieve mapping between SwissLipids lipid identifiers and their corresponding LIPID MAPS identifiers. Output should include SwissLipids identifier and name plus the LIPID MAPS identifier.
PREFIX lipidmaps: <https://www.lipidmaps.org/rdf/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 8 SELECT ?slm ?slmName ?lipidmaps WHERE { ?slm rdfs:label ?slmName . # Corresponding LIPID MAPS ?slm rdfs:seeAlso ?lipidmaps . FILTER (strstarts(str(?lipidmaps), str(lipidmaps:))) . } ORDER BY ?slmUse9: For a given list of LIPID MAPS identifiers return the list of corresponding SwissLipids identifiers. Output should include SwissLipids identifier and name plus the LIPID MAPS identifier. This query considers only the cross references in the SwissLipids entry – it does not attempt to query other levels to find links between parents or children. Recapitulates one ID mapping function on the website
PREFIX lipidmaps: <https://www.lipidmaps.org/rdf/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 9 SELECT ?lipidmaps ?slm ?slmName WHERE { VALUES ?lipidmaps {lipidmaps:LMSP01020001 lipidmaps:LMST01010069 lipidmaps:LMST04030222} ?slm rdfs:label ?slmName . # Corresponding SwissLipds entries ?slm rdfs:seeAlso ?lipidmaps . } ORDER BY ?lipidmapsUse10: Retrieve mapping between SwissLipids lipid identifiers and their corresponding HMDB identifiers. Output should include SwissLipids identifier and name plus the HMDB identifier.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 10 SELECT ?slm ?slmName ?hmdb WHERE { ?slm rdfs:label ?slmName . # Corresponding HMDB entries ?slm rdfs:seeAlso ?hmdb . FILTER regex(str(?hmdb), "hmdb") . } ORDER BY ?slmUse11: For a given list of HMDB identifiers return the list of corresponding SwissLipids identifiers. Output should include SwissLipids identifier and name plus the HMDB identifier. This query considers only the cross references in the SwissLipids entry – it does not attempt to query other levels to find links between parents or children. Recapitulates one ID mapping function on the website.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 11 prefix HMDB:<http://identifiers.org/hmdb/> SELECT ?hmdb ?slm ?slmName WHERE { VALUES ?hmdb {HMDB:HMDB00269 HMDB:HMDB00032 HMDB:HMDB01383} ?slm rdfs:label ?slmName . # Corresponding SwissLipids entries ?slm rdfs:seeAlso ?hmdb . } ORDER BY ?hmdbUse12: Retrieve mapping between SwissLipids lipid identifiers and their corresponding ChEBI identifiers. Output should include SwissLipids identifier and name plus the ChEBI identifier.
PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 12 SELECT ?slm ?slmName ?chebi WHERE { ?slm rdfs:label ?slmName . # Corresponding ChEBI entries ?slm owl:equivalentClass ?chebi . } ORDER BY ?slmUse13: For a given list of ChEBI identifiers return the list of corresponding SwissLipids identifiers. Output should include SwissLipids identifier and name plus the HMDB identifier. This query considers only the cross references in the SwissLipids entry – it does not attempt to query other levels to find links between parents or children. Recapitulates one ID mapping function on the website.
PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 13 SELECT ?chebi ?slm ?slmName WHERE { VALUES ?chebi {CHEBI:70846 CHEBI:70771 CHEBI:70829} ?slm rdfs:label ?slmName . # Corresponding SwissLipids entries ?slm owl:equivalentClass ?chebi . } ORDER BY ?chebiUse14: For a given list of LIPID MAPS identifiers return the list of corresponding ChEBI IDs. Output should include LIPID MAPS ID, the corresponding SwissLipids ID and name, plus the ChEBI ID. This query first identifies SwissLipids identifiers for a given list of HMDB identifiers. It then retrieves all children and from them the required LIPID MAPS identifiers. extends ex:9
PREFIX lipidmaps: <https://www.lipidmaps.org/rdf/> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 14 SELECT ?lipidmaps ?slm ?slmName ?chebi WHERE { #VALUES ?lipidmaps {lipidmaps:LMSP01020001 lipidmaps:LMST01010069 lipidmaps:LMST04030222} ?slm rdfs:label ?slmName . # Corresponding SwissLipids entries ?slm rdfs:seeAlso ?lipidmaps . FILTER regex(str(?lipidmaps), "lipidmaps") . # Hierarchical search #?children rdfs:subClassOf* ?slm . #?children rdfs:label ?name . # Corresponding ChEBI entries ?slm owl:equivalentClass ?chebi . } ORDER BY ?lipidmaps ?slm ?chebiUse15: For a given list of LipidX lipid identifiers return the list of published Isomeric subspecies. Output should include the LipidX ID and the corresponding SwissLipids ID(s) and name(s) plus PubMed ID(s). This query first identifies SwissLipids identifiers for a given list of LipidX identifiers. It then retrieves the corresponding Isomeric subspecies that are linked to at least one publication, and the corresponding PMIDs. extends ex:15
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?swisslipid ?lipidx ?isomericsubSwisslipid ?pubmed WHERE { VALUES ?hmdb {'HMDB00269' 'MDB00032'} BIND (IRI(CONCAT('http://identifiers.org/lipidx/', ?lipidx)) AS ?lipidxIRI) ?swisslipid rdfs:seeAlso ?lipidxIRI . ?swisslipid rdfs:subClassOf ?isomericsubSwisslipid . ?isomericsubSwisslipid SWISSLIPID:rank SWISSLIPID:Isomeric_Subspecies . ?isomericsubSwisslipid SWISSLIPID:citation ?pubmed . }Use26: Lipids produced in different organisms
PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rh: <http://rdf.rhea-db.org/> PREFIX up: <http://purl.uniprot.org/core/> SELECT ?swisslipid ?organism { ?swisslipid owl:equivalentClass ?chebi . SERVICE <https://sparql.rhea-db.org/sparql> { ?rhea rh:side/rh:contains/rh:compound ?compound . ?compound (rh:chebi|(rh:reactivePart/rh:chebi)|(rh:underlyingChebi/rh:chebi)) ?metabolite . } SERVICE <https://sparql.uniprot.org/sparql> { ?catalyticActivityAnnotation up:catalyticActivity/up:catalyzedReaction ?rhea . ?protein up:annotation ?catalyticActivityAnnotation ; up:organism ?organism . } }Use27: Find the list of SwissLipids for all organisms and their Isomeric subspecies
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rh: <http://rdf.rhea-db.org/> PREFIX up: <http://purl.uniprot.org/core/> SELECT ?swisslipid ?organism { ?swisslipid owl:equivalentClass ?chebi . SERVICE <https://sparql.rhea-db.org/sparql> { ?rhea rh:side/rh:contains/rh:compound ?compound . ?compound (rh:chebi|(rh:reactivePart/rh:chebi)|(rh:underlyingChebi/rh:chebi)) ?metabolite . } SERVICE <https://sparql.uniprot.org/sparql> { ?catalyticActivityAnnotation up:catalyticActivity/up:catalyzedReaction ?rhea . ?protein up:annotation ?catalyticActivityAnnotation ; up:organism ?organism . } ?swisslipidIsomericSubpecies rdfs:subClassOf ?swisslipid ; SWISSLIPID:rank SWISSLIPID:Isomeric_Subspecies . }Use34: Lipids affected by human enzymes
PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rh: <http://rdf.rhea-db.org/> PREFIX taxon: <http://purl.uniprot.org/taxonomy/> PREFIX up: <http://purl.uniprot.org/core/> SELECT ?swisslipid { ?swisslipid owl:equivalentClass ?chebi . SERVICE <https://sparql.rhea-db.org/sparql> { ?rhea rh:side/rh:contains/rh:compound ?compound . ?compound (rh:chebi|(rh:reactivePart/rh:chebi)|(rh:underlyingChebi/rh:chebi)) ?metabolite . } SERVICE <https://sparql.uniprot.org/sparql> { ?catalyticActivityAnnotation up:catalyticActivity/up:catalyzedReaction ?rhea . ?protein up:annotation ?catalyticActivityAnnotation ; up:organism taxon:9606 . } }Use35: Lipids by fatty acid component (hexadecanoate) at position sn1
PREFIX CHEBI: <http://purl.obolibrary.org/obo/CHEBI_> PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT ?swisslipid WHERE { VALUES (?chebi) { (CHEBI:7896) #hexadecanoate } ?swisslipidHexadeconate owl:equivalentClass ?chebi . ?swisslipid SWISSLIPID:hasPart [ SWISSLIPID:derived_from ?swisslipidHexadecanoate ; SWISSLIPID:position SWISSLIPID:sn1 ] }Use36: Returns the list of isomeric subspecies containing a specific combination of fatty acids at defined positions, but only those isomeric subspecies that are associated with a publication. If the user supplies a single fatty acid and position (e.g. hexadecanoate at sn1), find all lipids with that fatty acid at that position, irrespective of whether or not there are other fatty acids at positions (here sn2, sn3). could generalize this query to allow logical combinations of fatty acids (e.g. hexadecanoate at sn1 AND (9Z)-octadecenoate at sn2, hexadecanoate at sn1 AND NOT (9Z)-octadecenoate at sn2, etc) Output should include the corresponding SwissLipids ID(s) and name(s) and PMIDs.
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?startId ?startName ?tail1 ?tailName1 ?tail2 ?tailName2 ?id ?name ?pubmed WHERE { VALUES ?startId { SWISSLIPID:000121946 } ?startId rdfs:label ?startName . # tail components ?startId SWISSLIPID:haspart ?tail1 . ?startId SWISSLIPID:haspart ?tail2 . FILTER(!sameTerm(?tail1, ?tail2)) ?tail1 rdfs:label ?tailName1 . ?tail2 rdfs:label ?tailName2 . # Retrieve lipids with similar tails ?id SWISSLIPID:haspart ?tail1 , ?tail2 . # Restrict to isomeric subspecies with PubMed citation(s) ?id SWISSLIPID:rank SWISSLIPID:Isomeric_Subspecies . ?id SWISSLIPID:citation ?pubmed . # Retrieve name ?id rdfs:label ?name . } ORDER BY ?id ?tail1 ?tail2Use37: Returns the list of isomeric subspecies that contain the same fatty acid component(s) at the same position(s) as a user-defined lipid. The user supplies a lipid ID, from which we first retrieve the fatty acids and their positions, after which we search for other lipids with the same combination of fatty acids at the same positions. This query could be useful in the website (classification tab): for a given lipid, provide a list of the other lipids with the same “tail” e.g. for PA(16:0/18:1(9Z)) => hexadecanoate@sn1 AND (9Z)-octadecenoate@sn2 => PC(16:0/18:1(9Z)), PE(16:0/18:1(9Z)), PG(16:0/18:1(9Z)), PI(16:0/18:1(9Z)), PIP[3](16:0/18:1(9Z)), PIP[4](16:0/18:1(9Z)), PIP[5](16:0/18:1(9Z)), PI2P[3,4](16:0/18:1(9Z)), PI2P[4,5](16:0/18:1(9Z)), PI2P[3,5](16:0/18:1(9Z)), PI3P[3,4,5](16:0/18:1(9Z)), PS(16:0/18:1(9Z))… Output should include the corresponding SwissLipids ID(s) and name(s).
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 37 SELECT ?startId ?startName ?tail1 ?tailName1 ?tail2 ?tailName2 ?id ?name WHERE { VALUES ?startId { SWISSLIPID:000121946 } ?startId rdfs:label ?startName . # tail components ?startId SWISSLIPID:haspart ?tail1 . ?startId SWISSLIPID:haspart ?tail2 . FILTER(!sameTerm(?tail1, ?tail2)) ?tail1 rdfs:label ?tailName1 . ?tail2 rdfs:label ?tailName2 . # Retrieve lipids with similar tails ?id SWISSLIPID:haspart ?tail1 , ?tail2 . # Restrict to isomeric subspecies with PubMed citation(s) ?id SWISSLIPID:rank SWISSLIPID:Isomeric_Subspecies . # Retrieve name ?id rdfs:label ?name . } ORDER BY ?id ?tail1 ?tail2Use38: Returns the list of isomeric subspecies that contain the same fatty acid component(s) at the same position(s) as a user-defined lipid, but limits the output to published lipids linked to a PMID. Output should include the corresponding SwissLipids ID(s) and name(s) and the PMID(s) for each. Extends ex:36 Output should include the corresponding SwissLipids ID(s) and name(s).
PREFIX SWISSLIPID: <https://swisslipids.org/rdf/SLM_> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> # Example 38 SELECT ?startId ?startName ?tail1 ?tailName1 ?tail2 ?tailName2 ?id ?name ?pubmed WHERE { VALUES ?startId { SWISSLIPID:000121946 } ?startId rdfs:label ?startName . # tail components ?startId SWISSLIPID:haspart ?tail1 . ?startId SWISSLIPID:haspart ?tail2 . FILTER(!sameTerm(?tail1, ?tail2)) ?tail1 rdfs:label ?tailName1 . ?tail2 rdfs:label ?tailName2 . # Retrieve lipids with similar tails ?id SWISSLIPID:haspart ?tail1 , ?tail2 . # Restrict to isomeric subspecies with PubMed citation(s) ?id SWISSLIPID:rank SWISSLIPID:Isomeric_Subspecies . ?id SWISSLIPID:citation ?pubmed . # Retrieve name ?id rdfs:label ?name . } ORDER BY ?id ?tail1 ?tail2Use