-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Adafede-chemical-classes'
- Loading branch information
Showing
2 changed files
with
47 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 46 additions & 17 deletions
63
scholia/app/templates/chemical-class_class-hierarchy.sparql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,53 @@ | ||
#defaultView:Graph | ||
PREFIX target: <http://www.wikidata.org/entity/{{ q }}> | ||
|
||
SELECT DISTINCT ?class ?classLabel ?otherclass ?otherclassLabel ?rgb WITH { | ||
SELECT DISTINCT ?class ?otherclass ?rgb WHERE { | ||
# find the subclasses | ||
{ VALUES ?class { target: } | ||
# subclasses that have subclasses themselves | ||
{ ?otherclass wdt:P279 ?class . [] wdt:P279 ?otherclass BIND( "3182BD" AS ?rgb) } | ||
UNION | ||
# subclasses that do not have subclasses | ||
{ ?otherclass wdt:P279 ?class . MINUS { [] wdt:P279 ?otherclass } BIND( "E6550D" AS ?rgb) } | ||
SELECT | ||
?child ?childLabel | ||
?rgb | ||
?parent ?parentLabel | ||
WITH { | ||
SELECT ?child ?rgb ?parent WHERE { | ||
{ | ||
SELECT ?child ?rgb ?parent WHERE { | ||
SERVICE gas:service { | ||
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ; | ||
gas:in target: ; | ||
gas:traversalDirection "Forward" ; | ||
gas:out ?child ; | ||
gas:out1 ?depth ; | ||
gas:out2 ?parent1 ; | ||
gas:linkType wdt:P279 ; | ||
} | ||
?child wdt:P279 ?parent . | ||
BIND(IF(?child = target:, "FF0000", "FFFFFF") AS ?rgb) | ||
} | ||
} | ||
UNION | ||
# find the superclasses | ||
{ VALUES ?otherclass { target: } | ||
?otherclass wdt:P279 ?class . | ||
{ | ||
SELECT ?child ?rgb ?parent WHERE { | ||
BIND(target: AS ?parent) | ||
?child wdt:P279 ?parent . | ||
BIND("DDDDDD" AS ?rgb) | ||
} | ||
LIMIT 10 | ||
} | ||
} LIMIT 500 | ||
} AS %result | ||
} | ||
} AS %results | ||
WHERE { | ||
INCLUDE %result | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } | ||
} | ||
INCLUDE %results | ||
VALUES ?classes { | ||
wd:Q15711994 # group of isomeric entities | ||
wd:Q17339814 # group or class of chemical substances | ||
wd:Q47154513 # structural class of chemical entities | ||
wd:Q55640599 # group of chemical entities | ||
wd:Q56256173 # class of chemical entities with similar applications or functions | ||
wd:Q56256178 # class of chemical entities with similar source or occurrence | ||
wd:Q55662456 # group of ortho, meta, para isomers | ||
wd:Q59199015 # group of stereoisomers | ||
wd:Q72070508 # group or class of chemical entities | ||
wd:Q74892521 # imprecise class of chemical entities | ||
} | ||
?parent wdt:P31 ?classes. hint:Prior hint:runFirst TRUE. | ||
?child rdfs:label ?childLabel . FILTER(LANG(?childLabel) = "en") | ||
?parent rdfs:label ?parentLabel . FILTER(LANG(?parentLabel) = "en") | ||
} |