User:Pathwaybot/query examples

Welcome to WikiProject Gene Wiki
This page documents the Pathway bot, that it is maintained within the Wikiproject Gene Wiki. It is a WikiProject dedicated to make and maintiain Wikidata as a central hub of linked knowledge on Genes, Proteins, Diseases, Drugs, and related concepts.

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 ;
}
Try it!

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:

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:

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:

And try this visualisation too.

Combinatorial queriesEdit

WikiPathways and ReactomeEdit

WikiPathways and Reactome entries that share the same citationEdit

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:

All compounds which are potentially targeting Signaling by NOTCH1 in Cancer (Q37753018) (Reactome)Edit

The following query uses these:

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:

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 .
  }
}
Try it!

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". }
    }