From 5b108c98c666f7954e2fe54170e0e9662223345b Mon Sep 17 00:00:00 2001 From: Patrick Kalita Date: Tue, 8 Oct 2024 16:15:50 -0700 Subject: [PATCH] Replace `represents` network attribute with `labels` and `prov:wasDerivedFrom` --- src/gocam/translation/cx2/main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gocam/translation/cx2/main.py b/src/gocam/translation/cx2/main.py index 286c4c9..3f93cef 100644 --- a/src/gocam/translation/cx2/main.py +++ b/src/gocam/translation/cx2/main.py @@ -55,7 +55,7 @@ def _remove_species_code_suffix(label: str) -> str: @cache def _get_context(): - return prefixmaps.load_context("go").as_dict() + return prefixmaps.load_context("go") # Regex from @@ -105,14 +105,18 @@ def _add_input_output_nodes( ) # Create the CX2 network and set network-level attributes + go_context = _get_context() + go_converter = go_context.as_converter() cx2_network = CX2Network() cx2_network.set_network_attributes( { - "@context": json.dumps(_get_context()), + "@context": json.dumps(go_context.as_dict()), "name": gocam.title if gocam.title is not None else gocam.id, - "represents": gocam.id, + "prov:wasDerivedFrom": go_converter.expand(gocam.id), } ) + # This gets added separately so we can declare the datatype + cx2_network.add_network_attribute("labels", [gocam.id], "list_of_string") # Add nodes for activities, labeled by the activity's enabled_by object for activity in gocam.activities: