Closed nleguillarme closed 12 months ago
Hi,
Yes, I guess we would write something like:
spq_add("?value obo:IAO_0000039 ?trait_unit", .required=FALSE) %>%
spq_add("?trait_unit rdfs:label ?unit", .required=FALSE)
We haven't allowed for the user to use blank nodes for now. I'm not sure we will either (but I'll make an issue to make sure we properly ask ourselves ;-) ).
related to #202
@nleguillarme for this particular pattern, where you're labelling a variable, after #205 you'd run something like
library("glitter")
spq_init() %>%
spq_prefix(prefixes = c(obo = "http://purl.obolibrary.org/obo/")) %>%
spq_add("?value obo:IAO_0000039 ?trait_unit", .required = FALSE) %>%
spq_label(trait_unit)
#> PREFIX obo: <http://purl.obolibrary.org/obo/>
#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#> SELECT ?trait_unit (COALESCE(?trait_unit_labell,'') AS ?trait_unit_label)
#> ?value
#> WHERE {
#>
#> OPTIONAL {
#> ?value obo:IAO_0000039 ?trait_unit.
#>
#> OPTIONAL {
#> ?trait_unit rdfs:label ?trait_unit_labell.
#> FILTER(lang(?trait_unit_labell) IN ('en'))
#> }
#>
#> }
#>
#> }
Created on 2023-10-19 with reprex v2.0.2
Or
library("glitter")
spq_init() %>%
spq_prefix(prefixes = c(obo = "http://purl.obolibrary.org/obo/")) %>%
spq_add("?value obo:IAO_0000039 ?trait", .required = FALSE) %>%
spq_label(trait, .overwrite = TRUE)
#> PREFIX obo: <http://purl.obolibrary.org/obo/>
#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#> SELECT ?value (COALESCE(?trait_labell,'') AS ?trait)
#> WHERE {
#>
#> OPTIONAL {
#> ?value obo:IAO_0000039 ?trait0.
#>
#> OPTIONAL {
#> ?trait0 rdfs:label ?trait_labell.
#> FILTER(lang(?trait_labell) IN ('en'))
#> }
#>
#> }
#>
#> }
Created on 2023-10-19 with reprex v2.0.2
And a tad more cumbersome:
library("glitter")
spq_init() %>%
spq_prefix(prefixes = c(obo = "http://purl.obolibrary.org/obo/")) %>%
spq_add("?value obo:IAO_0000039 ?trait_unit", .required = FALSE) %>%
spq_add("?trait_unit rdfs:label ?unit", .sibling_triple_pattern = "?value obo:IAO_0000039 ?trait_unit")
#> PREFIX obo: <http://purl.obolibrary.org/obo/>
#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#> SELECT ?trait_unit ?unit ?value
#> WHERE {
#>
#> OPTIONAL {
#> ?value obo:IAO_0000039 ?trait_unit.
#>
#> ?trait_unit rdfs:label ?unit.
#> }
#>
#> }
Created on 2023-10-19 with reprex v2.0.2
Hi
I need to write a query with an optional graph pattern that contains several triples, for instance:
But it seems that glitter cannot handle this kind of pattern, as it results in the following:
I also tried using a blank node:
which results in the following error: