Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 03235eb

Browse files
committed
docs: document result sparql query
1 parent 2ff1ddc commit 03235eb

1 file changed

Lines changed: 24 additions & 34 deletions

File tree

docs/queries/result.rq

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,31 @@ PREFIX cat: <http://example.org/catplus/ontology/>
33
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
44
PREFIX schema: <https://schema.org/>
55

6-
SELECT ?contentUrl ?campaignName ?reactionType ?reactionName ?chemicalName ?casNumber ?smiles
6+
SELECT
7+
?contentUrl
8+
?reactionType
9+
?chemicalName
710
WHERE {
8-
# STEP 2: The outer query takes each ?s from the subquery result
9-
# and finds all the associated details for it.
10-
?s cat:hasBatch ?batch ;
11-
cat:hasChemical ?chemical ;
12-
schema:name ?campaignName ;
13-
schema:contentUrl ?contentUrl .
14-
?batch cat:reactionType ?reactionType ;
15-
cat:reactionName ?reactionName .
16-
?chemical allores:AFR_0002295 ?smiles ;
17-
allores:AFR_0002292 ?chemicalName ;
18-
cat:casNumber ?casNumber .
19-
20-
# --- Subquery Starts Here ---
21-
# STEP 1: This inner query runs first. Its only job is to find the
22-
# unique campaigns (?s) that match the filter, and then apply pagination.
23-
{
24-
SELECT DISTINCT ?s WHERE {
25-
?s rdf:type cat:Campaign ;
26-
cat:hasBatch ?batch ;
27-
cat:hasChemical ?chemical ;
28-
schema:contentUrl ?contentUrl .
29-
?batch cat:reactionType ?reactionType ;
30-
cat:reactionName ?reactionName .
31-
?chemical allores:AFR_0002295 ?smiles .
32-
# The FILTER must be inside the subquery to apply before the LIMIT.
33-
FILTER (?reactionType = 'N-methylation' || ?reactionName = 'Caffeine synthesis' || ?smiles = 'CO')
11+
?s schema:contentUrl ?contentUrl .
12+
?s cat:hasBatch ?batch .
13+
{?s cat:hasChemical ?chemical . ?s a cat:Campaign}
14+
UNION {?action cat:hasBatch ?batch . ?action cat:hasSample* ?sample . ?sample cat:hasChemical ?chemical .}
15+
?batch cat:reactionType ?reactionType .
16+
?chemical allores:AFR_0002292 ?chemicalName .
17+
{
18+
SELECT DISTINCT ?s WHERE {
19+
?batch cat:reactionType ?reactionType .
20+
?s rdf:type cat:Campaign .
21+
?s cat:hasBatch ?batch .
22+
{?s cat:hasChemical ?chemical . ?s a cat:Campaign}
23+
UNION {?action cat:hasBatch ?batch . ?action cat:hasSample* ?sample . ?sample cat:hasChemical ?chemical .}
24+
?s schema:contentUrl ?contentUrl .
25+
FILTER (?reactionType IN ('N-methylation'))
26+
}
27+
ORDER BY ASC(?contentUrl)
28+
LIMIT 3
29+
OFFSET 0
3430
}
35-
ORDER BY ASC(?contentUrl)
36-
LIMIT 3
37-
OFFSET 0
38-
}
39-
#--- Subquery Ends Here ---
4031
}
41-
GROUP BY ?contentUrl ?campaignName ?reactionType ?reactionName ?chemicalName ?casNumber ?smiles
42-
# This sorts the final results that are returned to the user.
32+
GROUP BY ?contentUrl ?reactionType ?chemicalName
4333
ORDER BY ASC(?contentUrl)

0 commit comments

Comments
 (0)