Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for is_event_assignment #171

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SBMLToolkit"
uuid = "86080e66-c8ac-44c2-a1a0-9adaadfe4a4e"
authors = ["paulflang", "anandijain"]
version = "0.1.29"
version = "0.1.30"

[deps]
Catalyst = "479239e8-5488-4da2-87a7-35f2df7eef83"
Expand Down
2 changes: 1 addition & 1 deletion src/drafts.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function is_event_assignment(k, model)
for ev in values(model.events)
for ev in last.(model.events)
for as in ev.event_assignments
if as.variable == k
return true
Expand Down
12 changes: 11 additions & 1 deletion src/systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,21 @@ function Catalyst.ReactionSystem(model::SBML.Model; kwargs...) # Todo: requires
# Dict(Catalyst.DEFAULT_IV.val => 0)))
push!(raterules_subs, rhs ~ o.lhs)
end
zero_rates = []
for (k, v) in merge(model.parameters, model.compartments)
if is_event_assignment(k, model)
if v.constant
ErrorException("$k appears in event assignment but should be constant.")
end
push!(zero_rates, D(create_var(k, IV; isbcspecies = true)) ~ 0)
end
end
if haskey(kwargs, :defaults)
defs = ModelingToolkit._merge(defs, kwargs[:defaults])
kwargs = filter(x -> !isequal(first(x), :defaults), kwargs)
end
rs = ReactionSystem([rxs..., algrules..., raterules_subs..., obsrules_rearranged...],
rs = ReactionSystem(
[rxs..., algrules..., raterules_subs..., obsrules_rearranged..., zero_rates...],
IV, first.(u0map), first.(parammap);
defaults = defs, name = gensym(:SBML),
continuous_events = get_events(model),
Expand Down
3 changes: 2 additions & 1 deletion test/simresults.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const case_ids = [7, # boundary_condition
140, # compartment size overridden with assignmentRule
170, # Model using parameters and rules only
325, # One reactions and two rate rules with four species in a 2D compartment
679 # Initial value calculated by assignmentRule in compartment of non-unit size # 1208, # Non-hOSU species with rateRule in variable compartment -> require MTK fix.
679, # Initial value calculated by assignmentRule in compartment of non-unit size # 1208, # Non-hOSU species with rateRule in variable compartment -> require MTK fix.
944 # Non-constant parameter as target of event_assignment
]

const logdir = joinpath(@__DIR__, "logs")
Expand Down
Loading