Compose
SPARQL query composition from diagram paths - pure-library module.
Canonical implementation of query composition from diagram paths:
Each node position gets a fresh variable named after its URI local name.
Duplicate variables get suffixed:
protein,protein_1,protein_2.Triple patterns are deduplicated.
rdf:typeassertions are optional.OPTIONALlabel clauses userdfs:label+dc:title.
- compose_query_from_paths(paths: list[dict[str, Any]], prefixes: dict[str, str], options: dict[str, Any] | None = None) dict[str, Any][source]
Generate a SPARQL query from diagram paths.
- Parameters:
paths – List of path dicts, each with an
edgeslist. Each edge hassource,target,predicate, andis_forward.prefixes – Namespace prefix map (e.g.
{"wp": "http://..."}.options – Optional dict with
include_types(bool),include_labels(bool),limit(int),value_bindings(dict).
- Returns:
{"query": "SELECT ...", "variable_map": {...}, "jsonld": {...}}- Return type: