Skip to content

Commit 84d5259

Browse files
authored
Merge pull request #127 from isaacsas/update_for_catalyst14
Update for Catalyst 14
2 parents 9c76271 + 2ff2b14 commit 84d5259

10 files changed

+75
-67
lines changed

Diff for: Project.toml

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ReactionNetworkImporters"
22
uuid = "b4db0fb7-de2a-5028-82bf-5021f5cfa881"
33
authors = ["Samuel Isaacson <[email protected]>"]
4-
version = "0.14.1"
4+
version = "0.15.0"
55

66
[deps]
77
Catalyst = "479239e8-5488-4da2-87a7-35f2df7eef83"
@@ -13,20 +13,18 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1313
[compat]
1414
Aqua = "0.8"
1515
CSVFiles = "1"
16-
Catalyst = "13"
16+
Catalyst = "14"
1717
DataFrames = "1.3"
1818
DataStructures = "0.18.13"
19-
DiffEqBase = "6.117"
19+
DiffEqBase = "6.151"
2020
LinearAlgebra = "1.10"
21-
ModelingToolkit = "8.51"
22-
OrdinaryDiffEq = "6.47"
23-
Plots = "1.30"
21+
ModelingToolkit = "9.24"
22+
OrdinaryDiffEq = "6.8"
2423
SafeTestsets = "0.1"
2524
SparseArrays = "1.10"
2625
Sundials = "4.4"
27-
Symbolics = "5.2"
26+
Symbolics = "5.33"
2827
Test = "1"
29-
TimerOutputs = "0.5"
3028
julia = "1.10"
3129

3230
[extras]
@@ -36,11 +34,9 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
3634
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
3735
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3836
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
39-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
4037
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
4138
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
4239
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
43-
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
4440

4541
[targets]
46-
test = ["Aqua", "CSVFiles", "DataFrames", "DiffEqBase", "LinearAlgebra", "OrdinaryDiffEq", "Plots", "SafeTestsets", "Sundials", "Test", "TimerOutputs"]
42+
test = ["Aqua", "CSVFiles", "DataFrames", "DiffEqBase", "LinearAlgebra", "OrdinaryDiffEq", "SafeTestsets", "Sundials", "Test"]

Diff for: README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ prnbng = loadrxnetwork(BNGNetwork(), fname)
5151
Here `BNGNetwork` is a type specifying the file format that is being loaded.
5252
`prnbng` is a `ParsedReactionNetwork` structure with the following fields:
5353

