Skip to content

Commit

Permalink
Merge branch 'Adafede-chemical-classes'
Browse files Browse the repository at this point in the history
  • Loading branch information
fnielsen committed May 6, 2024
2 parents 5673003 + 5768cf4 commit 97d1d05
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion scholia/app/templates/chemical-class.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2 id="related-chemicals">Example Compounds</h2>

<table class="table table-hover" id="related-chemicals-table"></table>

<h2 id="recent-literature">Recently published works on the chemical <a href="{{ url_for('app.show_topic_index') }}{{ q }}/latest-works/rss"><img height="24" width="48" src="{{ url_for('static', filename='images/rss-40674_320.png') }}" alt="RSS icon" /></a></h2>
<h2 id="recent-literature">Recently published works on the chemical class<a href="{{ url_for('app.show_topic_index') }}{{ q }}/latest-works/rss"><img height="24" width="48" src="{{ url_for('static', filename='images/rss-40674_320.png') }}" alt="RSS icon" /></a></h2>

<table class="table table-hover" id="recent-literature-table"></table>

Expand Down
63 changes: 46 additions & 17 deletions scholia/app/templates/chemical-class_class-hierarchy.sparql
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")
}

0 comments on commit 97d1d05

Please sign in to comment.