diff --git a/.github/workflows/commit-index.yml b/.github/workflows/commit-index.yml index 774e937..e8b6ce1 100644 --- a/.github/workflows/commit-index.yml +++ b/.github/workflows/commit-index.yml @@ -8,10 +8,6 @@ on: push: branches: [master] tags: ['*'] - # Commits pushed by "Process SPARQL TTL files" do not trigger push workflows. - workflow_run: - workflows: ["Process SPARQL TTL files"] - types: [completed] workflow_dispatch: permissions: diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml new file mode 100644 index 0000000..a493742 --- /dev/null +++ b/.github/workflows/examples.yml @@ -0,0 +1,23 @@ +name: Examples + +# Checks the example .ttl files on every pull request and push. On master it also +# publishes the examples-index branch that the SPARQL editor reads: index.json, +# history.json, a snapshot per version, the combined Turtle file and .rq exports. +# The tools come from wikipathways/Snorql-UI (tools/examples). + +on: + pull_request: + push: + branches: [master] + tags: ['*'] + workflow_dispatch: + +jobs: + examples: + uses: wikipathways/Snorql-UI/.github/workflows/examples-index.yml@v1.4.0 + with: + tools-ref: v1.4.0 + publish: ${{ github.event_name != 'pull_request' }} + sib-project: WikiPathways + permissions: + contents: write diff --git a/.github/workflows/extractRQs.yml b/.github/workflows/extractRQs.yml deleted file mode 100644 index b5dc91b..0000000 --- a/.github/workflows/extractRQs.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Process SPARQL TTL files - -on: - workflow_dispatch: - push: - branches: - - master - -jobs: - extract: - name: Extract SPARQL files - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: 3.11 - - name: Install dependencies - run: pip install rdflib - - name: Extract - run: python scripts/transformDotTtlToDotSparql.py - - name: Lint headers - run: python scripts/lint_headers.py - - - name: Commit new .rq files - run: | - git config --global user.name 'GitHub Action' - git config --global user.email 'action@github.com' - git add . - if git diff --exit-code --staged; then - echo "No changes" - else - git pull - git commit -m 'Updated .rq files' - git push - fi diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml new file mode 100644 index 0000000..29916de --- /dev/null +++ b/.github/workflows/live-test.yml @@ -0,0 +1,28 @@ +name: Live test + +# Runs every example against the WikiPathways SPARQL endpoint once a week and +# checks the expected number of results (snorql:expect). A failing run means a +# query broke, an endpoint it federates with is down, or the data changed. + +on: + schedule: + - cron: '17 5 * * 1' + workflow_dispatch: + +jobs: + live: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: wikipathways/Snorql-UI + ref: v1.4.0 + path: .snorql-tools + sparse-checkout: tools/examples + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: pip install -r .snorql-tools/tools/examples/requirements.txt + - name: Run the examples + run: python .snorql-tools/tools/examples/snorql_examples.py live --timeout 150 diff --git a/A. Metadata/HomologyConvertedPathways.ttl b/A. Metadata/HomologyConvertedPathways.ttl new file mode 100644 index 0000000..6528374 --- /dev/null +++ b/A. Metadata/HomologyConvertedPathways.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ010 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ010" ; + rdfs:label "Homology-Converted Pathways"@en ; + rdfs:comment "List all homology converted pathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-10-20"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Metadata ; + schema:keywords "homology", "organism" ; + schema:target ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: +PREFIX dc: +PREFIX cur: + +SELECT DISTINCT ?pathway (str(?title) as ?PathwayTitle) ?organism +WHERE { + ?pathway wp:ontologyTag cur:Homology_Converted ; + a wp:Pathway ; + dc:title ?title ; + wp:organismName ?organism . +} ORDER BY ASC(?organism) ASC(?PathwayTitle)""" . diff --git a/A. Metadata/authors.ttl b/A. Metadata/authors.ttl new file mode 100644 index 0000000..7d9b1a0 --- /dev/null +++ b/A. Metadata/authors.ttl @@ -0,0 +1,40 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ011 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ011" ; + rdfs:label "Authors of All Pathways"@en ; + rdfs:comment "Lists all pathway authors with their name, homepage, and ORCID, along with the number of pathways each author created."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-01-13"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metadata ; + schema:keywords "metadata" ; + schema:target ; + snorql:alias "A. Metadata/authors.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX foaf: + +SELECT (COUNT(DISTINCT ?pathway) AS ?count) ?page ?name ?orcid WHERE { + ?author_ ^dc:creator ?pathway ; + a foaf:Person . + OPTIONAL { ?author_ foaf:homepage ?page } + OPTIONAL { ?author_ foaf:name ?name } + OPTIONAL { ?author_ dc:identifier ?orcid } +} GROUP BY ?page ?name ?orcid + ORDER BY DESC(?count)""" . diff --git a/A. Metadata/datacounts/PathwayCountPerOntologyTerm.ttl b/A. Metadata/datacounts/PathwayCountPerOntologyTerm.ttl new file mode 100644 index 0000000..5e50202 --- /dev/null +++ b/A. Metadata/datacounts/PathwayCountPerOntologyTerm.ttl @@ -0,0 +1,37 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ067 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ067" ; + rdfs:label "Pathway Count per Ontology Term"@en ; + rdfs:comment "Counts the pathways tagged with each ontology term. Pathways can be tagged with terms from the Pathway, Cell Line and Disease ontologies; wp:ontologyTag covers all of them, as well as the curation and community tags."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-10-20"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DataCounts ; + schema:keywords "counts", "ontology" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: + +SELECT DISTINCT ?pwOntologyTerm (count(?pwOntologyTerm) as ?pathwayCount) +WHERE { + ?pathwayRDF wp:ontologyTag ?pwOntologyTerm . +} +GROUP BY ?pwOntologyTerm +ORDER BY DESC(?pathwayCount)""" . diff --git a/A. Metadata/datacounts/averagePerPathway.ttl b/A. Metadata/datacounts/averagePerPathway.ttl new file mode 100644 index 0000000..53b5cf3 --- /dev/null +++ b/A. Metadata/datacounts/averagePerPathway.ttl @@ -0,0 +1,57 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ012 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ012" ; + rdfs:label "Average Entity Type per Pathway"@en ; + rdfs:comment "Calculates the average, minimum, and maximum number of a selected entity type per pathway in WikiPathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-03-30"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:DataCounts ; + schema:keywords "metadata", "counts" ; + schema:target ; + snorql:alias "A. Metadata/datacounts/averagePerPathway.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:entityType ; + sh:name "Entity Type" ; + sh:defaultValue "DataNode" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "http://vocabularies.wikipathways.org/wp#{value}" ; + snorql:option [ rdf:value "DataNode" ; rdfs:label "Data Nodes" ; sh:order 1 ] ; + snorql:option [ rdf:value "GeneProduct" ; rdfs:label "Gene Products" ; sh:order 2 ] ; + snorql:option [ rdf:value "Interaction" ; rdfs:label "Interactions" ; sh:order 3 ] ; + snorql:option [ rdf:value "Metabolite" ; rdfs:label "Metabolites" ; sh:order 4 ] ; + snorql:option [ rdf:value "Protein" ; rdfs:label "Proteins" ; sh:order 5 ] ; + sh:order 1 + ] ; + sh:select """PREFIX dcterms: +PREFIX wp: + +SELECT (AVG(?no) AS ?avg) + (MIN(?no) AS ?min) + (MAX(?no) AS ?max) +WHERE { + SELECT ?Pathway (COUNT(?entity) AS ?no) + WHERE { + VALUES ?entityType { } + ?entity a ?entityType ; + dcterms:isPartOf ?Pathway . + ?Pathway a wp:Pathway .} + GROUP BY ?Pathway +}""" . diff --git a/A. Metadata/datacounts/countOfEntityType.ttl b/A. Metadata/datacounts/countOfEntityType.ttl new file mode 100644 index 0000000..9cd030a --- /dev/null +++ b/A. Metadata/datacounts/countOfEntityType.ttl @@ -0,0 +1,47 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ013 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ013" ; + rdfs:label "Count of Entity Type"@en ; + rdfs:comment "Counts the total number of a selected entity type in WikiPathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-03-30"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:DataCounts ; + schema:keywords "metadata", "counts" ; + schema:target ; + snorql:alias "A. Metadata/datacounts/countOfEntityType.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:entityType ; + sh:name "Entity Type" ; + sh:defaultValue "DataNode" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "http://vocabularies.wikipathways.org/wp#{value}" ; + snorql:option [ rdf:value "DataNode" ; rdfs:label "Data Nodes" ; sh:order 1 ] ; + snorql:option [ rdf:value "GeneProduct" ; rdfs:label "Gene Products" ; sh:order 2 ] ; + snorql:option [ rdf:value "Interaction" ; rdfs:label "Interactions" ; sh:order 3 ] ; + snorql:option [ rdf:value "Metabolite" ; rdfs:label "Metabolites" ; sh:order 4 ] ; + snorql:option [ rdf:value "Protein" ; rdfs:label "Proteins" ; sh:order 5 ] ; + sh:order 1 + ] ; + sh:select """SELECT DISTINCT (COUNT(?entity) AS ?count) +WHERE { + VALUES ?entityType { } + ?entity a ?entityType . +}""" . diff --git a/A. Metadata/datacounts/countPathways.ttl b/A. Metadata/datacounts/countPathways.ttl new file mode 100644 index 0000000..8a74542 --- /dev/null +++ b/A. Metadata/datacounts/countPathways.ttl @@ -0,0 +1,36 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ014 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ014" ; + rdfs:label "Count of Pathways"@en ; + rdfs:comment "Counts the total number of pathways in WikiPathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-08-12"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DataCounts ; + schema:keywords "metadata", "counts" ; + schema:target ; + snorql:alias "A. Metadata/datacounts/countPathways.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX skos: +PREFIX wp: + +SELECT DISTINCT (count(?Pathway) as ?PathwayCount) +WHERE { + ?Pathway a wp:Pathway, skos:Collection . +}""" . diff --git a/A. Metadata/datacounts/countSignalingPathways.ttl b/A. Metadata/datacounts/countSignalingPathways.ttl new file mode 100644 index 0000000..7949533 --- /dev/null +++ b/A. Metadata/datacounts/countSignalingPathways.ttl @@ -0,0 +1,40 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ015 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ015" ; + rdfs:label "Count of Signaling Pathways"@en ; + rdfs:comment "Counts the total number of signaling pathways in WikiPathways by filtering on the signaling pathway ontology tag."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-08-12"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:DataCounts ; + schema:keywords "metadata", "counts" ; + schema:target ; + snorql:alias "A. Metadata/datacounts/countSignalingPathways.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX owl: +PREFIX rdfs: +PREFIX wp: + +SELECT (count(distinct ?pathway) as ?pathwaycount) +WHERE { + ?tag1 a owl:Class ; + rdfs:label ?label . + ?tag rdfs:subClassOf* ?tag1. + ?pathway a wp:Pathway; wp:ontologyTag ?tag. +FILTER regex(str(?label), "signaling pathway") +}""" . diff --git a/A. Metadata/datacounts/linkoutCounts.ttl b/A. Metadata/datacounts/linkoutCounts.ttl new file mode 100644 index 0000000..d6b1009 --- /dev/null +++ b/A. Metadata/datacounts/linkoutCounts.ttl @@ -0,0 +1,43 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ016 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ016" ; + rdfs:label "External Linkout Counts"@en ; + rdfs:comment "Counts the number of distinct entities linked to each external database (ChEBI, ChemSpider, HMDB, PubChem, Ensembl, NCBI Gene, HGNC, Rhea, UniProt)."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-01-07"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DataCounts ; + schema:keywords "metadata", "counts" ; + schema:target ; + snorql:alias "A. Metadata/datacounts/linkoutCounts.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: + +SELECT ?pred (COUNT(DISTINCT ?entity) AS ?count) WHERE { + VALUES ?pred { + # metabolites + wp:bdbChEBI wp:bdbChemspider wp:bdbHmdb wp:bdbPubChem + # gene products + wp:bdbEnsembl wp:bdbEntrezGene wp:bdbHgncSymbol + # interactions + wp:bdbRhea wp:bdbUniprot + } + ?entity ?pred [] +} GROUP BY ?pred + ORDER BY DESC(?count)""" . diff --git a/A. Metadata/datasources/AllDataSources.ttl b/A. Metadata/datasources/AllDataSources.ttl new file mode 100644 index 0000000..b7eb765 --- /dev/null +++ b/A. Metadata/datasources/AllDataSources.ttl @@ -0,0 +1,35 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ072 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ072" ; + rdfs:label "All Data Sources"@en ; + rdfs:comment "Lists all data sources currently used for identifiers in WikiPathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-10-20"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DataSources ; + schema:keywords "data sources" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: + +SELECT DISTINCT (str(?datasourceLit) as ?datasource) +WHERE { + ?concept dc:source ?datasourceLit +}""" . diff --git a/A. Metadata/datasources/EntryCountPerDataSource.ttl b/A. Metadata/datasources/EntryCountPerDataSource.ttl new file mode 100644 index 0000000..6c524f9 --- /dev/null +++ b/A. Metadata/datasources/EntryCountPerDataSource.ttl @@ -0,0 +1,40 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ073 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ073" ; + rdfs:label "Entry Count per Data Source"@en ; + rdfs:comment "Counts the data nodes per data source in WikiPathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DataSources ; + schema:keywords "counts", "data sources" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX wp: + +SELECT (str(?datasourceLit) as ?datasource) + (count(DISTINCT ?dataNode) as ?numberEntries) +WHERE { + ?concept dc:source ?datasourceLit ; + wp:isAbout ?dataNode . +} +GROUP BY ?datasourceLit +ORDER BY DESC(?numberEntries)""" . diff --git a/A. Metadata/datasources/pathwaysForDatasource.ttl b/A. Metadata/datasources/pathwaysForDatasource.ttl new file mode 100644 index 0000000..a4f92b1 --- /dev/null +++ b/A. Metadata/datasources/pathwaysForDatasource.ttl @@ -0,0 +1,57 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ017 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ017" ; + rdfs:label "WikiPathways for Datasource Identifiers"@en ; + rdfs:comment "Lists pathways containing entities with identifiers from a selected data source, showing the pathway title and identifier URI."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-03-30"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:DataSources ; + schema:keywords "data sources" ; + schema:target ; + snorql:alias "A. Metadata/datasources/pathwaysForDatasource.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:datasource ; + sh:name "Data Source" ; + sh:defaultValue "Ensembl" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "http://vocabularies.wikipathways.org/wp#bdb{value}" ; + snorql:option [ rdf:value "Chemspider" ; rdfs:label "ChemSpider" ; sh:order 1 ] ; + snorql:option [ rdf:value "Ensembl" ; rdfs:label "Ensembl" ; sh:order 2 ] ; + snorql:option [ rdf:value "HgncSymbol" ; rdfs:label "HGNC" ; sh:order 3 ] ; + snorql:option [ rdf:value "Hmdb" ; rdfs:label "HMDB" ; sh:order 4 ] ; + snorql:option [ rdf:value "EntrezGene" ; rdfs:label "NCBI Gene" ; sh:order 5 ] ; + snorql:option [ rdf:value "PubChem" ; rdfs:label "PubChem" ; sh:order 6 ] ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?pathwayRes (str(?wpid) AS ?pathway) (str(?title) AS ?pathwayTitle) ?identifier +WHERE { + VALUES ?datasource { } + ?gene dcterms:identifier ?id ; + dcterms:isPartOf ?pathwayRes ; + ?datasource ?identifier . + ?pathwayRes a wp:Pathway ; + dcterms:identifier ?wpid ; + dc:title ?title . +}""" . diff --git a/A. Metadata/linksets.ttl b/A. Metadata/linksets.ttl index 1a32f29..60e518c 100644 --- a/A. Metadata/linksets.ttl +++ b/A. Metadata/linksets.ttl @@ -1,14 +1,37 @@ -@prefix ex: . +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . @prefix rdf: . @prefix rdfs: . @prefix schema: . @prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . -ex:metadata a sh:SPARQLExecutable, - sh:SPARQLSelectExecutable ; - rdfs:comment "Lists all linksets defined in this database with their titles, licenses, and creation dates."@en ; - sh:prefixes _:sparql_examples_prefixes ; - sh:select """SELECT DISTINCT ?dataset (str(?titleLit) as ?title) ?date ?license +wpq:WPQ002 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ002" ; + rdfs:label "Linksets Overview"@en ; + rdfs:comment "Returns all VoID linksets in the WikiPathways RDF with their title, creation date, and license information."@en ; + schema:version "1.0.0" ; + dcterms:created "2021-02-06"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metadata ; + schema:keywords "metadata" ; + schema:target ; + snorql:alias "A. Metadata/linksets.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX pav: +PREFIX void: + +SELECT DISTINCT ?dataset (str(?titleLit) as ?title) ?date ?license WHERE { ?dataset a void:Linkset ; dcterms:title ?titleLit . @@ -16,7 +39,4 @@ WHERE { ?dataset dcterms:license ?license ; pav:createdOn ?date . } -} -""" ; - schema:target ; - schema:keywords "linkset", "metadata" . +}""" . diff --git a/A. Metadata/metadata.ttl b/A. Metadata/metadata.ttl index 295ffec..d0d7a46 100644 --- a/A. Metadata/metadata.ttl +++ b/A. Metadata/metadata.ttl @@ -1,19 +1,40 @@ -@prefix ex: . +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . @prefix rdf: . @prefix rdfs: . @prefix schema: . @prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . -ex:metadata a sh:SPARQLExecutable, - sh:SPARQLSelectExecutable ; - rdfs:comment "Returns the title of the dataset, creation date, and license."@en ; - sh:prefixes _:sparql_examples_prefixes ; - sh:select """SELECT DISTINCT ?dataset (str(?titleLit) as ?title) ?date ?license +wpq:WPQ001 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ001" ; + rdfs:label "Dataset Metadata"@en ; + rdfs:comment "Returns all VoID datasets in the WikiPathways RDF with their title, creation date, and license information."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-08-12"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metadata ; + schema:keywords "metadata" ; + schema:target ; + snorql:alias "A. Metadata/metadata.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX pav: +PREFIX void: + +SELECT DISTINCT ?dataset (str(?titleLit) as ?title) ?date ?license WHERE { ?dataset a void:Dataset ; dcterms:title ?titleLit ; dcterms:license ?license ; pav:createdOn ?date . -}""" ; - schema:target ; - schema:keywords "license", "metadata" . +}""" . diff --git a/A. Metadata/prefixes.ttl b/A. Metadata/prefixes.ttl index 2770b13..a2be125 100644 --- a/A. Metadata/prefixes.ttl +++ b/A. Metadata/prefixes.ttl @@ -1,13 +1,32 @@ -@prefix ex: . +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . @prefix rdf: . @prefix rdfs: . @prefix schema: . @prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . -ex:metadata a sh:SPARQLExecutable, - sh:SPARQLSelectExecutable ; - rdfs:comment "Lists prefixes used in this database."@en ; - sh:prefixes _:sparql_examples_prefixes ; +wpq:WPQ003 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ003" ; + rdfs:label "SPARQL Prefixes"@en ; + rdfs:comment "Lists all namespace prefixes declared in the WikiPathways SPARQL endpoint via SHACL prefix declarations."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-11-12"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metadata ; + schema:keywords "metadata" ; + schema:target ; + snorql:alias "A. Metadata/prefixes.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; sh:select """PREFIX sh: PREFIX xsd: @@ -16,6 +35,4 @@ SELECT ?prefix ?namespace WHERE { sh:prefix ?prefix ; sh:namespace ?namespace ] . -}""" ; - schema:target ; - schema:keywords "prefix", "namespace" . +}""" . diff --git a/A. Metadata/species/MetaboliteCountPerSpecies.ttl b/A. Metadata/species/MetaboliteCountPerSpecies.ttl new file mode 100644 index 0000000..710fb72 --- /dev/null +++ b/A. Metadata/species/MetaboliteCountPerSpecies.ttl @@ -0,0 +1,40 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ070 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ070" ; + rdfs:label "Metabolite Count per Species"@en ; + rdfs:comment "Counts the metabolites per species. The RDF generation normalises identifiers, so metabolites with identifiers from different databases are not counted twice, but metabolites with different charge states are still counted separately."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Species ; + schema:keywords "counts", "metabolite", "organism" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT (count(distinct ?metabolite) as ?count) (str(?label) as ?species) WHERE { + ?metabolite a wp:Metabolite ; + dcterms:isPartOf ?pw . + ?pw dc:title ?title ; + wp:organism ?organism ; + wp:organismName ?label . +} GROUP BY ?label ORDER BY DESC(?count)""" . diff --git a/A. Metadata/species/PWsforSpecies.ttl b/A. Metadata/species/PWsforSpecies.ttl new file mode 100644 index 0000000..3e91214 --- /dev/null +++ b/A. Metadata/species/PWsforSpecies.ttl @@ -0,0 +1,51 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ009 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ009" ; + rdfs:label "Pathways for a Species"@en ; + rdfs:comment "Lists all pathways for a given species, returning the WikiPathways identifier and page URL. Default species is Mus musculus."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-11"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Species ; + schema:keywords "metadata", "organism" ; + schema:target ; + snorql:alias "A. Metadata/species/PWsforSpecies.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX foaf: +PREFIX wp: + +SELECT DISTINCT ?wpIdentifier ?pathway ?page +WHERE { + ?pathway dc:title ?title . + ?pathway foaf:page ?page . + ?pathway dc:identifier ?wpIdentifier . + VALUES ?species { "Homo sapiens" } + ?pathway wp:organismName ?species . + } +ORDER BY ?wpIdentifier""" . diff --git a/A. Metadata/species/PathwaysAndSpecies.ttl b/A. Metadata/species/PathwaysAndSpecies.ttl new file mode 100644 index 0000000..fa026e2 --- /dev/null +++ b/A. Metadata/species/PathwaysAndSpecies.ttl @@ -0,0 +1,36 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ007 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ007" ; + rdfs:label "Pathways and Their Species"@en ; + rdfs:comment "List pathways and their species."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-10-20"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Species ; + schema:keywords "organism" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: +PREFIX dc: + +SELECT DISTINCT (str(?title) as ?pathway) (str(?label) as ?organism) +WHERE { + ?pw dc:title ?title ; + wp:organismName ?label . +}""" . diff --git a/A. Metadata/species/SpeciesWithIRIs.ttl b/A. Metadata/species/SpeciesWithIRIs.ttl new file mode 100644 index 0000000..0b8961a --- /dev/null +++ b/A. Metadata/species/SpeciesWithIRIs.ttl @@ -0,0 +1,36 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ006 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ006" ; + rdfs:label "Species with Their IRIs"@en ; + rdfs:comment "Get the species currently in WikiPathways with their respective URIs."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-10-20"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Species ; + schema:keywords "organism" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: +PREFIX rdfs: + +SELECT DISTINCT ?organism (str(?label) as ?name) +WHERE { + ?concept wp:organism ?organism ; + wp:organismName ?label . +}""" . diff --git a/A. Metadata/species/countEntityPerSpecies.ttl b/A. Metadata/species/countEntityPerSpecies.ttl new file mode 100644 index 0000000..2397b37 --- /dev/null +++ b/A. Metadata/species/countEntityPerSpecies.ttl @@ -0,0 +1,54 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ018 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ018" ; + rdfs:label "Entity Type per Species"@en ; + rdfs:comment "Counts the number of distinct entities of a selected type per species in WikiPathways, ordered by count descending."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-03-30"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Species ; + schema:keywords "metadata", "organism" ; + schema:target ; + snorql:alias "A. Metadata/species/countEntityPerSpecies.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:entityType ; + sh:name "Entity Type" ; + sh:defaultValue "DataNode" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "http://vocabularies.wikipathways.org/wp#{value}" ; + snorql:option [ rdf:value "DataNode" ; rdfs:label "Data Nodes" ; sh:order 1 ] ; + snorql:option [ rdf:value "GeneProduct" ; rdfs:label "Gene Products" ; sh:order 2 ] ; + snorql:option [ rdf:value "Metabolite" ; rdfs:label "Metabolites" ; sh:order 3 ] ; + snorql:option [ rdf:value "Protein" ; rdfs:label "Proteins" ; sh:order 4 ] ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT (COUNT(DISTINCT ?entity) AS ?count) (str(?label) AS ?species) +WHERE { + VALUES ?entityType { } + ?entity a ?entityType ; + dcterms:isPartOf ?pw . + ?pw dc:title ?title ; + wp:organism ?organism ; + wp:organismName ?label . +} GROUP BY ?label ORDER BY DESC(?count)""" . diff --git a/A. Metadata/species/countPathwaysPerSpecies.ttl b/A. Metadata/species/countPathwaysPerSpecies.ttl new file mode 100644 index 0000000..397726d --- /dev/null +++ b/A. Metadata/species/countPathwaysPerSpecies.ttl @@ -0,0 +1,39 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ008 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ008" ; + rdfs:label "Pathways per Species"@en ; + rdfs:comment "Counts the number of pathways per species in WikiPathways, returning the species name, organism URI, and pathway count."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Species ; + schema:keywords "metadata", "organism" ; + schema:target ; + snorql:alias "A. Metadata/species/countPathwaysPerSpecies.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX wp: + +SELECT DISTINCT (str(?label) as ?name) ?organism (count(?pw) as ?pathwayCount) +WHERE { + ?pw dc:title ?title ; + wp:organism ?organism ; + wp:organismName ?label . +} +GROUP BY ?organism ?label +ORDER BY DESC(?pathwayCount)""" . diff --git a/AUTHORING.md b/AUTHORING.md new file mode 100644 index 0000000..2e57921 --- /dev/null +++ b/AUTHORING.md @@ -0,0 +1,178 @@ +# Writing and changing example queries + +Each example is one Turtle (`.ttl`) file: the SPARQL query plus its metadata, in the +format of [SIB's sparql-examples](https://github.com/sib-swiss/sparql-examples) with a +few extra terms from the [Snorql vocabulary](https://w3id.org/snorql/ns). The query +editor at reads them (through the published index, +see below), and so can any other tool that understands SIB's format. + +## Identifiers + +Every example has a permanent identifier, `WPQ` followed by a number (`WPQ036`). Its IRI +is `https://sparql.wikipathways.org/.well-known/sparql-examples/WPQ036`, and links to the +editor use it: `https://sparql.wikipathways.org/?example=WPQ036`. + +- The identifier never changes and is never reused. You can rename the file or move it to + another folder at any time; links keep working. +- For a new example, take the next free number: + `python /tools/examples/snorql_examples.py next-id` (or look at the highest + number in use and add one; CI rejects duplicates). +- Folders are only for keeping the files tidy. Where an example appears in the editor's + tree is set by its category (`dcterms:subject`), see `categories.ttl`. + +## Template + +```turtle +@prefix dcterms: . +@prefix param: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ086 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ086" ; + rdfs:label "Genes of a Pathway"@en ; + rdfs:comment "Lists all gene products in a given pathway."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-11"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "gene", "pathway" ; + schema:target ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP1560" ; + sh:datatype xsd:string ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +SELECT DISTINCT ?gene ?label WHERE { + VALUES ?pathwayId { "WP1560" } + ?pathway a wp:Pathway ; dcterms:identifier ?pathwayId . + ?gene a wp:GeneProduct ; dcterms:isPartOf ?pathway ; rdfs:label ?label . +}""" . +``` + +## Fields + +| Field | Required | What it holds | +|---|---|---| +| `dcterms:identifier` | yes | `WPQnnn`; the subject IRI must be `wpq:` + the same identifier | +| `rdfs:label` | yes | Title shown in the editor, with `@en` | +| `rdfs:comment` | yes | What the query does and returns, with `@en` | +| `schema:version` | yes | `MAJOR.MINOR.PATCH`, see [Versions](#versions) | +| `dcterms:created` | yes | Date the example was first written | +| `dcterms:creator` | yes | Who wrote it: ORCID IRI, or a profile page if there is no ORCID | +| `dcterms:contributor` | no | Others who changed it | +| `dcterms:license` | yes | The repository's licence, GPL-3.0 | +| `dcterms:subject` | yes | Category from `categories.ttl` (more than one is fine) | +| `schema:target` | yes | The SPARQL endpoint the query is for | +| `sh:select` / `sh:ask` / `sh:construct` / `spex:describe` | yes | The query, with all the PREFIX lines it uses | +| `schema:keywords` | no | Search terms | +| `spex:federatesWith` | if `SERVICE` is used | One per endpoint called with `SERVICE` | +| `schema:educationalLevel` | no | `beginner`, `intermediate` or `advanced` | +| `dcterms:references` | no | Paper or tutorial that explains or uses the query | +| `prov:wasDerivedFrom` | no | Where the query was adapted from | +| `snorql:expect` | no | Expected results with the default values, e.g. `[ snorql:minResults 1 ]`; checked weekly | +| `snorql:alias` | no | Old path of the example, so old `?example=` links keep working | + +Every creator and contributor IRI needs a name in `contributors.ttl`. Add yourself there +in the same pull request as your first example. + +Inside the `"""..."""` of the query, a backslash must be doubled (`\\d` for a regex `\d`), +and `"""` cannot appear. + +## Parameters + +A parameter is a value the user can change in the editor (a pathway, a species). The +query must still run as it is, so it binds the variable to the default value in a single +`VALUES` block; the editor replaces the value in that block. + +```turtle + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; # name in links (?species=...) and the variable ?species + sh:name "Species" ; # label in the editor + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; # the value is a string ... + snorql:autocomplete "species" ; # ... with suggestions from the editor's "species" list + sh:order 1 + ] ; +``` + +and in the query `VALUES ?species { "Homo sapiens" }` next to the triple patterns that use +`?species`. + +- **IRI values:** use `sh:nodeKind sh:IRI` and a template, e.g. + `snorql:valueTemplate "https://identifiers.org/wikipathways/{value}"`. The user types + `WP1560`; the `VALUES` block holds ``. +- **A fixed list:** one `snorql:option [ rdf:value "DataNode" ; rdfs:label "Data Nodes" ; sh:order 1 ]` + per allowed value (combine with a template for class or property names, e.g. + `"http://vocabularies.wikipathways.org/wp#{value}"`). +- **A different variable name:** `snorql:variable "pathway"` when the `VALUES` block binds + `?pathway` but the parameter is called `pathwayId`. +- Names `example`, `ref`, `version`, `endpoint` and `q` are taken by the editor's links. +- Where the `VALUES` block sits matters to Virtuoso: put it next to the patterns that use the + variable, after any `SERVICE` call in the same group (Virtuoso rejects a `VALUES` block + before a `SERVICE` call), and inside a subquery when the variable is used there. + +## Versions + +Each example has its own version. Raise it in every pull request that changes the example; +CI checks this. + +- **PATCH** (1.0.0 → 1.0.1): metadata only (title, description, keywords, category, ...). +- **MINOR** (1.0.1 → 1.1.0): the query or its parameters changed, same result columns. +- **MAJOR** (1.1.0 → 2.0.0): the result columns changed, or the query answers a different question. + +The editor can show every published version of an example, and a link can pin one: +`?example=WPQ036&version=1.0.0`. Collection releases (tags `vYYYY.MM`) freeze the whole set. + +## Removing an example + +Don't delete the file: identifiers must keep resolving. Mark it deprecated and say why, +and point to a replacement if there is one: + +```turtle + owl:deprecated true ; + dcterms:isReplacedBy wpq:WPQ040 ; +``` + +The editor hides deprecated examples from the tree but still opens them from links, with a +notice. + +## Checking your change + +CI runs these on every pull request. To run them yourself, with a checkout of +[Snorql-UI](https://github.com/wikipathways/Snorql-UI) next to this one: + +```bash +pip install -r ../Snorql-UI/tools/examples/requirements.txt +python ../Snorql-UI/tools/examples/snorql_examples.py check +python ../Snorql-UI/tools/examples/snorql_examples.py versions --base origin/master +python ../Snorql-UI/tools/examples/snorql_examples.py live --only WPQ036 # run against the endpoint +``` + +## What CI publishes + +On every push to `master`, CI rebuilds the `examples-index` branch: + +- `index.json`: all examples with their metadata and queries (what the editor loads); +- `history.json` and `versions//.json`: every published version; +- `sparql-examples.ttl`: all examples in one Turtle file; +- `rq/`: plain `.rq` files with the old comment header, for tools that read those. + +Don't edit that branch; it is replaced on every push. diff --git a/B. Communities/Inborn Errors of Metabolism/allMetabolicPWs.ttl b/B. Communities/Inborn Errors of Metabolism/allMetabolicPWs.ttl new file mode 100644 index 0000000..050401f --- /dev/null +++ b/B. Communities/Inborn Errors of Metabolism/allMetabolicPWs.ttl @@ -0,0 +1,40 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ020 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ020" ; + rdfs:label "Inborn Errors of Metabolism Metabolic Pathways"@en ; + rdfs:comment "Retrieves pathways classified under metabolic pathway ontology terms, filtering by label to find metabolic pathway annotations."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-08-12"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:InbornErrorsOfMetabolism ; + schema:keywords "communities", "inborn errors of metabolism", "metabolism" ; + schema:target ; + snorql:alias "B. Communities/Inborn Errors of Metabolism/allMetabolicPWs.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX owl: +PREFIX rdfs: +PREFIX wp: + +SELECT distinct ?pathway ?label ?tag +WHERE { + ?tag1 a owl:Class ; + rdfs:label ?label . + ?tag rdfs:subClassOf* ?tag1. + ?pathway a wp:Pathway; wp:ontologyTag ?tag. +FILTER regex(str(?label), "metabolic pathway") +}""" . diff --git a/B. Communities/Inborn Errors of Metabolism/countMetabolicPWs.ttl b/B. Communities/Inborn Errors of Metabolism/countMetabolicPWs.ttl new file mode 100644 index 0000000..e28c78f --- /dev/null +++ b/B. Communities/Inborn Errors of Metabolism/countMetabolicPWs.ttl @@ -0,0 +1,40 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ021 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ021" ; + rdfs:label "Count of IEM Metabolic Pathways"@en ; + rdfs:comment "Counts the total number of pathways classified under metabolic pathway ontology terms."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-08-12"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:InbornErrorsOfMetabolism ; + schema:keywords "communities", "inborn errors of metabolism", "metabolism" ; + schema:target ; + snorql:alias "B. Communities/Inborn Errors of Metabolism/countMetabolicPWs.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX owl: +PREFIX rdfs: +PREFIX wp: + +SELECT (count(distinct ?pathway) as ?pathwaycount) +WHERE { + ?tag1 a owl:Class ; + rdfs:label ?label . + ?tag rdfs:subClassOf* ?tag1. + ?pathway a wp:Pathway; wp:ontologyTag ?tag. +FILTER regex(str(?label), "metabolic pathway") +}""" . diff --git a/B. Communities/Inborn Errors of Metabolism/countProteinsMetabolitesRheaDiseases.ttl b/B. Communities/Inborn Errors of Metabolism/countProteinsMetabolitesRheaDiseases.ttl new file mode 100644 index 0000000..7a4c320 --- /dev/null +++ b/B. Communities/Inborn Errors of Metabolism/countProteinsMetabolitesRheaDiseases.ttl @@ -0,0 +1,80 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ022 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ022" ; + rdfs:label "IEM Proteins, Metabolites, Rhea, and Diseases"@en ; + rdfs:comment "Summarizes IEM community pathways with counts of proteins, metabolites, Rhea reaction annotations, missing Rhea IDs, and linked OMIM disease identifiers per pathway."@en ; + schema:version "1.0.0" ; + dcterms:created "2022-11-08"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:InbornErrorsOfMetabolism ; + schema:keywords "communities", "inborn errors of metabolism", "metabolism" ; + schema:target ; + snorql:alias "B. Communities/Inborn Errors of Metabolism/countProteinsMetabolitesRheaDiseases.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX cur: +PREFIX dc: +PREFIX gpml: +PREFIX rdf: +PREFIX wp: +PREFIX rdfs: +PREFIX dcterms: + +#Variable selection +SELECT DISTINCT (str(?title) as ?pathwayName) ?PWID +(count(distinct ?geneProduct) AS ?ProteinsInPWs) (count(distinct ?metaboliteNode) AS ?MetabolitesInPWs) +(count(distinct ?interactionID) AS ?RheaInPWs) (count(distinct ?interactionMissing) AS ?NoRheaInPWs) +(count(distinct ?omim) as ?diseaseIDs) + +WHERE { + + ?pathway wp:ontologyTag cur:IEM . + ?pathway dcterms:identifier ?PWID. #Obtain the ID + ?pathway wp:isAbout ?gpmlRDF_ID . #find the corresponding GPML link + ?pathway dc:title ?title . #Obtain the title + + { + ?geneProduct dcterms:isPartOf ?pathway . #Only those part of PW + ?geneProduct a wp:Protein . #Filter for Protein DataNodes + } + UNION + { + ?metaboliteNode a wp:Metabolite . #Filter for Metabolite DataNodes + ?metaboliteNode dcterms:isPartOf ?pathway . #Only those part of PW + } + UNION + { + OPTIONAL{?interaction wp:bdbRhea ?interactionID . #Find interactions with a Rhea ID + ?interaction dcterms:isPartOf ?pathway .} #Only those part of PW + } + UNION + { + OPTIONAL{?interactionMissing dcterms:isPartOf ?pathway . #Find additional interactions + ?interactionMissing rdf:type wp:Conversion . #That are of type 'metabolic conversion' + FILTER NOT EXISTS {?interactionMissing wp:bdbRhea ?interactionID . } #Without a Rhea ID + } + } + UNION { + ?diseaseNode dcterms:isPartOf ?gpmlRDF_ID . #Only check for matching pathways + ?diseaseNode rdf:type gpml:Label . #Only include textLabels + ?diseaseNode gpml:href ?omim . #That have an href attribute + FILTER regex(?omim, "omim.org", "i") #Only keep hrefs if they contain 'omim.org' + } + +} GROUP BY ?pathway ?title ?PWID +ORDER BY ASC(?pathway)""" . diff --git a/B. Communities/Lipids/LIPIDMAPS_Federated.ttl b/B. Communities/Lipids/LIPIDMAPS_Federated.ttl new file mode 100644 index 0000000..3b1fcb1 --- /dev/null +++ b/B. Communities/Lipids/LIPIDMAPS_Federated.ttl @@ -0,0 +1,50 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ024 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ024" ; + rdfs:label "LIPID MAPS Federated Query"@en ; + rdfs:comment "Retrieves lipid names, formulas, and associated pathways for a specific LIPID MAPS category by querying the LIPID MAPS SPARQL endpoint. May be slower due to external endpoint dependency."@en ; + schema:version "1.0.0" ; + dcterms:created "2023-02-13"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Lipids ; + schema:keywords "communities", "lipids", "LIPID MAPS" ; + schema:target ; + spex:federatesWith ; + snorql:alias "B. Communities/Lipids/LIPIDMAPS_Federated.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: +PREFIX chebi: + +SELECT ?lipid ?name ?formula ?lmid (GROUP_CONCAT(?wpid_;separator=", ") AS ?pathway) +WHERE { + SERVICE { + VALUES ?category { } + ?lipidmaps rdfs:label ?name ; + rdfs:subClassOf* ?category ; + chebi:formula ?formula . + } + BIND (IRI(CONCAT("https://identifiers.org/lipidmaps/", + SUBSTR(STR(?lipidmaps), 31))) AS ?lmid) + ?lipid wp:bdbLipidMaps ?lmid ; + dcterms:isPartOf ?pw . + ?pw a wp:Pathway ; dcterms:identifier ?wpid_ . +} +GROUP BY ?lipid ?name ?formula ?lmid""" . diff --git a/B. Communities/Lipids/LipidClassesTotal.ttl b/B. Communities/Lipids/LipidClassesTotal.ttl new file mode 100644 index 0000000..f6fab08 --- /dev/null +++ b/B. Communities/Lipids/LipidClassesTotal.ttl @@ -0,0 +1,71 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ023 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ023" ; + rdfs:label "Total Lipid Classes"@en ; + rdfs:comment "Counts the number of individual lipids in a specific LIPID MAPS subclass across human pathways. Change the FILTER value to query different subclasses (FA, GL, GP, SP, ST, PR, SL, PK)."@en ; + schema:version "1.0.0" ; + dcterms:created "2023-11-30"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Lipids ; + schema:keywords "communities", "lipids", "LIPID MAPS" ; + schema:target ; + snorql:alias "B. Communities/Lipids/LipidClassesTotal.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:lipidClass ; + sh:name "LIPID MAPS Class" ; + sh:defaultValue "FA" ; + sh:datatype xsd:string ; + snorql:option [ rdf:value "FA" ; rdfs:label "FA" ; sh:order 1 ] ; + snorql:option [ rdf:value "GL" ; rdfs:label "GL" ; sh:order 2 ] ; + snorql:option [ rdf:value "GP" ; rdfs:label "GP" ; sh:order 3 ] ; + snorql:option [ rdf:value "SP" ; rdfs:label "SP" ; sh:order 4 ] ; + snorql:option [ rdf:value "ST" ; rdfs:label "ST" ; sh:order 5 ] ; + snorql:option [ rdf:value "PR" ; rdfs:label "PR" ; sh:order 6 ] ; + snorql:option [ rdf:value "SL" ; rdfs:label "SL" ; sh:order 7 ] ; + snorql:option [ rdf:value "PK" ; rdfs:label "PK" ; sh:order 8 ] ; + sh:order 2 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT (count(DISTINCT ?lipidID) as ?IndividualLipidsPerClass) +WHERE { ?metabolite a wp:Metabolite ; + dcterms:identifier ?id ; + dcterms:isPartOf ?pathwayRes ; + wp:bdbLipidMaps ?lipidID . #Metabolite DataNodes need to have a LIPID MAPS ID, for this query to count correctly (some lipids might be missed due to missing Xrefs) + VALUES ?species { "Homo sapiens" } + ?pathwayRes a wp:Pathway ; + wp:organismName ?species; #Filter for a species (ommit when querying all pathways available for all species) + dcterms:identifier ?wpid ; + dc:title ?title . + VALUES ?lipidClass { "FA" } + FILTER regex(str(?lipidID), ?lipidClass ). #Filter for a LIPID MAPS ID subclass: 'FA' Fatty Acids ; 'GL' Glycerolipid ; 'GP' Glycerophospholipid ; 'SP' Sphingolipids ; 'ST' Sterol lipids ; 'PR' Prenol Lipids ; 'SL' Saccharolipids ; 'PK' Polyketides +}""" . diff --git a/B. Communities/Lipids/LipidsClassesCountPerPathway.ttl b/B. Communities/Lipids/LipidsClassesCountPerPathway.ttl new file mode 100644 index 0000000..4962784 --- /dev/null +++ b/B. Communities/Lipids/LipidsClassesCountPerPathway.ttl @@ -0,0 +1,73 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ025 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ025" ; + rdfs:label "Lipid Classes Count per Pathway"@en ; + rdfs:comment "Counts the number of lipids in a specific LIPID MAPS subclass per human pathway, ordered by count. Change the FILTER value to query different subclasses."@en ; + schema:version "1.0.0" ; + dcterms:created "2023-11-30"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Lipids ; + schema:keywords "communities", "lipids", "LIPID MAPS" ; + schema:target ; + snorql:alias "B. Communities/Lipids/LipidsClassesCountPerPathway.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:lipidClass ; + sh:name "LIPID MAPS Class" ; + sh:defaultValue "FA" ; + sh:datatype xsd:string ; + snorql:option [ rdf:value "FA" ; rdfs:label "FA" ; sh:order 1 ] ; + snorql:option [ rdf:value "GL" ; rdfs:label "GL" ; sh:order 2 ] ; + snorql:option [ rdf:value "GP" ; rdfs:label "GP" ; sh:order 3 ] ; + snorql:option [ rdf:value "SP" ; rdfs:label "SP" ; sh:order 4 ] ; + snorql:option [ rdf:value "ST" ; rdfs:label "ST" ; sh:order 5 ] ; + snorql:option [ rdf:value "PR" ; rdfs:label "PR" ; sh:order 6 ] ; + snorql:option [ rdf:value "SL" ; rdfs:label "SL" ; sh:order 7 ] ; + snorql:option [ rdf:value "PK" ; rdfs:label "PK" ; sh:order 8 ] ; + sh:order 2 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?pathwayRes (str(?wpid) AS ?pathway) (str(?title) AS ?pathwayTitle) (count(DISTINCT ?lipidID) AS ?Class_LipidsInPWs) +WHERE { ?metabolite a wp:Metabolite ; + dcterms:identifier ?id ; + dcterms:isPartOf ?pathwayRes ; + wp:bdbLipidMaps ?lipidID . #Metabolite DataNodes need to have a LIPID MAPS ID, for this query to count correctly (some lipids might be missed due to missing Xrefs) + VALUES ?species { "Homo sapiens" } + ?pathwayRes a wp:Pathway ; + wp:organismName ?species ; #Filter for a species (ommit when querying all pathways available for all species) + dcterms:identifier ?wpid ; + dc:title ?title . + VALUES ?lipidClass { "FA" } + FILTER regex(str(?lipidID), ?lipidClass ). #Filter for a LIPID MAPS ID subclass: 'FA' Fatty Acids ; 'GL' Glycerolipid ; 'GP' Glycerophospholipid ; 'SP' Sphingolipids ; 'ST' Sterol lipids ; 'PR' Prenol Lipids ; 'SL' Saccharolipids ; 'PK' Polyketides +} +GROUP BY ?pathwayRes ?wpid ?title +ORDER BY DESC(?Class_LipidsInPWs)""" . diff --git a/B. Communities/Lipids/LipidsCountPerPathway.ttl b/B. Communities/Lipids/LipidsCountPerPathway.ttl new file mode 100644 index 0000000..65b6b0c --- /dev/null +++ b/B. Communities/Lipids/LipidsCountPerPathway.ttl @@ -0,0 +1,56 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ026 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ026" ; + rdfs:label "Lipids Count per Pathway"@en ; + rdfs:comment "Counts the total number of lipids with LIPID MAPS identifiers per human pathway, ordered by count."@en ; + schema:version "1.0.0" ; + dcterms:created "2021-03-03"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Lipids ; + schema:keywords "communities", "lipids", "LIPID MAPS" ; + schema:target ; + snorql:alias "B. Communities/Lipids/LipidsCountPerPathway.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: +prefix lipidmaps: #IRI can be used to create URLs from identifiers in line 7 +select distinct ?pathwayRes (str(?wpid) as ?pathway) (str(?title) as ?pathwayTitle) (count(distinct ?lipidID) AS ?LipidsInPWs) +where { + ?metabolite a wp:Metabolite ; #Define what are metabolites + dcterms:identifier ?id ; #Find the identifier of a certain metabolite + dcterms:isPartOf ?pathwayRes ; #Define metabolites are part of a pathway + wp:bdbLipidMaps ?lipidID . #Find the LIPID MAPS identifier for a certain metabolite + VALUES ?species { "Homo sapiens" } + ?pathwayRes a wp:Pathway ; #Define what is a pathway + wp:organismName ?species ; #Filter pathways on species Human + dcterms:identifier ?wpid ; #Obtain identifier of pathway + dc:title ?title . #Obtain title of pathway +} +GROUP BY ?pathwayRes ?wpid ?title +ORDER BY DESC(?LipidsInPWs)""" . diff --git a/B. Communities/PathwayCountPerCurationTag.ttl b/B. Communities/PathwayCountPerCurationTag.ttl new file mode 100644 index 0000000..dfe0cb6 --- /dev/null +++ b/B. Communities/PathwayCountPerCurationTag.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ068 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ068" ; + rdfs:label "Pathway Count per Curation Tag"@en ; + rdfs:comment "Counts the pathways per curation and community tag."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-10-20"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Communities ; + schema:keywords "community", "counts", "curation" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: + +SELECT ?curationTag (count(DISTINCT ?pathway) as ?pathwayCount) +WHERE { + ?pathway wp:ontologyTag ?curationTag . + FILTER contains(STR(?curationTag), "Curation:") +} +GROUP BY ?curationTag +ORDER BY DESC(?pathwayCount)""" . diff --git a/B. Communities/Reactome/getPathways.ttl b/B. Communities/Reactome/getPathways.ttl new file mode 100644 index 0000000..5aa97b3 --- /dev/null +++ b/B. Communities/Reactome/getPathways.ttl @@ -0,0 +1,37 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ027 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ027" ; + rdfs:label "Reactome Pathways"@en ; + rdfs:comment "Lists all pathways tagged with the Reactome Approved curation tag."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Reactome ; + schema:keywords "communities", "Reactome" ; + schema:target ; + snorql:alias "B. Communities/Reactome/getPathways.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX cur: +PREFIX dc: +PREFIX wp: + +SELECT DISTINCT ?pathway (str(?titleLit) as ?title) +WHERE { + ?pathway wp:ontologyTag cur:Reactome_Approved ; + dc:title ?titleLit . +}""" . diff --git a/B. Communities/Reactome/refsReactomeAndWP.ttl b/B. Communities/Reactome/refsReactomeAndWP.ttl new file mode 100644 index 0000000..022ce7e --- /dev/null +++ b/B. Communities/Reactome/refsReactomeAndWP.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ028 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ028" ; + rdfs:label "References in Both Reactome and WikiPathways"@en ; + rdfs:comment "Counts publication references that appear in both Reactome-approved and WikiPathways Analysis Collection pathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Reactome ; + schema:keywords "communities", "Reactome" ; + schema:target ; + snorql:alias "B. Communities/Reactome/refsReactomeAndWP.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX cur: +PREFIX dcterms: +PREFIX wp: + +SELECT (COUNT(DISTINCT ?pubmed) AS ?count) +WHERE { + ?pubmed a wp:PublicationReference . + { ?pubmed dcterms:isPartOf/wp:ontologyTag cur:AnalysisCollection } + { ?pubmed dcterms:isPartOf/wp:ontologyTag cur:Reactome_Approved } +}""" . diff --git a/B. Communities/Reactome/refsReactomeNotWP.ttl b/B. Communities/Reactome/refsReactomeNotWP.ttl new file mode 100644 index 0000000..293fe98 --- /dev/null +++ b/B. Communities/Reactome/refsReactomeNotWP.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ029 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ029" ; + rdfs:label "References in Reactome but Not WikiPathways"@en ; + rdfs:comment "Counts publication references found in Reactome-approved pathways but not in the WikiPathways Analysis Collection."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Reactome ; + schema:keywords "communities", "Reactome" ; + schema:target ; + snorql:alias "B. Communities/Reactome/refsReactomeNotWP.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX cur: +PREFIX dcterms: +PREFIX wp: + +SELECT (COUNT(DISTINCT ?pubmed) AS ?count) +WHERE { + ?pubmed a wp:PublicationReference . + MINUS { ?pubmed dcterms:isPartOf/wp:ontologyTag cur:AnalysisCollection } + { ?pubmed dcterms:isPartOf/wp:ontologyTag cur:Reactome_Approved } +}""" . diff --git a/B. Communities/Reactome/refsWPNotReactome.ttl b/B. Communities/Reactome/refsWPNotReactome.ttl new file mode 100644 index 0000000..65c2a17 --- /dev/null +++ b/B. Communities/Reactome/refsWPNotReactome.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ030 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ030" ; + rdfs:label "References in WikiPathways but Not Reactome"@en ; + rdfs:comment "Counts publication references found in the WikiPathways Analysis Collection but not in Reactome-approved pathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Reactome ; + schema:keywords "communities", "Reactome" ; + schema:target ; + snorql:alias "B. Communities/Reactome/refsWPNotReactome.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX cur: +PREFIX dcterms: +PREFIX wp: + +SELECT (COUNT(DISTINCT ?pubmed) AS ?count) +WHERE { + ?pubmed a wp:PublicationReference . + { ?pubmed dcterms:isPartOf/wp:ontologyTag cur:AnalysisCollection } + MINUS { ?pubmed dcterms:isPartOf/wp:ontologyTag cur:Reactome_Approved } +}""" . diff --git a/B. Communities/communityPathways.ttl b/B. Communities/communityPathways.ttl new file mode 100644 index 0000000..8b44bd2 --- /dev/null +++ b/B. Communities/communityPathways.ttl @@ -0,0 +1,48 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ004 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ004" ; + rdfs:label "Community Pathways"@en ; + rdfs:comment "Lists all pathways tagged with a selected community curation tag."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-03-30"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Communities ; + schema:keywords "communities" ; + schema:target ; + snorql:alias "B. Communities/communityPathways.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:community ; + sh:name "Community" ; + sh:defaultValue "AOP" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "http://vocabularies.wikipathways.org/wp#Curation:{value}" ; + snorql:autocomplete "community" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX wp: + +SELECT DISTINCT ?pathway (str(?title) AS ?PathwayTitle) +WHERE { + VALUES ?community { } + ?pathway wp:ontologyTag ?community ; + a wp:Pathway ; + dc:title ?title . +}""" . diff --git a/B. Communities/communityProteins.ttl b/B. Communities/communityProteins.ttl new file mode 100644 index 0000000..368271c --- /dev/null +++ b/B. Communities/communityProteins.ttl @@ -0,0 +1,51 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ019 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ019" ; + rdfs:label "Community Proteins"@en ; + rdfs:comment "Lists all proteins found in pathways tagged with a selected community."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-03-30"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Communities ; + schema:keywords "communities" ; + schema:target ; + snorql:alias "B. Communities/communityProteins.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:community ; + sh:name "Community" ; + sh:defaultValue "AOP" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "http://vocabularies.wikipathways.org/wp#Curation:{value}" ; + snorql:autocomplete "community" ; + sh:order 1 + ] ; + sh:select """PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +SELECT DISTINCT ?pathway (str(?label) AS ?Protein) +WHERE { + VALUES ?community { } + ?pathway wp:ontologyTag ?community ; + a wp:Pathway . + ?protein a wp:Protein ; + rdfs:label ?label ; + dcterms:isPartOf ?pathway . +}""" . diff --git a/C. Collaborations/AOP-Wiki/MetaboliteInAOP-Wiki.ttl b/C. Collaborations/AOP-Wiki/MetaboliteInAOP-Wiki.ttl new file mode 100644 index 0000000..5a6941d --- /dev/null +++ b/C. Collaborations/AOP-Wiki/MetaboliteInAOP-Wiki.ttl @@ -0,0 +1,59 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ031 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ031" ; + rdfs:label "Metabolites in AOP-Wiki"@en ; + rdfs:comment "Finds metabolites in pathways of the chosen species that are linked to stressors in AOP-Wiki, by querying the AOP-Wiki SPARQL endpoint and matching on ChEBI identifiers."@en ; + schema:version "1.0.0" ; + dcterms:created "2023-08-10"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:AOPWiki ; + schema:keywords "collaborations", "AOP-Wiki", "metabolite" ; + schema:target ; + spex:federatesWith ; + snorql:alias "C. Collaborations/AOP-Wiki/MetaboliteInAOP-Wiki.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX skos: +PREFIX wp: +PREFIX cheminf: + +SELECT DISTINCT (str(?title) as ?pathwayName) ?chemical ?ChEBI ?ChemicalName ?mappedid ?LinkedStressor + +WHERE { + # Query AOP-Wiki first: it returns its few hundred ChEBI-mapped chemicals in one request, + # which are then joined to the local metabolites. With the SERVICE block last, the endpoint + # sends one remote request per metabolite and times out. + SERVICE { + ?mappedid a cheminf:000407 ; cheminf:000407 ?ChEBI . + ?cheLook a cheminf:000000 ; dc:title ?ChemicalName ; dcterms:isPartOf ?LinkedStressor ; skos:exactMatch ?mappedid . + } + ?chemical a wp:Metabolite ; dcterms:isPartOf ?pathway ; wp:bdbChEBI ?mappedid . + VALUES ?species { "Homo sapiens" } + ?pathway a wp:Pathway ; wp:organismName ?species ; dc:title ?title . +} +ORDER BY ?ChemicalName ?pathwayName""" . diff --git a/C. Collaborations/MetaNetX/reactionID_mapping.ttl b/C. Collaborations/MetaNetX/reactionID_mapping.ttl new file mode 100644 index 0000000..67c9f98 --- /dev/null +++ b/C. Collaborations/MetaNetX/reactionID_mapping.ttl @@ -0,0 +1,65 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ032 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ032" ; + rdfs:label "MetaNetX Reaction ID Mapping"@en ; + rdfs:comment "Maps Rhea reaction IDs from a WikiPathways pathway to MetaNetX reaction identifiers by querying the MetaNetX SPARQL endpoint. May be slower due to external endpoint dependency."@en ; + schema:version "1.0.0" ; + dcterms:created "2022-11-08"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:MetaNetX ; + schema:keywords "collaborations", "MetaNetX", "reaction" ; + schema:target ; + spex:federatesWith ; + snorql:alias "C. Collaborations/MetaNetX/reactionID_mapping.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX wp: +PREFIX rdfs: +PREFIX dcterms: +#Prefixes for the MetaNetX RDF: +PREFIX mnx: +PREFIX owl: +PREFIX rdf: +PREFIX rhea: + +#Variable selection +SELECT DISTINCT (str(?title) as ?pathwayName) ?PWID ?interactionID ?reac + +WHERE { +#Pathway Model IDs of interest +VALUES ?PWID {"WP5275"} + + ?pathway a wp:Pathway . #Define what a pathway is + ?pathway dcterms:identifier ?PWID. #Obtain the ID + ?pathway dc:title ?title . #Obtain the title + + ?interaction wp:bdbRhea ?interactionID . #Find interactions with a Rhea ID + ?interaction dcterms:isPartOf ?pathway . #Only those part of PW + + ##The IRI for Rhea-IDs from WikiPathways starts with https://identifiers.org/rhea/, where the one from MetaNetX starts with "http://rdf.rhea-db.org/ , so we need to rewrite the IRI + # Bind the created IRI into a new variable ?newIRI: take the Rhea IRI from WikiPathways as a string, + # remove the first 29 characters and put "http://rdf.rhea-db.org/" in front of what is left. + BIND(IRI(CONCAT("http://rdf.rhea-db.org/", SUBSTR(STR(?interactionID), 30))) AS ?newIRI) + SERVICE { + SELECT DISTINCT ?reac + WHERE{ + ?reac mnx:reacXref rhea:17658 .} + } + +} ORDER BY ASC(?pathway)""" . diff --git a/C. Collaborations/MolMeDB/ONEpubchem_MANYpathways.ttl b/C. Collaborations/MolMeDB/ONEpubchem_MANYpathways.ttl new file mode 100644 index 0000000..a3aadc6 --- /dev/null +++ b/C. Collaborations/MolMeDB/ONEpubchem_MANYpathways.ttl @@ -0,0 +1,62 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ033 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ033" ; + rdfs:label "Pathways for a PubChem Compound (MolMeDB)"@en ; + rdfs:comment "Finds all human pathways containing a specific MolMeDB compound by resolving its PubChem identifier through the MolMeDB SPARQL endpoint. May be slower due to external endpoint dependency."@en ; + schema:version "1.0.0" ; + dcterms:created "2021-11-12"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:MolMeDB ; + schema:keywords "collaborations", "MolMeDB", "PubChem" ; + schema:target ; + spex:federatesWith ; + snorql:alias "C. Collaborations/MolMeDB/ONEpubchem_MANYpathways.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX skos: +PREFIX wp: + +SELECT DISTINCT ?pathwayRes (str(?wpid) as ?pathway) (str(?title) as ?pathwayTitle) ((substr(str(?COMPOUND),46)) as ?PubChem) WHERE +{ + SERVICE { + skos:exactMatch ?COMPOUND. + filter (strstarts(str(?COMPOUND), 'http://rdf.ncbi.nlm.nih.gov/pubchem/compound/CID')) + } + + ?gene a wp:Metabolite ; + dcterms:identifier ?id ; + dcterms:isPartOf ?pathwayRes ; + wp:bdbPubChem ?COMPOUND . + + VALUES ?species { "Homo sapiens" } + ?pathwayRes a wp:Pathway ; + wp:organismName ?species; + dcterms:identifier ?wpid ; + dc:title ?title . +}""" . diff --git a/C. Collaborations/MolMeDB/SUBSETpathways_ONEpubchem.ttl b/C. Collaborations/MolMeDB/SUBSETpathways_ONEpubchem.ttl new file mode 100644 index 0000000..fb286fb --- /dev/null +++ b/C. Collaborations/MolMeDB/SUBSETpathways_ONEpubchem.ttl @@ -0,0 +1,65 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ034 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ034" ; + rdfs:label "PubChem Compound in Pathway Subset (MolMeDB)"@en ; + rdfs:comment "Checks a subset of pathways for the presence of a specific MolMeDB compound by querying the MolMeDB SPARQL endpoint. Uses nested federation with both MolMeDB and WikiPathways endpoints. May be slower due to external endpoint dependency."@en ; + schema:version "1.0.0" ; + dcterms:created "2021-11-15"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:MolMeDB ; + schema:keywords "collaborations", "MolMeDB", "PubChem" ; + schema:target ; + spex:federatesWith ; + spex:federatesWith ; + snorql:alias "C. Collaborations/MolMeDB/SUBSETpathways_ONEpubchem.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX skos: +PREFIX wp: + +SELECT DISTINCT ?pathwayRes (str(?wpid) as ?pathway) (str(?title) as ?pathwayTitle) ((substr(str(?COMPOUND),46)) as ?PubChem) WHERE { + SERVICE { + SERVICE { + VALUES ?wpid {"WP4224" "WP4225" "WP4571"} + + ?gene a wp:Metabolite ; + dcterms:identifier ?id ; + dcterms:isPartOf ?pathwayRes ; + wp:bdbPubChem ?COMPOUND . + + VALUES ?species { "Homo sapiens" } + ?pathwayRes a wp:Pathway ; + wp:organismName ?species ; + dcterms:identifier ?wpid ; + dc:title ?title . + } + + skos:exactMatch ?COMPOUND. + } +}""" . diff --git a/C. Collaborations/neXtProt/ProteinCellularLocation.ttl b/C. Collaborations/neXtProt/ProteinCellularLocation.ttl new file mode 100644 index 0000000..a7b4acf --- /dev/null +++ b/C. Collaborations/neXtProt/ProteinCellularLocation.ttl @@ -0,0 +1,58 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ084 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ084" ; + rdfs:label "Protein Cellular Location via neXtProt"@en ; + rdfs:comment "Retrieves subcellular locations for proteins in Rett syndrome pathways by querying the neXtProt SPARQL endpoint for gold-quality cellular component annotations. May be slower due to external endpoint dependency. The neXtProt SPARQL endpoint has been archived (it redirects to expasy.org/archives/nextprot), so this query no longer works."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-06"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:neXtProt ; + schema:keywords "collaborations", "neXtProt", "protein" ; + schema:target ; + spex:federatesWith ; + snorql:alias "C. Collaborations/neXtProt/ProteinCellularLocation.rq" ; + prov:wasDerivedFrom ; + owl:deprecated true ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: +PREFIX : +select distinct ?pathwayname ?entry (str(?gen) as ?gene) (group_concat(distinct str(?loclab); SEPARATOR = ",") as ?locations) where { + {?geneProduct a wp:Protein} + union + {?geneProduct a wp:GeneProduct} + ?geneProduct rdfs:label ?gen . + filter(!regex(?gen,"[ a-z-]")). + ?geneProduct dcterms:isPartOf ?pathway . + ?pathway a wp:Pathway . + ?pathway wp:organism ?organism . + filter(contains(str(?organism),"9606")) + ?pathway dc:title ?pathwayname . + filter(regex(?pathwayname,"Rett")). + service { + ?entry a :Entry ; + :gene / :name ?gen ; + :isoform ?iso. + ?iso :cellularComponent ?locannot . + ?locannot :term ?locterm . + ?locterm rdfs:label ?loclab . + ?locannot :evidence ?locev . + ?locev :quality :GOLD . + }} +group by ?pathwayname ?entry ?gen +order by ?pathwayname""" . diff --git a/C. Collaborations/neXtProt/ProteinMitochondria.ttl b/C. Collaborations/neXtProt/ProteinMitochondria.ttl new file mode 100644 index 0000000..b8d97dc --- /dev/null +++ b/C. Collaborations/neXtProt/ProteinMitochondria.ttl @@ -0,0 +1,58 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ085 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ085" ; + rdfs:label "Mitochondrial Proteins via neXtProt"@en ; + rdfs:comment "Identifies mitochondrial proteins in Rett syndrome pathways by querying the neXtProt SPARQL endpoint for gold-quality mitochondrion localization annotations. May be slower due to external endpoint dependency. The neXtProt SPARQL endpoint has been archived (it redirects to expasy.org/archives/nextprot), so this query no longer works."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-06"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:neXtProt ; + schema:keywords "collaborations", "neXtProt", "protein" ; + schema:target ; + spex:federatesWith ; + snorql:alias "C. Collaborations/neXtProt/ProteinMitochondria.rq" ; + prov:wasDerivedFrom ; + owl:deprecated true ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: +PREFIX : +PREFIX cv: + +select distinct ?pathwayname (group_concat(distinct ?gen; separator=",") as ?genes) where { + {?geneProduct a wp:Protein} + union + {?geneProduct a wp:GeneProduct} + ?geneProduct rdfs:label ?gen . + filter(!regex(?gen,"[ a-z-]")). + ?geneProduct dcterms:isPartOf ?pathway . + ?pathway a wp:Pathway . + ?pathway wp:organism ?organism . + filter(contains(str(?organism),"9606")) + ?pathway dc:title ?pathwayname . + filter(regex(?pathwayname,"Rett")). + service { + ?entry a :Entry . + ?entry :gene / :name ?gen . + ?entry :isoform / :cellularComponent ?loc . + values ?mitoloc {cv:SL-0173 cv:GO_0005739 } # SL and GO values for mitochondrion + ?loc :term / :childOf ?mitoloc. # mitochondrion + ?loc :evidence / :quality :GOLD . + }} +group by ?pathwayname +order by ?pathwayname""" . diff --git a/C. Collaborations/smallMolecules_Rhea_IDSM/molecularSimularity_Reactions.ttl b/C. Collaborations/smallMolecules_Rhea_IDSM/molecularSimularity_Reactions.ttl new file mode 100644 index 0000000..32ce263 --- /dev/null +++ b/C. Collaborations/smallMolecules_Rhea_IDSM/molecularSimularity_Reactions.ttl @@ -0,0 +1,75 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ035 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ035" ; + rdfs:label "Molecular Similarity Reactions via Rhea and IDSM"@en ; + rdfs:comment "Finds structurally similar compounds for reaction sources and targets in a pathway by querying the IDSM structure search service for molecular similarity. May be slower due to external endpoint dependency."@en ; + schema:version "1.0.0" ; + dcterms:created "2022-11-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:RheaIDSM ; + schema:keywords "collaborations", "Rhea", "IDSM", "reaction" ; + schema:target ; + spex:federatesWith ; + snorql:alias "C. Collaborations/smallMolecules_Rhea_IDSM/molecularSimularity_Reactions.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX owl: +PREFIX ebi: +PREFIX sachem: +PREFIX idsm: +PREFIX dcterms: +PREFIX wp: +PREFIX sso: +PREFIX rh: +PREFIX rdfs: +PREFIX xsd: + +SELECT distinct ?chebioSrc ?similarSrc ?chebioTgt ?similarTgt ?reaction WHERE { + ?interaction dcterms:isPartOf ?pathway ; a wp:Conversion ; + wp:source ?source ; + wp:target ?target . + ?source wp:bdbChEBI ?chebiSrc . + ?target wp:bdbChEBI ?chebiTgt . + ?pathway dcterms:identifier "WP4225". + BIND(iri(concat("http://purl.obolibrary.org/obo/CHEBI_", substr(str(?chebiSrc),37))) AS ?chebioSrc) + BIND(iri(concat("http://purl.obolibrary.org/obo/CHEBI_", substr(str(?chebiTgt),37))) AS ?chebioTgt) + + +#IDSM +SERVICE { + + ?chebioSrc ^sso:is-attribute-of / sso:has-value ?molfileSrc . + ?chebioTgt ^sso:is-attribute-of / sso:has-value ?molfileTgt . + [ sachem:compound ?similarSrc; sachem:score ?scoreSrc ] + sachem:similaritySearch [ + sachem:query ?molfileSrc ; +# sachem:cutoff "0.98"^^xsd:double + ]. + [ sachem:compound ?similarTgt; sachem:score ?scoreTgt ] + sachem:similaritySearch [ + sachem:query ?molfileTgt ; +# sachem:cutoff "0.98"^^xsd:double + ]. + } + +# SERVICE { +# ?reaction rh:side / rh:contains / rh:compound / rh:chebi ?similarSrc , ?similarTgt . +# ?reaction rdfs:subClassOf rh:Reaction . +# } + + }""" . diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..63be896 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,28 @@ +cff-version: 1.2.0 +message: "If you use these example queries, please cite them as below." +title: "WikiPathways SPARQL examples" +type: dataset +abstract: >- + Example SPARQL queries for the WikiPathways SPARQL endpoint, each with a permanent + identifier, a version and metadata, in the format of SIB's sparql-examples. +authors: + - family-names: Slenter + given-names: Denise + orcid: "https://orcid.org/0000-0001-8449-1318" + - family-names: Willighagen + given-names: Egon + orcid: "https://orcid.org/0000-0001-7542-0286" + - family-names: Winckers + given-names: Laurent + - family-names: Martens + given-names: Marvin + orcid: "https://orcid.org/0000-0003-2230-0840" + - name: "WikiPathways team" +license: GPL-3.0-only +repository-code: "https://github.com/wikipathways/SPARQLQueries" +url: "https://sparql.wikipathways.org/" +keywords: + - SPARQL + - WikiPathways + - RDF + - example queries diff --git a/D. General/GenesofPathway.ttl b/D. General/GenesofPathway.ttl new file mode 100644 index 0000000..a7eb4ef --- /dev/null +++ b/D. General/GenesofPathway.ttl @@ -0,0 +1,56 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ036 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ036" ; + rdfs:label "Genes of a Pathway"@en ; + rdfs:comment "Lists all gene products in a given pathway, returning the pathway identifier and gene product labels."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-11"^^xsd:date ; + dcterms:creator ; + dcterms:contributor , ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "general" ; + schema:target ; + snorql:alias "D. General/GenesofPathway.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP1560" ; + sh:datatype xsd:string ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +select distinct ?pathway (str(?label) as ?geneProduct) where { + { + SELECT ?pathwayRev ?pathway WHERE { + VALUES ?pathwayId { "WP1560" } + ?pathwayRev dcterms:identifier ?pathwayId . + ?pathwayRev a wp:Pathway . + ?pathwayRev dc:identifier ?pathway . + } + } + ?gene dcterms:isPartOf ?pathwayRev . + ?gene a wp:GeneProduct . + ?gene rdfs:label ?label . +}""" . diff --git a/D. General/GroupsAndComplexesWithGene.ttl b/D. General/GroupsAndComplexesWithGene.ttl new file mode 100644 index 0000000..a5b86f1 --- /dev/null +++ b/D. General/GroupsAndComplexesWithGene.ttl @@ -0,0 +1,43 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ066 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ066" ; + rdfs:label "Groups and Complexes with a Particular Gene"@en ; + rdfs:comment "Lists all groups and complexes that contain a particular gene or protein (wp:GeneProduct), here gene products whose label contains \"CYP\"."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "complex", "gene", "group" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +SELECT DISTINCT ?pathway (str(?label) as ?geneProduct) +WHERE { + ?gene a wp:GeneProduct . + ?gene rdfs:label ?label . + ?gene dcterms:isPartOf ?pathway . + + FILTER NOT EXISTS { ?pathway a wp:Interaction } . + FILTER NOT EXISTS { ?pathway a wp:Pathway } . + FILTER regex(str(?label), "CYP"). +}""" . diff --git a/D. General/InteractionsOfDataNode.ttl b/D. General/InteractionsOfDataNode.ttl new file mode 100644 index 0000000..f912fcf --- /dev/null +++ b/D. General/InteractionsOfDataNode.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ071 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ071" ; + rdfs:label "Interactions for a Particular Data Node"@en ; + rdfs:comment "Finds all interactions (wp:Interaction) connected to a particular data node, here the Ensembl gene ENSG00000125845."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "gene", "interaction" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?interaction ?pathway WHERE { + ?pathway a wp:Pathway . + ?interaction dcterms:isPartOf ?pathway . + ?interaction a wp:Interaction . + ?interaction wp:participants . +}""" . diff --git a/D. General/InteractionsofPathway.ttl b/D. General/InteractionsofPathway.ttl new file mode 100644 index 0000000..9eb0686 --- /dev/null +++ b/D. General/InteractionsofPathway.ttl @@ -0,0 +1,56 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ037 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ037" ; + rdfs:label "Interactions of a Pathway"@en ; + rdfs:comment "Returns all interactions in a given pathway along with the participating data nodes and their labels."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-11"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "general" ; + schema:target ; + snorql:alias "D. General/InteractionsofPathway.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP1425" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "https://identifiers.org/wikipathways/{value}" ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +SELECT DISTINCT ?pathway ?interaction ?participants ?DataNodeLabel +WHERE { + + VALUES ?pathwayId { } + ?pathway a wp:Pathway ; + dc:identifier ?pathwayId . + ?interaction dcterms:isPartOf ?pathway ; + a wp:Interaction ; + wp:participants ?participants . + ?participants a wp:DataNode ; + rdfs:label ?DataNodeLabel . +}""" . diff --git a/D. General/MetabolitesofPathway.ttl b/D. General/MetabolitesofPathway.ttl new file mode 100644 index 0000000..2684123 --- /dev/null +++ b/D. General/MetabolitesofPathway.ttl @@ -0,0 +1,54 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ038 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ038" ; + rdfs:label "Metabolites of a Pathway"@en ; + rdfs:comment "Lists all metabolites in a given pathway, returning the pathway identifier and metabolite labels."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-11"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "general" ; + schema:target ; + snorql:alias "D. General/MetabolitesofPathway.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP1560" ; + sh:datatype xsd:string ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +select distinct ?pathway (str(?label) as ?Metabolite) where { + { + SELECT ?pathway WHERE { + VALUES ?pathwayId { "WP1560" } + ?pathway dcterms:identifier ?pathwayId . + ?pathway a wp:Pathway . + } + } + ?metabolite a wp:Metabolite ; + rdfs:label ?label ; + dcterms:isPartOf ?pathway . +}""" . diff --git a/D. General/OntologyofPathway.ttl b/D. General/OntologyofPathway.ttl new file mode 100644 index 0000000..13143c5 --- /dev/null +++ b/D. General/OntologyofPathway.ttl @@ -0,0 +1,52 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ039 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ039" ; + rdfs:label "Ontology Terms of a Pathway"@en ; + rdfs:comment "Retrieves all ontology tags associated with a given pathway, returning the ontology term URI, pathway title, and identifier."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-11"^^xsd:date ; + dcterms:creator ; + dcterms:contributor , ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "general" ; + schema:target ; + snorql:alias "D. General/OntologyofPathway.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP1560" ; + sh:datatype xsd:string ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT (?o as ?pwOntologyTerm) (str(?titleLit) as ?title) ?pathway +WHERE { + VALUES ?pathwayId { "WP1560" } + ?pathwayRDF wp:ontologyTag ?o ; + dc:identifier ?pathway ; + dc:title ?titleLit ; + dcterms:identifier ?pathwayId . + + FILTER (! regex(str(?pathway), "group")) +}""" . diff --git a/D. General/PathwayCountPerDisease.ttl b/D. General/PathwayCountPerDisease.ttl new file mode 100644 index 0000000..c7f7be7 --- /dev/null +++ b/D. General/PathwayCountPerDisease.ttl @@ -0,0 +1,37 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ005 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ005" ; + rdfs:label "Pathway Count per Disease"@en ; + rdfs:comment "List all diseases and the number of pathways they are linked to, in decreasing order."@en ; + schema:version "1.0.0" ; + dcterms:created "2024-10-20"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "disease" ; + schema:target ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: +PREFIX rdfs: + +SELECT ?diseaseLabel ?disease (COUNT(DISTINCT ?pathway) AS ?count) +WHERE { + ?pathway wp:diseaseOntologyTag ?disease ; + a wp:Pathway . + ?disease rdfs:label ?diseaseLabel . +} GROUP BY ?diseaseLabel ?disease + ORDER BY DESC(?count)""" . diff --git a/D. General/PathwaysWithGene.ttl b/D. General/PathwaysWithGene.ttl new file mode 100644 index 0000000..a9e0ea0 --- /dev/null +++ b/D. General/PathwaysWithGene.ttl @@ -0,0 +1,42 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ065 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ065" ; + rdfs:label "Pathways with a Particular Gene"@en ; + rdfs:comment "Lists all pathways per instance of a particular gene or protein (wp:GeneProduct), here all gene products whose label contains \"CYP\"."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "gene", "pathway" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +SELECT DISTINCT ?pathway (str(?label) as ?geneProduct) +WHERE { + ?gene a wp:GeneProduct . + ?gene rdfs:label ?label . + ?gene dcterms:isPartOf ?pathway . + ?pathway a wp:Pathway . + + FILTER regex(str(?label), "CYP"). +}""" . diff --git a/D. General/PathwaysWithOntologyTerm.ttl b/D. General/PathwaysWithOntologyTerm.ttl new file mode 100644 index 0000000..753330c --- /dev/null +++ b/D. General/PathwaysWithOntologyTerm.ttl @@ -0,0 +1,40 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ069 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ069" ; + rdfs:label "Pathways with a Particular Ontology Term"@en ; + rdfs:comment "Lists the pathways tagged with a particular ontology term, here PW_0000296 from the Pathway Ontology."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:General ; + schema:keywords "ontology", "pathway" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX foaf: +PREFIX wp: +PREFIX obo: + +SELECT ?pathway (str(?titleLit) AS ?title) +WHERE { + ?pathwayRDF wp:ontologyTag obo:PW_0000296 ; + foaf:page ?pathway ; + dc:title ?titleLit . +}""" . diff --git a/E. Literature/allPathwayswithPubMed.ttl b/E. Literature/allPathwayswithPubMed.ttl new file mode 100644 index 0000000..be71aa0 --- /dev/null +++ b/E. Literature/allPathwayswithPubMed.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ040 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ040" ; + rdfs:label "All Pathways with PubMed References"@en ; + rdfs:comment "Lists pathways that have associated PubMed publication references, returning pathway and PubMed identifiers ordered by pathway."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Literature ; + schema:keywords "literature" ; + schema:target ; + snorql:alias "E. Literature/allPathwayswithPubMed.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?pathway ?pubmed +WHERE + {?pubmed a wp:PublicationReference . + ?pubmed dcterms:isPartOf ?pathway } +ORDER BY ?pathway +LIMIT 50""" . diff --git a/E. Literature/allReferencesForInteraction.ttl b/E. Literature/allReferencesForInteraction.ttl new file mode 100644 index 0000000..c84570a --- /dev/null +++ b/E. Literature/allReferencesForInteraction.ttl @@ -0,0 +1,53 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ041 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ041" ; + rdfs:label "All References for an Interaction"@en ; + rdfs:comment "Returns all publication references for interactions in a given pathway, including references attached to both the interaction itself and its participating data nodes."@en ; + schema:version "1.0.0" ; + dcterms:created "2022-10-26"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Literature ; + schema:keywords "literature" ; + schema:target ; + snorql:alias "E. Literature/allReferencesForInteraction.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP5200" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "https://identifiers.org/wikipathways/{value}" ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?pathway ?interaction ?pubmed ?partnerref WHERE { + VALUES ?pathwayId { } + ?pathway a wp:Pathway ; + dc:identifier ?pathwayId . + ?interaction dcterms:isPartOf ?pathway ; + a wp:Interaction ; + wp:participants ?partner; + dcterms:references ?pubmed . + OPTIONAL{?partner dc:identifier ?partnerID ; + dcterms:references ?partnerref .} +} LIMIT 100""" . diff --git a/E. Literature/countRefsPerPW.ttl b/E. Literature/countRefsPerPW.ttl new file mode 100644 index 0000000..c179b56 --- /dev/null +++ b/E. Literature/countRefsPerPW.ttl @@ -0,0 +1,37 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ042 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ042" ; + rdfs:label "Reference Count per Pathway"@en ; + rdfs:comment "Counts the number of PubMed publication references per pathway, sorted by descending reference count."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Literature ; + schema:keywords "literature" ; + schema:target ; + snorql:alias "E. Literature/countRefsPerPW.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?pathway (COUNT(?pubmed) AS ?numberOfReferences) +WHERE + {?pubmed a wp:PublicationReference . + ?pubmed dcterms:isPartOf ?pathway } +GROUP BY ?pathway +ORDER BY DESC(?numberOfReferences)""" . diff --git a/E. Literature/referencesForInteraction.ttl b/E. Literature/referencesForInteraction.ttl new file mode 100644 index 0000000..34fac89 --- /dev/null +++ b/E. Literature/referencesForInteraction.ttl @@ -0,0 +1,57 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ043 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ043" ; + rdfs:label "References for an Interaction"@en ; + rdfs:comment "Returns publication references directly attached to interactions in a given pathway, along with the participating data node labels."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-11"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Literature ; + schema:keywords "literature" ; + schema:target ; + snorql:alias "E. Literature/referencesForInteraction.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP5200" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "https://identifiers.org/wikipathways/{value}" ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +SELECT DISTINCT ?pathway ?interaction ?pubmed +WHERE { + + VALUES ?pathwayId { } + ?pathway a wp:Pathway ; + dc:identifier ?pathwayId . #filter for one pathway + ?interaction dcterms:isPartOf ?pathway ; + a wp:Interaction ; + dcterms:references ?pubmed ; + wp:participants ?participants . + ?participants a wp:DataNode ; + rdfs:label ?DataNodeLabel . +}""" . diff --git a/E. Literature/referencesForSpecificInteraction.ttl b/E. Literature/referencesForSpecificInteraction.ttl new file mode 100644 index 0000000..4e1bbcb --- /dev/null +++ b/E. Literature/referencesForSpecificInteraction.ttl @@ -0,0 +1,61 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ044 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ044" ; + rdfs:label "References for a Specific Interaction"@en ; + rdfs:comment "Returns publication references for a single interaction identified by both a pathway and a specific participant URI."@en ; + schema:version "1.0.0" ; + dcterms:created "2022-10-26"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:Literature ; + schema:keywords "literature" ; + schema:target ; + snorql:alias "E. Literature/referencesForSpecificInteraction.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP5200" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "https://identifiers.org/wikipathways/{value}" ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:proteinId ; + sh:name "UniProt Protein ID" ; + sh:defaultValue "P35498" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "https://identifiers.org/uniprot/{value}" ; + sh:order 2 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?pathway ?interaction ?pubmed WHERE { + ?pathway a wp:Pathway . + VALUES ?pathwayId { } + ?pathway dc:identifier ?pathwayId . #filter for pathway + ?interaction dcterms:isPartOf ?pathway . + ?interaction a wp:Interaction . + VALUES ?proteinId { } + ?interaction wp:participants ?proteinId. #filter for interaction + ?interaction dcterms:references ?pubmed . +} LIMIT 100""" . diff --git a/F. Datadump/CyTargetLinkerLinksetInput.ttl b/F. Datadump/CyTargetLinkerLinksetInput.ttl new file mode 100644 index 0000000..8ad2144 --- /dev/null +++ b/F. Datadump/CyTargetLinkerLinksetInput.ttl @@ -0,0 +1,43 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ045 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ045" ; + rdfs:label "CyTargetLinker Linkset Input"@en ; + rdfs:comment "Exports pathway-gene associations formatted as input for CyTargetLinker, a Cytoscape app for link set analysis. Returns pathway names and IDs paired with HGNC gene symbols and Entrez Gene IDs."@en ; + schema:version "1.0.0" ; + dcterms:created "2021-02-03"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:DataExport ; + schema:keywords "data export" ; + schema:target ; + snorql:alias "F. Datadump/CyTargetLinkerLinksetInput.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX fn: +PREFIX wp: + +select distinct (str(?title) as ?PathwayName) (str(?wpid) as ?PathwayID) (fn:substring(?genename,37) as ?GeneName) (fn:substring(?ncbiGeneId,34) as ?GeneID) where { + ?gene a wp:DataNode ; + dcterms:identifier ?id ; + dcterms:isPartOf ?pathwayRes ; + wp:bdbEntrezGene ?ncbiGeneId ; + wp:bdbHgncSymbol ?genename . + ?pathwayRes a wp:Pathway ; + dcterms:identifier ?wpid ; + dc:title ?title . +}""" . diff --git a/F. Datadump/dumpOntologyAndPW.ttl b/F. Datadump/dumpOntologyAndPW.ttl new file mode 100644 index 0000000..f25c9ad --- /dev/null +++ b/F. Datadump/dumpOntologyAndPW.ttl @@ -0,0 +1,42 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ046 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ046" ; + rdfs:label "Ontology and Pathway Data Export"@en ; + rdfs:comment "Exports pathway metadata including page URLs, titles, species, identifiers, and associated ontology tags for bulk download."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:license ; + dcterms:subject wpcat:DataExport ; + schema:keywords "data export" ; + schema:target ; + snorql:alias "F. Datadump/dumpOntologyAndPW.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX foaf: +PREFIX wp: + +SELECT DISTINCT ?depicts (str(?titleLit) as ?title) (str(?speciesLabelLit) as ?speciesLabel) ?identifier ?ontology +WHERE { + ?pathway foaf:page ?depicts . + ?pathway dc:title ?titleLit . + ?pathway wp:organism ?species . + ?pathway wp:organismName ?speciesLabelLit . + ?pathway dc:identifier ?identifier . + + OPTIONAL {?pathway wp:ontologyTag ?ontology .} +}""" . diff --git a/F. Datadump/dumpPWsofSpecies.ttl b/F. Datadump/dumpPWsofSpecies.ttl new file mode 100644 index 0000000..bea3f83 --- /dev/null +++ b/F. Datadump/dumpPWsofSpecies.ttl @@ -0,0 +1,51 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ047 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ047" ; + rdfs:label "Pathways by Species Data Export"@en ; + rdfs:comment "Exports all pathways for a given species, returning identifiers, titles, and page URLs ordered by pathway ID."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-11"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DataExport ; + schema:keywords "data export" ; + schema:target ; + snorql:alias "F. Datadump/dumpPWsofSpecies.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX foaf: +PREFIX wp: + +SELECT DISTINCT ?wpIdentifier ?pathway ?title ?page +WHERE { + VALUES ?species { "Homo sapiens" } + ?pathway dc:title ?title ; + foaf:page ?page ; + dc:identifier ?wpIdentifier ; + wp:organismName ?species . + } +ORDER BY ?wpIdentifier""" . diff --git a/G. Curation/MetabolitesDoubleMappingWikidata.ttl b/G. Curation/MetabolitesDoubleMappingWikidata.ttl new file mode 100644 index 0000000..8f7a049 --- /dev/null +++ b/G. Curation/MetabolitesDoubleMappingWikidata.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ050 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ050" ; + rdfs:label "Metabolites with Duplicate Wikidata Mappings"@en ; + rdfs:comment "Detects metabolites that are mapped to more than one Wikidata identifier, listing all duplicate mappings per metabolite."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Curation ; + schema:keywords "curation" ; + schema:target ; + snorql:alias "G. Curation/MetabolitesDoubleMappingWikidata.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: +PREFIX wdt: + +SELECT DISTINCT ?metaboliteID (GROUP_CONCAT(DISTINCT ?wikidata;separator=", ") AS ?results) WHERE { + ?metaboliteID a wp:Metabolite . + ?metaboliteID wp:bdbWikidata ?wikidata . + ?metaboliteID wp:bdbWikidata ?wikidata2 . + FILTER(?wikidata != ?wikidata2) +} GROUP BY ?metaboliteID""" . diff --git a/G. Curation/MetabolitesNotClassified.ttl b/G. Curation/MetabolitesNotClassified.ttl new file mode 100644 index 0000000..3b799f2 --- /dev/null +++ b/G. Curation/MetabolitesNotClassified.ttl @@ -0,0 +1,41 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ051 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ051" ; + rdfs:label "Unclassified Metabolites"@en ; + rdfs:comment "Finds data nodes with a data source annotation that are not classified as metabolites, grouped by data source with counts sorted descending."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Curation ; + schema:keywords "curation" ; + schema:target ; + snorql:alias "G. Curation/MetabolitesNotClassified.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +prefix wp: +prefix rdfs: +prefix dcterms: + +select (str(?datasourceLit) as ?datasource) (count(?identifier) as ?count) +where { + ?mb dc:source ?datasourceLit ; + dcterms:identifier ?identifier . + FILTER NOT EXISTS { ?mb a wp:Metabolite } +} group by ?datasourceLit +order by desc(?count)""" . diff --git a/G. Curation/MetabolitesWithoutLinkWikidata.ttl b/G. Curation/MetabolitesWithoutLinkWikidata.ttl new file mode 100644 index 0000000..a959ad0 --- /dev/null +++ b/G. Curation/MetabolitesWithoutLinkWikidata.ttl @@ -0,0 +1,37 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ052 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ052" ; + rdfs:label "Metabolites Without Wikidata Links"@en ; + rdfs:comment "Lists metabolites that have no Wikidata identifier mapping, useful for identifying gaps in cross-database linkage."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Curation ; + schema:keywords "curation" ; + schema:target ; + snorql:alias "G. Curation/MetabolitesWithoutLinkWikidata.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: +PREFIX wdt: + +SELECT DISTINCT ?metabolite WHERE { + ?metabolite a wp:Metabolite . + OPTIONAL { ?metabolite wp:bdbWikidata ?wikidata . } + FILTER (!BOUND(?wikidata)) +}""" . diff --git a/G. Curation/PWsWithoutDatanodes.ttl b/G. Curation/PWsWithoutDatanodes.ttl new file mode 100644 index 0000000..1007692 --- /dev/null +++ b/G. Curation/PWsWithoutDatanodes.ttl @@ -0,0 +1,41 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ053 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ053" ; + rdfs:label "Pathways Without Data Nodes"@en ; + rdfs:comment "Finds pathways that contain no data nodes, indicating empty or incomplete pathway entries that may need curation."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor , ; + dcterms:license ; + dcterms:subject wpcat:Curation ; + schema:keywords "curation" ; + schema:target ; + snorql:alias "G. Curation/PWsWithoutDatanodes.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX skos: +prefix wp: +prefix rdfs: +prefix dcterms: +prefix xsd: + +SELECT DISTINCT ?pathway +WHERE{ +?pathway a wp:Pathway, skos:Collection . +FILTER NOT EXISTS {?node dcterms:isPartOf ?pathway. +?node a wp:DataNode} +}""" . diff --git a/G. Curation/PWsWithoutRef.ttl b/G. Curation/PWsWithoutRef.ttl new file mode 100644 index 0000000..51a577e --- /dev/null +++ b/G. Curation/PWsWithoutRef.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ054 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ054" ; + rdfs:label "Pathways Without References"@en ; + rdfs:comment "Lists pathways that have no associated publication references, returning species, title, and pathway identifier sorted alphabetically."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Curation ; + schema:keywords "curation" ; + schema:target ; + snorql:alias "G. Curation/PWsWithoutRef.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT (STR(?speciesLabelLit) AS ?species) (STR(?titleLit) AS ?title) ?pathway WHERE { + ?pathway a wp:Pathway ; dc:title ?titleLit ; wp:organismName ?speciesLabelLit . + MINUS { ?pubmed a wp:PublicationReference . + ?pubmed dcterms:isPartOf ?pathway } +} ORDER BY ASC(?species) ASC(?title)""" . diff --git a/G. Curation/countPWsMetabolitesOccurSorted.ttl b/G. Curation/countPWsMetabolitesOccurSorted.ttl new file mode 100644 index 0000000..6d497dd --- /dev/null +++ b/G. Curation/countPWsMetabolitesOccurSorted.ttl @@ -0,0 +1,41 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ048 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ048" ; + rdfs:label "Pathways by Metabolite Occurrence Count"@en ; + rdfs:comment "Counts how many pathways each metabolite appears in, filtered to metabolites without a Wikidata mapping, sorted by descending pathway count."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Curation ; + schema:keywords "curation" ; + schema:target ; + snorql:alias "G. Curation/countPWsMetabolitesOccurSorted.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: +PREFIX wdt: + +SELECT ?metabolite (count(DISTINCT ?pathwayRes) as ?pathways) WHERE { + ?metabolite a wp:Metabolite ; + dcterms:identifier ?id ; + dcterms:isPartOf ?pathwayRes . + ?pathwayRes a wp:Pathway . + OPTIONAL { ?metabolite wp:bdbWikidata ?wikidata . } + FILTER (!BOUND(?wikidata)) +} GROUP BY ?metabolite ORDER BY DESC(?pathways)""" . diff --git a/G. Curation/countPWsWithoutRef.ttl b/G. Curation/countPWsWithoutRef.ttl new file mode 100644 index 0000000..5a4cc7c --- /dev/null +++ b/G. Curation/countPWsWithoutRef.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ049 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ049" ; + rdfs:label "Count of Pathways Without References"@en ; + rdfs:comment "Returns the total number of pathways that have no associated publication references."@en ; + schema:version "1.0.0" ; + dcterms:created "2020-10-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Curation ; + schema:keywords "curation" ; + schema:target ; + snorql:alias "G. Curation/countPWsWithoutRef.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT (count(DISTINCT ?pathway) AS ?pathwayCount) WHERE { + ?pathway a wp:Pathway ; dc:title ?titleLit ; wp:organismName ?speciesLabelLit . + MINUS { ?pubmed a wp:PublicationReference . + ?pubmed dcterms:isPartOf ?pathway } +}""" . diff --git a/H. Chemistry/ChEMBLCompoundsAndPathways.ttl b/H. Chemistry/ChEMBLCompoundsAndPathways.ttl new file mode 100644 index 0000000..14c734f --- /dev/null +++ b/H. Chemistry/ChEMBLCompoundsAndPathways.ttl @@ -0,0 +1,39 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ074 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ074" ; + rdfs:label "ChEMBL Compounds and Their Pathways"@en ; + rdfs:comment "Returns all compounds annotated with \"ChEMBL compound\" as data source, and the pathways they are in."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Chemistry ; + schema:keywords "ChEMBL", "data sources", "metabolite" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?identifier ?pathway +WHERE { + ?concept dcterms:isPartOf ?pathway . ?pathway a wp:Pathway . + ?concept dc:source "ChEMBL compound" . + ?concept dc:identifier ?identifier . +}""" . diff --git a/H. Chemistry/IDSM_similaritySearch.ttl b/H. Chemistry/IDSM_similaritySearch.ttl new file mode 100644 index 0000000..e1198ee --- /dev/null +++ b/H. Chemistry/IDSM_similaritySearch.ttl @@ -0,0 +1,76 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ055 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ055" ; + rdfs:label "IDSM Chemical Similarity Search"@en ; + rdfs:comment "Finds structurally similar ChEBI compounds for source and target metabolites in a pathway's directed interactions via the IDSM/ChEBI structure search service (idsm.elixir-czech.cz). May be slower due to external endpoint dependency."@en ; + schema:version "1.0.0" ; + dcterms:created "2022-11-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Chemistry ; + schema:keywords "chemistry" ; + schema:target ; + spex:federatesWith ; + snorql:alias "H. Chemistry/IDSM_similaritySearch.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP4225" ; + sh:datatype xsd:string ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX owl: +PREFIX ebi: +PREFIX sachem: +PREFIX idsm: +PREFIX dcterms: +PREFIX wp: +PREFIX sso: +PREFIX rh: +PREFIX rdfs: +PREFIX xsd: +SELECT distinct ((substr(str(?chebioSrc),32)) as ?SourceOrigin) ((substr(str(?similarSrc),32)) as ?SourceSimilar) ((substr(str(?chebioTgt),32)) as ?TargetOrigin) ((substr(str(?similarTgt),32)) as ?TargetSimilar) #?reaction +WHERE { + ?interaction dcterms:isPartOf ?pathway ; a wp:Conversion ; + wp:source ?source ; + wp:target ?target . + ?source wp:bdbChEBI ?chebiSrc . + ?target wp:bdbChEBI ?chebiTgt . + VALUES ?pathwayId { "WP4225" } + ?pathway dcterms:identifier ?pathwayId. + BIND(iri(concat("http://purl.obolibrary.org/obo/CHEBI_", substr(str(?chebiSrc),37))) AS ?chebioSrc) + BIND(iri(concat("http://purl.obolibrary.org/obo/CHEBI_", substr(str(?chebiTgt),37))) AS ?chebioTgt) +#IDSM +SERVICE { + ?chebioSrc ^sso:is-attribute-of / sso:has-value ?molfileSrc . + ?chebioTgt ^sso:is-attribute-of / sso:has-value ?molfileTgt . + [ sachem:compound ?similarSrc; sachem:score ?scoreSrc ] + sachem:similaritySearch [ + sachem:query ?molfileSrc ; + sachem:cutoff 98e-2 + ]. + [ sachem:compound ?similarTgt; sachem:score ?scoreTgt ] + sachem:similaritySearch [ + sachem:query ?molfileTgt ; + sachem:cutoff 98e-2 + ] . + } + }""" . diff --git a/H. Chemistry/MetabolitesWithInChIKeysFromWikidata.ttl b/H. Chemistry/MetabolitesWithInChIKeysFromWikidata.ttl new file mode 100644 index 0000000..c74434c --- /dev/null +++ b/H. Chemistry/MetabolitesWithInChIKeysFromWikidata.ttl @@ -0,0 +1,44 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ075 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ075" ; + rdfs:label "Metabolites with InChIKeys from Wikidata"@en ; + rdfs:comment "Lists metabolites in WikiPathways with their Wikidata identifier and fetches their InChIKey from Wikidata. Limited to 50 metabolites. Uses a federated SERVICE call; may be slow depending on endpoint availability."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Chemistry ; + schema:keywords "InChIKey", "metabolite", "Wikidata" ; + schema:target ; + spex:federatesWith ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: +PREFIX wdt: + +SELECT ?metabolite ?wikidata ?inchikey WHERE { + { + SELECT ?metabolite ?wikidata WHERE { + ?metabolite a wp:Metabolite ; + wp:bdbWikidata ?wikidata . + } LIMIT 50 + } + SERVICE { + ?wikidata wdt:P235 ?inchikey . + } +} LIMIT 50""" . diff --git a/H. Chemistry/smiles.ttl b/H. Chemistry/smiles.ttl new file mode 100644 index 0000000..1e95d83 --- /dev/null +++ b/H. Chemistry/smiles.ttl @@ -0,0 +1,35 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ056 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ056" ; + rdfs:label "SMILES for Metabolites"@en ; + rdfs:comment "Retrieves SMILES chemical structure notations for metabolites via their Wikidata links."@en ; + schema:version "1.0.0" ; + dcterms:created "2022-03-14"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Chemistry ; + schema:keywords "chemistry" ; + schema:target ; + snorql:alias "H. Chemistry/smiles.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX wp: +PREFIX cheminf: + +SELECT ?mol ?smilesDepict WHERE { + ?mol wp:bdbWikidata/cheminf:CHEMINF_000018 ?smilesDepict . +} LIMIT 25""" . diff --git a/HEADER_CONVENTIONS.md b/HEADER_CONVENTIONS.md deleted file mode 100644 index ac9ec4b..0000000 --- a/HEADER_CONVENTIONS.md +++ /dev/null @@ -1,180 +0,0 @@ -# Header Conventions Guide - -Definitive reference for `.rq` file header format in the WikiPathways SPARQL query collection. All enrichment work (Phases 2-4) must follow these rules. - -## Header Format Overview - -- Headers are comment lines (`#`) at the **top** of `.rq` files -- The header block ends at the **first blank line** -- One blank line separates headers from the SPARQL query body -- Fields use the format `# field: value` - -## Field Order - -Headers must appear in this order: - -``` -# title: [value] -# category: [value] -# description: [value] -# description: [continued value if multi-line] -# keywords: [optional, comma-separated] -# param: [optional, pipe-delimited] -``` - -**Required fields:** `title`, `category`, `description` -**Optional fields:** `keywords`, `param` - -## Field Specifications - -### `# title:` (required) - -One line. Clear, human-readable display name for the SNORQL UI. - -- Derived from query purpose, not the filename -- Use title case -- Keep concise (under ~60 characters) - -| Good | Bad | -|-----------------------------------|--------------------------| -| `# title: All Pathways for Species` | `# title: allPathwaysBySpecies` | -| `# title: Gene-Pathway Associations` | `# title: query1` | - -### `# category:` (required) - -One line. Exactly one value from the controlled vocabulary in `categories.json`. - -Valid values: Metadata, Data Sources, Communities, Collaborations, General, Literature, Data Export, Curation, Chemistry, DSMN, Authors. - -The category is determined by the query's directory location. See `categories.json` for the directory-to-category mapping. - -### `# description:` (required) - -Explains what the query does and what results to expect. - -**Single-line:** -``` -# description: Lists all pathways in the WikiPathways database. -``` - -**Multi-line:** Repeat the `# description:` prefix on each continuation line. This is required because the SNORQL parser collects all lines matching the `# description:` prefix. Bare continuation lines (e.g., `# continued text`) are NOT captured by the UI. - -``` -# description: Lists all pathways tagged with the AOP community. -# description: Returns pathway identifiers, titles, and organism. -``` - -**Federated queries** (those containing `SERVICE` clauses) should mention federation and potential performance impact: -``` -# description: Retrieves compound mappings from MetaNetX via federation. -# description: Uses a federated SERVICE call; may be slow depending on endpoint availability. -``` - -### `# keywords:` (optional, future) - -Comma-separated values on one line. NOT currently rendered by the SNORQL UI but included for future compatibility. - -``` -# keywords: pathways, species, metadata -``` - -### `# param:` (optional, Phase 4) - -Pipe-delimited format for parameterized queries: - -``` -# param: name | type | defaultValue | label -``` - -**Supported types:** -- `string` -- free-text input -- `uri` -- expects a URI value -- `enum:val1,val2,val3` -- dropdown selection - -Multiple parameters use multiple `# param:` lines. - -## SNORQL Parser Behavior - -The SNORQL parser scans **all lines** in the file for field-prefixed patterns, not just leading lines. This means: - -1. `# title:`, `# category:`, `# description:`, and `# param:` prefixes must **only** appear in the header block -2. Inline SPARQL comments elsewhere in the file must **not** use these exact prefixes -3. Use alternative phrasing for inline comments (e.g., `# Note: this filters by species` instead of `# description: this filters by species`) - -## Existing Comments Handling - -During enrichment (Phase 2+): - -- **Descriptive comments** at the top of `.rq` files should be interpreted and absorbed into `# description:` headers -- **Inline usage hints** (e.g., `# Replace "WP1560" with WP ID of interest`) remain as inline comments BELOW the header block; they are not folded into the description -- **Existing `# title:` or `# description:` lines** that already follow the conventions are kept as-is - -## TTL Metadata Mapping - -For queries with `.ttl` source files, the following mapping applies. This is documented for future reference; TTL metadata extraction is NOT implemented in Phase 1. - -| TTL Field | Header Field | Notes | -|--------------------|-------------------|--------------------------------------------| -| `rdfs:label` | `# title:` | If present; otherwise derive from filename | -| `rdfs:comment` | `# description:` | May need splitting into multiple lines | -| `schema:keywords` | `# keywords:` | NOT mapped to `# category:` | -| (folder location) | `# category:` | Always derived from directory, never TTL | - -## Complete Examples - -### Example 1: Minimal query (title + category + description) - -```sparql -# title: All Pathways -# category: General -# description: Returns all pathways in the WikiPathways database with their titles and organisms. - -SELECT DISTINCT ?pathway ?title ?organism -WHERE { - ?pathway a wp:Pathway ; - dc:title ?title ; - wp:organismName ?organism . -} -ORDER BY ?title -``` - -### Example 2: Multi-line description - -```sparql -# title: AOP Community Pathways -# category: Communities -# description: Lists all pathways tagged with the Adverse Outcome Pathway (AOP) community. -# description: Returns pathway identifiers, titles, and last revision dates. -# description: Useful for tracking AOP-related content in WikiPathways. - -SELECT ?pathway ?title ?date -WHERE { - ?pathway a wp:Pathway ; - dc:title ?title ; - dcterms:subject cur:AOP ; - pav:lastRefreshedOn ?date . -} -ORDER BY DESC(?date) -``` - -### Example 3: Parameterized query (Phase 4) - -```sparql -# title: Pathways by Species -# category: General -# description: Returns all pathways for a given species. -# param: species | enum:Homo sapiens,Mus musculus,Rattus norvegicus,... | Homo sapiens | Species - -SELECT ?pathway ?title -WHERE { - ?pathway a wp:Pathway ; - dc:title ?title ; - wp:organismName "{{species}}" . -} -ORDER BY ?title -``` - ---- - -*Reference document for WikiPathways SPARQL query header enrichment.* -*Controlled category vocabulary: see `categories.json`.* diff --git a/I. DirectedSmallMoleculesNetwork (DSMN)/controlling duplicate mappings from Wikidata.ttl b/I. DirectedSmallMoleculesNetwork (DSMN)/controlling duplicate mappings from Wikidata.ttl new file mode 100644 index 0000000..0704ae9 --- /dev/null +++ b/I. DirectedSmallMoleculesNetwork (DSMN)/controlling duplicate mappings from Wikidata.ttl @@ -0,0 +1,57 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ057 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ057" ; + rdfs:label "Controlling Duplicate Mappings from Wikidata"@en ; + rdfs:comment "Detects metabolites mapped to multiple Wikidata identifiers as a quality control step in the DSMN workflow."@en ; + schema:version "1.0.0" ; + dcterms:created "2023-11-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DSMN ; + schema:keywords "DSMN", "directed small molecules network" ; + schema:target ; + snorql:alias "I. DirectedSmallMoleculesNetwork (DSMN)/controlling duplicate mappings from Wikidata.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """### Part 1: ### +#Required prefixes for querying WikiPathways content in Blazegraph +PREFIX gpml: +PREFIX wp: +PREFIX wprdf: +PREFIX biopax: +PREFIX cas: +PREFIX dc: +PREFIX dcterms: +PREFIX foaf: +PREFIX ncbigene: +PREFIX pubmed: +PREFIX rdf: +PREFIX rdfs: +PREFIX skos: +PREFIX xsd: +PREFIX cur: + +### Part 2: ### +#Control for double mappings to Wikidata IDs. +SELECT DISTINCT ?metaboliteID +(GROUP_CONCAT(DISTINCT ?wikidata;separator=", ") AS ?results) +WHERE { + ?metaboliteID a wp:Metabolite . + ?metaboliteID wp:bdbWikidata ?wikidata . + ?metaboliteID wp:bdbWikidata ?wikidata2 . +FILTER(?wikidata != ?wikidata2) +} GROUP BY ?metaboliteID""" . diff --git a/I. DirectedSmallMoleculesNetwork (DSMN)/extracting directed metabolic reactions.ttl b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting directed metabolic reactions.ttl new file mode 100644 index 0000000..8938735 --- /dev/null +++ b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting directed metabolic reactions.ttl @@ -0,0 +1,84 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ058 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ058" ; + rdfs:label "Extracting Directed Metabolic Reactions"@en ; + rdfs:comment "Extracts directed metabolite-to-metabolite interactions from human pathways in the AnalysisCollection, returning source and target identifiers, interaction types, and Rhea IDs as part of the DSMN workflow."@en ; + schema:version "1.0.0" ; + dcterms:created "2023-11-09"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DSMN ; + schema:keywords "DSMN", "directed small molecules network" ; + schema:target ; + snorql:alias "I. DirectedSmallMoleculesNetwork (DSMN)/extracting directed metabolic reactions.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX cur: +PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +### Part 1: ### +SELECT DISTINCT ?interaction ?sourceDb ?targetDb ?mimtype +?pathway (str(?titleLit) as ?title) +?sourceCHEBI ?targetDbCHEBI ?sourceHMDB ?targetDbHMDB ?InteractionID +WHERE { + +### Part 2: ### +VALUES ?species { "Homo sapiens" } +?pathway a wp:Pathway ; + wp:organismName ?species ; + dc:title ?titleLit . + +### Part 3A: ### +FILTER (EXISTS {?pathway wp:ontologyTag cur:AnalysisCollection}) . +### Part 3B: ### +#FILTER (EXISTS {?pathway wp:ontologyTag cur:Reactome_Approved}) . +### Part 3C: ### +#FILTER (EXISTS {?pathway wp:ontologyTag cur:Lipids}) . + +### Part 4: ### +?interaction dcterms:isPartOf ?pathway ; + a wp:DirectedInteraction ; + wp:source ?source ; + wp:target ?target . +OPTIONAL{?interaction a ?mimtype}. +VALUES ?mimtype {wp:ComplexBinding wp:Conversion wp:Inhibition wp:Catalysis +wp:Stimulation wp:TranscriptionTranslation wp:DirectedInteraction} . + +### Part 5: ### +?source a wp:Metabolite . +?source wp:bdbWikidata ?sourceDb . +OPTIONAL{?source wp:bdbChEBI ?sourceCHEBI}. +OPTIONAL{?source wp:bdbHmdb ?sourceHMDB}. +?target a wp:Metabolite . +?target wp:bdbWikidata ?targetDb . +OPTIONAL{?target wp:bdbChEBI ?targetDbCHEBI}. +OPTIONAL{?target wp:bdbHmdb ?targetDbHMDB}. + +### Part 6: ### +OPTIONAL{?interaction wp:bdbRhea ?InteractionID} . +} ORDER BY DESC(?InteractionID)""" . diff --git a/I. DirectedSmallMoleculesNetwork (DSMN)/extracting ontologies and references for metabolic reactions.ttl b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting ontologies and references for metabolic reactions.ttl new file mode 100644 index 0000000..9f92198 --- /dev/null +++ b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting ontologies and references for metabolic reactions.ttl @@ -0,0 +1,72 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ059 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ059" ; + rdfs:label "Extracting Ontologies and References for Metabolic Reactions"@en ; + rdfs:comment "Retrieves ontology annotations, curation status, and literature references for directed metabolic reactions in human pathways as part of the DSMN workflow."@en ; + schema:version "1.0.0" ; + dcterms:created "2023-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DSMN ; + schema:keywords "DSMN", "directed small molecules network" ; + schema:target ; + snorql:alias "I. DirectedSmallMoleculesNetwork (DSMN)/extracting ontologies and references for metabolic reactions.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +### Part 1: ### +SELECT DISTINCT ?interaction ?sourceDb ?targetDb ?PWOnt ?DiseaseOnt +?curationstatus ?InteractionRef ?PWref ?sourceLit ?targetLit +WHERE { +VALUES ?species { "Homo sapiens" } +?pathway a wp:Pathway ; + wp:organismName ?species; + dc:title ?titleLit . +?interaction dcterms:isPartOf ?pathway ; + a wp:DirectedInteraction ; + wp:source ?source ; + wp:target ?target . +?source a wp:Metabolite . +?source wp:bdbWikidata ?sourceDb . +?target a wp:Metabolite . +?target wp:bdbWikidata ?targetDb . + +### Part 2: ### +#OPTIONAL{?pathway wp:pathwayOntologyTag ?PWOnt} . +#OPTIONAL{?pathway wp:diseaseOntologyTag ?DiseaseOnt} . + +### Part 3: ### +#OPTIONAL{?pathway wp:ontologyTag ?curationstatus} . + +### Part 4: ### +OPTIONAL{?interaction dcterms:bibliographicCitation ?InteractionRef} . +OPTIONAL{?pathway dcterms:references ?PWref} . +OPTIONAL{?source dcterms:bibliographicCitation ?sourceLit} . +OPTIONAL{?target dcterms:bibliographicCitation ?targetLit} . +}""" . diff --git a/I. DirectedSmallMoleculesNetwork (DSMN)/extracting protein titles and identifiers for metabolic reactions.ttl b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting protein titles and identifiers for metabolic reactions.ttl new file mode 100644 index 0000000..a82e412 --- /dev/null +++ b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting protein titles and identifiers for metabolic reactions.ttl @@ -0,0 +1,69 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ060 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ060" ; + rdfs:label "Extracting Protein Titles and Identifiers for Metabolic Reactions"@en ; + rdfs:comment "Extracts catalyzing proteins for directed metabolic reactions in human AnalysisCollection pathways, returning Ensembl identifiers and protein names as part of the DSMN workflow."@en ; + schema:version "1.0.0" ; + dcterms:created "2023-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:DSMN ; + schema:keywords "DSMN", "directed small molecules network" ; + schema:target ; + snorql:alias "I. DirectedSmallMoleculesNetwork (DSMN)/extracting protein titles and identifiers for metabolic reactions.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:species ; + sh:name "Species" ; + sh:defaultValue "Homo sapiens" ; + sh:datatype xsd:string ; + snorql:autocomplete "species" ; + sh:order 1 + ] ; + sh:select """PREFIX cur: +PREFIX dc: +PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +### Part 1: ### +SELECT DISTINCT ?interaction ?sourceDb ?targetDb ?proteinDBWPs ?proteinName +WHERE { +?pathway a wp:Pathway ; +wp:ontologyTag cur:AnalysisCollection ; +wp:organismName ?species; +dc:title ?titleLit . +?interaction dcterms:isPartOf ?pathway ; + a wp:DirectedInteraction ; + wp:source ?source ; + wp:target ?target . +?source a wp:Metabolite . +?source wp:bdbWikidata ?sourceDb . +?target a wp:Metabolite . +?target wp:bdbWikidata ?targetDb . + +### Part 2: ### +?interactions2 dcterms:isPartOf ?pathway; + a wp:Catalysis; + wp:source ?sources2; + wp:target ?interaction . +OPTIONAL{?sources2 wp:bdbEnsembl ?proteinDBWPs}. +OPTIONAL{?sources2 rdfs:label ?proteinName} . +VALUES ?species { "Homo sapiens" } +}""" . diff --git a/J. Authors/authorsOfAPathway.ttl b/J. Authors/authorsOfAPathway.ttl new file mode 100644 index 0000000..7dc2b5c --- /dev/null +++ b/J. Authors/authorsOfAPathway.ttl @@ -0,0 +1,59 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ061 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ061" ; + rdfs:label "Authors of a Pathway"@en ; + rdfs:comment "Lists all authors of a given pathway in ordinal order, returning name, ORCID, homepage, and pathway version."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-02-14"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Authors ; + schema:keywords "authors" ; + schema:target ; + snorql:alias "J. Authors/authorsOfAPathway.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:parameter [ + a sh:Parameter ; + sh:path param:pathwayId ; + sh:name "Pathway ID" ; + sh:defaultValue "WP4846" ; + snorql:variable "pathway" ; + sh:nodeKind sh:IRI ; + snorql:valueTemplate "https://identifiers.org/wikipathways/{value}" ; + snorql:autocomplete "pathway" ; + sh:order 1 + ] ; + sh:select """PREFIX gpml: +PREFIX wp: +PREFIX dc: +PREFIX foaf: +PREFIX wpq: +PREFIX pav: + +SELECT ?pathway ?version ?ordinal ?author_ ?name ?orcid ?page WHERE { + VALUES ?pathway { } + ?author_ a foaf:Person ; + wp:hasAuthorship ?authorship . + ?authorship ^wp:hasAuthorship ?pathway ; + wpq:series_ordinal ?ordinal . + ?pathway pav:hasVersion ?pathway_ . + ?pathway_ a wp:Pathway ; wp:isAbout / gpml:version ?version . + OPTIONAL { ?author_ foaf:homepage ?page } + OPTIONAL { ?author_ foaf:name ?name } + OPTIONAL { ?author_ dc:identifier ?orcid } +} ORDER BY ASC(?pathway) ASC(?ordinal)""" . diff --git a/J. Authors/contributors.ttl b/J. Authors/contributors.ttl new file mode 100644 index 0000000..e2df49a --- /dev/null +++ b/J. Authors/contributors.ttl @@ -0,0 +1,49 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ062 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ062" ; + rdfs:label "All Contributors"@en ; + rdfs:comment "Counts the number of pathways each first author (ordinal 1) contributes to, sorted by descending pathway count."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-02-14"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Authors ; + schema:keywords "authors" ; + schema:target ; + snorql:alias "J. Authors/contributors.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: +PREFIX dc: +PREFIX foaf: +PREFIX wpq: +PREFIX pav: + +SELECT (COUNT(DISTINCT ?pathway) AS ?count) ?name ?orcid ?page WHERE { + VALUES ?ordinal { "1" } + ?author_ a foaf:Person ; + wp:hasAuthorship ?authorship . + ?authorship ^wp:hasAuthorship ?pathway ; + wpq:series_ordinal ?ordinal . + ?pathway pav:hasVersion ?pathway_ . + ?pathway_ a wp:Pathway ; dcterms:identifier ?version . + OPTIONAL { ?author_ foaf:homepage ?page } + OPTIONAL { ?author_ foaf:name ?name } + OPTIONAL { ?author_ dc:identifier ?orcid } +} GROUP BY ?ordinal ?name ?orcid ?page + ORDER BY DESC(?count)""" . diff --git a/J. Authors/firstAuthors.ttl b/J. Authors/firstAuthors.ttl new file mode 100644 index 0000000..ca5acce --- /dev/null +++ b/J. Authors/firstAuthors.ttl @@ -0,0 +1,49 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ063 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ063" ; + rdfs:label "First Authors of Pathways"@en ; + rdfs:comment "Lists the first author (ordinal 1) of each pathway, ordered by pathway version number."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-02-14"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Authors ; + schema:keywords "authors" ; + schema:target ; + snorql:alias "J. Authors/firstAuthors.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: +PREFIX xsd: +PREFIX dc: +PREFIX foaf: +PREFIX wpq: +PREFIX pav: + +SELECT ?pathway ?version ?ordinal ?name ?orcid ?page WHERE { + VALUES ?ordinal { "1" } + ?author_ a foaf:Person ; + wp:hasAuthorship ?authorship . + ?authorship ^wp:hasAuthorship ?pathway ; + wpq:series_ordinal ?ordinal . + ?pathway pav:hasVersion ?pathway_ . + ?pathway_ a wp:Pathway ; dcterms:identifier ?version . + OPTIONAL { ?author_ foaf:homepage ?page } + OPTIONAL { ?author_ foaf:name ?name } + OPTIONAL { ?author_ dc:identifier ?orcid } +} ORDER BY ASC(xsd:integer(SUBSTR(str(?version),3))) ASC(?ordinal)""" . diff --git a/J. Authors/pathwayCountWithAtLeastXAuthors.ttl b/J. Authors/pathwayCountWithAtLeastXAuthors.ttl new file mode 100644 index 0000000..cc0b7eb --- /dev/null +++ b/J. Authors/pathwayCountWithAtLeastXAuthors.ttl @@ -0,0 +1,42 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ064 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ064" ; + rdfs:label "Pathways with Multiple Authors"@en ; + rdfs:comment "Counts how many pathways have at least N authors for each author ordinal position, showing the distribution of author counts across pathways."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-02-14"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Authors ; + schema:keywords "authors" ; + schema:target ; + snorql:alias "J. Authors/pathwayCountWithAtLeastXAuthors.rq" ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX foaf: +PREFIX wp: +PREFIX xsd: +PREFIX dc: +PREFIX wpq: + +SELECT ?atLeast (COUNT(DISTINCT ?pathway) AS ?count) WHERE { + ?author_ a foaf:Person ; + wp:hasAuthorship ?authorship . + ?authorship ^wp:hasAuthorship ?pathway ; + wpq:series_ordinal ?atLeast . +} GROUP BY ?atLeast + ORDER BY ASC(xsd:integer(?atLeast))""" . diff --git a/K. Metabolites/AllMetabolites.ttl b/K. Metabolites/AllMetabolites.ttl new file mode 100644 index 0000000..6fd9972 --- /dev/null +++ b/K. Metabolites/AllMetabolites.ttl @@ -0,0 +1,36 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ076 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ076" ; + rdfs:label "All Metabolites"@en ; + rdfs:comment "Lists all metabolite data nodes with their labels."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metabolites ; + schema:keywords "metabolite" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX rdfs: +PREFIX wp: + +SELECT DISTINCT ?mb ?label WHERE { + ?mb a wp:Metabolite ; + rdfs:label ?label . +}""" . diff --git a/K. Metabolites/EnzymaticReactionsBetweenMetabolites.ttl b/K. Metabolites/EnzymaticReactionsBetweenMetabolites.ttl new file mode 100644 index 0000000..ec8036e --- /dev/null +++ b/K. Metabolites/EnzymaticReactionsBetweenMetabolites.ttl @@ -0,0 +1,49 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ083 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ083" ; + rdfs:label "Enzymatic Reactions between Metabolites"@en ; + rdfs:comment "Lists catalysed reactions between two metabolites, with the pathway, the label of the catalyst, the source and target metabolites, and their Wikidata identifiers."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metabolites ; + schema:keywords "catalysis", "metabolite", "reaction" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX rdfs: +PREFIX wp: + +SELECT DISTINCT ?wpid ?catalyst ?source ?sourceDb ?target ?targetDb WHERE { + ?pathway a wp:Pathway ; + dc:identifier / dcterms:identifier ?wpid . + ?catalysis dcterms:isPartOf ?pathway ; + wp:source / rdfs:label ?catalyst ; + wp:participants ?reaction . + ?reaction a wp:Interaction . + ?reaction wp:source ?source . + ?source a wp:Metabolite . + OPTIONAL{?source wp:bdbWikidata ?sourceDb .} + + ?reaction wp:target ?target . + ?target a wp:Metabolite . + OPTIONAL{?target wp:bdbWikidata ?targetDb .} +} ORDER BY ASC(?source)""" . diff --git a/K. Metabolites/HumanMetabolome.ttl b/K. Metabolites/HumanMetabolome.ttl new file mode 100644 index 0000000..18ff036 --- /dev/null +++ b/K. Metabolites/HumanMetabolome.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ080 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ080" ; + rdfs:label "Human Metabolome"@en ; + rdfs:comment "Lists all metabolite data nodes in human pathways (NCBI Taxonomy 9606). Change the taxon, for example to 3702 for Arabidopsis thaliana, to get the metabolome of another species."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metabolites ; + schema:keywords "human", "metabolite", "organism" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: +PREFIX ncbi: + +SELECT DISTINCT ?mb WHERE { + ?mb a wp:Metabolite ; + dcterms:isPartOf ?pw . + ?pw wp:organism ncbi:9606 . +} ORDER BY ?mb""" . diff --git a/K. Metabolites/MetaboliteIdentifierCountPerDataSource.ttl b/K. Metabolites/MetaboliteIdentifierCountPerDataSource.ttl new file mode 100644 index 0000000..b90d538 --- /dev/null +++ b/K. Metabolites/MetaboliteIdentifierCountPerDataSource.ttl @@ -0,0 +1,40 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ078 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ078" ; + rdfs:label "Metabolite Identifier Count per Data Source"@en ; + rdfs:comment "Counts the distinct metabolite identifiers per data source. ChEBI, HMDB and LIPID MAPS are the main data sources for metabolite identifiers."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metabolites ; + schema:keywords "counts", "data sources", "metabolite" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX wp: + +SELECT (str(?datasource) as ?source) (count(distinct ?identifier) as ?count) +WHERE { + ?mb a wp:Metabolite ; + dc:source ?datasource ; + dc:identifier ?identifier . +} +GROUP BY ?datasource +ORDER BY DESC(?count)""" . diff --git a/K. Metabolites/MetabolitesInMostPathways.ttl b/K. Metabolites/MetabolitesInMostPathways.ttl new file mode 100644 index 0000000..2c485d6 --- /dev/null +++ b/K. Metabolites/MetabolitesInMostPathways.ttl @@ -0,0 +1,39 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ082 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ082" ; + rdfs:label "Metabolites in the Most Pathways"@en ; + rdfs:comment "Counts in how many pathways each metabolite data node occurs. The results are per data node, not per unique metabolite, because no identifier mapping is applied."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metabolites ; + schema:keywords "counts", "metabolite" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: + +SELECT ?mb (count(distinct ?pathway) as ?pwCount) +WHERE { + ?mb a wp:Metabolite ; + dcterms:isPartOf ?pathway . +} +GROUP BY ?mb +ORDER BY DESC(?pwCount)""" . diff --git a/K. Metabolites/MetabolitesInZebrafishPathways.ttl b/K. Metabolites/MetabolitesInZebrafishPathways.ttl new file mode 100644 index 0000000..7a47b69 --- /dev/null +++ b/K. Metabolites/MetabolitesInZebrafishPathways.ttl @@ -0,0 +1,39 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ077 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ077" ; + rdfs:label "Metabolites in Zebrafish Pathways"@en ; + rdfs:comment "Lists the metabolites in Danio rerio (zebrafish) pathways, with the pathway title."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metabolites ; + schema:keywords "metabolite", "organism", "zebrafish" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX dcterms: +PREFIX wp: + +SELECT DISTINCT ?metabolite (str(?titleLit) as ?title) WHERE { + ?metabolite a wp:Metabolite ; + dcterms:isPartOf ?pw . + ?pw dc:title ?titleLit ; + wp:organismName "Danio rerio" . +}""" . diff --git a/K. Metabolites/MetabolitesWithKEGGIdentifier.ttl b/K. Metabolites/MetabolitesWithKEGGIdentifier.ttl new file mode 100644 index 0000000..922c50d --- /dev/null +++ b/K. Metabolites/MetabolitesWithKEGGIdentifier.ttl @@ -0,0 +1,38 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ079 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ079" ; + rdfs:label "Metabolites with a KEGG Identifier"@en ; + rdfs:comment "Lists all KEGG Compound identifiers used for metabolite data nodes. Change the data source, for example to \"HMDB\", to list the identifiers from another database."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metabolites ; + schema:keywords "data sources", "KEGG", "metabolite" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dc: +PREFIX wp: + +SELECT DISTINCT ?identifier +WHERE { + ?mb a wp:Metabolite ; + dc:source "KEGG Compound" ; + dc:identifier ?identifier . +} ORDER BY ?identifier""" . diff --git a/K. Metabolites/PathwaysWithMostMetabolites.ttl b/K. Metabolites/PathwaysWithMostMetabolites.ttl new file mode 100644 index 0000000..66eb94d --- /dev/null +++ b/K. Metabolites/PathwaysWithMostMetabolites.ttl @@ -0,0 +1,39 @@ +@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . + +wpq:WPQ081 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ; + dcterms:identifier "WPQ081" ; + rdfs:label "Pathways with the Most Metabolites"@en ; + rdfs:comment "Counts the metabolite data nodes per pathway, with the pathways with the most metabolites first."@en ; + schema:version "1.0.0" ; + dcterms:created "2026-11-10"^^xsd:date ; + dcterms:creator ; + dcterms:contributor ; + dcterms:license ; + dcterms:subject wpcat:Metabolites ; + schema:keywords "counts", "metabolite" ; + schema:target ; + prov:wasDerivedFrom ; + prov:wasDerivedFrom ; + snorql:expect [ snorql:minResults 1 ] ; + sh:select """PREFIX dcterms: +PREFIX wp: + +SELECT ?pathway (count(distinct ?mb) as ?mbCount) +WHERE { + ?mb a wp:Metabolite ; + dcterms:isPartOf ?pathway . +} +GROUP BY ?pathway +ORDER BY DESC(?mbCount)""" . diff --git a/README.md b/README.md index a1aebc5..1887bc1 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,26 @@ # SPARQL Queries for WikiPathways -Example SPARQL queries for the [WikiPathways Snorql UI](http://sparql.wikipathways.org/). These queries are loaded automatically to help users explore WikiPathways RDF data and build novel queries. - -## Adding a new query - -1. **Pick the right directory.** Queries are organized by topic in lettered directories (A-J). Place your `.rq` file in the matching directory. - -2. **Add a header.** Every `.rq` file must start with these required header fields: - - ```sparql - # title: Genes of a Pathway - # category: General - # description: Lists all gene products in a given pathway, returning the pathway - # identifier and gene product labels. - - SELECT ... - ``` - - - `title` -- short, descriptive name - - `category` -- must match an entry in `categories.json` - - `description` -- what the query does (wrap long lines with `# ` continuation indent) - - See [HEADER_CONVENTIONS.md](HEADER_CONVENTIONS.md) for full details, including optional fields like `keywords` and `param`. - -3. **Alternative: TTL format.** You can also write a `.ttl` (Turtle/RDF) file using the SHACL `sh:SPARQLExecutable` pattern. The CI pipeline will auto-generate the corresponding `.rq` file on merge to `master`. If a `.ttl` source exists, do not edit the `.rq` file directly. +Example SPARQL queries for the [WikiPathways SPARQL editor](https://sparql.wikipathways.org/). +They help people explore the WikiPathways RDF and start their own queries. + +Each example is a Turtle file with the query and its metadata (title, description, +version, creators, category, parameters), in the format of +[SIB's sparql-examples](https://github.com/sib-swiss/sparql-examples). Every example has a +permanent identifier and IRI, for example +[`WPQ036`](https://sparql.wikipathways.org/?example=WPQ036) is +`https://sparql.wikipathways.org/.well-known/sparql-examples/WPQ036`. Files can be moved +and renamed without breaking links. + +- [AUTHORING.md](AUTHORING.md): how to write or change an example, and how versions work. +- `categories.ttl`: the categories that make up the editor's tree. +- `contributors.ttl`: names of creators and contributors. +- `collection.ttl`: the collection itself. + +On every push to `master`, CI publishes the `examples-index` branch, which the editor +reads; it also holds every past version of every example and plain `.rq` copies. + +The `.rq` files next to the `.ttl` files are the old format. They are kept only until the +editor reads the new index, and are no longer edited. ## License diff --git a/categories.json b/categories.json deleted file mode 100644 index ed9710e..0000000 --- a/categories.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "categories": { - "Metadata": [ - "A. Metadata/", - "A. Metadata/datacounts/", - "A. Metadata/species/" - ], - "Data Sources": [ - "A. Metadata/datasources/" - ], - "Communities": [ - "B. Communities/AOP/", - "B. Communities/CIRM Stem Cell Pathways/", - "B. Communities/COVID19/", - "B. Communities/Inborn Errors of Metabolism/", - "B. Communities/Lipids/", - "B. Communities/RareDiseases/", - "B. Communities/Reactome/", - "B. Communities/WormBase/" - ], - "Collaborations": [ - "C. Collaborations/AOP-Wiki/", - "C. Collaborations/MetaNetX/", - "C. Collaborations/MolMeDB/", - "C. Collaborations/neXtProt/", - "C. Collaborations/smallMolecules_Rhea_IDSM/" - ], - "General": [ - "D. General/" - ], - "Literature": [ - "E. Literature/" - ], - "Data Export": [ - "F. Datadump/" - ], - "Curation": [ - "G. Curation/" - ], - "Chemistry": [ - "H. Chemistry/" - ], - "DSMN": [ - "I. DirectedSmallMoleculesNetwork (DSMN)/" - ], - "Authors": [ - "J. Authors/" - ] - } -} diff --git a/categories.ttl b/categories.ttl new file mode 100644 index 0000000..25cfb11 --- /dev/null +++ b/categories.ttl @@ -0,0 +1,67 @@ +@prefix sh: . +@prefix skos: . +@prefix wpcat: . + +# Categories of the examples. The query editor builds its tree of examples from +# these: top-level categories in sh:order, subcategories through skos:broader. +# An example names its category with dcterms:subject (more than one is fine). +# Folders in this repository are only for keeping the files tidy. + +wpcat: a skos:ConceptScheme ; + skos:prefLabel "Categories of WikiPathways SPARQL examples"@en . + +wpcat:Metadata a skos:Concept ; skos:inScheme wpcat: ; sh:order 1 ; + skos:prefLabel "Metadata"@en . +wpcat:DataCounts a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Metadata ; sh:order 1 ; + skos:prefLabel "Data counts"@en . +wpcat:Species a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Metadata ; sh:order 2 ; + skos:prefLabel "Species"@en . + +wpcat:DataSources a skos:Concept ; skos:inScheme wpcat: ; sh:order 2 ; + skos:prefLabel "Data Sources"@en . + +wpcat:Communities a skos:Concept ; skos:inScheme wpcat: ; sh:order 3 ; + skos:prefLabel "Communities"@en . +wpcat:InbornErrorsOfMetabolism a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Communities ; sh:order 1 ; + skos:prefLabel "Inborn Errors of Metabolism"@en . +wpcat:Lipids a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Communities ; sh:order 2 ; + skos:prefLabel "Lipids"@en . +wpcat:Reactome a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Communities ; sh:order 3 ; + skos:prefLabel "Reactome"@en . + +wpcat:Collaborations a skos:Concept ; skos:inScheme wpcat: ; sh:order 4 ; + skos:prefLabel "Collaborations"@en . +wpcat:AOPWiki a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Collaborations ; sh:order 1 ; + skos:prefLabel "AOP-Wiki"@en . +wpcat:MetaNetX a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Collaborations ; sh:order 2 ; + skos:prefLabel "MetaNetX"@en . +wpcat:MolMeDB a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Collaborations ; sh:order 3 ; + skos:prefLabel "MolMeDB"@en . +wpcat:neXtProt a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Collaborations ; sh:order 4 ; + skos:prefLabel "neXtProt"@en . +wpcat:RheaIDSM a skos:Concept ; skos:inScheme wpcat: ; skos:broader wpcat:Collaborations ; sh:order 5 ; + skos:prefLabel "Rhea and IDSM"@en . + +wpcat:General a skos:Concept ; skos:inScheme wpcat: ; sh:order 5 ; + skos:prefLabel "General"@en . + +wpcat:Literature a skos:Concept ; skos:inScheme wpcat: ; sh:order 6 ; + skos:prefLabel "Literature"@en . + +wpcat:DataExport a skos:Concept ; skos:inScheme wpcat: ; sh:order 7 ; + skos:prefLabel "Data Export"@en . + +wpcat:Curation a skos:Concept ; skos:inScheme wpcat: ; sh:order 8 ; + skos:prefLabel "Curation"@en . + +wpcat:Chemistry a skos:Concept ; skos:inScheme wpcat: ; sh:order 9 ; + skos:prefLabel "Chemistry"@en . + +wpcat:Metabolites a skos:Concept ; skos:inScheme wpcat: ; sh:order 10 ; + skos:prefLabel "Metabolites"@en . + +wpcat:DSMN a skos:Concept ; skos:inScheme wpcat: ; sh:order 11 ; + skos:prefLabel "Directed Small Molecules Network (DSMN)"@en . + +wpcat:Authors a skos:Concept ; skos:inScheme wpcat: ; sh:order 12 ; + skos:prefLabel "Authors"@en . diff --git a/collection.ttl b/collection.ttl new file mode 100644 index 0000000..5741dd7 --- /dev/null +++ b/collection.ttl @@ -0,0 +1,17 @@ +@prefix dcterms: . +@prefix schema: . +@prefix snorql: . +@prefix void: . + +# The collection of WikiPathways SPARQL examples in this repository. Every example +# has a permanent identifier WPQnnn; its IRI is the uriSpace below followed by the +# identifier. Files can be renamed or moved without breaking links. + + a snorql:ExampleCollection, schema:Dataset ; + schema:name "WikiPathways SPARQL examples" ; + schema:description "Example SPARQL queries for the WikiPathways SPARQL endpoint, shown in the query editor at https://sparql.wikipathways.org/."@en ; + schema:url ; + schema:codeRepository ; + dcterms:license ; + void:uriSpace "https://sparql.wikipathways.org/.well-known/sparql-examples/" ; + snorql:identifierPrefix "WPQ" . diff --git a/contributors.ttl b/contributors.ttl new file mode 100644 index 0000000..74e087c --- /dev/null +++ b/contributors.ttl @@ -0,0 +1,24 @@ +@prefix schema: . + +# Names for the creators and contributors of the examples (dcterms:creator and +# dcterms:contributor). Use the ORCID IRI when the person has one, otherwise a +# profile page such as their GitHub page. Add yourself here in the same pull +# request as your first example. + + a schema:Person ; + schema:name "Denise Slenter" ; + schema:sameAs . + + a schema:Person ; + schema:name "Egon Willighagen" ; + schema:sameAs . + + a schema:Person ; + schema:name "Laurent Winckers" . + + a schema:Person ; + schema:name "Marvin Martens" ; + schema:sameAs . + + a schema:Organization ; + schema:name "WikiPathways team" . diff --git a/scripts/compare_live.py b/scripts/compare_live.py new file mode 100644 index 0000000..81f95c5 --- /dev/null +++ b/scripts/compare_live.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +"""Check that the migrated .ttl examples return what the .rq files returned. + +For every .ttl that has an .rq alias (snorql:alias), run the .rq query (its +{{param}} placeholders filled with the defaults, as the query editor did) and +the .ttl query against the endpoint, and compare the result columns and the +rows (as a multiset). Also prints both run times, to spot VALUES blocks that +Virtuoso handles more slowly than the constants they replaced. + +Usage, from the repository root: + + python scripts/compare_live.py [--only WPQ036 WPQ061] [--workers 4] +""" + +import argparse +import collections +import concurrent.futures +import json +import pathlib +import re +import sys +import time +import urllib.parse +import urllib.request + +from rdflib import Graph, Namespace +from rdflib.namespace import DCTERMS + +REPO = pathlib.Path(__file__).resolve().parent.parent +SH = Namespace("http://www.w3.org/ns/shacl#") +SCHEMA = Namespace("https://schema.org/") +SNORQL = Namespace("https://w3id.org/snorql/ns#") +OWL_DEPRECATED = "http://www.w3.org/2002/07/owl#deprecated" + + +def run(endpoint, query, timeout): + data = urllib.parse.urlencode({"query": query}).encode() + req = urllib.request.Request(endpoint, data=data, headers={ + "Accept": "application/sparql-results+json", "User-Agent": "wikipathways-sparqlqueries-migration-check"}) + start = time.time() + with urllib.request.urlopen(req, timeout=timeout) as r: + doc = json.loads(r.read().decode("utf-8")) + secs = time.time() - start + cols = doc.get("head", {}).get("vars", []) + rows = collections.Counter( + json.dumps({k: (v.get("type"), v.get("value"), v.get("datatype"), v.get("xml:lang")) + for k, v in b.items()}, sort_keys=True) + for b in doc.get("results", {}).get("bindings", [])) + return cols, rows, secs + + +def rq_query(path): + text = path.read_text(encoding="utf-8") + defaults = {} + for m in re.finditer(r"^#\s*param:\s*(.+)$", text, re.M): + parts = [p.strip() for p in m.group(1).split("|")] + defaults[parts[0]] = parts[2] + lines = text.split("\n") + n = 0 + while n < len(lines) and lines[n].startswith("#"): + n += 1 + body = "\n".join(lines[n:]) + return re.sub(r"\{\{\s*(\w+)\s*\}\}", lambda m: defaults[m.group(1)], body) + + +def compare(ttl, timeout): + g = Graph().parse(ttl, format="turtle") + s = next(g.subjects(DCTERMS.identifier, None)) + ident = str(g.value(s, DCTERMS.identifier)) + alias = g.value(s, SNORQL.alias) + if alias is None or any(str(p) == OWL_DEPRECATED for p in g.predicates(s, None)): + return ident, None + target = str(g.value(s, SCHEMA.target)) + new_q = str(g.value(s, SH.select)) + old_q = rq_query(REPO / str(alias)) + try: + oc, orows, osecs = run(target, old_q, timeout) + except Exception as e: + return ident, f"old query failed: {str(e)[:100]}" + try: + nc, nrows, nsecs = run(target, new_q, timeout) + except Exception as e: + return ident, f"new query failed: {str(e)[:100]}" + status = [] + if oc != nc: + status.append(f"columns differ: {oc} -> {nc}") + if orows != nrows: + status.append(f"rows differ: {sum(orows.values())} -> {sum(nrows.values())}") + verdict = "SAME" if not status else "DIFF " + "; ".join(status) + return ident, f"{verdict} | {sum(nrows.values())} rows | {osecs:.1f} s -> {nsecs:.1f} s" + + +def main(): + ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) + ap.add_argument("--only", nargs="*", help="identifiers to compare") + ap.add_argument("--workers", type=int, default=4) + ap.add_argument("--timeout", type=int, default=180) + args = ap.parse_args() + support = {"collection.ttl", "categories.ttl", "contributors.ttl"} + files = [p for p in REPO.rglob("*.ttl") + if p.relative_to(REPO).as_posix() not in support and ".git" not in p.parts] + if args.only: + files = [p for p in files if any(f'"{i}"' in p.read_text(encoding="utf-8") for i in args.only)] + results = [] + with concurrent.futures.ThreadPoolExecutor(args.workers) as pool: + for ident, result in pool.map(lambda p: compare(p, args.timeout), files): + if result is not None: + results.append((ident, result)) + bad = 0 + for ident, result in sorted(results): + print(f"{ident} | {result}") + bad += not result.startswith("SAME") + print(f"{len(results)} compared, {bad} not the same", file=sys.stderr) + sys.exit(1 if bad else 0) + + +if __name__ == "__main__": + main() diff --git a/scripts/lint_headers.py b/scripts/lint_headers.py deleted file mode 100644 index 627302d..0000000 --- a/scripts/lint_headers.py +++ /dev/null @@ -1,73 +0,0 @@ -"""CI lint script: validates required headers on all .rq query files.""" - -import pathlib -import re -import sys - -ROOT = pathlib.Path(__file__).resolve().parent.parent -EXCLUDED_DIRS = {".planning", ".git", ".github", "scripts", "tests"} - -REQUIRED_FIELDS = ["title", "category", "description"] -FIELD_PATTERNS = { - field: re.compile(rf"^# {field}: .+") for field in REQUIRED_FIELDS -} - - -def find_rq_files(): - """Return sorted list of .rq file paths, excluding non-query directories.""" - results = [] - for rq_file in sorted(ROOT.rglob("*.rq")): - rel = rq_file.relative_to(ROOT) - parts = rel.parts - if parts and parts[0] in EXCLUDED_DIRS: - continue - results.append(rq_file) - return results - - -def parse_header(filepath): - """Extract consecutive comment lines from the top of an .rq file.""" - lines = [] - with open(filepath, encoding="utf-8") as f: - for line in f: - stripped = line.rstrip("\n\r") - if stripped.startswith("#"): - lines.append(stripped) - else: - break - return lines - - -def lint_file(filepath): - """Check a single .rq file for required header fields. - - Returns a list of error strings (empty if file passes). - """ - header = parse_header(filepath) - rel_path = filepath.relative_to(ROOT) - errors = [] - for field in REQUIRED_FIELDS: - pattern = FIELD_PATTERNS[field] - if not any(pattern.match(line) for line in header): - errors.append(f"{rel_path}: missing '# {field}:' header") - return errors - - -def main(): - """Lint all .rq files and report results.""" - rq_files = find_rq_files() - all_errors = [] - for rq_file in rq_files: - all_errors.extend(lint_file(rq_file)) - - if all_errors: - for error in all_errors: - print(f"ERROR: {error}") - sys.exit(1) - else: - print(f"OK: {len(rq_files)} files passed lint check") - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/scripts/migrate_rq_to_ttl.py b/scripts/migrate_rq_to_ttl.py new file mode 100644 index 0000000..b3eb105 --- /dev/null +++ b/scripts/migrate_rq_to_ttl.py @@ -0,0 +1,664 @@ +#!/usr/bin/env python3 +"""One-off migration: turn the .rq example queries into .ttl example files. + +Kept for the record of how the .ttl files were made; after the migration the +.ttl files are edited by hand (see AUTHORING.md) and this script is not run again. + +For every .rq file with a comment header (# title, # category, # description, +# param) it writes a .ttl file next to it, in the format checked by Snorql-UI's +tools/examples/snorql_examples.py: + +- the identifier WPQnnn takes the number the query already has in + BiGCAT-UM/sparql-examples (scripts/wikipathways/sources.tsv), so the two map 1:1; + queries without a number there get the next free numbers; +- every {{param}} placeholder becomes a query variable, bound to the default in a + VALUES block in the innermost group where the parameter is used, so the query + is valid SPARQL that runs as it is; the parameter itself becomes a sh:Parameter; +- PREFIX lines that Virtuoso does not need but other SPARQL engines do are added; +- created, creator and contributors come from the git history of the .rq file + (which in most cases starts with the 2020 restructure of this repository); +- prov:wasDerivedFrom points at the .rq file at the commit it was migrated from, + and snorql:alias keeps the old path, so old ?example=.rq links still work. + +It also imports the examples that exist only in BiGCAT-UM/sparql-examples (written +from the WikiPathways website pages), so this repository holds every WPQ example. + +Usage, from the repository root: + + python scripts/migrate_rq_to_ttl.py --bigcat ../sparql-examples [--check] +""" + +import argparse +import csv +import pathlib +import re +import subprocess +import sys +import urllib.parse + +from rdflib import Graph, Namespace +from rdflib.namespace import RDFS, DCTERMS + +REPO = pathlib.Path(__file__).resolve().parent.parent +BASE = "https://sparql.wikipathways.org/.well-known/sparql-examples/" +TARGET = "https://sparql.wikipathways.org/sparql" +LICENSE = "https://www.gnu.org/licenses/gpl-3.0.html" +SOURCE_BASE = "https://github.com/wikipathways/SPARQLQueries/blob/" +BIGCAT_BASE = "https://github.com/BiGCAT-UM/sparql-examples/blob/" + +SH = Namespace("http://www.w3.org/ns/shacl#") +SCHEMA = Namespace("https://schema.org/") +SPEX = Namespace("https://purl.expasy.org/sparql-examples/ontology#") +CITO = Namespace("http://purl.org/spar/cito/") + +MARVIN = "https://orcid.org/0000-0003-2230-0840" +DENISE = "https://orcid.org/0000-0001-8449-1318" +EGON = "https://orcid.org/0000-0001-7542-0286" +LAURENT = "https://github.com/laurent2207" +WP_TEAM = "https://www.wikipathways.org/" +AUTHORS = { + "Marvin Martens": MARVIN, "marvinm2": MARVIN, + "De": DENISE, "Denise Slenter": DENISE, "DeniseSl22": DENISE, + "Egon Willighagen": EGON, "egonw": EGON, + "Laurent Winckers": LAURENT, +} +BOTS = {"GitHub Action", "github-actions[bot]"} + +# Folder -> category (the most specific one). The tree in the query editor used to +# be the folder tree; these keep the same grouping. +FOLDER_CATEGORY = { + "A. Metadata": "Metadata", + "A. Metadata/datacounts": "DataCounts", + "A. Metadata/species": "Species", + "A. Metadata/datasources": "DataSources", + "B. Communities": "Communities", + "B. Communities/Inborn Errors of Metabolism": "InbornErrorsOfMetabolism", + "B. Communities/Lipids": "Lipids", + "B. Communities/Reactome": "Reactome", + "C. Collaborations/AOP-Wiki": "AOPWiki", + "C. Collaborations/MetaNetX": "MetaNetX", + "C. Collaborations/MolMeDB": "MolMeDB", + "C. Collaborations/neXtProt": "neXtProt", + "C. Collaborations/smallMolecules_Rhea_IDSM": "RheaIDSM", + "D. General": "General", + "E. Literature": "Literature", + "F. Datadump": "DataExport", + "G. Curation": "Curation", + "H. Chemistry": "Chemistry", + "I. DirectedSmallMoleculesNetwork (DSMN)": "DSMN", + "J. Authors": "Authors", + "K. Metabolites": "Metabolites", +} + +# Extra keywords per folder, on top of the category (as in BiGCaT's rq2ttl.py). +FOLDER_KEYWORDS = { + "A. Metadata/datacounts": ["counts"], + "A. Metadata/species": ["organism"], + "B. Communities/Inborn Errors of Metabolism": ["inborn errors of metabolism", "metabolism"], + "B. Communities/Lipids": ["lipids", "LIPID MAPS"], + "B. Communities/Reactome": ["Reactome"], + "C. Collaborations/AOP-Wiki": ["AOP-Wiki", "metabolite"], + "C. Collaborations/MetaNetX": ["MetaNetX", "reaction"], + "C. Collaborations/MolMeDB": ["MolMeDB", "PubChem"], + "C. Collaborations/neXtProt": ["neXtProt", "protein"], + "C. Collaborations/smallMolecules_Rhea_IDSM": ["Rhea", "IDSM", "reaction"], + "I. DirectedSmallMoleculesNetwork (DSMN)": ["directed small molecules network"], +} + +# Parameters that the editor gave autocomplete by their name only. +LEGACY_AUTOCOMPLETE = {"pathwayId": "pathway", "species": "species"} + +# Queries whose endpoint is gone: kept as deprecated examples so links still resolve. +DEPRECATED = { + "C. Collaborations/neXtProt/ProteinCellularLocation.rq": + "The neXtProt SPARQL endpoint has been archived (it redirects to expasy.org/archives/nextprot), " + "so this query no longer works.", + "C. Collaborations/neXtProt/ProteinMitochondria.rq": + "The neXtProt SPARQL endpoint has been archived (it redirects to expasy.org/archives/nextprot), " + "so this query no longer works.", +} + +# Queries where Virtuoso answers differently depending on where the VALUES block +# sits: here only a block at the end of the group returns the same rows as the +# old constant did (both forms miss some valid rows; that is a Virtuoso issue). +VALUES_AT_END = { + "I. DirectedSmallMoleculesNetwork (DSMN)/extracting protein titles and identifiers for metabolic reactions.rq", +} + +# Examples that exist only in BiGCAT-UM/sparql-examples: number -> (path here, category). +IMPORTS = { + "005": ("D. General/PathwayCountPerDisease.ttl", "General"), + "006": ("A. Metadata/species/SpeciesWithIRIs.ttl", "Species"), + "007": ("A. Metadata/species/PathwaysAndSpecies.ttl", "Species"), + "010": ("A. Metadata/HomologyConvertedPathways.ttl", "Metadata"), + "065": ("D. General/PathwaysWithGene.ttl", "General"), + "066": ("D. General/GroupsAndComplexesWithGene.ttl", "General"), + "067": ("A. Metadata/datacounts/PathwayCountPerOntologyTerm.ttl", "DataCounts"), + "068": ("B. Communities/PathwayCountPerCurationTag.ttl", "Communities"), + "069": ("D. General/PathwaysWithOntologyTerm.ttl", "General"), + "070": ("A. Metadata/species/MetaboliteCountPerSpecies.ttl", "Species"), + "071": ("D. General/InteractionsOfDataNode.ttl", "General"), + "072": ("A. Metadata/datasources/AllDataSources.ttl", "DataSources"), + "073": ("A. Metadata/datasources/EntryCountPerDataSource.ttl", "DataSources"), + "074": ("H. Chemistry/ChEMBLCompoundsAndPathways.ttl", "Chemistry"), + "075": ("H. Chemistry/MetabolitesWithInChIKeysFromWikidata.ttl", "Chemistry"), + "076": ("K. Metabolites/AllMetabolites.ttl", "Metabolites"), + "077": ("K. Metabolites/MetabolitesInZebrafishPathways.ttl", "Metabolites"), + "078": ("K. Metabolites/MetaboliteIdentifierCountPerDataSource.ttl", "Metabolites"), + "079": ("K. Metabolites/MetabolitesWithKEGGIdentifier.ttl", "Metabolites"), + "080": ("K. Metabolites/HumanMetabolome.ttl", "Metabolites"), + "081": ("K. Metabolites/PathwaysWithMostMetabolites.ttl", "Metabolites"), + "082": ("K. Metabolites/MetabolitesInMostPathways.ttl", "Metabolites"), + "083": ("K. Metabolites/EnzymaticReactionsBetweenMetabolites.ttl", "Metabolites"), +} + +HEADER_FIELD = re.compile(r"^#\s*(title|category|description|keywords|param):\s?(.*)$") + +PREFIXES = """@prefix dcterms: . +@prefix owl: . +@prefix param: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix schema: . +@prefix sh: . +@prefix snorql: . +@prefix spex: . +@prefix wpcat: . +@prefix wpq: . +@prefix xsd: . +""" + + +class MigrationError(Exception): + pass + + +def git(repo, *args): + r = subprocess.run(["git", "-C", str(repo), *args], capture_output=True, text=True) + if r.returncode != 0: + raise MigrationError(f"git {' '.join(args)}: {r.stderr.strip()}") + return r.stdout + + +# ---------------------------------------------------------------- query text + +def mask(query): + """Same-length copy of the query with comments, strings and IRIs blanked out.""" + out = list(query) + i, n = 0, len(query) + + def blank(a, b): + for k in range(a, b): + if out[k] != "\n": + out[k] = " " + while i < n: + c = query[i] + if c == "#": + j = query.find("\n", i) + j = n if j < 0 else j + blank(i, j) + i = j + elif c == "<": + j = query.find(">", i) + if j > 0 and not re.search(r"\s", query[i:j]): + blank(i, j + 1) + i = j + 1 + else: + i += 1 + elif c in "\"'": + quote = query[i:i + 3] if query[i:i + 3] in ('"""', "'''") else c + j = i + len(quote) + while j < n and query[j:j + len(quote)] != quote: + j += 2 if query[j] == "\\" else 1 + blank(i, min(n, j + len(quote))) + i = j + len(quote) + else: + i += 1 + return "".join(out) + + +def brace_stack(code, pos): + """Positions of the '{' that are open at pos (outermost first).""" + stack = [] + for i, c in enumerate(code[:pos]): + if c == "{": + stack.append(i) + elif c == "}" and stack: + stack.pop() + return stack + + +def is_subquery(code, brace): + return re.match(r"\{\s*SELECT\b", code[brace:], re.I) is not None + + +def used_prefixes(query): + code = mask(query) + code = re.sub(r"(?im)^\s*PREFIX\s+[\w.-]*:\s*", " ", code) + names = re.findall(r"(?]*)>", query)} + + +def add_prefixes(body, namespaces, where): + missing = sorted(used_prefixes(body) - set(declared_prefixes(body))) + unknown = [p for p in missing if p not in namespaces] + if unknown: + raise MigrationError(f"{where}: prefixes not known: {', '.join(unknown)}") + prologue = "".join(f"PREFIX {p}: <{namespaces[p]}>\n" for p in missing) + if prologue and not re.match(r"(?i)\s*PREFIX\b", body): + prologue += "\n" + return (prologue + body).strip() + "\n" + + +def encode_value(value): + return urllib.parse.quote(value, safe="-_.!~*'()") + + +def placeholder_terms(body, name, namespaces): + """Every term holding {{name}}: list of (start, end, kind, template).""" + terms = [] + ph = "{{" + name + "}}" + for m in re.finditer(re.escape(ph), body): + s, e = m.start(), m.end() + # Inside a string literal "...": the whole literal must be the placeholder. + if body[s - 1:s] == '"' and body[e:e + 1] == '"': + if body[e + 1:e + 2] in ("@", "^"): + raise MigrationError(f"{{{{{name}}}}}: literal with a language tag or datatype") + terms.append((s - 1, e + 1, "literal", None)) + continue + # Inside an IRI <...{{name}}...>. + lt = body.rfind("<", 0, s) + gt = body.find(">", e) + if lt >= 0 and gt >= 0 and not re.search(r"[\s<>]", body[lt + 1:s] + body[e:gt]): + template = body[lt + 1:s] + "{value}" + body[e:gt] + terms.append((lt, gt + 1, "iri", template)) + continue + # A prefixed name pfx:local{{name}}rest. + pm = re.search(r"([A-Za-z][\w.-]*)?:([\w.%-]*)$", body[:s]) + if pm: + rest = re.match(r"[\w.%-]*", body[e:]).group(0) + prefix = pm.group(1) or "" + ns = declared_prefixes(body).get(prefix) or namespaces.get(prefix) + if ns is None: + raise MigrationError(f"{{{{{name}}}}}: unknown prefix {prefix}:") + template = ns + pm.group(2) + "{value}" + rest + terms.append((pm.start(), e + len(rest), "iri", template)) + continue + raise MigrationError(f"{{{{{name}}}}} is not inside a literal, an IRI or a prefixed name") + return terms + + +def turn_into_values(body, params, namespaces, where, at_end=False): + """Replace each {{param}} by ?param and bind it in a VALUES block. Returns (body, kinds).""" + kinds = {} + for name, _, default, _ in params: + terms = placeholder_terms(body, name, namespaces) + if not terms: + raise MigrationError(f"{where}: parameter {name} is not used in the query") + shapes = {(k, t) for _, _, k, t in terms} + if len(shapes) != 1: + raise MigrationError(f"{where}: parameter {name} is used in different ways: {shapes}") + kind, template = shapes.pop() + if kind == "literal": + value_term = '"' + default.replace("\\", "\\\\").replace('"', '\\"') + '"' + else: + value_term = "<" + template.replace("{value}", encode_value(default)) + ">" + # Already the only value of a VALUES block: keep that block and its variable. + if len(terms) == 1: + s, e, _, _ = terms[0] + m = re.search(r"(?i)\bVALUES\s+[?$](\w+)\s*\{\s*$", body[:s]) + if m and re.match(r"\s*\}", body[e:]): + kinds[name] = (kind, template, m.group(1)) + body = body[:s] + value_term + body[e:] + continue + kinds[name] = (kind, template, None) + if re.search(r"[?$]" + re.escape(name) + r"\b", body): + raise MigrationError(f"{where}: the query already has a variable ?{name}") + # Replace from the end so earlier offsets stay valid; remember the new offsets. + offsets = [] + for s, e, _, _ in sorted(terms, reverse=True): + body = body[:s] + "?" + name + body[e:] + offsets = [o - (e - s) + len(name) + 1 for o in offsets] + offsets.append(s) + code = mask(body) + stacks = [brace_stack(code, o) for o in offsets] + common = [] + for level in zip(*stacks): + if len(set(level)) != 1: + break + common.append(level[0]) + if not common: + raise MigrationError(f"{where}: {name} is used outside any group") + group = common[-1] + for st in stacks: + for b in st[len(common):]: + if is_subquery(code, b): + raise MigrationError(f"{where}: {name} is used inside a subquery below its common group") + insert = f"VALUES ?{name} {{ {value_term} }}" + # When every use is directly in that group, put the block just before the + # statement with the first use: Virtuoso rejects a VALUES block before a + # SERVICE call in the same group ("Unsupported combination of subqueries + # and service invocations"), but accepts it after one. + if at_end: + close = group + 1 + depth = 1 + while depth: + depth += {"{": 1, "}": -1}.get(code[close], 0) + close += 1 + close -= 1 + line_start = body.rfind("\n", 0, close) + 1 + indent = re.match(r"[ \t]*", body[body.rfind("\n", 0, group) + 1:]).group(0) + body = body[:line_start] + indent + insert + "\n" + body[line_start:] + continue + if all(len(st) == len(common) for st in stacks): + first = min(offsets) + k = first + while k > group + 1 and not (code[k - 1] in "{}" or (code[k - 1] == "." and code[k:k + 1].isspace())): + k -= 1 + stmt = k + (len(code[k:first]) - len(code[k:first].lstrip())) + line_start = body.rfind("\n", 0, stmt) + 1 + if stmt > group + 1 and not body[line_start:stmt].strip(): + indent = body[line_start:stmt] + body = body[:line_start] + indent + insert + "\n" + body[line_start:] + continue + line_start = body.rfind("\n", 0, group) + 1 + after = body[group + 1:] + nl = re.match(r"[ \t]*\n([ \t]*)", after) + if nl: + indent = nl.group(1) or (re.match(r"[ \t]*", body[line_start:]).group(0) + " ") + body = body[:group + 1] + "\n" + indent + insert + body[group + 1:] + else: + body = body[:group + 1] + " " + insert + body[group + 1:] + return body, kinds + + +# ---------------------------------------------------------------- turtle + +def turtle_string(text): + return '"' + text.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n") + '"' + + +def turtle_long_string(text): + text = text.replace("\\", "\\\\") + text = re.sub(r'"(?=""|"*$)', r'\\"', text) + return '"""' + text + '"""' + + +def query_form(query): + code = mask(query) + code = re.sub(r"(?im)^\s*(PREFIX\s+[\w.-]*:|BASE)\s*", " ", code) + m = re.search(r"(?i)\b(SELECT|ASK|CONSTRUCT|DESCRIBE)\b", code) + if not m: + raise MigrationError("cannot find the query form") + return m.group(1).lower() + + +def services(query): + code = re.sub(r"#[^\n]*", "", query) + return sorted(set(re.findall(r"(?i)\bSERVICE\s+(?:SILENT\s+)?<([^>]+)>", code))) + + +FORMS = { + "select": ("sh:SPARQLSelectExecutable", "sh:select"), + "ask": ("sh:SPARQLAskExecutable", "sh:ask"), + "construct": ("sh:SPARQLConstructExecutable", "sh:construct"), + "describe": ("spex:SPARQLDescribeExecutable", "spex:describe"), +} + + +def render(ex): + """Turtle for one example (a dict).""" + cls, prop = FORMS[query_form(ex["query"])] + L = [PREFIXES, f"wpq:{ex['id']} a sh:SPARQLExecutable, {cls} ;"] + add = L.append + add(f' dcterms:identifier "{ex["id"]}" ;') + add(f" rdfs:label {turtle_string(ex['label'])}@en ;") + add(f" rdfs:comment {turtle_string(ex['comment'])}@en ;") + add(' schema:version "1.0.0" ;') + add(f' dcterms:created "{ex["created"]}"^^xsd:date ;') + add(" dcterms:creator " + ", ".join(f"<{c}>" for c in ex["creators"]) + " ;") + if ex["contributors"]: + add(" dcterms:contributor " + ", ".join(f"<{c}>" for c in ex["contributors"]) + " ;") + add(f" dcterms:license <{LICENSE}> ;") + add(f" dcterms:subject wpcat:{ex['category']} ;") + if ex["keywords"]: + add(" schema:keywords " + ", ".join(turtle_string(k) for k in ex["keywords"]) + " ;") + add(f" schema:target <{TARGET}> ;") + for s in services(ex["query"]): + add(f" spex:federatesWith <{s}> ;") + for a in ex.get("aliases", []): + add(f" snorql:alias {turtle_string(a)} ;") + for d in ex["derived"]: + add(f" prov:wasDerivedFrom <{d}> ;") + if ex.get("deprecated"): + add(" owl:deprecated true ;") + else: + add(" snorql:expect [ snorql:minResults 1 ] ;") + for order, p in enumerate(ex["params"], 1): + add(" sh:parameter [") + add(" a sh:Parameter ;") + add(f" sh:path param:{p['name']} ;") + add(f" sh:name {turtle_string(p['label'])} ;") + add(f" sh:defaultValue {turtle_string(p['default'])} ;") + if p.get("variable"): + add(f" snorql:variable {turtle_string(p['variable'])} ;") + if p["kind"] == "iri": + add(" sh:nodeKind sh:IRI ;") + add(f" snorql:valueTemplate {turtle_string(p['template'])} ;") + else: + add(" sh:datatype xsd:string ;") + if p.get("autocomplete"): + add(f" snorql:autocomplete {turtle_string(p['autocomplete'])} ;") + for k, o in enumerate(p.get("options") or [], 1): + add(f" snorql:option [ rdf:value {turtle_string(o[0])} ; rdfs:label {turtle_string(o[1])} ;" + f" sh:order {k} ] ;") + add(f" sh:order {order}") + add(" ] ;") + add(f" {prop} {turtle_long_string(ex['query'].rstrip())} .") + ttl = "\n".join(L) + "\n" + g = Graph() + g.parse(data=ttl, format="turtle") + s = next(g.subjects(DCTERMS.identifier, None)) + found = [str(o) for p, o in g.predicate_objects(s) if str(p).endswith(("#select", "#ask", "#construct", "#describe"))] + if found != [ex["query"].rstrip()]: + raise MigrationError(f"{ex['id']}: the query does not survive the Turtle round trip") + return ttl + + +# ---------------------------------------------------------------- sources + +class RqFile: + def __init__(self, rel): + self.rel = rel + self.title, self.category, self.description, self.keywords, self.params = "", "", [], [], [] + text = (REPO / rel).read_text(encoding="utf-8").replace("\r\n", "\n") + lines = text.split("\n") + n, field = 0, None + while n < len(lines) and lines[n].startswith("#"): + m = HEADER_FIELD.match(lines[n]) + if m: + field, value = m.group(1), m.group(2).strip() + if field == "title": + self.title = value + elif field == "category": + self.category = value + elif field == "description": + self.description.append(value) + elif field == "keywords": + self.keywords += [k.strip() for k in value.split(",") if k.strip()] + elif field == "param": + parts = [p.strip() for p in value.split("|")] + parts += [""] * (4 - len(parts)) + self.params.append(tuple(parts[:4])) + elif field == "description" and lines[n].startswith("#"): + self.description.append(lines[n].lstrip("#").strip()) + n += 1 + self.body = "\n".join(lines[n:]).strip("\n") + + +def history(paths): + """(created date, [author names] oldest first) over the history of these files.""" + log = [] + for rel in paths: + if not (REPO / rel).exists(): + continue + out = git(REPO, "log", "--follow", "--format=%cs\t%an", "--", rel) + log += [tuple(line.split("\t", 1)) for line in out.splitlines() if line] + log.sort() + authors = [] + for _, a in log: + if a not in BOTS and a not in authors: + authors.append(a) + return (log[0][0] if log else None), authors + + +def people(authors): + iris = [] + for a in authors: + if a not in AUTHORS: + raise MigrationError(f"no IRI for git author {a!r}; add it to AUTHORS") + if AUTHORS[a] not in iris: + iris.append(AUTHORS[a]) + return iris + + +def keywords_for(rq): + words = [rq.category.lower() if rq.category != "DSMN" else rq.category] + folder = str(pathlib.PurePosixPath(rq.rel).parent) + words += FOLDER_KEYWORDS.get(folder, []) + rq.keywords + seen, out = set(), [] + for w in words: + if w and w.lower() not in seen: + seen.add(w.lower()) + out.append(w) + return out + + +def load_namespaces(bigcat): + g = Graph() + g.parse(bigcat / "examples" / "WikiPathways" / "prefixes.ttl", format="turtle") + return {str(p): str(ns) for _, d in g.subject_objects(SH.declare) + for p in g.objects(d, SH.prefix) for ns in g.objects(d, SH.namespace)} + + +def from_rq(ident, rel, namespaces): + rq = RqFile(rel) + folder = str(pathlib.PurePosixPath(rel).parent) + if folder not in FOLDER_CATEGORY: + raise MigrationError(f"{rel}: no category for folder {folder}") + body, kinds = (turn_into_values(rq.body, rq.params, namespaces, rel, rel in VALUES_AT_END) + if rq.params else (rq.body, {})) + query = add_prefixes(body, namespaces, rel) + ttl_rel = re.sub(r"\.rq$", ".ttl", rel) + created, authors = history([rel, ttl_rel]) + persons = people(authors) + sha = git(REPO, "log", "-1", "--format=%H", "--", rel).strip() + params = [] + for name, ptype, default, label in rq.params: + kind, template, variable = kinds[name] + p = {"name": name, "label": label, "default": default, "kind": kind, "template": template, + "variable": variable} + if ptype.startswith("enum:"): + opts = [] + for o in ptype[5:].split(","): + o = o.strip() + value, _, olabel = o.partition("=") + opts.append((value, olabel or value)) + p["options"] = opts + elif ptype.startswith("autocomplete:"): + p["autocomplete"] = ptype[13:].strip() + elif name in LEGACY_AUTOCOMPLETE: + p["autocomplete"] = LEGACY_AUTOCOMPLETE[name] + params.append(p) + comment = " ".join(d for d in rq.description if d) + deprecated = rel in DEPRECATED + if deprecated: + comment += " " + DEPRECATED[rel] + return { + "id": ident, "path": ttl_rel, "label": rq.title, "comment": comment, "created": created, + "creators": persons[:1], "contributors": persons[1:], + "category": FOLDER_CATEGORY[folder], "keywords": keywords_for(rq), + "aliases": [rel], "derived": [SOURCE_BASE + sha + "/" + urllib.parse.quote(rel)], + "params": params, "query": query, "deprecated": deprecated, + } + + +def from_bigcat(number, bigcat): + rel_here, category = IMPORTS[number] + rel = f"examples/WikiPathways/{number}.ttl" + g = Graph() + g.parse(bigcat / rel, format="turtle") + s = next(g.subjects(SCHEMA.target, None)) + query = None + for p in (SH.select, SH.ask, SH.construct, SPEX.describe): + query = query or g.value(s, p) + out = git(bigcat, "log", "--follow", "--format=%cs\t%an\t%H", "--", rel).splitlines() + created, first_author, _ = out[-1].split("\t") + sha = out[0].split("\t")[2] + derived = [BIGCAT_BASE + sha + "/" + rel] + derived += [str(o) for o in g.objects(s, CITO.usesMethodIn)] + if int(number) >= 65: + # Written on 2026-11-10 from the queries on the WikiPathways website pages. + creators, contributors = [WP_TEAM], [AUTHORS[first_author]] + else: + creators, contributors = [AUTHORS[first_author]], [] + return { + "id": "WPQ" + number, "path": rel_here, "label": str(g.value(s, RDFS.label)), + "comment": " ".join(str(c) for c in g.objects(s, RDFS.comment)), "created": created, + "creators": creators, "contributors": contributors, "category": category, + "keywords": sorted({str(k) for k in g.objects(s, SCHEMA.keywords)}, key=str.casefold), + "aliases": [], "derived": derived, "params": [], "query": str(query).strip() + "\n", + "deprecated": False, + } + + +def main(): + ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) + ap.add_argument("--bigcat", required=True, type=pathlib.Path, help="checkout of BiGCAT-UM/sparql-examples") + ap.add_argument("--check", action="store_true", help="write nothing") + args = ap.parse_args() + bigcat = args.bigcat.resolve() + namespaces = load_namespaces(bigcat) + + with open(bigcat / "scripts" / "wikipathways" / "sources.tsv", encoding="utf-8", newline="") as f: + rows = list(csv.DictReader(f, delimiter="\t")) + numbers = {r["source"]: r["id"] for r in rows if r["kind"] in ("rq", "same") and r["source"].endswith(".rq")} + used = {int(r["id"]) for r in rows if r["id"].isdigit()} + rq_files = sorted((p.relative_to(REPO).as_posix() for p in REPO.rglob("*.rq") + if p.relative_to(REPO).parts[0] not in {".git", "scripts"}), key=str.casefold) + examples, errors = [], [] + for rel in rq_files: + if rel not in numbers: + numbers[rel] = f"{max(used) + 1:03d}" + used.add(max(used) + 1) + print(f"new number {numbers[rel]} for {rel}") + try: + examples.append(from_rq("WPQ" + numbers[rel], rel, namespaces)) + except MigrationError as e: + errors.append(str(e)) + for number in sorted(IMPORTS): + examples.append(from_bigcat(number, bigcat)) + if errors: + for e in errors: + print("ERROR: " + e, file=sys.stderr) + sys.exit(1) + + ids = [e["id"] for e in examples] + assert len(ids) == len(set(ids)), "duplicate identifiers" + for ex in examples: + ttl = render(ex) + if not args.check: + path = REPO / ex["path"] + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(ttl, encoding="utf-8") + print(f"{len(examples)} examples ({sum(1 for e in examples if e['deprecated'])} deprecated), " + f"{sum(1 for e in examples if e['params'])} with parameters") + + +if __name__ == "__main__": + main() diff --git a/scripts/transformDotTtlToDotSparql.py b/scripts/transformDotTtlToDotSparql.py deleted file mode 100644 index 821061e..0000000 --- a/scripts/transformDotTtlToDotSparql.py +++ /dev/null @@ -1,77 +0,0 @@ -import os -import glob -from rdflib import Graph - - -def extract_header(filepath): - """Extract the leading comment-line header block from an .rq file. - - Reads consecutive lines starting with '#' from the top of the file, - stopping at the first blank line or first non-comment line. Returns - the header lines joined with a trailing newline (the blank separator), - or an empty string if no header is found or the file does not exist. - """ - if not os.path.exists(filepath): - return "" - - header_lines = [] - with open(filepath, encoding="utf-8") as f: - for line in f: - stripped = line.rstrip("\n") - if stripped.startswith("#"): - header_lines.append(stripped) - else: - break - - if header_lines: - return "\n".join(header_lines) + "\n" - return "" - - -def process_ttl_file(ttl_path): - """Parse a .ttl file and write the extracted SPARQL to a .rq file. - - If the .rq file already exists and has a comment header block, that - header is preserved above the regenerated SPARQL content. If the TTL - contains no SPARQL query, the .rq file is not touched. - """ - rq_path = ttl_path[:-4] + ".rq" - fn = os.path.basename(ttl_path)[:-4] - print("file: " + fn) - - header = extract_header(rq_path) - - g = Graph() - g.parse(ttl_path) - - knows_query = """prefix sh: -SELECT DISTINCT ?query ?sparql -WHERE { - ?query sh:select | sh:ask | sh:construct ?sparql . -}""" - - qres = g.query(knows_query) - sparql_content = "" - for row in qres: - sparql_content += str(row.sparql) - - if not sparql_content.strip(): - print(f" WARNING: No SPARQL found in {ttl_path}, skipping .rq write") - return - - with open(rq_path, "w", encoding="utf-8") as sparql_file: - if header: - sparql_file.write(header + "\n") - sparql_file.write(sparql_content) - - -# Path to Turtle files -ttl_files_path = '**/*.ttl' - -if __name__ == "__main__": - # Get the list of .ttl files - ttl_files = glob.glob(ttl_files_path, recursive=True) - - # Process each Turtle file - for i in ttl_files: - process_ttl_file(i)