54-
- `rn`, a Catalyst `ReactionSystem`
54+
- `rn`, a Catalyst `ReactionSystem`. **Note** this system is *not* marked
55+
complete by default (see the [Catalyst docs](https://catalyst.sciml.ai/) for
56+
a discussion of completeness of systems).
5557
- `u0`, a `Dict` mapping initial condition symbolic variables to numeric values
5658
and/or symbolic expressions.
5759
- `p`, a `Dict` mapping parameter symbolic variables to numeric values and/or
@@ -71,7 +73,7 @@ reaction system by
7173

7274
```julia
7375
using OrdinaryDiffEq, Catalyst
74-
rn = prnbng.rn
76+
rn = complete(prnbng.rn) # get the reaction network and mark it complete
7577
tf = 100000.0
7678
oprob = ODEProblem(rn, Float64[], (0.0, tf), Float64[])
7779
sol = solve(oprob, Tsit5(), saveat = tf / 1000.0)
@@ -169,18 +171,18 @@ reaction rate expressions. These two types have the following fields:
169171
involving parameters and species like `k*A`.
170172

171173
- matrix inputs
172-
174+
173175
+ For `MatrixNetwork`
174-
176+
175177
* `substoich`, a number of species by number of reactions matrix with entry
176178
`(i,j)` giving the stoichiometric coefficient of species `i` as a
177179
substrate in reaction `j`.
178180
* `prodstoich`, a number of species by number of reactions matrix with entry
179181
`(i,j)` giving the stoichiometric coefficient of species `i` as a product
180182
in reaction `j`.
181-
183+
182184
+ For `ComplexMatrixNetwork`
183-
185+
184186
* `stoichmat`, the complex stoichiometry matrix [defined
185187
here](https://docs.sciml.ai/Catalyst/stable/api/catalyst_api/#Catalyst.complexstoichmat).
186188
* `incidencemat`, the complex incidence matrix [defined
@@ -194,14 +196,16 @@ reaction rate expressions. These two types have the following fields:
194196
[ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/stable/)
195197
`@parameters` macro. If no parameters are used it is an optional keyword.
196198
- `t`, an optional Symbolics.jl variable representing time as the independent
197-
variable of the reaction network. If not provided `Catalyst.DEFAULT_IV` is
199+
variable of the reaction network. If not provided `Catalyst.default_t()` is
198200
used to determine the default time variable.
199201

200202
For both input types, `loadrxnetwork` returns a `ParsedReactionNetwork`, `prn`,
201203
with only the field, `prn.rn`, filled in. `prn.rn` corresponds to the generated
202204
[Catalyst.jl
203205
`ReactionSystem`](https://docs.sciml.ai/Catalyst/stable/api/catalyst_api/#Catalyst.ReactionSystem)
204-
that represents the network.
206+
that represents the network. **Note**, `prn.rn` is not marked as complete by
207+
default and must be manually completed by setting `rn = complete(prn.rn)` before
208+
creating an `ODEProblem` or such, see the Catalyst docs for details.
205209

206210
Dispatches are added if `substoich` and `prodstoich` both have the type
207211
`SparseMatrixCSC`in case of `MatrixNetwork` (or `stoichmat` and `incidencemat`

Diff for: docs/Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
44
ReactionNetworkImporters = "b4db0fb7-de2a-5028-82bf-5021f5cfa881"
55

66
[compat]
7-
Catalyst = "13.0"
7+
Catalyst = "14.0"
88
Documenter = "1"
9-
ReactionNetworkImporters = "0.14"
9+
ReactionNetworkImporters = "0.15"

Diff for: docs/make.jl

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using Documenter
22
using ReactionNetworkImporters
33

4-
cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
5-
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
4+
docpath = Base.source_dir()
5+
assetpath = joinpath(docpath, "src", "assets")
6+
cp(joinpath(docpath, "Manifest.toml"), joinpath(assetpath, "Manifest.toml"), force = true)
7+
cp(joinpath(docpath, "Project.toml"), joinpath(assetpath, "Project.toml"), force = true)
68

79
include("pages.jl")
810

@@ -25,8 +27,7 @@ makedocs(sitename = "ReactionNetworkImporters.jl",
2527
canonical = "https://docs.sciml.ai/ReactionNetworkImporters/stable/"),
2628
modules = [ReactionNetworkImporters],
2729
checkdocs = :exports, warnonly = [:missing_docs],
28-
clean = true, doctest = false, linkcheck = true,
29-
pages = pages)
30+
clean = true, doctest = false, pages = pages)
3031

3132
deploydocs(repo = "github.com/SciML/ReactionNetworkImporters.jl.git";
3233
push_preview = true)

Diff for: docs/src/index.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Pkg.add("ReactionNetworkImporters")
3535

3636
- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
3737
- There are a few community forums:
38-
38+
3939
+ The #diffeq-bridged and #sciml-bridged channels in the
4040
[Julia Slack](https://julialang.org/slack/)
4141
+ The #diffeq-bridged and #sciml-bridged channels in the
@@ -63,7 +63,9 @@ prnbng = loadrxnetwork(BNGNetwork(), fname)
6363
Here `BNGNetwork` is a type specifying the file format that is being loaded.
6464
`prnbng` is a `ParsedReactionNetwork` structure with the following fields:
6565

66-
- `rn`, a Catalyst `ReactionSystem`
66+
- `rn`, a Catalyst `ReactionSystem`. **Note** this system is *not* marked
67+
complete by default (see the [Catalyst docs](https://catalyst.sciml.ai/) for
68+
a discussion of completeness of systems).
6769
- `u0`, a `Dict` mapping initial condition symbolic variables to numeric values
6870
and/or symbolic expressions.
6971
- `p`, a `Dict` mapping parameter symbolic variables to numeric values and/or
@@ -83,7 +85,7 @@ reaction system by
8385

8486
```julia
8587
using OrdinaryDiffEq, Catalyst
86-
rn = prnbng.rn
88+
rn = complete(prnbng.rn) # get the reaction network and mark it complete
8789
tf = 100000.0
8890
oprob = ODEProblem(rn, Float64[], (0.0, tf), Float64[])
8991
sol = solve(oprob, Tsit5(), saveat = tf / 1000.0)
@@ -181,18 +183,18 @@ reaction rate expressions. These two types have the following fields:
181183
involving parameters and species like `k*A`.
182184

183185
- matrix inputs
184-
186+
185187
+ For `MatrixNetwork`
186-
188+
187189
* `substoich`, a number of species by number of reactions matrix, with entry
188190
`(i,j)` giving the stoichiometric coefficient of species `i` as a
189191
substrate in reaction `j`.
190192
* `prodstoich`, a number of species by number of reactions matrix, with entry
191193
`(i,j)` giving the stoichiometric coefficient of species `i` as a product
192194
in reaction `j`.
193-
195+
194196
+ For `ComplexMatrixNetwork`
195-
197+
196198
* `stoichmat`, the complex stoichiometry matrix [defined
197199
here](https://docs.sciml.ai/Catalyst/stable/api/catalyst_api/#Catalyst.complexstoichmat).
198200
* `incidencemat`, the complex incidence matrix [defined
@@ -206,14 +208,16 @@ reaction rate expressions. These two types have the following fields:
206208
[ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/stable/)
207209
`@parameters` macro. If no parameters are used, it is an optional keyword.
208210
- `t`, an optional Symbolics.jl variable representing time as the independent
209-
variable of the reaction network. If not provided, `Catalyst.DEFAULT_IV` is
211+
variable of the reaction network. If not provided, `Catalyst.default_t()` is
210212
used to determine the default time variable.
211213

212214
For both input types, `loadrxnetwork` returns a `ParsedReactionNetwork`, `prn`,
213215
with only the field, `prn.rn`, filled in. `prn.rn` corresponds to the generated
214216
[Catalyst.jl
215217
`ReactionSystem`](https://docs.sciml.ai/Catalyst/stable/api/catalyst_api/#Catalyst.ReactionSystem)
216-
that represents the network.
218+
that represents the network. **Note**, `prn.rn` is not marked as complete by
219+
default and must be manually completed by setting `rn = complete(prn.rn)` before
220+
creating an `ODEProblem` or such, see the Catalyst docs for details.
217221

218222
Dispatches are added if `substoich` and `prodstoich` both have the type
219223
`SparseMatrixCSC`in case of `MatrixNetwork` (or `stoichmat` and `incidencemat`

Diff for: src/parsing_routines_bngnetworkfiles.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function loadrxnetwork(ft::BNGNetwork, rxfilename; name = gensym(:ReactionSystem
221221
file = open(rxfilename, "r")
222222
lines = readlines(file)
223223
idx = 1
224-
t = Catalyst.DEFAULT_IV
224+
t = Catalyst.default_t()
225225

226226
print("Parsing parameters...")
227227
ptoids, pvals, idx = parse_params(ft, lines, idx)
@@ -250,7 +250,7 @@ function loadrxnetwork(ft::BNGNetwork, rxfilename; name = gensym(:ReactionSystem
250250
print("Creating species and parameters for evaluating expressions...")
251251
opmod = Module()
252252
Base.eval(opmod, :(using Catalyst))
253-
Base.eval(opmod, :(t = Catalyst.DEFAULT_IV))
253+
Base.eval(opmod, :(t = Catalyst.default_t()))
254254
for p in ps
255255
psym = nameof(p)
256256
Base.eval(opmod, :($(psym) = $p))
@@ -275,7 +275,7 @@ function loadrxnetwork(ft::BNGNetwork, rxfilename; name = gensym(:ReactionSystem
275275
# setup default values / expressions for params and initial conditions
276276
defmap, pmap, u0map = exprs_to_defs(opmod, ptoids, pvals, specs, u0exprs)
277277

278-
# build the model
278+
# build the model
279279
rn = ReactionSystem(rxs, t, specs, ps; name = name, observed = obseqs,
280280
defaults = defmap, kwargs...)
281281

Diff for: src/parsing_routines_matrixnetworks.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function loadrxnetwork(mn::MatrixNetwork{S, T, U, V, W, X};
4242
numspecs = sz[1]
4343
numrxs = sz[2]
4444

45-
t = (mn.t === nothing) ? Catalyst.DEFAULT_IV : mn.t
45+
t = (mn.t === nothing) ? Catalyst.default_t() : mn.t
4646
species = isempty(mn.species) ? [funcsym(:S, t, i) for i in 1:numspecs] : mn.species
4747

4848
# create the reactions
@@ -89,7 +89,7 @@ function loadrxnetwork(mn::MatrixNetwork{S, T, U, V, W, X};
8989
numspecs = sz[1]
9090
numrxs = sz[2]
9191

92-
t = (mn.t === nothing) ? Catalyst.DEFAULT_IV : mn.t
92+
t = (mn.t === nothing) ? Catalyst.default_t() : mn.t
9393
species = isempty(mn.species) ? [funcsym(:S, t, i) for i in 1:numspecs] : mn.species
9494

9595
# create the reactions
@@ -182,7 +182,7 @@ function loadrxnetwork(cmn::ComplexMatrixNetwork{S, T, U, V, W, X};
182182
@assert all(([-1, 0, 1]), cmn.incidencemat)
183183
numrxs = size(cmn.incidencemat, 2)
184184

185-
t = (cmn.t === nothing) ? Catalyst.DEFAULT_IV : cmn.t
185+
t = (cmn.t === nothing) ? Catalyst.default_t() : cmn.t
186186
species = isempty(cmn.species) ? [funcsym(:S, t, i) for i in 1:numspecs] : cmn.species
187187

188188
rxs = Vector{Reaction}(undef, numrxs)
@@ -227,7 +227,7 @@ function loadrxnetwork(cmn::ComplexMatrixNetwork{S, T, U, V, W, X};
227227
@assert all(([-1, 0, 1]), cmn.incidencemat)
228228
numrxs = size(cmn.incidencemat, 2)
229229

230-
t = (cmn.t === nothing) ? Catalyst.DEFAULT_IV : cmn.t
230+
t = (cmn.t === nothing) ? Catalyst.default_t() : cmn.t
231231
species = isempty(cmn.species) ? [funcsym(:S, t, i) for i in 1:numspecs] : cmn.species
232232

233233
rxs = Vector{Reaction}(undef, numrxs)

Diff for: test/test_higherorder_odes.jl

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using DiffEqBase, Catalyst, Plots, OrdinaryDiffEq, DataFrames, CSVFiles, LinearAlgebra
1+
using DiffEqBase, Catalyst, OrdinaryDiffEq, DataFrames, CSVFiles, LinearAlgebra
22
using ReactionNetworkImporters
3+
# using Plots
34

45
# parameters
56
doplot = false
@@ -18,7 +19,7 @@ println("done")
1819

1920
# load the BNG reaction network in DiffEqBio
2021
prnbng = loadrxnetwork(BNGNetwork(), fname)
21-
rn = prnbng.rn
22+
rn = complete(prnbng.rn)
2223
boprob = ODEProblem(rn, Float64[], (0.0, tf), Float64[])
2324

2425
# Test that u0 == u₀ (used when the u0 indexing was introduced).
@@ -28,16 +29,16 @@ boprob = ODEProblem(rn, Float64[], (0.0, tf), Float64[])
2829
@unpack A = rn
2930
Asol = gdatdf[!, :A]
3031

31-
# note solvers run _much_ faster the second time
32+
# note solvers run _much_ faster the second time
3233
bsol = solve(boprob, Tsit5(), abstol = 1e-12, reltol = 1e-12, saveat = tf / nsteps);
3334

34-
if doplot
35-
plotlyjs()
36-
p1 = plot(gdatdf[!, :time], gdatdf[!, :A], label = :A_BNG)
37-
plot!(p1, bsol.t, bsol[A], label = :A_DE)
38-
display(p1)
39-
println("Err = ", norm(gdatdf[!, :A] - bsol[Aid, :], Inf))
40-
end
35+
# if doplot
36+
# plotlyjs()
37+
# p1 = plot(gdatdf[!, :time], gdatdf[!, :A], label = :A_BNG)
38+
# plot!(p1, bsol.t, bsol[A], label = :A_DE)
39+
# display(p1)
40+
# println("Err = ", norm(gdatdf[!, :A] - bsol[Aid, :], Inf))
41+
# end
4142

4243
@test all(bsol.t .== gdatdf[!, :time])
4344
@test all(abs.(gdatdf[!, :A] - bsol[A]) .< 1e-6 .* abs.(gdatdf[!, :A]))

Diff for: test/test_nullrxs_odes.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ println("done")
1919

2020
# load the BNG reaction network in DiffEqBio
2121
prnbng = loadrxnetwork(BNGNetwork(), fname)
22-
rn = prnbng.rn;
23-
u0 = Float64[];
24-
p = Float64[];
22+
rn = complete(prnbng.rn)
23+
u0 = Float64[]
24+
p = Float64[]
2525
boprob = ODEProblem(rn, u0, (0.0, tf), p)
2626

2727
# Test that u0 == u₀ (used when the u0 indexing was introduced).
2828
@test isequal(prnbng.u0, prnbng.u₀)
2929

30-
# note solvers run _much_ faster the second time
31-
bsol = solve(boprob, Tsit5(), abstol = 1e-12, reltol = 1e-12, saveat = tf / nsteps);
30+
# note solvers run _much_ faster the second time
31+
bsol = solve(boprob, Tsit5(), abstol = 1e-12, reltol = 1e-12, saveat = tf / nsteps)
3232

3333
if doplot
3434
plotlyjs()

Diff for: test/test_repressilator_odes.jl

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using DiffEqBase, Catalyst, Plots, OrdinaryDiffEq, DataFrames, CSVFiles, LinearAlgebra
1+
using DiffEqBase, Catalyst, OrdinaryDiffEq, DataFrames, CSVFiles, LinearAlgebra
22
using ReactionNetworkImporters
33

4+
# using Plots
5+
46
# parameters
57
doplot = false
68
networkname = "Repressilator"
@@ -18,9 +20,9 @@ println("done")
1820

1921
# load the BNG reaction network in DiffEqBio
2022
prnbng = loadrxnetwork(BNGNetwork(), fname)
21-
rn = prnbng.rn;
22-
u0 = Float64[];
23-
p = Float64[];
23+
rn = complete(prnbng.rn)
24+
u0 = Float64[]
25+
p = Float64[]
2426
boprob = ODEProblem(rn, u0, (0.0, tf), p)
2527

2628
# Test that u0 == u₀ (used when the u0 indexing was introduced).
@@ -29,16 +31,16 @@ boprob = ODEProblem(rn, u0, (0.0, tf), p)
2931
# BNG simulation data testing
3032
bngsol = gdatdf[!, :pTetR]
3133

32-
# note solvers run _much_ faster the second time
34+
# note solvers run _much_ faster the second time
3335
bsol = solve(boprob, Tsit5(), abstol = 1e-12, reltol = 1e-12, saveat = tf / nsteps);
3436
@unpack pTetR = rn
3537

36-
if doplot
37-
plotlyjs()
38-
p1 = plot(gdatdf[!, :time], gdatdf[!, :pTetR], label = :BNGPTetR)
39-
plot!(p1, bsol.t, bsol[pTetR], label = :DEBPTetR)
40-
display(p1)
41-
end
38+
# if doplot
39+
# plotlyjs()
40+
# p1 = plot(gdatdf[!, :time], gdatdf[!, :pTetR], label = :BNGPTetR)
41+
# plot!(p1, bsol.t, bsol[pTetR], label = :DEBPTetR)
42+
# display(p1)
43+
# end
4244

4345
@test all(bsol.t .== gdatdf[!, :time])
4446
@test all(abs.(gdatdf[!, :pTetR] - bsol[pTetR]) .< 1e-6 .* abs.(gdatdf[!, :pTetR]))

0 commit comments

Comments
 (0)