Skip to content

Commit a52ced8

Browse files
committed
add model files
1 parent 399374d commit a52ced8

File tree

3 files changed

+275
-16
lines changed

3 files changed

+275
-16
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Created by COPASI version 4.42 (Build 284) on 2024-01-10 09:22 with libSBML version 5.20.0. -->
3+
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4">
4+
<model metaid="COPASI0" id="New_Model" name="New Model">
5+
<annotation>
6+
<copasi:COPASI xmlns:copasi="http://www.copasi.org/static/sbml">
7+
<rdf:RDF xmlns:dcterms="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
8+
<rdf:Description rdf:about="#COPASI0">
9+
<dcterms:created>
10+
<rdf:Description>
11+
<dcterms:W3CDTF>2024-01-09T21:46:45Z</dcterms:W3CDTF>
12+
</rdf:Description>
13+
</dcterms:created>
14+
</rdf:Description>
15+
</rdf:RDF>
16+
</copasi:COPASI>
17+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
18+
<rdf:Description rdf:about="#COPASI0">
19+
<dcterms:created rdf:parseType="Resource">
20+
<dcterms:W3CDTF>2024-01-09T21:46:45Z</dcterms:W3CDTF>
21+
</dcterms:created>
22+
<dcterms:modified rdf:parseType="Resource">
23+
<dcterms:W3CDTF>2024-01-09T21:46:45Z</dcterms:W3CDTF>
24+
</dcterms:modified>
25+
</rdf:Description>
26+
</rdf:RDF>
27+
</annotation>
28+
<listOfFunctionDefinitions>
29+
<functionDefinition id="Constant_flux__irreversible" name="Constant flux (irreversible)">
30+
<math xmlns="http://www.w3.org/1998/Math/MathML">
31+
<lambda>
32+
<bvar>
33+
<ci> v </ci>
34+
</bvar>
35+
<ci> v </ci>
36+
</lambda>
37+
</math>
38+
</functionDefinition>
39+
</listOfFunctionDefinitions>
40+
<listOfUnitDefinitions>
41+
<unitDefinition id="length" name="length">
42+
<listOfUnits>
43+
<unit kind="metre" exponent="1" scale="0" multiplier="1"/>
44+
</listOfUnits>
45+
</unitDefinition>
46+
<unitDefinition id="area" name="area">
47+
<listOfUnits>
48+
<unit kind="metre" exponent="2" scale="0" multiplier="1"/>
49+
</listOfUnits>
50+
</unitDefinition>
51+
<unitDefinition id="volume" name="volume">
52+
<listOfUnits>
53+
<unit kind="litre" exponent="1" scale="0" multiplier="1"/>
54+
</listOfUnits>
55+
</unitDefinition>
56+
<unitDefinition id="time" name="time">
57+
<listOfUnits>
58+
<unit kind="second" exponent="1" scale="0" multiplier="1"/>
59+
</listOfUnits>
60+
</unitDefinition>
61+
<unitDefinition id="substance" name="substance">
62+
<listOfUnits>
63+
<unit kind="mole" exponent="1" scale="0" multiplier="1"/>
64+
</listOfUnits>
65+
</unitDefinition>
66+
</listOfUnitDefinitions>
67+
<listOfCompartments>
68+
<compartment id="compartment" name="compartment" spatialDimensions="3" size="1" constant="true"/>
69+
</listOfCompartments>
70+
<listOfSpecies>
71+
<species id="X" name="X" compartment="compartment" hasOnlySubstanceUnits="true" initialAmount="2" boundaryCondition="false" constant="false"/>
72+
<species id="Y" name="Y" compartment="compartment" hasOnlySubstanceUnits="true" initialAmount="10" boundaryCondition="false" constant="false"/>
73+
</listOfSpecies>
74+
<listOfParameters>
75+
<parameter id="A" name="A" value="1" constant="true"/>
76+
<parameter id="B" name="B" value="4" constant="true"/>
77+
</listOfParameters>
78+
<listOfReactions>
79+
<reaction id="r2" name="r2" reversible="false">
80+
<listOfReactants>
81+
<speciesReference species="Y" stoichiometry="1"/>
82+
<speciesReference species="X" stoichiometry="2"/>
83+
</listOfReactants>
84+
<listOfProducts>
85+
<speciesReference species="X" stoichiometry="3"/>
86+
</listOfProducts>
87+
<kineticLaw>
88+
<math xmlns="http://www.w3.org/1998/Math/MathML">
89+
<apply>
90+
<times/>
91+
<ci> compartment </ci>
92+
<ci> k1 </ci>
93+
<apply>
94+
<power/>
95+
<ci> X </ci>
96+
<cn> 2 </cn>
97+
</apply>
98+
<ci> Y </ci>
99+
</apply>
100+
</math>
101+
<listOfParameters>
102+
<parameter id="k1" name="k1" value="1"/>
103+
</listOfParameters>
104+
</kineticLaw>
105+
</reaction>
106+
<reaction id="r3" name="r3" reversible="false">
107+
<listOfReactants>
108+
<speciesReference species="X" stoichiometry="1"/>
109+
</listOfReactants>
110+
<listOfProducts>
111+
<speciesReference species="Y" stoichiometry="1"/>
112+
</listOfProducts>
113+
<kineticLaw>
114+
<math xmlns="http://www.w3.org/1998/Math/MathML">
115+
<apply>
116+
<times/>
117+
<ci> compartment </ci>
118+
<ci> B </ci>
119+
<ci> X </ci>
120+
</apply>
121+
</math>
122+
</kineticLaw>
123+
</reaction>
124+
<reaction id="r4" name="r4" reversible="false">
125+
<listOfReactants>
126+
<speciesReference species="X" stoichiometry="1"/>
127+
</listOfReactants>
128+
<kineticLaw>
129+
<math xmlns="http://www.w3.org/1998/Math/MathML">
130+
<apply>
131+
<times/>
132+
<ci> compartment </ci>
133+
<ci> k1 </ci>
134+
<ci> X </ci>
135+
</apply>
136+
</math>
137+
<listOfParameters>
138+
<parameter id="k1" name="k1" value="1"/>
139+
</listOfParameters>
140+
</kineticLaw>
141+
</reaction>
142+
<reaction id="r1" name="r1" reversible="false">
143+
<listOfProducts>
144+
<speciesReference species="X" stoichiometry="1"/>
145+
</listOfProducts>
146+
<kineticLaw>
147+
<math xmlns="http://www.w3.org/1998/Math/MathML">
148+
<apply>
149+
<times/>
150+
<ci> compartment </ci>
151+
<apply>
152+
<ci> Constant_flux__irreversible </ci>
153+
<ci> A </ci>
154+
</apply>
155+
</apply>
156+
</math>
157+
</kineticLaw>
158+
</reaction>
159+
</listOfReactions>
160+
</model>
161+
</sbml>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Created by BioNetGen 2.3.1
2+
begin parameters
3+
1 Na 6.022e23 # Constant
4+
2 V 1.4e-15 # Constant
5+
3 c0 1e9 # Constant
6+
4 c1 224 # Constant
7+
5 c2 9 # Constant
8+
6 c3 0.5 # Constant
9+
7 c4 5e-4 # Constant
10+
8 c5 0.167 # Constant
11+
9 c6 ln(2)/120 # Constant
12+
10 c7 ln(2)/600 # Constant
13+
11 tF 1e-4 # Constant
14+
12 rF 1000 # Constant
15+
13 pF 1000 # Constant
16+
14 _rateLaw1 (((c0/Na)/V)*tF)/pF # ConstantExpression
17+
15 _rateLaw2 c1*tF # ConstantExpression
18+
16 _rateLaw3 (((c0/Na)/V)*tF)/pF # ConstantExpression
19+
17 _rateLaw4 c2*tF # ConstantExpression
20+
18 _rateLaw5 c3*rF # ConstantExpression
21+
19 _rateLaw6 c4*rF # ConstantExpression
22+
20 _rateLaw7 (c5/rF)*pF # ConstantExpression
23+
21 _rateLaw8 (((c0/Na)/V)*tF)/pF # ConstantExpression
24+
22 _rateLaw9 c1*tF # ConstantExpression
25+
23 _rateLaw10 (((c0/Na)/V)*tF)/pF # ConstantExpression
26+
24 _rateLaw11 c2*tF # ConstantExpression
27+
25 _rateLaw12 c3*rF # ConstantExpression
28+
26 _rateLaw13 c4*rF # ConstantExpression
29+
27 _rateLaw14 (c5/rF)*pF # ConstantExpression
30+
28 _rateLaw15 (((c0/Na)/V)*tF)/pF # ConstantExpression
31+
29 _rateLaw16 c1*tF # ConstantExpression
32+
30 _rateLaw17 (((c0/Na)/V)*tF)/pF # ConstantExpression
33+
31 _rateLaw18 c2*tF # ConstantExpression
34+
32 _rateLaw19 c3*rF # ConstantExpression
35+
33 _rateLaw20 c4*rF # ConstantExpression
36+
34 _rateLaw21 (c5/rF)*pF # ConstantExpression
37+
end parameters
38+
begin species
39+
1 Null() 1
40+
2 gTetR(lac!1,lac!2).pLacI(tet!1).pLacI(tet!2) 1
41+
3 gCI(tet!1,tet!2).pTetR(cI!1).pTetR(cI!2) 1
42+
4 gLacI(cI!1,cI!2).pCI(lac!1).pCI(lac!2) 1
43+
5 mTetR() 3163
44+
6 mCI() 6819
45+
7 mLacI() 129
46+
8 pTetR(cI) 183453
47+
9 pCI(lac) 2006198
48+
10 pLacI(tet) 165670
49+
11 gTetR(lac!1,lac).pLacI(tet!1) 0
50+
12 gCI(tet!1,tet).pTetR(cI!1) 0
51+
13 gLacI(cI!1,cI).pCI(lac!1) 0
52+
14 gTetR(lac,lac) 0
53+
15 gCI(tet,tet) 0
54+
16 gLacI(cI,cI) 0
55+
end species
56+
begin reactions
57+
1 2 10,11 2*_rateLaw4 #_reverse__R2
58+
2 2 2,5 _rateLaw6 #_R4
59+
3 5 5,8 _rateLaw7 #_R5
60+
4 1,5 1 c6 #_R6
61+
5 1,8 1 c7 #_R7
62+
6 3 8,12 2*_rateLaw11 #_reverse__R9
63+
7 3 3,6 _rateLaw13 #_R11
64+
8 6 6,9 _rateLaw14 #_R12
65+
9 1,6 1 c6 #_R13
66+
10 1,9 1 c7 #_R14
67+
11 4 9,13 2*_rateLaw18 #_reverse__R16
68+
12 4 4,7 _rateLaw20 #_R18
69+
13 7 7,10 _rateLaw21 #_R19
70+
14 1,7 1 c6 #_R20
71+
15 1,10 1 c7 #_R21
72+
16 11 10,14 _rateLaw2 #_reverse__R1
73+
17 10,11 2 _rateLaw3 #_R2
74+
18 11 5,11 _rateLaw6 #_R4
75+
19 12 8,15 _rateLaw9 #_reverse__R8
76+
20 8,12 3 _rateLaw10 #_R9
77+
21 12 6,12 _rateLaw13 #_R11
78+
22 13 9,16 _rateLaw16 #_reverse__R15
79+
23 9,13 4 _rateLaw17 #_R16
80+
24 13 7,13 _rateLaw20 #_R18
81+
25 10,14 11 2*_rateLaw1 #_R1
82+
26 14 5,14 _rateLaw5 #_R3
83+
27 8,15 12 2*_rateLaw8 #_R8
84+
28 15 6,15 _rateLaw12 #_R10
85+
29 9,16 13 2*_rateLaw15 #_R15
86+
30 16 7,16 _rateLaw19 #_R17
87+
end reactions
88+
begin groups
89+
1 pTetR 8
90+
2 pCI 9
91+
3 pLacI 10
92+
4 NULL 1
93+
end groups

