From 20b2a81463d2621a2796c91890462b7dba81463b Mon Sep 17 00:00:00 2001 From: Samuel Isaacson Date: Sat, 15 Aug 2020 21:00:36 -0400 Subject: [PATCH 1/3] updates --- .github/workflows/CompatHelper.yml | 26 ++++++++++++++++++++ README.md | 34 ++++++++++++++++++-------- src/parsing_routines_matrixnetworks.jl | 4 +-- 3 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/CompatHelper.yml diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..5083ba8 --- /dev/null +++ b/.github/workflows/CompatHelper.yml @@ -0,0 +1,26 @@ +name: CompatHelper + +on: + schedule: + - cron: '00 * * * *' + issues: + types: [opened, reopened] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1.3.0] + julia-arch: [x86] + os: [ubuntu-latest] + steps: + - uses: julia-actions/setup-julia@latest + with: + version: ${{ matrix.julia-version }} + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: julia -e 'using CompatHelper; CompatHelper.main()' diff --git a/README.md b/README.md index a9d80ae..86e2140 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,11 @@ following formats: ## Examples ### Loading a BioNetGen .net file -A simple network from the builtin BioNetGen bngl examples is the [repressilator](data/repressilator/Repressilator.bngl). The `generate_network` command in the bngl file outputs a reduced network description, i.e. a [.net](data/repressilator/Repressilator.net) file, which can be loaded into a Catalyst `ReactionSystem` as: +A simple network from the builtin BioNetGen bngl examples is the +[repressilator](data/repressilator/Repressilator.bngl). The `generate_network` +command in the bngl file outputs a reduced network description, i.e. a +[.net](data/repressilator/Repressilator.net) file, which can be loaded into a +Catalyst `ReactionSystem` as: ```julia using ReactionNetworkImporters fname = "PATH/TO/Repressilator.net" @@ -27,11 +31,19 @@ Here `BNGNetwork` is a type specifying the file format that is being loaded. - `rn`, a Catalyst `reaction_network` - `u₀`, the initial condition (as a `Vector{Float64}`) - `p`, the parameter vector (as a `Vector{Float64}`) -- `paramexprs`, the parameter vector as a mix of `Numbers`, `Symbols` and `Exprs`. `p` is generated by evaluation of these expressions and symbols. -- `varstonames`, a `Dict` mapping from the internal `Symbol` of a species used in the generated `ReactionSystem` to a `Symbol` generated from the name in the .net file. This is necessary as BioNetGen can generate exceptionally long species names, involving characters that lead to malformed species names when used with `Catalyst`. -- `groupstoids`, a `Dict` mapping the `Symbol`s (i.e. names) for any species groups defined in the .net file to a vector of indices into `u₀` where the corresponding species are stored. +- `paramexprs`, the parameter vector as a mix of `Numbers`, `Symbols` and + `Exprs`. `p` is generated by evaluation of these expressions and symbols. +- `varstonames`, a `Dict` mapping from the internal `Symbol` of a species used + in the generated `ReactionSystem` to a `Symbol` generated from the name in the + .net file. This is necessary as BioNetGen can generate exceptionally long + species names, involving characters that lead to malformed species names when + used with `Catalyst`. +- `groupstoids`, a `Dict` mapping the `Symbol`s (i.e. names) for any species + groups defined in the .net file to a vector of indices into `u₀` where the + corresponding species are stored. -Given `prnbng`, we can construct and solve the corresponding ODE model for the reaction system by +Given `prnbng`, we can construct and solve the corresponding ODE model for the +reaction system by ```julia using OrdinaryDiffEq, Catalyst rn = prnbng.rn @@ -85,8 +97,8 @@ prn = loadrxnetwork(MatrixNetwork(), rateexprs::AbstractVector, substoich::AbstractMatrix, prodstoich::AbstractMatrix; - species=Symbol[], - params=Symbol[]) + species::AbstractVector=Operation[], + params::AbstractVector=Operation[]) ``` Here `MatrixNetwork()` is the dispatch type, which selects that we are constructing a matrix-based stoichiometric representation as input. The other @@ -102,8 +114,10 @@ parameters are: - `prodstoich` - A number of species by number of reactions matrix with entry `(i,j)` giving the stoichiometric coefficient of species `i` as a product in reaction `j`. -- `species` - Optional `ModelingToolkit.Operation`s representing each species in the network. -- `parameters` - Optional `ModelingToolkit.Operation`s representing each parameter in the network. +- `species` - Optional `ModelingToolkit.Operation`s representing each species in + the network. +- `parameters` - Optional `ModelingToolkit.Operation`s representing each + parameter in the network. `prn` is again a `ParsedReactionNetwork`, with only the `reaction_network` field, `prn.rn`, defined. @@ -114,7 +128,7 @@ A dispatch is added if `substoich` and `prodstoich` both have the type If the keyword argument `species` is not set, the resulting reaction network will simply name the species `S1`, `S2`,..., `SN` for a system with `N` total -species. `params` defaults to an empty vector of `Symbol`s, so that it does not +species. `params` defaults to an empty vector of `Operation`s, so that it does not need to be set for systems with no parameters. ---- diff --git a/examples/test_bcr_odes.jl b/examples/test_bcr_odes.jl index 04a07a9..b54e8a9 100644 --- a/examples/test_bcr_odes.jl +++ b/examples/test_bcr_odes.jl @@ -31,7 +31,7 @@ show(to) rnbng = prnbng.rn; u0 = prnbng.u₀; p = prnbng.p; @timeit to "bODESystem" bosys = convert(ODESystem, rnbng) show(to) -@timeit to "bODEProb" boprob = ODEProblem(bosys, Pair.(species(rnbng,u0), (0.,tf), Pair.(params(rnbng),p)) +@timeit to "bODEProb" boprob = ODEProblem(bosys, Pair.(species(rnbng),u0), (0.,tf), Pair.(params(rnbng),p)) show(to) u = copy(u0); du = similar(u); From e2e712b418fb5d375673e00a39eccf96b0592541 Mon Sep 17 00:00:00 2001 From: Samuel Isaacson Date: Sat, 15 Aug 2020 21:29:43 -0400 Subject: [PATCH 3/3] finish BCR updates --- examples/test_bcr_odes.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/test_bcr_odes.jl b/examples/test_bcr_odes.jl index b54e8a9..9bb79d7 100644 --- a/examples/test_bcr_odes.jl +++ b/examples/test_bcr_odes.jl @@ -6,7 +6,7 @@ using ReactionNetworkImporters using TimerOutputs # parameters -doplot = true +doplot = false networkname = "testbcrbng" tf = 10000. build_jac = false @@ -47,8 +47,8 @@ show(to) println() # BNG simulation results for Activated Syk -asykgroups = prnbng.groupstoids[!,:Activated_Syk] -asyksyms = findall(x -> x ∈ asykgroups, rnbng.syms_to_ints) +asykgroups = prnbng.groupstoids[:Activated_Syk] +#asyksyms = findall(x -> x ∈ asykgroups, rnbng.syms_to_ints) # asynbng = zeros(length(gdatdf[:time])) # for sym in asyksyms # global asynbng @@ -72,9 +72,9 @@ basyk = sum(bsol[asykgroups,:], dims=1) if doplot plotlyjs() - plot(gdatdf[!,:time][2:end], gdatdf[!,:Activated_Syk][2:end], xscale=:log10, label=:AsykGroup, linestyle=:dot) + plot(gdatdf[!,:time][2:end], gdatdf[!,:Activated_Syk][2:end], xscale=:log10, label="AsykGroup", linestyle=:dot) # # plot!(cdatdf[:time][2:end], asynbng[2:end], xscale=:log10, label=:AsykSum) - plot!(bsol.t[2:end], basyk'[2:end], label=:AsykDEBio, xscale=:log10) + plot!(bsol.t[2:end], basyk'[2:end], label="AsykDEBio", xscale=:log10) end # test the error, note may be large in abs value though small relatively @@ -82,4 +82,4 @@ end # #norm(asynbng - basyk', Inf) norm(gdatdf[!,:Activated_Syk] - basyk', Inf) -@assert all(abs.(gdatdf[:Activated_Syk] - asynbng) .< 1e-6 * abs.(gdatdf[:Activated_Syk])) \ No newline at end of file +#@assert all(abs.(gdatdf[!,:Activated_Syk] - basyk') .< 1e-6 * abs.(gdatdf[:Activated_Syk])) \ No newline at end of file