diff --git a/A. Metadata/authors.rq b/A. Metadata/authors.rq
deleted file mode 100644
index 1d73858..0000000
--- a/A. Metadata/authors.rq
+++ /dev/null
@@ -1,16 +0,0 @@
-# title: Authors of All Pathways
-# category: Metadata
-# description: Lists all pathway authors with their name, homepage, and ORCID,
-# along with the number of pathways each author created.
-
-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/averagePerPathway.rq b/A. Metadata/datacounts/averagePerPathway.rq
deleted file mode 100644
index 701d668..0000000
--- a/A. Metadata/datacounts/averagePerPathway.rq
+++ /dev/null
@@ -1,17 +0,0 @@
-# title: Average Entity Type per Pathway
-# category: Metadata
-# description: Calculates the average, minimum, and maximum number of a selected
-# entity type per pathway in WikiPathways.
-# param: entityType|enum:DataNode=Data Nodes,GeneProduct=Gene Products,Interaction=Interactions,Metabolite=Metabolites,Protein=Proteins|DataNode|Entity Type
-
-SELECT (AVG(?no) AS ?avg)
- (MIN(?no) AS ?min)
- (MAX(?no) AS ?max)
-WHERE {
- SELECT ?Pathway (COUNT(?entity) AS ?no)
- WHERE {
- ?entity a wp:{{entityType}} ;
- dcterms:isPartOf ?Pathway .
- ?Pathway a wp:Pathway .}
- GROUP BY ?Pathway
-}
diff --git a/A. Metadata/datacounts/countOfEntityType.rq b/A. Metadata/datacounts/countOfEntityType.rq
deleted file mode 100644
index 65ccf7b..0000000
--- a/A. Metadata/datacounts/countOfEntityType.rq
+++ /dev/null
@@ -1,9 +0,0 @@
-# title: Count of Entity Type
-# category: Metadata
-# description: Counts the total number of a selected entity type in WikiPathways.
-# param: entityType|enum:DataNode=Data Nodes,GeneProduct=Gene Products,Interaction=Interactions,Metabolite=Metabolites,Protein=Proteins|DataNode|Entity Type
-
-SELECT DISTINCT (COUNT(?entity) AS ?count)
-WHERE {
- ?entity a wp:{{entityType}} .
-}
diff --git a/A. Metadata/datacounts/countPathways.rq b/A. Metadata/datacounts/countPathways.rq
deleted file mode 100644
index 71bcac8..0000000
--- a/A. Metadata/datacounts/countPathways.rq
+++ /dev/null
@@ -1,8 +0,0 @@
-# title: Count of Pathways
-# category: Metadata
-# description: Counts the total number of pathways in WikiPathways.
-
-SELECT DISTINCT (count(?Pathway) as ?PathwayCount)
-WHERE {
- ?Pathway a wp:Pathway, skos:Collection .
-}
diff --git a/A. Metadata/datacounts/countSignalingPathways.rq b/A. Metadata/datacounts/countSignalingPathways.rq
deleted file mode 100644
index dc8cea4..0000000
--- a/A. Metadata/datacounts/countSignalingPathways.rq
+++ /dev/null
@@ -1,13 +0,0 @@
-# title: Count of Signaling Pathways
-# category: Metadata
-# description: Counts the total number of signaling pathways in WikiPathways by
-# filtering on the signaling pathway ontology tag.
-
-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.rq b/A. Metadata/datacounts/linkoutCounts.rq
deleted file mode 100644
index 2734e2d..0000000
--- a/A. Metadata/datacounts/linkoutCounts.rq
+++ /dev/null
@@ -1,17 +0,0 @@
-# title: External Linkout Counts
-# category: Metadata
-# description: Counts the number of distinct entities linked to each external database
-# (ChEBI, ChemSpider, HMDB, PubChem, Ensembl, NCBI Gene, HGNC, Rhea, UniProt).
-
-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/pathwaysForDatasource.rq b/A. Metadata/datasources/pathwaysForDatasource.rq
deleted file mode 100644
index 159d6cb..0000000
--- a/A. Metadata/datasources/pathwaysForDatasource.rq
+++ /dev/null
@@ -1,15 +0,0 @@
-# title: WikiPathways for Datasource Identifiers
-# category: Data Sources
-# description: Lists pathways containing entities with identifiers from a selected
-# data source, showing the pathway title and identifier URI.
-# param: datasource|enum:Chemspider=ChemSpider,Ensembl=Ensembl,HgncSymbol=HGNC,Hmdb=HMDB,EntrezGene=NCBI Gene,PubChem=PubChem|Ensembl|Data Source
-
-SELECT DISTINCT ?pathwayRes (str(?wpid) AS ?pathway) (str(?title) AS ?pathwayTitle) ?identifier
-WHERE {
- ?gene dcterms:identifier ?id ;
- dcterms:isPartOf ?pathwayRes ;
- wp:bdb{{datasource}} ?identifier .
- ?pathwayRes a wp:Pathway ;
- dcterms:identifier ?wpid ;
- dc:title ?title .
-}
diff --git a/A. Metadata/linksets.rq b/A. Metadata/linksets.rq
deleted file mode 100644
index e5bca9f..0000000
--- a/A. Metadata/linksets.rq
+++ /dev/null
@@ -1,14 +0,0 @@
-# title: Linksets Overview
-# category: Metadata
-# description: Returns all VoID linksets in the WikiPathways RDF with their title,
-# creation date, and license information.
-
-SELECT DISTINCT ?dataset (str(?titleLit) as ?title) ?date ?license
-WHERE {
- ?dataset a void:Linkset ;
- dcterms:title ?titleLit .
- OPTIONAL {
- ?dataset dcterms:license ?license ;
- pav:createdOn ?date .
- }
-}
diff --git a/A. Metadata/metadata.rq b/A. Metadata/metadata.rq
deleted file mode 100644
index a5796a4..0000000
--- a/A. Metadata/metadata.rq
+++ /dev/null
@@ -1,12 +0,0 @@
-# title: Dataset Metadata
-# category: Metadata
-# description: Returns all VoID datasets in the WikiPathways RDF with their title,
-# creation date, and license information.
-
-SELECT DISTINCT ?dataset (str(?titleLit) as ?title) ?date ?license
-WHERE {
- ?dataset a void:Dataset ;
- dcterms:title ?titleLit ;
- dcterms:license ?license ;
- pav:createdOn ?date .
-}
\ No newline at end of file
diff --git a/A. Metadata/prefixes.rq b/A. Metadata/prefixes.rq
deleted file mode 100644
index 3466c58..0000000
--- a/A. Metadata/prefixes.rq
+++ /dev/null
@@ -1,14 +0,0 @@
-# title: SPARQL Prefixes
-# category: Metadata
-# description: Lists all namespace prefixes declared in the WikiPathways SPARQL
-# endpoint via SHACL prefix declarations.
-
-PREFIX sh:
-PREFIX xsd:
-
-SELECT ?prefix ?namespace WHERE {
- [] sh:declare [
- sh:prefix ?prefix ;
- sh:namespace ?namespace
- ] .
-}
\ No newline at end of file
diff --git a/A. Metadata/species/PWsforSpecies.rq b/A. Metadata/species/PWsforSpecies.rq
deleted file mode 100644
index ddbeb0f..0000000
--- a/A. Metadata/species/PWsforSpecies.rq
+++ /dev/null
@@ -1,14 +0,0 @@
-# title: Pathways for a Species
-# category: Metadata
-# description: Lists all pathways for a given species, returning the WikiPathways
-# identifier and page URL. Default species is Mus musculus.
-# param: species | string | Homo sapiens | Species
-
-SELECT DISTINCT ?wpIdentifier ?pathway ?page
-WHERE {
- ?pathway dc:title ?title .
- ?pathway foaf:page ?page .
- ?pathway dc:identifier ?wpIdentifier .
- ?pathway wp:organismName "{{species}}" .
- }
-ORDER BY ?wpIdentifier
diff --git a/A. Metadata/species/countEntityPerSpecies.rq b/A. Metadata/species/countEntityPerSpecies.rq
deleted file mode 100644
index 3ae6622..0000000
--- a/A. Metadata/species/countEntityPerSpecies.rq
+++ /dev/null
@@ -1,14 +0,0 @@
-# title: Entity Type per Species
-# category: Metadata
-# description: Counts the number of distinct entities of a selected type per species
-# in WikiPathways, ordered by count descending.
-# param: entityType|enum:DataNode=Data Nodes,GeneProduct=Gene Products,Metabolite=Metabolites,Protein=Proteins|DataNode|Entity Type
-
-SELECT (COUNT(DISTINCT ?entity) AS ?count) (str(?label) AS ?species)
-WHERE {
- ?entity a wp:{{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.rq b/A. Metadata/species/countPathwaysPerSpecies.rq
deleted file mode 100644
index 3bdf4c4..0000000
--- a/A. Metadata/species/countPathwaysPerSpecies.rq
+++ /dev/null
@@ -1,13 +0,0 @@
-# title: Pathways per Species
-# category: Metadata
-# description: Counts the number of pathways per species in WikiPathways, returning
-# the species name, organism URI, and pathway count.
-
-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/B. Communities/Inborn Errors of Metabolism/allMetabolicPWs.rq b/B. Communities/Inborn Errors of Metabolism/allMetabolicPWs.rq
deleted file mode 100644
index 69e40db..0000000
--- a/B. Communities/Inborn Errors of Metabolism/allMetabolicPWs.rq
+++ /dev/null
@@ -1,13 +0,0 @@
-# title: Inborn Errors of Metabolism Metabolic Pathways
-# category: Communities
-# description: Retrieves pathways classified under metabolic pathway ontology terms,
-# filtering by label to find metabolic pathway annotations.
-
-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.rq b/B. Communities/Inborn Errors of Metabolism/countMetabolicPWs.rq
deleted file mode 100644
index e98129e..0000000
--- a/B. Communities/Inborn Errors of Metabolism/countMetabolicPWs.rq
+++ /dev/null
@@ -1,13 +0,0 @@
-# title: Count of IEM Metabolic Pathways
-# category: Communities
-# description: Counts the total number of pathways classified under metabolic pathway
-# ontology terms.
-
-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.rq b/B. Communities/Inborn Errors of Metabolism/countProteinsMetabolitesRheaDiseases.rq
deleted file mode 100644
index 819a492..0000000
--- a/B. Communities/Inborn Errors of Metabolism/countProteinsMetabolitesRheaDiseases.rq
+++ /dev/null
@@ -1,53 +0,0 @@
-# title: IEM Proteins, Metabolites, Rhea, and Diseases
-# category: Communities
-# description: Summarizes IEM community pathways with counts of proteins, metabolites,
-# Rhea reaction annotations, missing Rhea IDs, and linked OMIM disease identifiers
-# per pathway.
-
-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.rq b/B. Communities/Lipids/LIPIDMAPS_Federated.rq
deleted file mode 100644
index 8976a5d..0000000
--- a/B. Communities/Lipids/LIPIDMAPS_Federated.rq
+++ /dev/null
@@ -1,23 +0,0 @@
-# title: LIPID MAPS Federated Query
-# category: Communities
-# description: 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.
-
-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.rq b/B. Communities/Lipids/LipidClassesTotal.rq
deleted file mode 100644
index 134845f..0000000
--- a/B. Communities/Lipids/LipidClassesTotal.rq
+++ /dev/null
@@ -1,19 +0,0 @@
-# title: Total Lipid Classes
-# category: Communities
-# description: 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).
-# param: species | string | Homo sapiens | Species
-# param: lipidClass | enum:FA,GL,GP,SP,ST,PR,SL,PK | FA | LIPID MAPS Class
-
-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)
- ?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 .
- 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.rq b/B. Communities/Lipids/LipidsClassesCountPerPathway.rq
deleted file mode 100644
index 6d09a99..0000000
--- a/B. Communities/Lipids/LipidsClassesCountPerPathway.rq
+++ /dev/null
@@ -1,20 +0,0 @@
-# title: Lipid Classes Count per Pathway
-# category: Communities
-# description: 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.
-# param: species | string | Homo sapiens | Species
-# param: lipidClass | enum:FA,GL,GP,SP,ST,PR,SL,PK | FA | LIPID MAPS Class
-
-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)
- ?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 .
- 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.rq b/B. Communities/Lipids/LipidsCountPerPathway.rq
deleted file mode 100644
index e72cbe6..0000000
--- a/B. Communities/Lipids/LipidsCountPerPathway.rq
+++ /dev/null
@@ -1,20 +0,0 @@
-# title: Lipids Count per Pathway
-# category: Communities
-# description: Counts the total number of lipids with LIPID MAPS identifiers per human
-# pathway, ordered by count.
-# param: species | string | Homo sapiens | Species
-
-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
- ?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/Reactome/getPathways.rq b/B. Communities/Reactome/getPathways.rq
deleted file mode 100644
index c8f7b19..0000000
--- a/B. Communities/Reactome/getPathways.rq
+++ /dev/null
@@ -1,9 +0,0 @@
-# title: Reactome Pathways
-# category: Communities
-# description: Lists all pathways tagged with the Reactome Approved curation tag.
-
-SELECT DISTINCT ?pathway (str(?titleLit) as ?title)
-WHERE {
- ?pathway wp:ontologyTag cur:Reactome_Approved ;
- dc:title ?titleLit .
-}
diff --git a/B. Communities/Reactome/refsReactomeAndWP.rq b/B. Communities/Reactome/refsReactomeAndWP.rq
deleted file mode 100644
index e4a49a2..0000000
--- a/B. Communities/Reactome/refsReactomeAndWP.rq
+++ /dev/null
@@ -1,11 +0,0 @@
-# title: References in Both Reactome and WikiPathways
-# category: Communities
-# description: Counts publication references that appear in both Reactome-approved and
-# WikiPathways Analysis Collection pathways.
-
-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.rq b/B. Communities/Reactome/refsReactomeNotWP.rq
deleted file mode 100644
index ea3b1f5..0000000
--- a/B. Communities/Reactome/refsReactomeNotWP.rq
+++ /dev/null
@@ -1,11 +0,0 @@
-# title: References in Reactome but Not WikiPathways
-# category: Communities
-# description: Counts publication references found in Reactome-approved pathways but not
-# in the WikiPathways Analysis Collection.
-
-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.rq b/B. Communities/Reactome/refsWPNotReactome.rq
deleted file mode 100644
index e59578a..0000000
--- a/B. Communities/Reactome/refsWPNotReactome.rq
+++ /dev/null
@@ -1,11 +0,0 @@
-# title: References in WikiPathways but Not Reactome
-# category: Communities
-# description: Counts publication references found in the WikiPathways Analysis Collection
-# but not in Reactome-approved pathways.
-
-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.rq b/B. Communities/communityPathways.rq
deleted file mode 100644
index 7973848..0000000
--- a/B. Communities/communityPathways.rq
+++ /dev/null
@@ -1,11 +0,0 @@
-# title: Community Pathways
-# category: Communities
-# description: Lists all pathways tagged with a selected community curation tag.
-# param: community|autocomplete:community|AOP|Community
-
-SELECT DISTINCT ?pathway (str(?title) AS ?PathwayTitle)
-WHERE {
- ?pathway wp:ontologyTag cur:{{community}} ;
- a wp:Pathway ;
- dc:title ?title .
-}
diff --git a/B. Communities/communityProteins.rq b/B. Communities/communityProteins.rq
deleted file mode 100644
index 4af3ace..0000000
--- a/B. Communities/communityProteins.rq
+++ /dev/null
@@ -1,13 +0,0 @@
-# title: Community Proteins
-# category: Communities
-# description: Lists all proteins found in pathways tagged with a selected community.
-# param: community|autocomplete:community|AOP|Community
-
-SELECT DISTINCT ?pathway (str(?label) AS ?Protein)
-WHERE {
- ?pathway wp:ontologyTag cur:{{community}} ;
- a wp:Pathway .
- ?protein a wp:Protein ;
- rdfs:label ?label ;
- dcterms:isPartOf ?pathway .
-}
diff --git a/C. Collaborations/AOP-Wiki/MetaboliteInAOP-Wiki.rq b/C. Collaborations/AOP-Wiki/MetaboliteInAOP-Wiki.rq
deleted file mode 100644
index 6187418..0000000
--- a/C. Collaborations/AOP-Wiki/MetaboliteInAOP-Wiki.rq
+++ /dev/null
@@ -1,22 +0,0 @@
-# title: Metabolites in AOP-Wiki
-# category: Collaborations
-# description: 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.
-# param: species | string | Homo sapiens | Species
-
-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 .
- ?pathway a wp:Pathway ; wp:organismName "{{species}}" ; dc:title ?title .
-}
-ORDER BY ?ChemicalName ?pathwayName
diff --git a/C. Collaborations/MetaNetX/reactionID_mapping.rq b/C. Collaborations/MetaNetX/reactionID_mapping.rq
deleted file mode 100644
index f001b51..0000000
--- a/C. Collaborations/MetaNetX/reactionID_mapping.rq
+++ /dev/null
@@ -1,40 +0,0 @@
-# title: MetaNetX Reaction ID Mapping
-# category: Collaborations
-# description: 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.
-
-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.rq b/C. Collaborations/MolMeDB/ONEpubchem_MANYpathways.rq
deleted file mode 100644
index fbf7c49..0000000
--- a/C. Collaborations/MolMeDB/ONEpubchem_MANYpathways.rq
+++ /dev/null
@@ -1,24 +0,0 @@
-# title: Pathways for a PubChem Compound (MolMeDB)
-# category: Collaborations
-# description: 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.
-# param: species | string | Homo sapiens | Species
-
-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 .
-
- ?pathwayRes a wp:Pathway ;
- wp:organismName "{{species}}";
- dcterms:identifier ?wpid ;
- dc:title ?title .
-}
diff --git a/C. Collaborations/MolMeDB/SUBSETpathways_ONEpubchem.rq b/C. Collaborations/MolMeDB/SUBSETpathways_ONEpubchem.rq
deleted file mode 100644
index 91b71c0..0000000
--- a/C. Collaborations/MolMeDB/SUBSETpathways_ONEpubchem.rq
+++ /dev/null
@@ -1,26 +0,0 @@
-# title: PubChem Compound in Pathway Subset (MolMeDB)
-# category: Collaborations
-# description: 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.
-# param: species | string | Homo sapiens | Species
-
-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 .
-
- ?pathwayRes a wp:Pathway ;
- wp:organismName "{{species}}" ;
- dcterms:identifier ?wpid ;
- dc:title ?title .
- }
-
- skos:exactMatch ?COMPOUND.
- }
-}
diff --git a/C. Collaborations/neXtProt/ProteinCellularLocation.rq b/C. Collaborations/neXtProt/ProteinCellularLocation.rq
deleted file mode 100644
index fee702a..0000000
--- a/C. Collaborations/neXtProt/ProteinCellularLocation.rq
+++ /dev/null
@@ -1,31 +0,0 @@
-# title: Protein Cellular Location via neXtProt
-# category: Collaborations
-# description: 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.
-
-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.rq b/C. Collaborations/neXtProt/ProteinMitochondria.rq
deleted file mode 100644
index 3f7e1a3..0000000
--- a/C. Collaborations/neXtProt/ProteinMitochondria.rq
+++ /dev/null
@@ -1,31 +0,0 @@
-# title: Mitochondrial Proteins via neXtProt
-# category: Collaborations
-# description: 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.
-
-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.rq b/C. Collaborations/smallMolecules_Rhea_IDSM/molecularSimularity_Reactions.rq
deleted file mode 100644
index 4187157..0000000
--- a/C. Collaborations/smallMolecules_Rhea_IDSM/molecularSimularity_Reactions.rq
+++ /dev/null
@@ -1,51 +0,0 @@
-# title: Molecular Similarity Reactions via Rhea and IDSM
-# category: Collaborations
-# description: 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.
-
-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/D. General/GenesofPathway.rq b/D. General/GenesofPathway.rq
deleted file mode 100644
index c791beb..0000000
--- a/D. General/GenesofPathway.rq
+++ /dev/null
@@ -1,18 +0,0 @@
-# title: Genes of a Pathway
-# category: General
-# description: Lists all gene products in a given pathway, returning the pathway
-# identifier and gene product labels.
-# param: pathwayId|autocomplete:pathway|WP1560|Pathway ID
-
-select distinct ?pathway (str(?label) as ?geneProduct) where {
- {
- SELECT ?pathwayRev ?pathway WHERE {
- ?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/InteractionsofPathway.rq b/D. General/InteractionsofPathway.rq
deleted file mode 100644
index afbaeac..0000000
--- a/D. General/InteractionsofPathway.rq
+++ /dev/null
@@ -1,17 +0,0 @@
-# title: Interactions of a Pathway
-# category: General
-# description: Returns all interactions in a given pathway along with the
-# participating data nodes and their labels.
-# param: pathwayId|autocomplete:pathway|WP1425|Pathway ID
-
-SELECT DISTINCT ?pathway ?interaction ?participants ?DataNodeLabel
-WHERE {
-
- ?pathway a wp:Pathway ;
- dc:identifier .
- ?interaction dcterms:isPartOf ?pathway ;
- a wp:Interaction ;
- wp:participants ?participants .
- ?participants a wp:DataNode ;
- rdfs:label ?DataNodeLabel .
-}
diff --git a/D. General/MetabolitesofPathway.rq b/D. General/MetabolitesofPathway.rq
deleted file mode 100644
index 3b7c072..0000000
--- a/D. General/MetabolitesofPathway.rq
+++ /dev/null
@@ -1,17 +0,0 @@
-# title: Metabolites of a Pathway
-# category: General
-# description: Lists all metabolites in a given pathway, returning the pathway
-# identifier and metabolite labels.
-# param: pathwayId|autocomplete:pathway|WP1560|Pathway ID
-
-select distinct ?pathway (str(?label) as ?Metabolite) where {
- {
- SELECT ?pathway WHERE {
- ?pathway dcterms:identifier "{{pathwayId}}" .
- ?pathway a wp:Pathway .
- }
- }
- ?metabolite a wp:Metabolite ;
- rdfs:label ?label ;
- dcterms:isPartOf ?pathway .
-}
diff --git a/D. General/OntologyofPathway.rq b/D. General/OntologyofPathway.rq
deleted file mode 100644
index 3ec77b5..0000000
--- a/D. General/OntologyofPathway.rq
+++ /dev/null
@@ -1,15 +0,0 @@
-# title: Ontology Terms of a Pathway
-# category: General
-# description: Retrieves all ontology tags associated with a given pathway,
-# returning the ontology term URI, pathway title, and identifier.
-# param: pathwayId|autocomplete:pathway|WP1560|Pathway ID
-
-SELECT (?o as ?pwOntologyTerm) (str(?titleLit) as ?title) ?pathway
-WHERE {
- ?pathwayRDF wp:ontologyTag ?o ;
- dc:identifier ?pathway ;
- dc:title ?titleLit ;
- dcterms:identifier "{{pathwayId}}" .
-
- FILTER (! regex(str(?pathway), "group"))
-}
diff --git a/E. Literature/allPathwayswithPubMed.rq b/E. Literature/allPathwayswithPubMed.rq
deleted file mode 100644
index 76e6299..0000000
--- a/E. Literature/allPathwayswithPubMed.rq
+++ /dev/null
@@ -1,11 +0,0 @@
-# title: All Pathways with PubMed References
-# category: Literature
-# description: Lists pathways that have associated PubMed publication references,
-# returning pathway and PubMed identifiers ordered by pathway.
-
-SELECT DISTINCT ?pathway ?pubmed
-WHERE
- {?pubmed a wp:PublicationReference .
- ?pubmed dcterms:isPartOf ?pathway }
-ORDER BY ?pathway
-LIMIT 50
diff --git a/E. Literature/allReferencesForInteraction.rq b/E. Literature/allReferencesForInteraction.rq
deleted file mode 100644
index f4af000..0000000
--- a/E. Literature/allReferencesForInteraction.rq
+++ /dev/null
@@ -1,17 +0,0 @@
-# title: All References for an Interaction
-# category: Literature
-# description: Returns all publication references for interactions in a given
-# pathway, including references attached to both the interaction itself and its
-# participating data nodes.
-# param: pathwayId | string | WP5200 | Pathway ID
-
-SELECT DISTINCT ?pathway ?interaction ?pubmed ?partnerref WHERE {
- ?pathway a wp:Pathway ;
- dc:identifier .
- ?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.rq b/E. Literature/countRefsPerPW.rq
deleted file mode 100644
index 5f44eb8..0000000
--- a/E. Literature/countRefsPerPW.rq
+++ /dev/null
@@ -1,11 +0,0 @@
-# title: Reference Count per Pathway
-# category: Literature
-# description: Counts the number of PubMed publication references per pathway,
-# sorted by descending reference count.
-
-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.rq b/E. Literature/referencesForInteraction.rq
deleted file mode 100644
index 2e37acb..0000000
--- a/E. Literature/referencesForInteraction.rq
+++ /dev/null
@@ -1,18 +0,0 @@
-# title: References for an Interaction
-# category: Literature
-# description: Returns publication references directly attached to interactions in a
-# given pathway, along with the participating data node labels.
-# param: pathwayId | string | WP5200 | Pathway ID
-
-SELECT DISTINCT ?pathway ?interaction ?pubmed
-WHERE {
-
- ?pathway a wp:Pathway ;
- dc:identifier . #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.rq b/E. Literature/referencesForSpecificInteraction.rq
deleted file mode 100644
index 8237dfa..0000000
--- a/E. Literature/referencesForSpecificInteraction.rq
+++ /dev/null
@@ -1,15 +0,0 @@
-# title: References for a Specific Interaction
-# category: Literature
-# description: Returns publication references for a single interaction identified by
-# both a pathway and a specific participant URI.
-# param: pathwayId | string | WP5200 | Pathway ID
-# param: proteinId | string | P35498 | UniProt Protein ID
-
-SELECT DISTINCT ?pathway ?interaction ?pubmed WHERE {
- ?pathway a wp:Pathway .
- ?pathway dc:identifier . #filter for pathway
- ?interaction dcterms:isPartOf ?pathway .
- ?interaction a wp:Interaction .
- ?interaction wp:participants . #filter for interaction
- ?interaction dcterms:references ?pubmed .
-} LIMIT 100
diff --git a/F. Datadump/CyTargetLinkerLinksetInput.rq b/F. Datadump/CyTargetLinkerLinksetInput.rq
deleted file mode 100644
index fc124b8..0000000
--- a/F. Datadump/CyTargetLinkerLinksetInput.rq
+++ /dev/null
@@ -1,16 +0,0 @@
-# title: CyTargetLinker Linkset Input
-# category: Data Export
-# description: 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.
-
-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.rq b/F. Datadump/dumpOntologyAndPW.rq
deleted file mode 100644
index 77fbc53..0000000
--- a/F. Datadump/dumpOntologyAndPW.rq
+++ /dev/null
@@ -1,15 +0,0 @@
-# title: Ontology and Pathway Data Export
-# category: Data Export
-# description: Exports pathway metadata including page URLs, titles, species, identifiers,
-# and associated ontology tags for bulk download.
-
-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.rq b/F. Datadump/dumpPWsofSpecies.rq
deleted file mode 100644
index ea37d83..0000000
--- a/F. Datadump/dumpPWsofSpecies.rq
+++ /dev/null
@@ -1,14 +0,0 @@
-# title: Pathways by Species Data Export
-# category: Data Export
-# description: Exports all pathways for a given species, returning identifiers,
-# titles, and page URLs ordered by pathway ID.
-# param: species | string | Homo sapiens | Species
-
-SELECT DISTINCT ?wpIdentifier ?pathway ?title ?page
-WHERE {
- ?pathway dc:title ?title ;
- foaf:page ?page ;
- dc:identifier ?wpIdentifier ;
- wp:organismName "{{species}}" .
- }
-ORDER BY ?wpIdentifier
diff --git a/G. Curation/MetabolitesDoubleMappingWikidata.rq b/G. Curation/MetabolitesDoubleMappingWikidata.rq
deleted file mode 100644
index 99fb6cc..0000000
--- a/G. Curation/MetabolitesDoubleMappingWikidata.rq
+++ /dev/null
@@ -1,13 +0,0 @@
-# title: Metabolites with Duplicate Wikidata Mappings
-# category: Curation
-# description: Detects metabolites that are mapped to more than one Wikidata
-# identifier, listing all duplicate mappings per metabolite.
-
-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.rq b/G. Curation/MetabolitesNotClassified.rq
deleted file mode 100644
index 9bc5a4a..0000000
--- a/G. Curation/MetabolitesNotClassified.rq
+++ /dev/null
@@ -1,16 +0,0 @@
-# title: Unclassified Metabolites
-# category: Curation
-# description: Finds data nodes with a data source annotation that are not classified
-# as metabolites, grouped by data source with counts sorted descending.
-
-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.rq b/G. Curation/MetabolitesWithoutLinkWikidata.rq
deleted file mode 100644
index 4e5e2d2..0000000
--- a/G. Curation/MetabolitesWithoutLinkWikidata.rq
+++ /dev/null
@@ -1,12 +0,0 @@
-# title: Metabolites Without Wikidata Links
-# category: Curation
-# description: Lists metabolites that have no Wikidata identifier mapping, useful for
-# identifying gaps in cross-database linkage.
-
-PREFIX wdt:
-
-SELECT DISTINCT ?metabolite WHERE {
- ?metabolite a wp:Metabolite .
- OPTIONAL { ?metabolite wp:bdbWikidata ?wikidata . }
- FILTER (!BOUND(?wikidata))
-}
diff --git a/G. Curation/PWsWithoutDatanodes.rq b/G. Curation/PWsWithoutDatanodes.rq
deleted file mode 100644
index 6c94c22..0000000
--- a/G. Curation/PWsWithoutDatanodes.rq
+++ /dev/null
@@ -1,16 +0,0 @@
-# title: Pathways Without Data Nodes
-# category: Curation
-# description: Finds pathways that contain no data nodes, indicating empty or
-# incomplete pathway entries that may need curation.
-
-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.rq b/G. Curation/PWsWithoutRef.rq
deleted file mode 100644
index 2442109..0000000
--- a/G. Curation/PWsWithoutRef.rq
+++ /dev/null
@@ -1,10 +0,0 @@
-# title: Pathways Without References
-# category: Curation
-# description: Lists pathways that have no associated publication references,
-# returning species, title, and pathway identifier sorted alphabetically.
-
-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.rq b/G. Curation/countPWsMetabolitesOccurSorted.rq
deleted file mode 100644
index ac5bffb..0000000
--- a/G. Curation/countPWsMetabolitesOccurSorted.rq
+++ /dev/null
@@ -1,15 +0,0 @@
-# title: Pathways by Metabolite Occurrence Count
-# category: Curation
-# description: Counts how many pathways each metabolite appears in, filtered to
-# metabolites without a Wikidata mapping, sorted by descending pathway count.
-
-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.rq b/G. Curation/countPWsWithoutRef.rq
deleted file mode 100644
index 09d2e20..0000000
--- a/G. Curation/countPWsWithoutRef.rq
+++ /dev/null
@@ -1,10 +0,0 @@
-# title: Count of Pathways Without References
-# category: Curation
-# description: Returns the total number of pathways that have no associated
-# publication references.
-
-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/IDSM_similaritySearch.rq b/H. Chemistry/IDSM_similaritySearch.rq
deleted file mode 100644
index 1b7bac5..0000000
--- a/H. Chemistry/IDSM_similaritySearch.rq
+++ /dev/null
@@ -1,44 +0,0 @@
-# title: IDSM Chemical Similarity Search
-# category: Chemistry
-# description: 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.
-# param: pathwayId | string | WP4225 | Pathway ID
-
-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 .
- ?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/smiles.rq b/H. Chemistry/smiles.rq
deleted file mode 100644
index 22f53e3..0000000
--- a/H. Chemistry/smiles.rq
+++ /dev/null
@@ -1,10 +0,0 @@
-# title: SMILES for Metabolites
-# category: Chemistry
-# description: Retrieves SMILES chemical structure notations for metabolites via
-# their Wikidata links.
-
-PREFIX cheminf:
-
-SELECT ?mol ?smilesDepict WHERE {
- ?mol wp:bdbWikidata/cheminf:CHEMINF_000018 ?smilesDepict .
-} LIMIT 25
diff --git a/I. DirectedSmallMoleculesNetwork (DSMN)/controlling duplicate mappings from Wikidata.rq b/I. DirectedSmallMoleculesNetwork (DSMN)/controlling duplicate mappings from Wikidata.rq
deleted file mode 100644
index 4eeb83e..0000000
--- a/I. DirectedSmallMoleculesNetwork (DSMN)/controlling duplicate mappings from Wikidata.rq
+++ /dev/null
@@ -1,33 +0,0 @@
-# title: Controlling Duplicate Mappings from Wikidata
-# category: DSMN
-# description: Detects metabolites mapped to multiple Wikidata identifiers as a
-# quality control step in the DSMN workflow.
-
-### 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.rq b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting directed metabolic reactions.rq
deleted file mode 100644
index c165db5..0000000
--- a/I. DirectedSmallMoleculesNetwork (DSMN)/extracting directed metabolic reactions.rq
+++ /dev/null
@@ -1,47 +0,0 @@
-# title: Extracting Directed Metabolic Reactions
-# category: DSMN
-# description: 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.
-# param: species | string | Homo sapiens | Species
-
-### Part 1: ###
-SELECT DISTINCT ?interaction ?sourceDb ?targetDb ?mimtype
-?pathway (str(?titleLit) as ?title)
-?sourceCHEBI ?targetDbCHEBI ?sourceHMDB ?targetDbHMDB ?InteractionID
-WHERE {
-
-### Part 2: ###
-?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.rq b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting ontologies and references for metabolic reactions.rq
deleted file mode 100644
index 595c345..0000000
--- a/I. DirectedSmallMoleculesNetwork (DSMN)/extracting ontologies and references for metabolic reactions.rq
+++ /dev/null
@@ -1,36 +0,0 @@
-# title: Extracting Ontologies and References for Metabolic Reactions
-# category: DSMN
-# description: Retrieves ontology annotations, curation status, and literature
-# references for directed metabolic reactions in human pathways as part of the
-# DSMN workflow.
-# param: species | string | Homo sapiens | Species
-
-### Part 1: ###
-SELECT DISTINCT ?interaction ?sourceDb ?targetDb ?PWOnt ?DiseaseOnt
-?curationstatus ?InteractionRef ?PWref ?sourceLit ?targetLit
-WHERE {
-?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.rq b/I. DirectedSmallMoleculesNetwork (DSMN)/extracting protein titles and identifiers for metabolic reactions.rq
deleted file mode 100644
index 10efc47..0000000
--- a/I. DirectedSmallMoleculesNetwork (DSMN)/extracting protein titles and identifiers for metabolic reactions.rq
+++ /dev/null
@@ -1,31 +0,0 @@
-# title: Extracting Protein Titles and Identifiers for Metabolic Reactions
-# category: DSMN
-# description: Extracts catalyzing proteins for directed metabolic reactions in
-# human AnalysisCollection pathways, returning Ensembl identifiers and protein
-# names as part of the DSMN workflow.
-# param: species | string | Homo sapiens | Species
-
-### 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} .
-}
diff --git a/J. Authors/authorsOfAPathway.rq b/J. Authors/authorsOfAPathway.rq
deleted file mode 100644
index 2e6caf8..0000000
--- a/J. Authors/authorsOfAPathway.rq
+++ /dev/null
@@ -1,23 +0,0 @@
-# title: Authors of a Pathway
-# category: Authors
-# description: Lists all authors of a given pathway in ordinal order, returning
-# name, ORCID, homepage, and pathway version.
-# param: pathwayId | string | WP4846 | Pathway ID
-
-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.rq b/J. Authors/contributors.rq
deleted file mode 100644
index 4519e6e..0000000
--- a/J. Authors/contributors.rq
+++ /dev/null
@@ -1,23 +0,0 @@
-# title: All Contributors
-# category: Authors
-# description: Counts the number of pathways each first author (ordinal 1)
-# contributes to, sorted by descending pathway count.
-
-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.rq b/J. Authors/firstAuthors.rq
deleted file mode 100644
index 5789a35..0000000
--- a/J. Authors/firstAuthors.rq
+++ /dev/null
@@ -1,22 +0,0 @@
-# title: First Authors of Pathways
-# category: Authors
-# description: Lists the first author (ordinal 1) of each pathway, ordered by
-# pathway version number.
-
-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.rq b/J. Authors/pathwayCountWithAtLeastXAuthors.rq
deleted file mode 100644
index fb93921..0000000
--- a/J. Authors/pathwayCountWithAtLeastXAuthors.rq
+++ /dev/null
@@ -1,15 +0,0 @@
-# title: Pathways with Multiple Authors
-# category: Authors
-# description: Counts how many pathways have at least N authors for each author
-# ordinal position, showing the distribution of author counts across pathways.
-
-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/README.md b/README.md
index 1887bc1..9b6e3d5 100644
--- a/README.md
+++ b/README.md
@@ -19,8 +19,10 @@ and renamed without breaking links.
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.
+The examples used to be `.rq` files; the last commit with them is `fed6a2d`, which also has
+the scripts that converted them. Old links to an `.rq` path still open the right example, and
+the `rq/` folder of the `examples-index` branch has generated `.rq` copies for tools that read
+that format.
## License
diff --git a/scripts/compare_live.py b/scripts/compare_live.py
deleted file mode 100644
index 81f95c5..0000000
--- a/scripts/compare_live.py
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/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/migrate_rq_to_ttl.py b/scripts/migrate_rq_to_ttl.py
deleted file mode 100644
index b3eb105..0000000
--- a/scripts/migrate_rq_to_ttl.py
+++ /dev/null
@@ -1,664 +0,0 @@
-#!/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()