User:Pathwaybot/query examples
On this page query examples on pathway content on Wikidata. Query suggestion or requests are more than welcome. Request and suggestion can be submitted to the Discussion page
Source specific queriesEdit
WikiPathwaysEdit
List all items sourced from WikiPathwaysEdit
SELECT * WHERE {
?item wdt:P2410 ?wpid ;
}
List all items sourced from WikiPathways and the last update in WikidataEdit
The following query uses these:
- Properties: WikiPathways ID (P2410)
SELECT ?item ?itemLabel ?dateModifier WHERE { ?item wdt:P2410 ?wpid ; schema:dateModified ?dateModifier . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Chromosomal positions of genes in a WikiPathwaysEdit
For pathway WP534 in this case:
The following query uses these:
- Properties: has part(s) (P527) , WikiPathways ID (P2410) , chromosome (P1057) , short name (P1813) , HGNC gene symbol (P353) , genomic start (P644) , genomic end (P645) , genomic assembly (P659)
SELECT DISTINCT ?name ?chr ?start ?stop WITH { SELECT DISTINCT ?gene ?name ?chr WHERE { VALUES ?pathwayID { "WP534" } ?pathway wdt:P527 ?gene ; wdt:P2410 ?pathwayID . ?gene wdt:P1057/wdt:P1813 ?chr ; wdt:P353 ?name . } } AS %result WHERE { INCLUDE %result ?gene p:P644 [ pq:P659 wd:Q20966585 ; ps:P644 ?start ] . ?gene p:P645 [ pq:P659 wd:Q20966585 ; ps:P645 ?stop ] }
And try this visualisation too.
ReactomeEdit
List all items sourced from ReactomeEdit
The following query uses these:
- Properties: Reactome ID (P3937)
SELECT DISTINCT ?pathway ?pathwayLabel ?reactomeID WHERE { ?pathway wdt:P3937 ?reactomeID . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
List all items sourced from Reactome and the last update in WikidataEdit
The following query uses these:
- Properties: Reactome ID (P3937)
SELECT ?item ?itemLabel ?dateModifier WHERE { ?item wdt:P3937 ?wpid ; schema:dateModified ?dateModifier . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Get all top level entries from ReactomeEdit
The following query uses these:
- Properties: Reactome ID (P3937) , has part(s) (P527)
SELECT DISTINCT ?item ?itemLabel WHERE { ?item wdt:P3937 ?reactome_id ; wdt:P527 ?pwpart . FILTER NOT EXISTS { ?parent wdt:P527 ?item . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Get all child nodes from ReactomeEdit
The following query uses these:
- Properties: Reactome ID (P3937) , has part(s) (P527) , instance of (P31)
SELECT DISTINCT ?item ?itemLabel WHERE { ?item wdt:P3937 ?reactome_id ; wdt:P527 ?pwpart . FILTER NOT EXISTS { {?pwpart wdt:P31 wd:Q4915012 } UNION {?pwpart wdt:P31 wd:Q2996394 } ?pwpart wdt:P527 ?child_node . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Visualize the hierarchies captured in ReactomeEdit
The following query uses these:
- Properties: Reactome ID (P3937) , part of (P361)
Features: Graph (Q24515287)
#defaultView:Graph
SELECT ?item ?itemLabel ?pwpart ?pwpartLabel WHERE {
#VALUES ?pwpart {wd:Q34340147}
?item wdt:P3937 ?reactomeID1 .
?item wdt:P361+ ?pwpart .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Chromosomal positions of genes in a ReactomeEdit
For pathway R-HSA-532668 in this case:
The following query uses these:
- Properties: has part(s) (P527) , encoded by (P702) , Reactome ID (P3937) , chromosome (P1057) , short name (P1813) , HGNC gene symbol (P353) , genomic start (P644) , genomic end (P645) , genomic assembly (P659)
SELECT DISTINCT ?name ?chr ?start ?stop WITH { SELECT DISTINCT ?gene ?name ?chr WHERE { VALUES ?pathwayID { "R-HSA-532668" } ?pathway wdt:P527+/wdt:P702 ?gene ; wdt:P3937 ?pathwayID . ?gene wdt:P1057/wdt:P1813 ?chr ; wdt:P353 ?name . } } AS %result WHERE { INCLUDE %result ?gene p:P644 [ pq:P659 wd:Q20966585 ; ps:P644 ?start ] . ?gene p:P645 [ pq:P659 wd:Q20966585 ; ps:P645 ?stop ] }
And try this visualisation too.
Combinatorial queriesEdit
WikiPathways and ReactomeEdit
Edit
The following query uses these:
- Properties: WikiPathways ID (P2410) , cites work (P2860) , Reactome ID (P3937)
SELECT ?wp_pathway ?wp_pathwayLabel ?cites ?citesLabel ?reactome_pathway ?reactome_pathwayLabel WHERE { ?wp_pathway wdt:P2410 ?wpid ; wdt:P2860 ?cites . ?reactome_pathway wdt:P3937 ?reactomeid ; wdt:P2860 ?cites . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
Pathways and PDBEdit
Biological pathways with protein structures in the PDB databaseEdit
The following query uses these:
- Properties: instance of (P31) , has part(s) (P527) , encodes (P688) , PDB structure ID (P638) , WikiPathways ID (P2410) , Reactome ID (P3937)
SELECT ?pathway ?pathwayLabel ?WikiPathways ?Reactome (COUNT(DISTINCT ?protein) as ?count) WHERE { VALUES ?pathwayType { wd:Q4915012 wd:Q2996394 } ?pathway wdt:P31 ?pathwayType . { ?pathway wdt:P527/wdt:P688 ?protein . } UNION { ?pathway wdt:P527 ?protein . } ?protein wdt:P638 ?PDBID . OPTIONAL { ?pathway wdt:P2410 ?WikiPathways } OPTIONAL { ?pathway wdt:P3937 ?Reactome } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?pathway ?pathwayLabel ?WikiPathways ?Reactome ORDER BY DESC(?count)
Compounds and PathwaysEdit
All compounds which are potentially targeting Parkinsons Disease Pathway (Q29883419) (Wikipathways)Edit
The following query uses these:
- Properties: WikiPathways ID (P2410) , has part(s) (P527) , encodes (P688) , physically interacts with (P129)
SELECT ?wpid ?gene ?geneLabel ?protein ?proteinLabel ?compound ?compoundLabel WHERE { wd:Q29883419 wdt:P2410 ?wpid; wdt:P527 ?gene. ?gene wdt:P688 ?protein. ?protein wdt:P129 ?compound . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
All compounds which are potentially targeting Signaling by NOTCH1 in Cancer (Q37753018) (Reactome)Edit
The following query uses these:
- Properties: part of (P361) , has part(s) (P527) , UniProt protein ID (P352) , encodes (P688) , physically interacts with (P129)
SELECT DISTINCT ?gene ?geneLabel ?protein ?proteinLabel ?compound ?compoundLabel WHERE { VALUES ?item {wd:Q37753018} ?pwpart wdt:P361* ?item ; wdt:P527 ?protein . ?protein wdt:P352 ?uniprot . ?gene wdt:P688 ?protein . ?protein wdt:P129 ?compound . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
WikiPathways and CIViCEdit
Get known variants reported in CIViC database (Q27612411) for genes reported in a WikiPathways pathway : Bladder cancer (Q30230812)Edit
The following query uses these:
- Items: bladder cancer (Q504775)
- Properties: WikiPathways ID (P2410) , has part(s) (P527) , subclass of (P279) , CIViC variant ID (P3329) , biological variant of (P3433) , positive therapeutic predictor for (P3354) , negative therapeutic predictor for (P3355) , positive diagnostic predictor for (P3356) , negative diagnostic predictor for (P3357) , positive prognostic predictor for (P3358) , negative prognostic predictor for (P3359) , medical condition treated (P2175)
SELECT DISTINCT ?pathway ?pathwayLabel ?pwpart ?pwpartLabel ?variant ?variantLabel ?disease?diseaseLabel WHERE { VALUES ?predictor {p:P3354 p:P3355 p:P3356 p:P3357 p:P3358 p:P3359} VALUES ?predictorQualifier {pq:P2175} VALUES ?wpID {"WP2828"} ?pathway wdt:P2410 ?wpID ; # Pathways has a WikiPathways identifier wdt:P527 ?pwpart . # which contains pathways parts ?disease wdt:P279+ wd:Q504775 . # The disease is a subclass of urinary bladder cancer # based on annotations in the Disease ontology ?variant wdt:P3329 ?civicID ; # a variant known in CIViC ?predictor ?node ; # has a predicting relation with diseases # labeled as being a subclass of urinary bladder cancer wdt:P3433 ?pwpart . # variant is biological variant of {?node ?predictorStatement ?drug_label ; ?predictorQualifier ?disease .} UNION { ?node ?predictorStatement ?disease . } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Federated queriesEdit
Wikidata and the SPARQL endpoint of WikiPathwaysEdit
The endpoint has a UI at https://sparql.wikipathways.org and the SPARQL endpoint lives at https://sparql.wikipathways.org/sparql
Known interaction types in WikiPathways for a pathway with Identifier WP716Edit
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
SELECT DISTINCT ?interaction_type WHERE {
VALUES ?wpid {"WP716"}
?item wdt:P2410 ?wpid ;
wdt:P2888 ?source_pathway .
SERVICE <http://sparql.wikipathways.org/sparql> {
?wp_pathway dc:identifier ?source_pathway .
?s dcterms:isPartOf ?wp_pathway, ?interaction .
?interaction rdf:type wp:Interaction .
?interaction rdf:type ?interaction_type .
?interaction wp:participants ?participants .
}
}
Local annotations from WikiPathways using Federated query on a Pathway with identifier WP716Edit
The following query uses these:
- Properties: WikiPathways ID (P2410) , exact match (P2888)
PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX wp: <http://vocabularies.wikipathways.org/wp#> SELECT DISTINCT ?item ?pw_annotation WHERE { VALUES ?wpid {"WP716"} ?item wdt:P2410 ?wpid ; wdt:P2888 ?source_pathway . SERVICE <http://sparql.wikipathways.org/sparql> { ?wp_pathway dc:identifier ?source_pathway . ?wp_pathway wp:ontologyTag ?pw_annotation . # ?pw_annotation rdfs:label ?annotation_label . } }
Lists SMILES of substrates and products of metabolic conversions.Edit
The following query uses these:
- Properties: canonical SMILES (P233) , isomeric SMILES (P2017)
PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX wp: <http://vocabularies.wikipathways.org/wp#> SELECT DISTINCT ?sourceWD ?sourceWDLabel ?sourceSMILES ?targetWD ?targetWDLabel ?targetSMILES WITH { SELECT ?sourceWD ?targetWD WHERE { SERVICE <http://sparql.wikipathways.org/sparql> { ?pathway a wp:Pathway . ?interaction dcterms:isPartOf ?pathway . ?interaction a wp:Interaction, wp:Conversion . ?interaction wp:source ?source . ?source a wp:Metabolite; wp:bdbWikidata ?sourceWD . ?interaction wp:target ?target . ?target a wp:Metabolite; wp:bdbWikidata ?targetWD . } } } AS %results WHERE { INCLUDE %results OPTIONAL { ?sourceWD wdt:P233 ?sourceSMILEScan } OPTIONAL { ?sourceWD wdt:P2017 ?sourceSMILESiso } BIND (COALESCE(?sourceSMILESiso, ?sourceSMILEScan) AS ?sourceSMILES) OPTIONAL { ?targetWD wdt:P233 ?targetSMILEScan } OPTIONAL { ?targetWD wdt:P2017 ?targetSMILESiso } BIND (COALESCE(?targetSMILESiso, ?targetSMILEScan) AS ?targetSMILES) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Lists metabolites in WikiPathways and InChIKeys from WikidataEdit
The following query uses these:
- Properties: InChIKey (P235)
PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX wp: <http://vocabularies.wikipathways.org/wp#> SELECT DISTINCT ?metabolite ?wikidata ?inchikey WITH { SELECT ?metabolite ?wikidata WHERE { SERVICE <http://sparql.wikipathways.org/sparql> { ?metabolite a wp:Metabolite ; wp:bdbWikidata ?wikidata . } } } AS %results WHERE { INCLUDE %results ?wikidata wdt:P235 ?inchikey . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Lists metabolites in WikiPathways with InChIKeys and formal charge from WikidataEdit
The following query uses these:
- Properties: InChIKey (P235)
PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX wp: <http://vocabularies.wikipathways.org/wp#> SELECT DISTINCT ?metabolite ?wikidata ?inchikey ?charge WITH { SELECT ?metabolite ?wikidata WHERE { SERVICE <http://sparql.wikipathways.org/sparql> { ?metabolite a wp:Metabolite ; wp:bdbWikidata ?wikidata . } } } AS %results WHERE { INCLUDE %results ?wikidata wdt:P235 ?inchikey . bind( if(substr(?inchikey,27) = "N", "0"^^xsd:integer, if(substr(?inchikey,27) = "M", "-1"^^xsd:integer, if(substr(?inchikey,27) = "O", "+1"^^xsd:integer, if(substr(?inchikey,27) = "L", "-2"^^xsd:integer, if(substr(?inchikey,27) = "P", "+2"^^xsd:integer, if(substr(?inchikey,27) = "K", "-3"^^xsd:integer, if(substr(?inchikey,27) = "J", "-4"^^xsd:integer, if(substr(?inchikey,27) = "I", "-5"^^xsd:integer, if(substr(?inchikey,27) = "F", "-8"^^xsd:integer, "999"^^xsd:integer # ERROR ) ) ) ) ) ) ) ) ) as ?charge ) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
Lists metabolites in WikiPathways and chemical formulas and names from WikidataEdit
The following query uses these:
- Properties: chemical formula (P274)
PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX wp: <http://vocabularies.wikipathways.org/wp#> SELECT DISTINCT ?metabolite ?wikidata ?wikidataLabel ?chemFormula WITH { SELECT ?metabolite ?wikidata WHERE { SERVICE <http://sparql.wikipathways.org/sparql> { ?metabolite a wp:Metabolite ; wp:bdbWikidata ?wikidata . } } } AS %results WHERE { INCLUDE %results ?wikidata wdt:P274 ?chemFormula . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }