WolfgangFahl / snapquery

Frontend to Introduce Named Queries and Named Query Middleware to wikidata
Apache License 2.0
7 stars 4 forks source link

add domain to NamedQueries #39

Closed WolfgangFahl closed 4 months ago

WolfgangFahl commented 4 months ago

This json shows the new style:

{
  "domain": "orkg.org",
  "namespace": "examples",
  "target_graph_name": "orkg",
  "queries": [
    {
      "query_id": "ComputerSciencePapers--examples@orkg.org",
      "domain": "orkg.org",
      "namespace": "examples",
      "name": "ComputerSciencePapers",
      "sparql": "PREFIX orkgr: <http://orkg.org/orkg/resource/>\nPREFIX orkgc: <http://orkg.org/orkg/class/>\nPREFIX orkgp: <http://orkg.org/orkg/predicate/>\nSELECT ?paper ?paper_title ?doi\n  WHERE {\n    ?paper rdf:type orkgc:Paper ;\n           rdfs:label ?paper_title ;\n           orkgp:P30 orkgr:R132 \n    OPTIONAL { ?paper orkgp:P26 ?doi } .\n}\nLIMIT 5",
      "url": "https://orkg.org/sparql",
      "title": "ORKG papers of the research field \"Computer Sciences\"",
      "description": "List 5 papers from the Computer Sciences research field in ORKG, including their titles and DOIs if available."
    },
    {
      "query_id": "PaperMetadata--examples@orkg.org",
      "domain": "orkg.org",
      "namespace": "examples",
      "name": "PaperMetadata",
      "sparql": "PREFIX orkgr: <http://orkg.org/orkg/resource/>\nPREFIX orkgc: <http://orkg.org/orkg/class/>\nPREFIX orkgp: <http://orkg.org/orkg/predicate/>\n    \nSELECT ?paper ?paper_title \n       ?url ?author\n       ?venue ?venue_label\n       ?doi ?publication_month ?publication_year\n       ?research_field ?research_field_label\n       ?contribution\nWHERE {\n    # comment out the BINDing line to get the metadata of all papers.\n    BIND(orkgr:R141003 AS ?paper)\n    \n    ?paper rdf:type orkgc:Paper;\n           rdfs:label ?paper_title ;\n           orkgp:hasAuthors ?authors ;\n           orkgp:P30 ?research_field .\n    \n    ?research_field rdfs:label ?research_field_label .\n    \n    ?authors ?seq_n ?author .\n    \n    OPTIONAL { ?paper orkgp:P26 ?doi } .\n    OPTIONAL { ?paper orkgp:url ?url } .\n    OPTIONAL { ?paper orkgp:P28 ?publication_month } .\n    OPTIONAL { ?paper orkgp:P29 ?publication_year } .\n    OPTIONAL { ?paper orkgp:HAS_VENUE ?venue .\n               ?venue rdfs:label ?venue_label } .\n    OPTIONAL { ?paper orkgp:P31 ?contribution } .\n    FILTER(REGEX(STR(?seq_n), CONCAT(STR(rdf:), \"_\\\\d+\")))\n}\nLIMIT 25",
      "url": "https://orkg.org/sparql",
      "title": "Metadata of a specific or all ORKG paper(s)",
      "description": "Retrieve detailed metadata for a specific ORKG paper (or all papers if the BIND line is commented out), including title, authors, venue, DOI, publication date, research field, and contributions."
    }
  ]
}
WolfgangFahl commented 4 months ago

this jq script is an example for updating the content

{
  "domain": "bitplan.com",
  "namespace": "federated-queries",
  "target_graph_name": "wikidata",
  "queries": [
    {
      "query_id": "ATMs around Munich belonging to the Bankcard-Servicenetz interbank network (federated query)--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "ATMs around Munich belonging to the Bankcard-Servicenetz interbank network (federated query)",
      "sparql": "#defaultView:Map{\"hide\":[\"?atm\",\"?geometry\"], \"layer\": \"?bankLabel\"}\nPREFIX bif: <bif:>\nSELECT ?atm ?geometry ?bank ?bankLabel WHERE {\n  hint:Query hint:optimizer \"None\".\n\n  SERVICE <http://linkedgeodata.org/sparql> {\n    { ?atm a lgdo:Bank; lgdo:atm true. }\n    UNION { ?atm a lgdo:Atm. }\n\n    ?atm geom:geometry [geo:asWKT ?geometry];\n         lgdo:operator ?operator.\n    FILTER(bif:st_intersects(?geometry, bif:st_point(11.5746898, 48.1479876), 5)) # 5 km around Munich\n  }\n\n  BIND(STRLANG(?operator, \"de\") as ?bankLabel)\n  ?bank rdfs:label ?bankLabel.\n\n  # bank is part of the Bankcard service network, either via an explicit statement or implicitly due to its legal form (unless explicitly excluded)\n  { ?bank wdt:P527 wd:Q806724. }\n  UNION { ?bank wdt:P1454 wd:Q5349747. }\n  MINUS { wd:Q806724 wdt:P3113 ?bank. }\n}\n",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#ATMs_around_Munich_belonging_to_the_Bankcard-Servicenetz_interbank_network_(federated_query)",
      "title": "ATMs around Munich belonging to the Bankcard-Servicenetz interbank network (federated query)",
      "description": ""
    },
    {
      "query_id": "Metabolite-metabolite interactions (mostly conversions) and their pKa change (federated query)--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Metabolite-metabolite interactions (mostly conversions) and their pKa change (federated query)",
      "sparql": "#defaultView:Dimensions\nSELECT DISTINCT ?wpid ?metaboliteLabel ?pKa ?pKa2 ?metabolite2Label ?wpid2\nWITH {\n  SELECT ?wpid ?source_pathway ?metabolite ?pKa ?pKa2 ?metabolite2 ?wpid2\n  WHERE {\n    # VALUES ?wpid { \"WP550\" }\n    ?pathway wdt:P2410 ?wpid ;\n             wdt:P527 ?metabolite ;\n             wdt:P2888 ?source_pathway .\n    ?metabolite wdt:P1117 ?pKa .\n\n    SERVICE <http://sparql.wikipathways.org/sparql> {\n      ?wp_mb1 wp:bdbWikidata ?metabolite .\n      ?wp_mb1 dcterms:isPartOf ?interaction .\n      ?interaction rdf:type wp:Interaction .\n      ?wp_mb2 dct:isPartOf ?interaction .\n      ?wp_mb2 wp:bdbWikidata ?metabolite2 .\n      FILTER (?wp_mb1 != ?wp_mb2)\n    }\n  }\n} AS %result\nWHERE {\n  INCLUDE %result\n  ?metabolite2 wdt:P1117 ?pKa2 .\n  ?pathway2 wdt:P2410 ?wpid2 ;\n             wdt:P527 ?metabolite2 ;\n  SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],en\". }\n}",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Metabolite-metabolite_interactions_(mostly_conversions)_and_their_pKa_change_(federated_query)",
      "title": "Metabolite-metabolite interactions (mostly conversions) and their pKa change (federated query)",
      "description": "Federated query using the WikiPathways SPARQL endpoint to retrieve interaction information. The dimensions plot show the pKa changes during metabolite-metabolite interaction. It must be noted here that many very basic or very acidic are reported in pathways as the uncharged structure, whereas in normal biological pathways these compounds are charged and then have quite different pKa charges."
    },
    {
      "query_id": "Biomarkers in Wikidata which interact with proteins in human pathways from Wikipathways--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Biomarkers in Wikidata which interact with proteins in human pathways from Wikipathways",
      "sparql": "SELECT DISTINCT ?biomarkerLabel ?proteinLabel ?geneID ?WP_gene ?PathwayID ?PathwayName #results that are displayed.\nWHERE {\n  VALUES ?biomarker {wd:Q420633 wd:Q27125809 wd:Q422462} #you can add more biomarkers here if needed, separated by a space.\n  ?biomarker wdt:P31 wd:Q11173. #Stating that all biomarkers have to be \"instance of\" \"chemical compound\" (you could ommit this, but query will probably take longer).\n  ?biomarker wdt:P638 ?pdbID . #Checking if a biomarker has a Protein Databank ID (PDB) -> meaning the metabolite can interact with a protein.\n  ?protein wdt:P31 wd:Q8054 . #Stating that all proteins are \"instance of\" \"protein\"\n  ?protein wdt:P638 ?pdbID . #Checking which proteins have a PDB ID, which we queried previously in relationship to the biomarkers.\n  ?protein wdt:P702 ?gene . #Connecting the protein to a gene (\"encoded by\" relationship) -> to get an identifier we can use later in federated WikiPathways query.\n  ?gene wdt:P703 wd:Q15978631 . #Now removing all genes that are not found in species \"Homo sapiens\". -> This info is not always available for proteins in WikiData.\n  ?gene wdt:P2888 ?geneID . #Getting the \"exact match\" identifier for the gene, related to the protein, related to the biomarker.\n\n  ##The IRI from Wikidata starts with http:// , where the one from WikiPathways starts with https:// , so we need to rewrite the IRI\n    BIND(                      # Bind the created IRI into a new variable (called ?newIRI)\n        IRI(                   # Convert the string back to an IRI\n          CONCAT(              # Concatenate item 1 and 2 together as one string\n               \"https\",        # First item to concat (more items can be added with a comma\n              #Second item to concat:\n               SUBSTR(         # Obtain a substring\n                 STR(?geneID), # Convert the geneID IRI from Wikidata to a string,\n                 5)            # removing the first 5 characters (<http)\n        )) AS ?newIRI          # Name for the new variable\n    )\n\n  SERVICE <http://sparql.wikipathways.org/sparql> { #Connecting to the WikiPathways SPARQL endpoint.\n     ?WP_pathway a wp:Pathway . #Stating a ?WP_pathway is indeed a pathway in the WikiPathways RDF .\n     ?WP_pathway wp:organismName \"Homo sapiens\" . #Removing all PWs not for species Homo sapiens.\n     ?WP_pathway dc:identifier ?PathwayID . #Query the identifier of the pathway in WPs.\n     ?WP_pathway dc:title ?PathwayName . #Obtaining the name of the pathway.\n\n     ?WP_gene a wp:Protein . #Stating that a ?WP_gene is a Protein DataNode (you could ommit this, to also get all DataNodes modeled as GeneProducts out, but query will take longer).\n     ?WP_gene wp:bdbEntrezGene ?newIRI . #Connecting the previously queried \"exact match\" from WikiData to the NCBI/Entrez Gene ID in WPs.\n     ?WP_gene dct:isPartOf ?WP_pathway . #Connecting the WP_gene to the WP_pathway.\n\n   }\n OPTIONAL {?biomarker rdfs:label ?biomarkerLabel. #Create a label (aka name) for the biomarkers in WikiData, without using the service query.\nFILTER(LANG(?biomarkerLabel) = \"en\").\n}\n   OPTIONAL {?protein rdfs:label ?proteinLabel. #Create a label(aka name) for the proteins in WikiData, without using the service query.\nFILTER(LANG(?proteinLabel) = \"en\").\n}\n\n}\nORDER BY DESC (?biomarkerLabel) #Order results for biomarkers",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Biomarkers_in_Wikidata_which_interact_with_proteins_in_human_pathways_from_Wikipathways",
      "title": "Biomarkers in Wikidata which interact with proteins in human pathways from Wikipathways",
      "description": ""
    },
    {
      "query_id": "Known interaction types in Wikipathways for a pathway with Identifier WP716 (federated query)--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Known interaction types in Wikipathways for a pathway with Identifier WP716 (federated query)",
      "sparql": "SELECT DISTINCT ?interaction_type WHERE {\n  VALUES ?wpid {\"WP716\"}\n  ?item wdt:P2410 ?wpid ;\n        wdt:P2888 ?source_pathway .\n\n  SERVICE <http://sparql.wikipathways.org/sparql> {\n     ?wp_pathway dc:identifier ?source_pathway .\n     ?s dct:isPartOf ?wp_pathway, ?interaction .\n     ?interaction rdf:type wp:Interaction .\n     ?interaction rdf:type ?interaction_type .\n     ?interaction wp:participants ?participants .\n  }\n}",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Known_interaction_types_in_Wikipathways_for_a_pathway_with_Identifier_WP716_(federated_query)",
      "title": "Known interaction types in Wikipathways for a pathway with Identifier WP716 (federated query)",
      "description": ""
    },
    {
      "query_id": "Local annotations from Wikipathways using Federated query on a Pathway with identifier WP716 (federated query)--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Local annotations from Wikipathways using Federated query on a Pathway with identifier WP716 (federated query)",
      "sparql": "SELECT DISTINCT ?item ?pw_annotation WHERE {\n  VALUES ?wpid {\"WP716\"}\n  ?item wdt:P2410 ?wpid ;\n        wdt:P2888 ?source_pathway .\n\n  SERVICE <http://sparql.wikipathways.org/sparql> {\n     ?wp_pathway dc:identifier ?source_pathway .\n     ?wp_pathway wp:ontologyTag ?pw_annotation .\n     # ?pw_annotation rdfs:label ?annotation_label .\n   }\n}\n",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Local_annotations_from_Wikipathways_using_Federated_query_on_a_Pathway_with_identifier_WP716_(federated_query)",
      "title": "Local annotations from Wikipathways using Federated query on a Pathway with identifier WP716 (federated query)",
      "description": ""
    },
    {
      "query_id": "Universities ranked by PageRank on English Wikipedia (federated query)--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Universities ranked by PageRank on English Wikipedia (federated query)",
      "sparql": "SELECT DISTINCT ?uni ?uniLabel ?pr WHERE {\n  ?uni wdt:P31/wdt:P279* wd:Q3918.\n  SERVICE <http://dbpedia.org/sparql> {\n    ?uni vrank:hasRank/vrank:rankValue ?pr\n  }\n  SERVICE wikibase:label {\n    bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],en\".\n  }\n} ORDER BY DESC(?pr) LIMIT 50",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Universities_ranked_by_PageRank_on_English_Wikipedia_(federated_query)",
      "title": "Universities ranked by PageRank on English Wikipedia (federated query)",
      "description": ""
    },
    {
      "query_id": "Editors of the WOP 2014--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Editors of the WOP 2014",
      "sparql": "# Editors of the WOP 2014\nSELECT DISTINCT ?editor ?editorName\nWHERE {\n  SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {\n    wd:Q113544723 wdt:P179 ?editor.\n    ?editor schema:name ?editorName.\n  }\n}",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples",
      "title": "Editors of the WOP 2014",
      "description": ""
    },
    {
      "query_id": "Birth place of all persons with a Wikidata link (using SERVICE)--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Birth place of all persons with a Wikidata link (using SERVICE)",
      "sparql": "SELECT ?person_name ?person_wikidata_id ?place_of_birth (COUNT(DISTINCT ?paper_title) AS ?count) ?coordinates WHERE {\n  ?person_dblp rdf:type dblp:Person .\n  ?person_dblp dblp:wikidata ?person_wikidata_id .\n  ?person_dblp ^dblp:authoredBy/dblp:title ?paper_title .\n  ?person_dblp rdfs:label ?person_name .\n  ?text ql:contains-entity ?paper_title .\n  ?text ql:contains-word \"graph algo*\" .\n  SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {\n    SELECT ?person_wikidata_id ?place_of_birth ?coordinates {\n\t  ?person_wikidata_id wdt:P2456 ?person_dblp_id .\n\t  ?person_wikidata_id wdt:P19 ?place_of_birth_id .\n\t  ?place_of_birth_id @en@rdfs:label ?place_of_birth .\n      ?place_of_birth_id wdt:P625 ?coordinates\n\t}\n  }\n}\nGROUP BY ?person_name ?person_wikidata_id ?place_of_birth ?coordinates\nORDER BY DESC(?count)",
      "url": "",
      "title": "Birth place of all persons with a Wikidata link (using SERVICE)",
      "description": ""
    },
    {
      "query_id": "Birth places for particular venues (using SERVICE)--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Birth places for particular venues (using SERVICE)",
      "sparql": "SELECT ?person_name ?person_wikidata_id ?place_of_birth (COUNT(DISTINCT ?paper) AS ?count) ?coordinates WHERE {\n  ?person_dblp rdf:type dblp:Person .\n  ?person_dblp dblp:wikidata ?person_wikidata_id .\n  ?person_dblp ^dblp:authoredBy ?paper .\n  ?paper dblp:publishedIn ?venue .\n  ?person_dblp rdfs:label ?person_name .\n  FILTER REGEX(?venue, \"SIGIR|CIKM|ECIR\")\n  SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {\n    SELECT ?person_wikidata_id ?place_of_birth ?coordinates {\n      ?person_wikidata_id wdt:P2456 ?person_dblp_id .\n      ?person_wikidata_id wdt:P19 ?place_of_birth_id .\n      ?place_of_birth_id @en@rdfs:label ?place_of_birth .\n      ?place_of_birth_id wdt:P625 ?coordinates\n    }\n  }\n}\nGROUP BY ?person_name ?person_wikidata_id ?place_of_birth ?coordinates\nHAVING (?count > 10)\nORDER BY DESC(?count)",
      "url": "",
      "title": "Birth places for particular venues (using SERVICE)",
      "description": ""
    },
    {
      "query_id": "Affiliations by conference (using SERVICE)--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": "Affiliations by conference (using SERVICE)",
      "sparql": "SELECT ?affiliation (COUNT(?venue) AS ?count) (GROUP_CONCAT(DISTINCT ?person_name) AS ?people) ?coordinates WHERE {\n  ?person_dblp rdf:type dblp:Person .\n  ?person_dblp dblp:wikidata ?person_wikidata_id .\n  ?person_dblp ^dblp:authoredBy/dblp:publishedIn ?venue .\n  ?person_dblp rdfs:label ?person_name .\n  FILTER REGEX(?venue, \"SIGIR|CIKM|ECIR\")\n  SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {\n    SELECT ?person_wikidata_id ?affiliation ?coordinates {\n      ?person_wikidata_id wdt:P2456 ?person_dblp_id .\n      ?person_wikidata_id wdt:P108 ?affiliation_id .\n      ?affiliation_id @en@rdfs:label ?affiliation .\n      ?affiliation_id wdt:P625 ?coordinates\n    }\n  }\n}\nGROUP BY ?affiliation ?coordinates\nHAVING (?count > 10)\nORDER BY DESC(?count)",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples",
      "title": "Affiliations by conference (using SERVICE)",
      "description": ""
    },
    {
      "query_id": " For orkg author get dblp id over orcid--federated-queries@bitplan.com",
      "domain": "bitplan.com",
      "namespace": "federated-queries",
      "name": " For orkg author get dblp id over orcid",
      "sparql": "# For orkg author get dblp id over orcid\nSELECT ?authorLabel ?orcid ?qid\nWHERE {\n  SERVICE <https://orkg.org/triplestore>{\n  orkgr:R599385 rdfs:label ?authorLabel.\n  orkgr:R599385 orkgp:HAS_ORCID ?orcid.\n  SERVICE <https://sparql.dblp.org/sparql>{\n      ?dblpAuthor datacite:hasIdentifier [\n\t\tdatacite:usesIdentifierScheme datacite:orcid ;\n\t\tlitre:hasLiteralValue ?orcid ;\n        a datacite:PersonalIdentifier\n\t  ].\n    ?dblpAuthor dblp:wikidata ?qid.\n  }\n  }\n}",
      "url": "https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples",
      "title": " For orkg author get dblp id over orcid",
      "description": ""
    }
  ]
}