docs/src/model_creation/model_file_loading_and_export.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Catalyst stores chemical reaction network (CRN) models in `ReactionSystem` structures. This tutorial describes how to load such `ReactionSystem`s from, and save them to, files. This can be used to save models between Julia sessions, or transfer them from one session to another. Furthermore, to facilitate the computation modelling of CRNs, several standardised file formats have been created to represent CRN models (e.g. [SBML](https://sbml.org/)). These enables CRN models to be shared between different softwares and programming languages. While Catalyst itself does not have the functionality for loading such files, we will here (briefly) introduce a few packages that can load files to Catalyst `ReactionSystem`s.
33

44
## Saving Catalyst models to, and loading them from, Julia files
5-
Catalyst provides a `save_reaction_system` function, enabling the user to save a `ReactionSystem` to a file. Here we demonstrate it by first creating a simple catalysis network
5+
Catalyst provides a `save_reactionsystem` function, enabling the user to save a `ReactionSystem` to a file. Here we demonstrate this by first creating a [simple cross-coupling model](@ref basic_CRN_library_cc):
66
```@example file_handling_1
77
using Catalyst
88
rn = @reaction_network begin
@@ -13,21 +13,24 @@ end
1313
```
1414
and next saving it to a file
1515
```@example file_handling_1
16-
save_reaction_system("reaction_network.jl", rn)
16+
save_reactionsystem("cross_coupling.jl", rn)
1717
```
18-
Here, `save_reaction_system`'s first argument is the path to the file where we wish to save it. The second argument is the `ReactionSystem` we wish to save. To load the file, we use Julia's `include` function:
18+
Here, `save_reactionsystem`'s first argument is the path to the file where we wish to save it. The second argument is the `ReactionSystem` we wish to save. To load the file, we use Julia's `include` function:
1919
```@example file_handling_1
20-
loaded_rn = include("reaction_network.jl")
20+
loaded_rn = include("cross_coupling.jl")
2121
```
2222

2323
!!! note
24-
The destination file can be in a folder. E.g. `save_reaction_system("my_folder/reaction_network.jl", rn)` saves the model to the file "reaction_network.jl" in the folder "my_folder".
24+
The destination file can be in a folder. E.g. `save_reactionsystem("my_folder/reaction_network.jl", rn)` saves the model to the file "reaction_network.jl" in the folder "my_folder".
2525

26-
`include` is used to execute the Julia code from any file. This means that `save_reaction_system` actually saves the model as executable code which re-generates the exact model which was saved (this is the reason why we use the ".jl" extension for the saved file). Indeed, if we print the file we can confirm this:
26+
Here, `include` is used to execute the Julia code from any file. This means that `save_reactionsystem` actually saves the model as executable code which re-generates the exact model which was saved (this is the reason why we use the ".jl" extension for the saved file). Indeed, if we print the file we can confirm this:
2727
```@example file_handling_1
28-
println(read("reaction_network.jl", String))
29-
rm("reaction_network.jl") # hide
28+
read("cross_coupling.jl", String)
3029
```
30+
```@example file_handling_1
31+
rm("cross_coupling.jl")
32+
```
33+
This functionality can also be used or print a model to simplify checking its various components.
3134

3235
## Loading and Saving arbitrary Julia variables using Serialization.jl
3336
Julia provide a general and lightweight interface for loading and saving Julia structures to and from files that it can be good to be aware of. It is called [Serialization.jl](https://docs.julialang.org/en/v1/stdlib/Serialization/) and provides two functions, `serialize` and `deserialize`. The first allow us to write a Julia structure to a file. E.g. if we wish to save a parameter set associated with our model, we can use
@@ -42,24 +45,26 @@ loaded_sol = deserialize("saved_parameters.jls")
4245
```
4346

4447
## [Loading .net files usings ReactionNetworkImporters.jl](@id file_loading_rni_net)
45-
A general-purpose format for storing CRN models are so-called .net files. These can be generated by e.g. [BioNetGen](https://bionetgen.org/). The [ReactionNetworkImporters.jl](https://github.com/SciML/ReactionNetworkImporters.jl) package enables the loading of such files to Catalyst `ReactionSystem`. Here we load a [repressilator](https://en.wikipedia.org/wiki/Repressilator) model stored in the "repressilator.net" file:
48+
A general-purpose format for storing CRN models are so-called .net files. These can be generated by e.g. [BioNetGen](https://bionetgen.org/). The [ReactionNetworkImporters.jl](https://github.com/SciML/ReactionNetworkImporters.jl) package enables the loading of such files to Catalyst `ReactionSystem`. Here we load a [Repressilator](@ref basic_CRN_library_repressilator) model stored in the "repressilator.net" file:
4649
```@example file_handling_3
4750
using ReactionNetworkImporters
4851
cp("../assets/model_files/repressilator.net", "repressilator.net") # hide
4952
prn = loadrxnetwork(BNGNetwork(), "repressilator.net")
5053
rm("repressilator.net") # hide
5154
prn # hide
5255
```
53-
Here, .net files not only contain information regarding the reaction network itself, but also the numeric values (initial conditions and parameter values) required for simulating it. Hence, `loadrxnetwork` generates a `ParsedReactionNetwork` structure, containing all this information. You can access the model as `prn.rn`, the initial conditions as `prn.u0`, and the parameter values as `prn.p`. Furthermore, these initial conditions and parameter values are also made [*default* values](@ref ref) of the model.
56+
Here, .net files not only contain information regarding the reaction network itself, but also the numeric values (initial conditions and parameter values) required for simulating it. Hence, `loadrxnetwork` generates a `ParsedReactionNetwork` structure, containing all this information. You can access the model as `prn.rn`, the initial conditions as `prn.u0`, and the parameter values as `prn.p`. Furthermore, these initial conditions and parameter values are also made [*default* values](@ref dsl_advanced_options_default_vals) of the model.
5457

55-
A parsed reaction network can be provided directly to various problem types for simulation. E.g. here we perform an ODE simulation of our repressilator model:
58+
A parsed reaction network's content can then be provided to various problem types for simulation. E.g. here we perform an ODE simulation of our repressilator model:
5659
```@example file_handling_3
5760
using Catalyst, OrdinaryDiffEq, Plots
58-
tspan = (0.0, 1000.0)
59-
oprob = ODEProblem(prn, tspan)
61+
tspan = (0.0, 100.0)
62+
oprob = ODEProblem(prn.rn, Float64[], tspan, Float64[])
6063
sol = solve(oprob)
6164
plot(sol)
6265
```
66+
Note that, as all initial conditions and parameters have default values, we can provide empty vectors for these into our `ODEProblem`.
67+
6368

6469
!!! note
6570
It should be noted that .net files supports a wide range of potential model features, not all of which are currently supported by ReactionNetworkImporters. Hence, there might be some .net files which `loadrxnetwork` will not be able to load.
@@ -69,7 +74,7 @@ A more detailed description of ReactionNetworkImporter's features can be found i
6974
## Loading SBML files using SBMLImporter.jl and SBMLToolkit.jl
7075
The Systems Biology Markup Language (SBML) is the most widespread format for representing CRN models. Currently, there exists two different Julia packages, [SBMLImporter.jl](https://github.com/sebapersson/SBMLImporter.jl) and [SBMLToolkit.jl](https://github.com/SciML/SBMLToolkit.jl), both of which are able to load SBML files to Catalyst `ReactionSystem` structures. SBML is able to represent a *very* wide range of model featuresSome of these are not supported by these packages (or Catalyst). Hence, there exist SBML files (typically containing obscure model features such as events with time delays) that currently cannot be loaded into Catalyst models.
7176

72-
SBMLImporter's `load_SBML` function can be used to load SBML files. Here, we load a [Brusselator](https://en.wikipedia.org/wiki/Brusselator) model stored in the "brusselator.xml" file:
77+
SBMLImporter's `load_SBML` function can be used to load SBML files. Here, we load a [Brusselator](@ref basic_CRN_library_brusselator) model stored in the "brusselator.xml" file:
7378
```@example file_handling_4
7479
using SBMLImporter
7580
cp("../assets/model_files/brusselator.xml", "brusselator.xml") # hide
@@ -81,8 +86,8 @@ Here, while [ReactionNetworkImporters generates a `ParsedReactionSystem` only](@
8186
```@example file_handling_4
8287
using Catalyst, OrdinaryDiffEq, Plots
8388
tspan = (0.0, 1000.0)
84-
oprob = ODEProblem(prn, tspan)
85-
sol = solve(oprob; cb=cbs)
89+
oprob = ODEProblem(prn.rn, Float64[], tspan, Float64[])
90+
sol = solve(oprob; callback = cbs)
8691
plot(sol)
8792
```
8893

0 commit comments

Comments
 (0)