Skip to content

Commit 2a45c02

Browse files
committed
fix: address parsing errors from BMA
1 parent 4ade993 commit 2a45c02

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/qualitative_networks.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,12 @@ function classify_activators_inhibitors(d::AbstractDict)
741741
return Dict(e => classify_activators_inhibitors(fn) for (e, fn) in d)
742742
end
743743

744-
function remove_ids_from_entities_in_target_fn(ex)
744+
function swap_entity_names_to_var_ids(ex)
745745
@match ex begin
746-
::Symbol => Symbol(first(rsplit(string(ex), "_"; limit = 2)))
746+
::Symbol && if (ex [:+, :-, :/, :*, :min, :max, :ceil, :floor])
747+
end => :(var($(parse(Int, last(rsplit(string(ex), "_"; limit = 2))))))
747748
Expr(:call, op, children...) =>
748-
Expr(:call, op, remove_ids_from_entities_in_target_fn.(children)...)
749+
Expr(:call, op, swap_entity_names_to_var_ids.(children)...)
749750
_ => ex
750751
end
751752
end
@@ -763,7 +764,7 @@ function qn_to_bma_dict(qn::QN{N,S,M}) where {N,S,C,G,L<:EntityIdName,M<:MetaGra
763764
entity_names = name.(entities(qn))
764765
functions = [target_functions(qn)[e] for e in entities(qn)]
765766
activator_inhibitor_pairs = classify_activators_inhibitors(target_functions(qn))
766-
functions = remove_ids_from_entities_in_target_fn.(functions)
767+
functions = swap_entity_names_to_var_ids.(functions)
767768

768769
variables = [
769770
Dict(
@@ -796,7 +797,10 @@ function qn_to_bma_dict(qn::QN{N,S,M}) where {N,S,C,G,L<:EntityIdName,M<:MetaGra
796797
]
797798
output_dict = Dict(
798799
"Model" => Dict("Variables" => variables, "Relationships" => relationships),
799-
"Layout" => Dict(),
800+
"Layout" => Dict(
801+
"Variables" =>
802+
[Dict("Id" => v["Id"], "Name" => v["Name"]) for v in variables],
803+
),
800804
)
801805

802806
return output_dict

0 commit comments

Comments
 (0)