From 631277510fc820047fb07a268461aa33d1594225 Mon Sep 17 00:00:00 2001 From: mboudet Date: Thu, 10 Aug 2023 17:19:22 +0200 Subject: [PATCH] Move default query back to faldo ontology --- CHANGELOG.md | 1 + askomics/libaskomics/SparqlQuery.py | 6 +++--- docs/abstraction.md | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e34d082..f36a7ae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ This changelog was started for release 4.2.0. - 'Same strand' queries will now match 'BothStrand' with a forward or reverse strand - Use '+', '-' and '.' for strand values in CSV instead of raw value (for homogenization) - Now allows 'infinite' recursive blocks (ie, a Minus block inside a Union block, or the opposite) +- Overhaul faldo relation: add 'direct shortcut' triples between entities and values, to avoid using slow property paths when using faldo queries ### Security diff --git a/askomics/libaskomics/SparqlQuery.py b/askomics/libaskomics/SparqlQuery.py index 222f9128..a2ee56d4 100644 --- a/askomics/libaskomics/SparqlQuery.py +++ b/askomics/libaskomics/SparqlQuery.py @@ -1538,7 +1538,7 @@ def build_query_from_json(self, preview=False, for_editor=False): if attribute["visible"] or Utils.check_key_in_list_of_dict(attribute["filters"], "filterValue") or attribute["id"] in start_end or attribute["id"] in linked_attributes: subject = self.format_sparql_variable("{}{}_uri".format(attribute["entityLabel"], attribute["nodeId"])) if attribute["faldo"]: - predicate = "askomics:{}".format("faldoBegin" if attribute["faldo"].endswith("faldoStart") else "faldoEnd") + predicate = "faldo:location/faldo:{}/faldo:position".format("begin" if attribute["faldo"].endswith("faldoStart") else "end") else: predicate = "<{}>".format(attribute["uri"]) obj = self.format_sparql_variable("{}{}_{}".format(attribute["entityLabel"], attribute["nodeId"], attribute["label"])) @@ -1623,7 +1623,7 @@ def build_query_from_json(self, preview=False, for_editor=False): category_value_uri = self.format_sparql_variable("{}{}_{}Category".format(attribute["entityLabel"], attribute["nodeId"], attribute["label"])) category_label = self.format_sparql_variable("{}{}_{}".format(attribute["entityLabel"], attribute["humanNodeId"], attribute["label"])) if attribute["faldo"] and attribute["faldo"].endswith("faldoReference"): - category_name = 'askomics:faldoReference' + category_name = 'faldo:location/faldo:begin/faldo:reference' self.store_triple({ "subject": node_uri, "predicate": category_name, @@ -1640,7 +1640,7 @@ def build_query_from_json(self, preview=False, for_editor=False): "nested_end": True if attribute["optional"] else False }, block_id, sblock_id, pblock_ids, depth) elif attribute["faldo"] and attribute["faldo"].endswith("faldoStrand"): - category_name = 'askomics:faldoStrand' + category_name = 'faldo:location/faldo:begin/rdf:type' self.store_triple({ "subject": node_uri, "predicate": category_name, diff --git a/docs/abstraction.md b/docs/abstraction.md index d4f782b5..4bdb23ca 100644 --- a/docs/abstraction.md +++ b/docs/abstraction.md @@ -111,6 +111,19 @@ A FALDO entity have to be declared as FALDO on the abstraction. If attribute are Four FALDO attributes are supported by AskOmics: reference, strand, start and end. +!!! warning + AskOmics expect faldo entities to follow the faldo ontology for triple definition. Ex: + ```turtle + # Reference + :Entity faldo:location/faldo:begin/faldo:reference "value" + # strand + :Entity faldo:location/faldo:begin/rdf:type "value" + # Start + :Entity faldo:location/faldo:begin/faldo:position "value" + # Stop. + :Entity faldo:location/faldo:end/faldo:position "value" + ``` + ### faldo:reference A faldo:reference attribute derive from a Category attribute. @@ -190,8 +203,10 @@ The default faldo ontology uses a chain of triple to describe the position (ex, This make *faldo queries* (included_in/overlap_with/distant_from) extremely slow. To improve query time, AskOmics can use 'shortcut triples', direct relations between the Entity and the reference/strand, to quickly filter entities on the same reference/strand/both. For example: ```turtle -:EntityName faldo:reference reference_uri . -:EntityName faldo:strand strand_uri . +:EntityName askomics:faldoReference reference_uri . +:EntityName askomics:faldoBegin begin_value . +:EntityName askomics:faldoEnd end_value . +:EntityName askomics:faldoStrand strand_uri . :EntityName askomics:referenceStrand reference_strand_uri . ```