Skip to content

Commit 8946990

Browse files
committed
Update queries for taxon aspect
1 parent cf22e7a commit 8946990

File tree

7 files changed

+58
-60
lines changed

7 files changed

+58
-60
lines changed

scholia/app/templates/taxon_co-occurring-taxa.sparql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
2+
13
#title: Taxa that co-occur with the target taxon in the literature
24
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
35
PREFIX bd: <http://www.bigdata.com/rdf#>
6+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
47
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
58
PREFIX wikibase: <http://wikiba.se/ontology#>
69
SELECT ?count (CONCAT("/topics/", SUBSTR(STR(target:),32), ",", SUBSTR(STR(?taxon),32)) AS ?countUrl) ?taxon ?taxonLabel (CONCAT("/taxon/", SUBSTR(STR(?taxon),32)) AS ?taxonUrl) ?example_work ?example_workLabel (CONCAT("/work/", SUBSTR(STR(?example_work),32)) AS ?example_workUrl) WHERE {
@@ -18,7 +21,7 @@ SELECT ?count (CONCAT("/topics/", SUBSTR(STR(target:),32), ",", SUBSTR(STR(?taxo
1821
}
1922
GROUP BY ?taxon
2023
}
21-
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
24+
{{ sparql_helpers.labels(["?taxon", "?example_work"], languages) }}
2225
}
2326
ORDER BY DESC(?count)
2427
LIMIT 200
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
2+
13
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
24
PREFIX bd: <http://www.bigdata.com/rdf#>
35
PREFIX wd: <http://www.wikidata.org/entity/>
46
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
57
PREFIX wikibase: <http://wikiba.se/ontology#>
68
SELECT ?gene ?geneLabel ?geneDescription ?chromosome ?chromosomeLabel ?chromosomeDescription {
7-
{
8-
SELECT ?gene ?chromosome WHERE {
9-
?gene wdt:P31 wd:Q7187 ;
10-
wdt:P703 target: ;
11-
wdt:P1057 ?chromosome .
12-
}
13-
}
14-
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
9+
?gene wdt:P31 wd:Q7187 ;
10+
wdt:P703 target: ;
11+
wdt:P1057 ?chromosome .
12+
{{ sparql_helpers.labels(["?gene", "?chromosome"], languages) }}
13+
{{ sparql_helpers.descriptions(["?gene", "?chromosome"], languages) }}
1514
}

scholia/app/templates/taxon_identifiers.sparql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
2+
13
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
24
PREFIX bd: <http://www.bigdata.com/rdf#>
35
PREFIX wd: <http://www.wikidata.org/entity/>
@@ -44,7 +46,8 @@ SELECT ?Identifier ?IdentifierLabel ?id (SAMPLE(?idUrls) AS ?idUrl) ?IdentifierD
4446
BIND (IRI(REPLACE(?formatterurl, '\\\\$1', STR(?id))) AS ?idUrls) .
4547
}
4648
}
47-
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
49+
{{ sparql_helpers.labels(["?Identifier"], languages) }}
50+
{{ sparql_helpers.descriptions(["?Identifier"], languages) }}
4851
}
4952
GROUP BY ?Identifier ?IdentifierLabel ?IdentifierDescription ?id
5053
ORDER BY ASC(?IdentifierLabel)

scholia/app/templates/taxon_metabolome.sparql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
2+
13
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
24
PREFIX bd: <http://www.bigdata.com/rdf#>
35
PREFIX wd: <http://www.wikidata.org/entity/>
@@ -25,5 +27,6 @@ SELECT DISTINCT ?metabolite ?metaboliteLabel ?metaboliteChemicalStructure ?metab
2527
BIND (COALESCE(?isoSmiles, ?canSmiles) AS ?metaboliteChemicalStructure)
2628
}
2729
}
28-
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
30+
{{ sparql_helpers.labels(["?metabolite"], languages) }}
31+
{{ sparql_helpers.descriptions(["?metabolite"], languages) }}
2932
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
2+
13
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
24
PREFIX bd: <http://www.bigdata.com/rdf#>
35
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
46
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
57
PREFIX wikibase: <http://wikiba.se/ontology#>
6-
SELECT (COUNT(?middle) AS ?distance) (GROUP_CONCAT(DISTINCT ?rank_label_; SEPARATOR=", ") AS ?rank) ?parent ?parentLabel ?parentDescription {
8+
SELECT (COUNT(?middle) AS ?distance) (GROUP_CONCAT(DISTINCT ?rank_Label; SEPARATOR=", ") AS ?rank) ?parent ?parentLabel ?parentDescription {
79
target: wdt:P171* ?middle .
810
?middle wdt:P171+ ?parent .
911
?parent wdt:P105 ?rank_ .
10-
OPTIONAL {
11-
?rank_ rdfs:label ?rank_label_ . FILTER (LANG(?rank_label_) = 'en')
12-
}
13-
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
12+
{{ sparql_helpers.labels(["?rank_", "?parent"], languages) }}
13+
{{ sparql_helpers.descriptions(["?parent"], languages) }}
1414
}
1515
GROUP BY ?parent ?parentLabel ?parentDescription
1616
ORDER BY ?distance
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
2+
13
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
24
PREFIX bd: <http://www.bigdata.com/rdf#>
35
PREFIX wd: <http://www.wikidata.org/entity/>
46
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
57
PREFIX wikibase: <http://wikiba.se/ontology#>
68
SELECT ?protein ?proteinLabel ?proteinDescription ?gene ?geneLabel {
7-
{
8-
SELECT ?protein ?gene ?chromosome WHERE {
9-
?protein wdt:P31 wd:Q8054 ;
10-
wdt:P703 target: .
11-
}
12-
}
13-
?protein wdt:P702 ?gene .
14-
# SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
9+
?protein wdt:P31 wd:Q8054 ;
10+
wdt:P703 target: ;
11+
wdt:P702 ?gene.
12+
{{ sparql_helpers.labels(["?protein", "?gene"], languages) }}
13+
{{ sparql_helpers.descriptions(["?protein"], languages) }}
1514
}
Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,38 @@
1+
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
2+
13
#defaultView:Graph
24
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
35
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
46
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
5-
SELECT ?child ?childLabel ?rgb ?parent ?parentLabel WHERE {
7+
SELECT (?child_ AS ?child) ?childLabel ?rgb (?parent_ AS ?parent) ?parentLabel WHERE {
68
{
7-
SELECT ?child ?rgb ?parent WHERE {
8-
{
9-
# Parent taxa
10-
SELECT ?child ?rgb ?parent WHERE {
11-
SERVICE gas:service {
12-
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ;
13-
gas:in target: ;
14-
# We should not do undirected here because this could result
15-
# in very big graphs.
16-
gas:traversalDirection "Forward" ;
17-
gas:out ?child ;
18-
gas:out1 ?depth ;
19-
gas:out2 ?parent1 ;
20-
gas:linkType wdt:P171 ;
21-
}
22-
?child wdt:P171 ?parent .
23-
BIND (IF(?child = target:,"FF0000","FFFFFF") AS ?rgb)
24-
}
25-
}
26-
UNION {
27-
# Child taxa
28-
SELECT ?child ?rgb ?parent WHERE {
29-
BIND (target: AS ?parent)
30-
?child wdt:P171 ?parent .
31-
BIND ("DDDDDD" AS ?rgb)
32-
}
33-
LIMIT 100
34-
}
35-
}
9+
# Parent taxa
10+
target: wdt:P171* ?child_ .
11+
?child_ wdt:P171 ?parent_ .
12+
BIND ("FFFFFF" AS ?rgb)
13+
} UNION {
14+
# Child taxa
15+
{SELECT ?child_ ?parent_ WHERE {
16+
BIND (target: AS ?parent_) .
17+
?child_ wdt:P171 ?parent_ .
18+
} LIMIT 100}
19+
BIND ("DDDDDD" AS ?rgb)
20+
} UNION {
21+
BIND (target: AS ?child_) .
22+
?child_ wdt:P171 ?parent_ .
23+
BIND ("FF0000" AS ?rgb)
3624
}
37-
?child rdfs:label ?child_label . FILTER (LANG(?child_label) = 'en')
38-
?parent rdfs:label ?parent_label . FILTER (LANG(?parent_label) = 'en')
25+
3926
OPTIONAL {
40-
?child wdt:P105/rdfs:label ?child_rank_label . FILTER (LANG(?child_rank_label) = 'en')
27+
?child_ wdt:P105 ?child_rank_ .
28+
{{ sparql_helpers.labels(["?child_rank_"], languages) }}
4129
}
4230
OPTIONAL {
43-
?parent wdt:P105/rdfs:label ?parent_rank_label . FILTER (LANG(?parent_rank_label) = 'en')
31+
?parent_ wdt:P105 ?parent_rank_ .
32+
{{ sparql_helpers.labels(["?parent_rank_"], languages) }}
4433
}
45-
BIND (CONCAT(?child_label, " - ", COALESCE(?child_rank_label, "???")) AS ?childLabel)
46-
BIND (CONCAT(?parent_label, " - ", COALESCE(?parent_rank_label, "???")) AS ?parentLabel)
34+
{{ sparql_helpers.labels(["?child_", "?parent_"], languages) }}
35+
36+
BIND (CONCAT(?child_Label, " - ", COALESCE(?child_rank_Label, "???")) AS ?childLabel)
37+
BIND (CONCAT(?parent_Label, " - ", COALESCE(?parent_rank_Label, "???")) AS ?parentLabel)
4738
}

0 commit comments

Comments
 (0)