You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/devdocs/dev_guide.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
Beginning with v15, Catalyst is using a new release process to try to ensure
5
5
continuing stability of releases. Before making a release one should
6
6
7
-
1. Create a new release branch, i.e. "release-15.0.0"
7
+
1. Create a new release branch, i.e. "release-15.0.0".
8
8
2. On this branch, cap major dependencies to their latest version that works and
9
9
for which tests pass.
10
10
- Caps need to be included in both Project.toml and docs/Project.toml.
@@ -16,13 +16,13 @@ continuing stability of releases. Before making a release one should
16
16
issues can arise that do not lead to actual errors in the doc CI).
17
17
4. Release via the [registration
18
18
issue](https://github.com/SciML/Catalyst.jl/issues/127) with the
19
-
command:
19
+
command:
20
20
21
-
```
22
-
@JuliaRegistrator register branch=release-15.0.0
23
-
```
21
+
```
22
+
@JuliaRegistrator register branch=release-15.0.0
23
+
```
24
24
25
-
modifying as appropriate for the version you are releasing.
25
+
modifying as appropriate for the version you are releasing.
26
26
27
27
If there is subsequently a need to increment the version of a dependency, this
28
28
should be done via a new release that follows the above process, and modifies
@@ -38,7 +38,9 @@ Catalyst release branch*.
38
38
39
39
### Checking doc builds for errors
40
40
When updating documentation, Catalyst will run any Julia code provided within example blocks to dynamically create figures and outputs. In addition to automatically creating these for us, it also provides an automatic check that all code in documentation is correct. Here, if any of the documentation code throws an error, the build job will fail. The documentation build job can be found at the bottom of a PRs conversation, here is an example of a failed one:
To check what errors were produced, click on the "Details" link of the job. Next, any errors can be found at the bottom of the "Build and deploy" section (which should be opened automatically).
Copy file name to clipboardExpand all lines: docs/src/model_creation/dsl_basics.md
+36-36Lines changed: 36 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,15 +39,15 @@ Finally, `rn = ` is used to store the model in the variable `rn` (a normal Julia
39
39
## [Defining parameters and species in the DSL](@id dsl_description_parameters_basics)
40
40
Typically, the rates are not constants, but rather parameters (which values can be set e.g. at [the beginning of each simulation](@ref simulation_intro_ODEs)). To set parametric rates, simply use whichever symbol you wish to represent your parameter with. E.g. to set the above rates to `a` and `b`, we use:
41
41
```@example dsl_basics
42
-
rn1 = @reaction_network begin
42
+
rn = @reaction_network begin
43
43
a, X --> Y
44
44
b, Y --> X
45
45
end
46
46
```
47
47
48
48
Here we have used single-character symbols to designate all species and parameters. Multi-character symbols, however, are also permitted. E.g. we could call the rates `kX` and `kY`:
49
49
```@example dsl_basics
50
-
rn1 = @reaction_network begin
50
+
rn = @reaction_network begin
51
51
kX, X --> Y
52
52
kY, Y --> X
53
53
end
@@ -59,22 +59,22 @@ Generally, anything that is a [permitted Julia variable name](https://docs.julia
59
59
### [Reactions with multiple substrates or products](@id dsl_description_reactions_multiples)
60
60
Previously, our reactions have had a single substrate and a single product. However, reactions with multiple substrates and/or products are possible. Here, all the substrates (or products) are listed and separated by a `+`. E.g. to create a model where `X` and `Y` bind (at rate `kB`) to form `XY` (which then can dissociate, at rate `kD`, to form `XY`) we use:
61
61
```@example dsl_basics
62
-
rn2 = @reaction_network begin
62
+
rn = @reaction_network begin
63
63
kB, X + Y --> XY
64
64
kD, XY --> X + Y
65
65
end
66
66
```
67
67
Reactions can have any number of substrates and products, and their names do not need to have any relationship to each other, as demonstrated by the following mock model:
68
68
```@example dsl_basics
69
-
rn3 = @reaction_network begin
69
+
rn = @reaction_network begin
70
70
k, X + Y + Z --> A + B + C + D
71
71
end
72
72
```
73
73
74
74
### [Reactions with degradation or production](@id dsl_description_reactions_degradation_and_production)
75
75
Some reactions have no products, in which case the substrate(s) are degraded (i.e. removed from the system). To denote this, set the reaction's right-hand side to `0`. Similarly, some reactions have no substrates, in which case the product(s) are produced (i.e. added to the system). This is denoted by setting the left-hand side to `0`. E.g. to create a model where a single species `X` is both created (in the first reaction) and degraded (in a second reaction), we use:
76
76
```@example dsl_basics
77
-
rn4 = @reaction_network begin
77
+
rn = @reaction_network begin
78
78
p, 0 --> X
79
79
d, X --> 0
80
80
end
@@ -83,7 +83,7 @@ end
83
83
### [Reactions with non-unitary stoichiometries](@id dsl_description_reactions_stoichiometries)
84
84
Reactions may include multiple copies of the same reactant (i.e. a substrate or a product). To specify this, the reactant is preceded by a number indicating its number of copies (also called the reactant's *stoichiometry*). E.g. to create a model where two copies of `X` dimerise to form `X2` (which then dissociate back to two `X` copies) we use:
85
85
```@example dsl_basics
86
-
rn5 = @reaction_network begin
86
+
rn = @reaction_network begin
87
87
kB, 2X --> X2
88
88
kD, X2 --> 2X
89
89
end
@@ -92,7 +92,7 @@ Reactants whose stoichiometries are not defined are assumed to have stoichiometr
92
92
93
93
Stoichiometries can be combined with `()` to define them for multiple reactants. Here, the following (mock) model declares the same reaction twice, both with and without this notation:
it is common that reactions occur in both directions (so-called *bi-directional* reactions). Here, it is possible to bundle the reactions into a single line by using the `<-->` arrow. When we do this, the rate term must include two separate rates (one for each direction, these are enclosed by a `()` and separated by a `,`). I.e. the two-state model can be declared using:
112
112
```@example dsl_basics
113
-
rn7 = @reaction_network begin
113
+
rn_bidir = @reaction_network begin
114
114
(k1,k2), X1 <--> X2
115
115
end
116
116
```
117
117
Here, the first rate (`k1`) denotes the *forward rate* and the second rate (`k2`) the *backwards rate*.
118
118
119
119
Catalyst also permits writing pure backwards reactions. These use identical syntax to forward reactions, but with the `<--` arrow:
120
120
```@example dsl_basics
121
-
rn8 = @reaction_network begin
121
+
rn_ytox = @reaction_network begin
122
122
k, X <-- Y
123
123
end
124
124
```
125
125
Here, the substrate(s) are on the right-hand side and the product(s) are on the left-hand side. Hence, the above model can be written identically using:
126
126
```@example dsl_basics
127
-
rn8 = @reaction_network begin
127
+
rn_ytox = @reaction_network begin
128
128
k, Y --> X
129
129
end
130
130
```
@@ -133,56 +133,56 @@ Generally, using forward reactions is clearer than backwards ones, with the latt
133
133
### [Bundling similar reactions on a single line](@id dsl_description_reaction_bundling_similar)
134
134
There exist additional situations where models contain similar reactions (e.g. systems where all system components degrade at identical rates). Reactions which share either rates, substrates, or products can be bundled into a single line. Here, the parts which are different for the reactions are written using `(,)` (containing one separate expression for each reaction). E.g., let us consider the following model where species `X` and `Y` both degrade at the rate `d`:
135
135
```@example dsl_basics
136
-
rn8 = @reaction_network begin
136
+
rn_deg = @reaction_network begin
137
137
d, X --> 0
138
138
d, Y --> 0
139
139
end
140
140
```
141
141
These share both their rates (`d`) and products (`0`), however, the substrates are different (`X` and `Y`). Hence, the reactions can be bundled into a single line using the common rate and product expression while providing separate substrate expressions:
142
142
```@example dsl_basics
143
-
rn8 = @reaction_network begin
143
+
rn_deg = @reaction_network begin
144
144
d, (X,Y) --> 0
145
145
end
146
146
```
147
147
This declaration of the model is identical to the previous one. Reactions can share any subset of the rate, substrate, and product expression (the cases where they share all or none, however, do not make sense to use). I.e. if the two reactions also have different degradation rates:
148
148
```@example dsl_basics
149
-
rn9 = @reaction_network begin
149
+
rn_deg2 = @reaction_network begin
150
150
dX, X --> 0
151
151
dY, Y --> 0
152
152
end
153
153
```
154
154
This can be represented using:
155
155
```@example dsl_basics
156
-
rn9 = @reaction_network begin
156
+
rn_deg2 = @reaction_network begin
157
157
(dX,dY), (X,Y) --> 0
158
158
end
159
159
```
160
160
161
161
It is possible to use bundling for any number of reactions. E.g. in the following model we bundle the conversion of a species $X$ between its various forms (where all reactions use the same rate $k$):
162
162
```@example dsl_basics
163
-
rn10 = @reaction_network begin
163
+
rn = @reaction_network begin
164
164
k, (X0,X1,X2,X3) --> (X1,X2,X3,X4)
165
165
end
166
166
```
167
167
168
168
It is possible to combine bundling with bi-directional reactions. In this case, the rate is first split into the forward and backwards rates. These may then (or may not) indicate several rates. We exemplify this using the two following two (identical) networks, created with and without bundling.
169
169
```@example dsl_basics
170
-
rn11 = @reaction_network begin
170
+
rn_sp = @reaction_network begin
171
171
kf, S --> P1
172
172
kf, S --> P2
173
173
kb_1, P1 --> S
174
174
kb_2, P2 --> S
175
175
end
176
176
```
177
177
```@example dsl_basics
178
-
rn11 = @reaction_network begin
178
+
rn_sp = @reaction_network begin
179
179
(kf, (kb_1, kb_2)), S <--> (P1,P2)
180
180
end
181
181
```
182
182
183
183
Like when we designated stoichiometries, reaction bundling can be applied very generally to create some truly complicated reactions:
184
184
```@example dsl_basics
185
-
rn12 = @reaction_network begin
185
+
rn = @reaction_network begin
186
186
((pX, pY, pZ),d), (0, Y0, Z0) <--> (X, Y, Z1+Z2)
187
187
end
188
188
```
@@ -193,38 +193,38 @@ So far we have assumed that all reaction rates are constant (being either a numb
193
193
194
194
Let us consider a model with an activator (`A`, which degraded at a constant rate) and a protein (`P`). The production rate of `P` depends both on `A` and a parameter (`kP`). We model this through:
195
195
```@example dsl_basics
196
-
rn_13 = @reaction_network begin
196
+
rn_ap = @reaction_network begin
197
197
d, A --> 0
198
198
kP*A, 0 --> P
199
199
end
200
200
```
201
201
Here, `P`'s production rate will be reduced as `A` decays. We can [print the ODE this model produces with `Latexify`](@ref visualisation_latex):
202
202
```@example dsl_basics
203
203
using Latexify
204
-
latexify(rn_13; form = :ode)
204
+
latexify(rn_ap; form = :ode)
205
205
```
206
206
207
207
In this case, we can generate an equivalent model by instead adding `A` as both a substrate and a product to `P`'s production reaction:
208
208
```@example dsl_basics
209
-
rn_13_alt = @reaction_network begin
209
+
rn_ap_alt = @reaction_network begin
210
210
d, A --> 0
211
211
kp, A --> A + P
212
212
end
213
213
```
214
214
We can confirm that this generates the same ODE:
215
215
```@example dsl_basics
216
-
latexify(rn_13_alt; form = :ode)
216
+
latexify(rn_ap_alt; form = :ode)
217
217
```
218
218
Here, while these models will generate identical ODE, SDE, and jump simulations, the chemical reaction network models themselves are not equivalent. Generally, as pointed out in the two notes below, using the second form is preferable.
219
219
!!! warning
220
-
While `rn_13` and `rn_13_alt` will generate equivalent simulations, for jump simulations, the first model will have reduced performance as it generates a less performant representation of the system in JumpProcesses. It is generally recommended to write pure mass action reactions such that there is just a single constant within the rate constant expression for optimal performance of jump process simulations.
220
+
While `rn_ap` and `rn_ap_alt` will generate equivalent simulations, for jump simulations, the first model will have reduced performance as it generates a less performant representation of the system in JumpProcesses. It is generally recommended to write pure mass action reactions such that there is just a single constant within the rate constant expression for optimal performance of jump process simulations.
221
221
222
222
!!! danger
223
223
Catalyst automatically infers whether quantities appearing in the DSL are species or parameters (as described [here](@ref dsl_advanced_options_declaring_species_and_parameters)). Generally, anything that does not appear as a reactant is inferred to be a parameter. This means that if you want to model a reaction activated by a species (e.g. `kp*A, 0 --> P`), but that species does not occur as a reactant, it will be interpreted as a parameter. This can be handled by [manually declaring the system species](@ref dsl_advanced_options_declaring_species_and_parameters).
224
224
225
225
Above we used a simple example where the rate was the product of a species and a parameter. However, any valid Julia expression of parameters, species, and values can be used. E.g the following is a valid model:
226
226
```@example dsl_basics
227
-
rn_14 = @reaction_network begin
227
+
rn = @reaction_network begin
228
228
2.0 + X^2, 0 --> X + Y
229
229
k1 + k2^k3, X --> ∅
230
230
pi * X/(sqrt(2) + Y), Y → ∅
@@ -234,15 +234,15 @@ end
234
234
### [Using functions in rates](@id dsl_description_nonconstant_rates_functions)
235
235
It is possible for the rate to contain Julia functions. These can either be functions from Julia's standard library:
Two functions frequently used within systems biology are the [*Michaelis-Menten*](https://en.wikipedia.org/wiki/Michaelis%E2%80%93Menten_kinetics) and [*Hill*](https://en.wikipedia.org/wiki/Hill_equation_(biochemistry)) functions. These are pre-defined in Catalyst and can be called using `mm(X,v,K)` and `hill(X,v,K,n)`. E.g. a self-activation loop where `X` activates its own production through a Hill function can be created using:
253
253
```@example dsl_basics
254
-
rn_18 = @reaction_network begin
254
+
rn = @reaction_network begin
255
255
hill(X,v,K,n), 0 --> P
256
256
d, X --> 0
257
257
end
@@ -267,15 +267,15 @@ Catalyst comes with the following predefined functions:
Previously we have assumed that the rates are independent of the time variable, $t$. However, time-dependent reactions are also possible. Here, simply use `t` to represent the time variable. E.g., to create a production/degradation model where the production rate decays as time progresses, we can use:
269
269
```@example dsl_basics
270
-
rn_14 = @reaction_network begin
270
+
rn = @reaction_network begin
271
271
kp/(1 + t), 0 --> P
272
272
d, P --> 0
273
273
end
274
274
```
275
275
276
276
Like previously, `t` can be part of any valid expression. E.g. to create a reaction with a cyclic rate (e.g. to represent a [circadian system](https://en.wikipedia.org/wiki/Circadian_rhythm)) we can use:
Previously all stoichiometric constants have been integer numbers, however, decimal numbers are also permitted. Here we create a birth-death model where each production reaction produces 1.5 units of `X`:
295
295
```@example dsl_basics
296
-
rn_16 = @reaction_network begin
296
+
rn = @reaction_network begin
297
297
p, 0 --> 1.5X
298
298
d, X --> 0
299
299
end
@@ -303,15 +303,15 @@ It is also possible to have non-integer stoichiometric coefficients for substrat
It is possible for stoichiometric coefficients to be parameters. E.g. here we create a generic polymerisation system where `n` copies of `X` bind to form `Xn`:
305
305
```@example dsl_basics
306
-
rn_17 = @reaction_network begin
306
+
rn = @reaction_network begin
307
307
(kB,kD), n*X <--> Xn
308
308
end
309
309
```
310
310
Now we can designate the value of `n` through a parameter when we e.g. create an `ODEProblem`:
311
311
```@example dsl_basics
312
312
u0 = [:X => 5.0, :Xn => 1.0]
313
313
ps = [:kB => 1.0, :kD => 0.1, :n => 4]
314
-
oprob = ODEProblem(rn_17, u0, (0.0, 1.0), ps)
314
+
oprob = ODEProblem(rn, u0, (0.0, 1.0), ps)
315
315
nothing # hide
316
316
```
317
317
@@ -321,7 +321,7 @@ Julia permits any Unicode characters to be used in variable names, thus Catalyst
321
321
### [Using ∅ in degradation/production reactions](@id dsl_description_symbols_empty_set)
322
322
Previously, we described how `0` could be used to [create degradation or production reactions](@ref dsl_description_reactions_degradation_and_production). Catalyst permits the user to instead use the `∅` symbol. E.g. the production/degradation system can alternatively be written as:
323
323
```@example dsl_basics
324
-
rn4 = @reaction_network begin
324
+
rn_pd = @reaction_network begin
325
325
p, ∅ --> X
326
326
d, X --> ∅
327
327
end
@@ -335,7 +335,7 @@ Catalyst uses `-->`, `<-->`, and `<--` to denote forward, bi-directional, and ba
335
335
336
336
E.g. the production/degradation system can alternatively be written as:
337
337
```@example dsl_basics
338
-
rn4 = @reaction_network begin
338
+
rn_pd = @reaction_network begin
339
339
p, ∅ → X
340
340
d, X → ∅
341
341
end
@@ -361,7 +361,7 @@ nothing # hide
361
361
362
362
This functionality can also be used to create less serious models:
0 commit comments