Skip to content

Commit b9c210a

Browse files
committed
save progress
1 parent 815b4bf commit b9c210a

File tree

1 file changed

+59
-25
lines changed

1 file changed

+59
-25
lines changed

docs/src/02_model_creation/03_programmatic_CRN_construction.md

+59-25
Original file line numberDiff line numberDiff line change
@@ -267,37 +267,13 @@ sol = solve(oprob)
267267
plot(sol)
268268
```
269269

270-
271270
## [Additional options for declaration of `Reaction`s](@id programmatic_CRN_construction_reactions_options)
272271
When describing the DSL, we also describe a range of [options for declaring various types of reactions](@ref ref). Each type of reaction that can be created using the DSL can also be created programmatically. Below, we briefly describe each case.
273272

274-
### [Reactions with non-unitary stoichiometries](@id programmatic_CRN_construction_reactions_options_stoichiometries)
275-
Previously, we assumed that all reactions' substrates and products had stoichiometry 1. Other stoichiometries ([including decimal, parametric, and distributed, ones](@ref ref)) are possible. To designate this we provide two additional arguments to the `Reaction` constructor, designating the substrates and products stoichiometries respectively.
276-
277-
E.g. to model a simple dimerisation system (where two copies of $X$ dimerise to form $X2$, which then may dissociate back into two copies of $X$) we use
278-
```@example programmatic_6
279-
using Catalyst # hide
280-
t = default_t()
281-
@species X(t) X2(t)
282-
@parameters kB kD
283-
rxs = [
284-
Reaction(kB, [X], [X2], [2], [1]),
285-
Reaction(kD, [X2], [X], [1], [2])
286-
]
287-
@named dimerisation_model = ReactionSystem(rxs, t)
288-
```
289-
Here, `Reaction(k, [X], [X2], [2], [1])` indicates that there are `2` copies of $X$ and one copy of $X2$ involved in the reaction.
290-
291-
If there are multiple substrates and/or products, the order of the stoichiometries must correspond to the order in which these occur. E.g. to create a reaction `k, 2X + Y --> X + 2Y` we would use
292-
```@example programmatic_6
293-
@parameters k
294-
@species X(t) Y(t)
295-
Reaction(k, [X, Y], [X, Y], [2, 1], [1, 2]),
296-
```
297-
298273
### [Production and degradation reactions](@id programmatic_CRN_construction_reactions_options_production_and_degradation)
299274
To designate [an absence of substrates and/or products](@ref ref), we simply give an empty vector. E.g. to create a [birth-death model](@ref ref) we use
300275
```@example programmatic_6
276+
using Catalyst # hide
301277
@parameters p d
302278
@species X(t)
303279
rxs = [
@@ -338,6 +314,64 @@ Finally, Catalyst also pre-defined a few functions commonly used in systems biol
338314
Reaction(mm(E, v, K), [Xi], [Xa])
339315
```
340316

317+
### [Reactions with non-unitary stoichiometries](@id programmatic_CRN_construction_reactions_options_stoichiometries)
318+
Previously, we assumed that all reactions' substrates and products had stoichiometry 1. Other stoichiometries ([including decimal, parametric, and distributed, ones](@ref ref)) are possible. To designate this we provide two additional arguments to the `Reaction` constructor, designating the substrates and products stoichiometries respectively.
319+
320+
E.g. to model a simple dimerisation system (where two copies of $X$ dimerise to form $X2$, which then may dissociate back into two copies of $X$) we use
321+
```@example programmatic_6
322+
t = default_t()
323+
@species X(t) X2(t)
324+
@parameters kB kD
325+
rxs = [
326+
Reaction(kB, [X], [X2], [2], [1]),
327+
Reaction(kD, [X2], [X], [1], [2])
328+
]
329+
@named dimerisation_model = ReactionSystem(rxs, t)
330+
```
331+
Here, `Reaction(k, [X], [X2], [2], [1])` indicates that there are `2` copies of $X$ and one copy of $X2$ involved in the reaction.
332+
333+
If there are multiple substrates and/or products, the order of the stoichiometries must correspond to the order in which these occur. E.g. to create a reaction `k, 2X + Y --> X + 2Y` we would use
334+
```@example programmatic_6
335+
@parameters k
336+
@species X(t) Y(t)
337+
Reaction(k, [X, Y], [X, Y], [2, 1], [1, 2]),
338+
```
339+
340+
### [Reactions with non-standard stoichiometries](@id programmatic_CRN_construction_reactions_options_stoichiometries)
341+
Reactant stoichiometries does not need to be integers, but can also be other numbers, parameters, or expressions.
342+
343+
Here we create a birth-death model where each production reaction produces 1.5 units of `X`:
344+
```@example programmatic_6
345+
t = default_t()
346+
@species X(t)
347+
@parameters p d
348+
rxs = [
349+
Reaction(p, [], [X], [], [1.5]),
350+
Reaction(d, [X], [])
351+
]
352+
@named bd_model = ReactionSystem(rxs, t)
353+
```
354+
It is also possible to have non-integer stoichiometric coefficients for substrates. However, in this case the [`combinatoric_ratelaw = false`](@ref ref) option must be used. We note that non-integer stoichiometric coefficients does not make sense in most fields, however, this features is available for use for models where it does make sense.
355+
356+
It is possible for stoichiometric coefficients to be parameters. E.g. here we create a generic polymerisation system where `n` copies of `X` binds to form `Xn`:
357+
```@example dsl_1
358+
t = default_t()
359+
@species X(t) Xn(t)
360+
@parameters kB kD
361+
rxs = [
362+
Reaction(kB, [X], [Xn], [n], [1]),
363+
Reaction(kD, [Xn], [X], [1], [n])
364+
]
365+
@named polymerisation_model = ReactionSystem(rxs, t)
366+
```
367+
Now we can designate the value of `n` through a parameter when we e.g. create an `ODEProblem`:
368+
```@example dsl_1
369+
u0 = [X => 5.0, Xn => 1.0]
370+
ps = [kB => 1.0, kD => 0.1, n => 4]
371+
oprob = ODEProblem(polymerisation_model, u0, (0.0, 1.0), ps)
372+
nothing # hide
373+
```
374+
341375
### [Additional `Reaction` constructor arguments](@id programmatic_CRN_construction_reactions_options_)
342376
The `Reaction` constructor accepts several additional optional arguments. E.g. to [disable to use of mass action to compute reaction propensities, and instead use the rate only], you can use the `only_use_rate = true` argument:
343377
```@example programmatic_6

0 commit comments

Comments
 (0)