Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
paulflang committed Jun 2, 2024
1 parent 0386d44 commit 8e369d7
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ makedocs(;
assets = ["assets/favicon.ico"]),
pages = [
"Home" => "index.md",
"API documentation" => "api.md",
"API documentation" => "api.md"
])

deploydocs(;
Expand Down
2 changes: 1 addition & 1 deletion src/SBMLToolkit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include("utils.jl")

export ReactionSystem, ODESystem
export readSBML, readSBMLFromString, set_level_and_version, convert_simplify_math,
convert_promotelocals_expandfuns
convert_promotelocals_expandfuns
export DefaultImporter, ReactionSystemImporter, ODESystemImporter

end
18 changes: 9 additions & 9 deletions src/reactions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ function get_unidirectional_components(bidirectional_math)
end

function add_reaction!(rxs::Vector{Reaction},
kl::Num,
reactant_references::Vector{SBML.SpeciesReference},
product_references::Vector{SBML.SpeciesReference},
model::SBML.Model;
enforce_rate = false)
kl::Num,
reactant_references::Vector{SBML.SpeciesReference},
product_references::Vector{SBML.SpeciesReference},
model::SBML.Model;
enforce_rate = false)
reactants, products, rstoichvals, pstoichvals = get_reagents(reactant_references,
product_references, model)
isnothing(reactants) && isnothing(products) && return
Expand All @@ -78,8 +78,8 @@ end
Get reagents
"""
function get_reagents(reactant_references::Vector{SBML.SpeciesReference},
product_references::Vector{SBML.SpeciesReference},
model::SBML.Model)
product_references::Vector{SBML.SpeciesReference},
model::SBML.Model)
reactants = String[]
products = String[]
rstoich = Float64[]
Expand Down Expand Up @@ -146,7 +146,7 @@ end
Get kineticLaw for use in MTK.Reaction
"""
function use_rate(kl::Num, react::Union{Vector{Num}, Nothing},
stoich::Union{Vector{<:Real}, Nothing})
stoich::Union{Vector{<:Real}, Nothing})
rate_const = get_massaction(kl, react, stoich)
if !isnan(rate_const)
kl = rate_const
Expand All @@ -161,7 +161,7 @@ end
Get rate constant of mass action kineticLaws
"""
function get_massaction(kl::Num, reactants::Union{Vector{Num}, Nothing},
stoich::Union{Vector{<:Real}, Nothing})
stoich::Union{Vector{<:Real}, Nothing})
function check_args(x::SymbolicUtils.BasicSymbolic{Real})
check_args(Val(SymbolicUtils.istree(x)), x)
end
Expand Down
4 changes: 2 additions & 2 deletions src/systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Create a `ModelingToolkit.ODESystem` from an SBML file, using the default import
See also [`Model`](@ref) and [`ODESystemImporter`](@ref).
"""
function SBML.readSBML(sbmlfile::String, ::ODESystemImporter;
include_zero_odes::Bool = true, kwargs...) # Returns an MTK.ODESystem
include_zero_odes::Bool = true, kwargs...) # Returns an MTK.ODESystem
convert(ODESystem, readSBML(sbmlfile, ReactionSystemImporter(), kwargs...),
include_zero_odes = include_zero_odes)
end
Expand Down Expand Up @@ -105,7 +105,7 @@ Create an `ODESystem` from an `SBML.Model`.
See also [`ReactionSystem`](@ref).
"""
function ModelingToolkit.ODESystem(model::SBML.Model; include_zero_odes::Bool = true,
kwargs...)
kwargs...)
rs = ReactionSystem(model; kwargs...)
convert(ODESystem, rs; include_zero_odes = include_zero_odes)
end
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function create_var(x, iv; isbcspecies = false, irreducible = false)
sym = Symbol(x)
Symbolics.unwrap(first(@species $sym(iv) [
isbcspecies = isbcspecies,
irreducible = irreducible,
irreducible = irreducible
]))
end
function create_param(x; isconstantspecies = false)
Expand Down
13 changes: 8 additions & 5 deletions test/reactions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ SPECIES3 = SBML.Species(name = "s1s2", compartment = "c1", initial_amount = 1.0,
boundary_condition = false, constant = false)
KINETICMATH1 = SBML.MathIdent("k1")
KINETICMATH2 = SBML.MathApply("*", SBML.Math[SBML.MathIdent("k1"), SBML.MathIdent("s2")])
REACTION1 = SBML.Reaction(products = [
SBML.SpeciesReference(species = "s1", stoichiometry = 1),
REACTION1 = SBML.Reaction(
products = [
SBML.SpeciesReference(species = "s1", stoichiometry = 1)
],
kinetic_math = KINETICMATH1,
reversible = false)
Expand All @@ -40,8 +41,9 @@ truereaction = Catalyst.Reaction(k1, nothing, [s1], nothing, [1]) # Todo: imple
@test isequal(reaction, truereaction)

km = SBML.MathTime("x")
reac = SBML.Reaction(reactants = [
SBML.SpeciesReference(species = "s1", stoichiometry = 1.0),
reac = SBML.Reaction(
reactants = [
SBML.SpeciesReference(species = "s1", stoichiometry = 1.0)
],
kinetic_math = km,
reversible = false)
Expand Down Expand Up @@ -114,7 +116,8 @@ m = SBML.Model(species = Dict("s" => s), reactions = Dict("r1" => r))
@test isequal((nothing, nothing, nothing, nothing),
SBMLToolkit.get_reagents(r.products, r.reactants, m))

r = SBML.Reaction(reactants = [SBML.SpeciesReference(species = "s", stoichiometry = 1.0),
r = SBML.Reaction(
reactants = [SBML.SpeciesReference(species = "s", stoichiometry = 1.0),
SBML.SpeciesReference(species = "s", stoichiometry = 1.0)],
reversible = false)
m = SBML.Model(species = Dict("s" => s), reactions = Dict("r1" => r))
Expand Down
3 changes: 2 additions & 1 deletion test/rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ assignment_true = 7 * compartment
@test isequal(assignment, assignment_true)

r = SBML.AssignmentRule("S2", SBML.MathVal(1))
@test_throws ErrorException("Cannot find target for rule with ID `S2`") SBMLToolkit.get_var_and_assignment(m,
@test_throws ErrorException("Cannot find target for rule with ID `S2`") SBMLToolkit.get_var_and_assignment(
m,
r)

# Test get_volume_correction
Expand Down
3 changes: 1 addition & 2 deletions test/simresults.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ 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.
]

const logdir = joinpath(@__DIR__, "logs")
Expand Down
10 changes: 6 additions & 4 deletions test/systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ KINETICMATH3 = SBML.MathApply("-",
SBML.Math[SBML.MathIdent("k1"),
SBML.MathIdent("s1")]),
KINETICMATH1])
REACTION1 = SBML.Reaction(products = [
SBML.SpeciesReference(species = "s1", stoichiometry = 1.0),
REACTION1 = SBML.Reaction(
products = [
SBML.SpeciesReference(species = "s1", stoichiometry = 1.0)
],
kinetic_math = KINETICMATH1,
reversible = false)
REACTION2 = SBML.Reaction(reactants = [
SBML.SpeciesReference(species = "s1", stoichiometry = 1.0),
REACTION2 = SBML.Reaction(
reactants = [
SBML.SpeciesReference(species = "s1", stoichiometry = 1.0)
],
kinetic_math = KINETICMATH3,
reversible = true)
Expand Down
6 changes: 4 additions & 2 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ sym = SBMLToolkit.map_symbolics_ident(SBML.MathIdent("B"), MODEL1)
@parameters C D Bc

test = SBML.MathApply("*",
SBML.Math[SBML.MathApply("+",
SBML.Math[SBML.MathApply("*",
SBML.Math[
SBML.MathApply("+",
SBML.Math[
SBML.MathApply("*",
SBML.Math[SBML.MathAvogadro("A"),
SBML.MathIdent("B")]),
SBML.MathApply("-",
Expand Down

0 comments on commit 8e369d7

Please sign in to comment.