Skip to content

Commit 4954a36

Browse files
committed
WIP: activator inhibitor classification broken
1 parent 2e8675c commit 4954a36

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ version = "0.0.5"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
8+
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
89
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
910
DynamicalSystemsBase = "6e36e845-645a-534a-86f2-f5d4aa5a06b4"
1011
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
@@ -23,6 +24,7 @@ StructUtils = "ec057cc2-7a8d-4b58-b3b3-92acb9f63b42"
2324

2425
[compat]
2526
AbstractTrees = "0.4.5"
27+
AutoHashEquals = "2.2.0"
2628
DocStringExtensions = "0.9.3"
2729
DynamicalSystemsBase = "3.13.2"
2830
Graphs = "1.12"

src/qualitative_networks.jl

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SciMLBase
44
import StructUtils
55

66
using AbstractTrees: Leaves, PostOrderDFS
7+
using AutoHashEquals: @auto_hash_equals
78
using DynamicalSystemsBase: ArbitrarySteppable, current_parameters, initial_state
89
using Graphs: AbstractGraph, SimpleDiGraph, add_edge!, add_vertex!, ne
910
using HerbConstraints: DomainRuleNode, Forbidden, Ordered, Unique, VarNode, addconstraint!
@@ -226,14 +227,31 @@ struct EntityName{S} <: EntityLabel
226227
end
227228
name(e::EntityName) = e.name
228229

229-
struct EntityIdName{S} <: EntityLabel
230+
@auto_hash_equals struct EntityIdName{S} <: EntityLabel
230231
id::Int
231232
name::S
232233
end
234+
function EntityIdName(en::EntityName)
235+
en_str = string(name(en))
236+
name_id_str_split = rsplit(en_str, "_"; limit = 2)
237+
if length(name_id_str_split) != 2
238+
error("""Failed to convert the EntityName $en to an EntityIdName. \
239+
Expecting an EntityName with a name in the form of "Name_00".""")
240+
end
241+
(name_str, id_str) = name_id_str_split
242+
243+
id_val = tryparse(Int, id_str)
244+
if isnothing(id_val)
245+
error("""Entity name ($(name(en))) contained an underscore but the \
246+
content after the underscore ($id_str) could not be parsed as \
247+
an integer to convert it to an ID.""")
248+
end
249+
250+
return EntityIdName(id_val, string(name_str))
251+
end
233252
id(e::EntityIdName) = e.id
234253
name(e::EntityIdName) = e.name
235254
combined_name(e::EntityIdName) = Symbol("$(name(e))_$(id(e))")
236-
Base.:(==)(e::EntityIdName, e2::EntityIdName) = id(e) == id(e2) && name(e) == name(e2)
237255

238256
struct Entity{I<:EntityLabel,D}
239257
label::I
@@ -293,14 +311,15 @@ function update_functions_to_interaction_graph(
293311

294312
for dst in entities_in_model
295313
input_entities = get_used_entities(target_function(dst), entities_in_model)
296-
for src in EntityName.(input_entities)
314+
for src in EntityIdName.(EntityName.(input_entities))
315+
dst_label = label(dst)
297316
l = collect(labels(graph))
298-
if !(src l && label(dst) l)
317+
if !(src l && dst_label l)
299318
error(
300-
"""Could not add edge from $src to $(label(dst)). The vertex labels in the graph are currently $(collect(labels(graph))).""",
319+
"""Could not add edge from $src to $(dst_label). The vertex labels in the graph are currently $(collect(labels(graph))).""",
301320
)
302321
end
303-
add_edge!(graph, src, label(dst))
322+
add_edge!(graph, src, dst_label)
304323
end
305324
end
306325

@@ -759,12 +778,14 @@ function qn_to_bma_dict(qn::QN{N,S,M}) where {N,S,C,G,L<:EntityIdName,M<:MetaGra
759778
"Name" => n,
760779
) for (d, i, n, f) in zip(lower_upper, ids, entity_names, functions)
761780
]
781+
Main.@infiltrate
762782
relationships = [
763783
Dict(
764784
"Id" => i,
765-
"FromVariable" => tryparse(Int, last(split(string(src), '_'))),
766-
"ToVariable" => tryparse(Int, last(split(string(dst), '_'))),
785+
"FromVariable" => id(src),
786+
"ToVariable" => id(dst),
767787
"Type" => let (activators, inhibitors) = activator_inhibitor_pairs[dst]
788+
Main.@infiltrate
768789
if src in activators
769790
"Activator"
770791
elseif src in inhibitors

test/quick.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TestEnv.activate() do
1212
runtests(
1313
GraphDynamicalSystems,
1414
name = r"^(?!Code).+$",
15-
failfast = true,
15+
# failfast = true,
1616
failures_first = true,
1717
)
1818
end

0 commit comments

Comments
 (0)