y_petri 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1347ac63d577bc10cd1097a90b6aec47bdfda2a9
4
+ data.tar.gz: 792b0903dae48bd92ccc12058780c6a4c1a33e9e
5
+ SHA512:
6
+ metadata.gz: 32780effaa62b9d5637b21d57246b7d64ce6ec9ba21edfdfd6c40c22e3c343e210e1ed422e0540d6bc7c05d3f2a780a5ca9ef213802697e4af7e54a0041926c2
7
+ data.tar.gz: cc7e2eb8d2de3b44d7cd4a2691d3ec32031f2a1a71125cc22e655a18a55c71d78ce1b6be41820399e625c1ed5c5ed842095ad7e2529def359dad8410704bd543
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *~
2
+ .#*
3
+ \#*#
4
+ *.gem
5
+ *.rbc
6
+ .bundle
7
+ .config
8
+ .yardoc
9
+ Gemfile.lock
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in y_petri.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 boris
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # YPetri
2
+
3
+ y_petri is a Petri net domain model and simulator
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'y_petri'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install y_petri
18
+
19
+ ## Usage
20
+
21
+ y_petri can be used either interactively (in irb with
22
+ 'include YPetri'), or from another program. YPetri::Manipulator
23
+ provides the command interface.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,164 @@
1
+ #encoding: utf-8
2
+
3
+ require 'y_petri'
4
+ include YPetri
5
+
6
+ # general assumptions
7
+ Cytoplasm_volume_in_litres = 5.0e-11
8
+ NA = 6.022e23
9
+ Pieces_per_micromolar = NA / 1_000_000 * Cytoplasm_volume_in_litres
10
+
11
+ # simulation settings
12
+ set_step 60
13
+ set_target_time 60 * 60 * 24
14
+
15
+ # places
16
+ AMP = Place m!: 8695.0
17
+ ADP = Place m!: 6521.0
18
+ ATP = Place m!: 3152.0
19
+ Deoxycytidine = Place( m!: 0.5 )
20
+ DeoxyCTP = Place( m!: 1.0 )
21
+ DeoxyGMP = Place( m!: 1.0 )
22
+ U12P = Place( m!: 2737.0 )
23
+ DeoxyUMP_DeoxyUDP_pool = Place( m!: 0.0 )
24
+ DeoxyTMP = Place( m!: 3.3 )
25
+ DeoxyTDP_DeoxyTTP_pool = Place( m!: 5.0 )
26
+ Thymidine = Place( m!: 0.5 )
27
+ TK1 = Place( m!: 100_000 )
28
+ TYMS = Place( m!: 100_000 )
29
+ RNR = Place( m!: 100_000 )
30
+ TMPK = Place( m!: 100_000 )
31
+
32
+ # molecular masses
33
+ TK1_kDa = 24.8
34
+ TYMS_kDa = 66.0
35
+ RNR_kDa = 140.0
36
+ TMPK_kDa = 50.0
37
+
38
+ # enzyme specific activities
39
+ TK1_a = 5.40
40
+ TYMS_a = 3.80
41
+ RNR_a = 1.00
42
+ TMPK_a = 0.83
43
+
44
+ # clamps
45
+ clamp AMP: 8695.0, ADP: 6521.0, ATP: 3152.0
46
+ clamp Deoxycytidine: 0.5, DeoxyCTP: 1.0, DeoxyGMP: 1.0
47
+ clamp Thymidine: 0.5
48
+ clamp U12P: 2737.0
49
+
50
+ # functions
51
+ Vmax_per_minute_per_enzyme_molecule =
52
+ lambda { |enzyme_specific_activity_in_micromol_per_minute_per_mg,
53
+ enzyme_molecular_mass_in_kDa|
54
+ enzyme_specific_activity_in_micromol_per_minute_per_mg *
55
+ enzyme_molecular_mass_in_kDa }
56
+ Vmax_per_minute =
57
+ lambda { |specific_activity, kDa, enzyme_molecules_per_cell|
58
+ Vmax_per_minute_per_enzyme_molecule.( specific_activity, kDa ) *
59
+ enzyme_molecules_per_cell }
60
+ Vmax_per_second =
61
+ lambda { |specific_activity, kDa, enzyme_molecules_per_cell|
62
+ Vmax_per_minute.( specific_activity,
63
+ kDa,
64
+ enzyme_molecules_per_cell ) / 60 }
65
+ Km_reduced =
66
+ lambda { |km, ki_hash={}|
67
+ ki_hash.map { |concentration, ci_Ki|
68
+ concentration / ci_Ki
69
+ }.reduce( 1, :+ ) * km }
70
+ Occupancy =
71
+ lambda { |concentration, reactant_Km, compet_inh_w_Ki_hash={}|
72
+ concentration / ( concentration +
73
+ Km_reduced.( reactant_Km,
74
+ compet_inh_w_Ki_hash ) ) }
75
+ MM_with_inh_micromolars_per_second =
76
+ lambda { |reactant_concentration,
77
+ enzyme_specific_activity,
78
+ enzyme_mass_in_kDa,
79
+ enzyme_molecules_per_cell,
80
+ reactant_Km,
81
+ competitive_inh_w_Ki_hash={}|
82
+ Vmax_per_second.( enzyme_specific_activity,
83
+ enzyme_mass_in_kDa,
84
+ enzyme_molecules_per_cell ) *
85
+ Occupancy.( reactant_concentration,
86
+ reactant_Km,
87
+ competitive_inh_w_Ki_hash ) }
88
+ MMi = MM_with_inh_micromolars_per_second
89
+
90
+ # michaelis constants
91
+ TK1_Thymidine_Km = 5.0
92
+ TYMS_DeoxyUMP_Km = 2.0
93
+ RNR_UDP_Km = 1.0
94
+ TMPK_DeoxyTMP_Km = 12.0
95
+
96
+ # DNA synthesis speed
97
+ DNA_creation_speed = 3_000_000_000 / ( 12 * 3600 )
98
+
99
+ # transitions
100
+ Transition name: :TK1_Thymidine_DeoxyTMP,
101
+ domain: [ Thymidine,
102
+ TK1,
103
+ DeoxyTDP_DeoxyTTP_pool,
104
+ DeoxyCTP,
105
+ Deoxycytidine,
106
+ AMP,
107
+ ADP,
108
+ ATP ],
109
+ stoichiometry: { Thymidine: -1,
110
+ DeoxyTMP: 1 },
111
+ rate: proc { |rc, e, pool1, ci2, ci3, master1, master2, master3|
112
+ ci1 = pool1 * master3 / ( master2 + master3 )
113
+ MMi.( rc, TK1_a, TK1_kDa, e, TK1_Thymidine_Km,
114
+ ci1 => 13.5, ci2 => 0.8, ci3 => 40.0 )
115
+ }
116
+ Transition name: :TYMS_DeoxyUMP_DeoxyTMP,
117
+ domain: [ DeoxyUMP_DeoxyUDP_pool,
118
+ TYMS,
119
+ AMP,
120
+ ADP,
121
+ ATP ],
122
+ stoichiometry: { DeoxyUMP_DeoxyUDP_pool: -1,
123
+ DeoxyTMP: 1 },
124
+ rate: proc { |pool, e, master1, master2, master3|
125
+ rc = pool * master2 / ( master1 + master2 )
126
+ MMi.( rc, TYMS_a, TYMS_kDa, e, TYMS_DeoxyUMP_Km )
127
+ }
128
+ Transition name: :RNR_UDP_DeoxyUDP,
129
+ domain: [ U12P,
130
+ RNR, DeoxyUMP_DeoxyUDP_pool,
131
+ AMP,
132
+ ADP,
133
+ ATP ],
134
+ stoichiometry: { U12P: -1,
135
+ DeoxyUMP_DeoxyUDP_pool: 1 },
136
+ rate: proc { |pool, e, master1, master2, master3|
137
+ rc = pool * master2 / ( master1 + master2 )
138
+ MMi.( rc, RNR_a, RNR_kDa, e, RNR_UDP_Km )
139
+ }
140
+ Transition name: :DNA_polymerase_consumption_of_DeoxyTTP,
141
+ stoichiometry: { DeoxyTDP_DeoxyTTP_pool: -1 },
142
+ rate: proc { DNA_creation_speed / 4 }
143
+ Transition name: :TMPK_DeoxyTMP_DeoxyTDP,
144
+ domain: [ DeoxyTMP,
145
+ TMPK,
146
+ ADP,
147
+ DeoxyTDP_DeoxyTTP_pool,
148
+ DeoxyGMP,
149
+ AMP,
150
+ ATP ],
151
+ stoichiometry: { DeoxyTMP: -1,
152
+ TMPK: 0,
153
+ DeoxyTDP_DeoxyTTP_pool: 1 },
154
+ rate: proc { |rc, e, ci1, pool, ci4, master1, master3|
155
+ master2 = ci1
156
+ ci2 = pool * master2 / ( master2 + master3 )
157
+ ci3 = pool * master3 / ( master2 + master3 )
158
+ MMi.( rc, TMPK_a, TMPK_kDa, e, TMPK_DeoxyTMP_Km,
159
+ ci1 => 250.0, ci2 => 30.0, ci3 => 750, ci4 => 117 )
160
+ }
161
+
162
+ # execution
163
+ run!
164
+ plot_recording
@@ -0,0 +1,176 @@
1
+ #encoding: utf-8
2
+
3
+ require 'y_petri'
4
+ include YPetri
5
+ require 'sy'
6
+
7
+
8
+ # === General assumptions
9
+
10
+ Cytoplasm_volume = 5.0e-11.l
11
+ Pieces_per_concentration = SY::Nᴀ * Cytoplasm_volume
12
+
13
+
14
+ # === Simulation settings
15
+
16
+ set_step 60.s
17
+ set_target_time 20.min
18
+ set_sampling 120.s
19
+
20
+
21
+ # === Places
22
+
23
+ AMP = Place m!: 8695.0.µM
24
+ ADP = Place m!: 6521.0.µM
25
+ ATP = Place m!: 3152.0.µM
26
+ Deoxycytidine = Place m!: 0.5.µM
27
+ DeoxyCTP = Place m!: 1.0.µM
28
+ DeoxyGMP = Place m!: 1.0.µM
29
+ U12P = Place m!: 2737.0.µM
30
+ DeoxyU12P = Place m!: 0.0.µM
31
+ DeoxyTMP = Place m!: 3.3.µM
32
+ DeoxyT23P = Place m!: 5.0.µM
33
+ Thymidine = Place m!: 0.5.µM
34
+ TK1 = Place m!: 100_000.unit.( SY::MoleAmount ) / Cytoplasm_volume
35
+ TYMS = Place m!: 100_000.unit.( SY::MoleAmount ) / Cytoplasm_volume
36
+ RNR = Place m!: 100_000.unit.( SY::MoleAmount ) / Cytoplasm_volume
37
+ TMPK = Place m!: 100_000.unit.( SY::MoleAmount ) / Cytoplasm_volume
38
+
39
+
40
+ # === Enzyme molecular masses
41
+
42
+ TK1_m = 24.8.kDa
43
+ TYMS_m = 66.0.kDa
44
+ RNR_m = 140.0.kDa
45
+ TMPK_m = 50.0.kDa
46
+
47
+
48
+ # === Specific activities of the enzymes
49
+
50
+ TK1_a = 5.40.µmol.min⁻¹.mg⁻¹
51
+ TYMS_a = 3.80.µmol.min⁻¹.mg⁻¹
52
+ RNR_a = 1.00.µmol.min⁻¹.mg⁻¹
53
+ TMPK_a = 0.83.µmol.min⁻¹.mg⁻¹
54
+
55
+
56
+ # === Clamps
57
+
58
+ clamp AMP: 8695.0.µM, ADP: 6521.0.µM, ATP: 3152.0.µM
59
+ clamp Deoxycytidine: 0.5.µM, DeoxyCTP: 1.0.µM, DeoxyGMP: 1.0.µM
60
+ clamp Thymidine: 0.5.µM
61
+ clamp U12P: 2737.0.µM
62
+
63
+
64
+ # === Function closures
65
+
66
+ # Vmax of an enzyme.
67
+ #
68
+ Vmax_enzyme = lambda { |specific_activity, mass, enz_conc|
69
+ specific_activity * mass * enz_conc.( SY::Molecularity )
70
+ }
71
+
72
+ # Michaelis constant reduced for competitive inhibitors.
73
+ #
74
+ Km_reduced = lambda { |km, ki_hash={}|
75
+ ki_hash.map { |concentration, ci_Ki| concentration / ci_Ki }
76
+ .reduce( 1, :+ ) * km
77
+ }
78
+
79
+ # Occupancy of enzyme active sites at given concentration of reactants
80
+ # and competitive inhibitors.
81
+ #
82
+ Occupancy = lambda { |reactant_conc, reactant_Km, ci_Ki={}|
83
+ reactant_conc / ( reactant_conc + Km_reduced.( reactant_Km, ci_Ki ) )
84
+ }
85
+
86
+ # Michaelis and Menten equation with competitive inhibitors.
87
+ #
88
+ MMi = MM_equation_with_inhibitors = lambda {
89
+ |reactant_conc, enz_spec_act, enz_mass, enz_conc, r_Km, ci_Ki={}|
90
+ Vmax_enzyme.( enz_spec_act, enz_mass, enz_conc ) *
91
+ Occupancy.( reactant_conc, r_Km, ci_Ki )
92
+ }
93
+
94
+
95
+ # === Michaelis constants of the enzymes involved.
96
+
97
+ TK1_Thymidine_Km = 5.0.µM
98
+ TYMS_DeoxyUMP_Km = 2.0.µM
99
+ RNR_UDP_Km = 1.0.µM
100
+ TMPK_DeoxyTMP_Km = 12.0.µM
101
+
102
+
103
+ # === DNA synthesis speed.
104
+
105
+ DNA_creation_speed =
106
+ 3_000_000_000.unit.( SY::MoleAmount ) / 12.h / Cytoplasm_volume
107
+
108
+
109
+ # === Transitions
110
+
111
+ # Synthesis of TMP by TK1.
112
+ #
113
+ TK1_Thymidine_DeoxyTMP = Transition s: { Thymidine: -1, DeoxyTMP: 1 },
114
+ domain: [ Thymidine, TK1, DeoxyT23P, DeoxyCTP, Deoxycytidine, AMP, ADP, ATP ],
115
+ rate: proc { |rc, e, pool1, ci2, ci3, master1, master2, master3|
116
+ ci1 = pool1 * master3 / ( master2 + master3 )
117
+ MMi.( rc, TK1_a, TK1_m, e, TK1_Thymidine_Km,
118
+ ci1 => 13.5.µM, ci2 => 0.8.µM, ci3 => 40.0.µM )
119
+ }
120
+
121
+ # Methylation of DeoxyUMP into TMP by TYMS.
122
+ #
123
+ TYMS_DeoxyUMP_DeoxyTMP = Transition s: { DeoxyU12P: -1, DeoxyTMP: 1 },
124
+ domain: [ DeoxyU12P, TYMS, AMP, ADP, ATP ],
125
+ rate: proc { |pool, e, master1, master2, master3|
126
+ rc = pool * master2 / ( master1 + master2 )
127
+ MMi.( rc, TYMS_a, TYMS_m, e, TYMS_DeoxyUMP_Km )
128
+ }
129
+
130
+ # Reduction of UDP into DeoxyUDP by RNR.
131
+ #
132
+ RNR_UDP_DeoxyUDP = Transition s: { U12P: -1, DeoxyU12P: 1 },
133
+ domain: [ U12P, RNR, DeoxyU12P, AMP, ADP, ATP ],
134
+ rate: proc { |pool, e, master1, master2, master3|
135
+ rc = pool * master2 / ( master1 + master2 )
136
+ MMi.( rc, RNR_a, RNR_m, e, RNR_UDP_Km )
137
+ }
138
+
139
+ # Consumption of TTP by DNA synthesis.
140
+ #
141
+ DeoxyTTP_to_DNA = Transition s: { DeoxyT23P: -1 },
142
+ rate: proc { DNA_creation_speed / 4 }
143
+
144
+ # Phosphorylation of TMP into TDP-TTP pool.
145
+ #
146
+ TMPK_DeoxyTMP_DeoxyTDP = Transition s: { DeoxyTMP: -1, TMPK: 0, DeoxyT23P: 1 },
147
+ domain: [ DeoxyTMP, TMPK, ADP, DeoxyT23P, DeoxyGMP, AMP, ATP ],
148
+ rate: proc { |rc, e, ci1, pool, ci4, master1, master3|
149
+ master2 = ci1
150
+ ci2 = pool * master2 / ( master2 + master3 )
151
+ ci3 = pool * master3 / ( master2 + master3 )
152
+ MMi.( rc, TMPK_a, TMPK_m, e, TMPK_DeoxyTMP_Km,
153
+ ci1 => 250.0.µM, ci2 => 30.0.µM, ci3 => 750.µM, ci4 => 117.µM )
154
+ }
155
+
156
+ # TMPK_DeoxyTMP_DeoxyTDP = SR_transition DeoxyTMP: -1, TMPK: 0, DeoxyT23P: 1 do
157
+ # MMi.( DeoxyTMP, TMPK_a, TMPK_m, TMPK, TMPK_DeoxyTMP_Km,
158
+ # ADP => 250.0.µM,
159
+ # ( DeoxyT23P * ADP / ( ADP + ATP ) ) => 30.0.µM,
160
+ # ( DeoxyT23P * ATP / ( ADP + ATP ) ) => 750.µM,
161
+ # DeoxyGMP => 117.µM )
162
+ # end
163
+
164
+ # RubyVM::InstructionSequence.disassemble( block )
165
+ # # and then process it to reconstruct the domain and construct the real closure
166
+
167
+
168
+ # === Simulation execution
169
+
170
+ # YPetri::DEBUG = true
171
+ run!
172
+
173
+
174
+ # === Plotting of the results
175
+
176
+ plot_recording
@@ -0,0 +1,150 @@
1
+ #encoding: utf-8
2
+
3
+ require 'y_petri'
4
+ include YPetri
5
+ require 'sy'
6
+ require 'mathn'
7
+
8
+ # === General assumptions
9
+
10
+ Cell_diameter = 10.µm
11
+ Cytoplasm_volume = ( 4 / 3 * Math::PI * ( Cell_diameter / 2 ) ** 3 ).( SY::LitreVolume )
12
+ # Cytoplasm_volume = 5.0e-11.l # of an average cell
13
+ # How many molecules are there in the average cell per micromolar.
14
+ Pieces_per_µM = ( 1.µM * Cytoplasm_volume ).in( :unit )
15
+
16
+ # === Simulation settings
17
+
18
+ set_step 60.s.in( :s )
19
+ set_target_time 20.min.in( :s )
20
+ set_sampling 120.s.in( :s )
21
+
22
+ # === Places (all in µM)
23
+
24
+ AMP = Place m!: 8695.0
25
+ ADP = Place m!: 6521.0
26
+ ATP = Place m!: 3152.0
27
+ DeoxyCytidine = Place m!: 0.5
28
+ DeoxyCTP = Place m!: 1.0
29
+ DeoxyGMP = Place m!: 1.0
30
+ U12P = Place m!: 2737.0
31
+ DeoxyU12P = Place m!: 0.0
32
+ DeoxyTMP = Place m!: 3.3
33
+ DeoxyT23P = Place m!: 5.0
34
+ Thymidine = Place m!: 0.5
35
+ TK1 = Place m!: 100_000 / Pieces_per_µM
36
+ TYMS = Place m!: 100_000 / Pieces_per_µM
37
+ RNR = Place m!: 100_000 / Pieces_per_µM
38
+ TMPK = Place m!: 100_000 / Pieces_per_µM
39
+
40
+ # === Molecular masses
41
+
42
+ TK1_m = 24.8.kDa
43
+ TYMS_m = 66.0.kDa
44
+ RNR_m = 140.0.kDa
45
+ TMPK_m = 50.0.kDa
46
+
47
+ # === Enzyme specific activities
48
+
49
+ TK1_a = 5.40.µmol.min⁻¹.mg⁻¹
50
+ TYMS_a = 3.80.µmol.min⁻¹.mg⁻¹
51
+ RNR_a = 1.00.µmol.min⁻¹.mg⁻¹
52
+ TMPK_a = 0.83.µmol.min⁻¹.mg⁻¹
53
+
54
+ # === Enzyme kcat
55
+
56
+ TK1_k_cat = ( TK1_a * TK1_m ).( SY::Amount / SY::Time ).in :s⁻¹
57
+ TYMS_k_cat = ( TYMS_a * TYMS_m ).( SY::Amount / SY::Time ).in :s⁻¹
58
+ RNR_k_cat = ( RNR_a * RNR_m ).( SY::Amount / SY::Time ).in :s⁻¹
59
+ TMPK_k_cat = ( TMPK_a * TMPK_m ).( SY::Amount / SY::Time ).in :s⁻¹
60
+
61
+ # === Clamps (all in µM)
62
+
63
+ clamp AMP: 8695.0, ADP: 6521.0, ATP: 3152.0
64
+ clamp DeoxyCytidine: 0.5, DeoxyCTP: 1.0, DeoxyGMP: 1.0
65
+ clamp Thymidine: 0.5
66
+ clamp U12P: 2737.0
67
+
68
+ # === Function closures
69
+
70
+ # Vmax of an enzyme.
71
+ #
72
+ Vmax = -> enzyme_µM, k_cat do enzyme_µM * k_cat end
73
+
74
+ # Michaelis constant reduced for competitive inhibitors.
75
+ #
76
+ Km_reduced = -> reactant_Km, hash_Ki=Hash.new do
77
+ hash_Ki.map { |compet_inhibitor_concentration, compet_inhibitor_Ki|
78
+ compet_inhibitor_concentration / compet_inhibitor_Ki
79
+ }.reduce( 1, :+ ) * reactant_Km
80
+ end
81
+
82
+ # Occupancy fraction of the Michaelis-Menten equation.
83
+ #
84
+ Occupancy = -> reactant_µM, reactant_Km, hash_Ki=Hash.new do
85
+ reactant_µM / ( reactant_µM + Km_reduced.( reactant_Km, hash_Ki ) )
86
+ end
87
+
88
+ # Michaelis-Menten equation with competitive inhibitors.
89
+ #
90
+ MMi = -> reactant_µM, reactant_Km, enzyme_µM, k_cat, hash_Ki=Hash.new do
91
+ Vmax.( enzyme_µM, k_cat ) * Occupancy.( reactant_µM, reactant_Km, hash_Ki )
92
+ end
93
+
94
+ # === Michaelis constants (all in µM)
95
+
96
+ TK1_Thymidine_Km = 5.0
97
+ TYMS_DeoxyUMP_Km = 2.0
98
+ RNR_UDP_Km = 1.0
99
+ TMPK_DeoxyTMP_Km = 12.0
100
+
101
+ # === DNA synthesis speed
102
+
103
+ S_phase_duration = 12.h
104
+ Genome_size = 3_000_000_000 # of bases
105
+ DNA_creation_speed = Genome_size / S_phase_duration.in( :s ) # in base.s⁻¹
106
+
107
+ # === Transitions
108
+
109
+ Transition name: :TK1_Thymidine_DeoxyTMP,
110
+ domain: [ Thymidine, TK1, DeoxyT23P, DeoxyCTP, DeoxyCytidine, AMP, ADP, ATP ],
111
+ stoichiometry: { Thymidine: -1, DeoxyTMP: 1 },
112
+ rate: proc { |reactant, enzyme, pool, inhibitor_2, inhibitor_3, mono, di, tri|
113
+ inhibitor_1 = pool * tri / ( di + tri ) # conc. of DeoxyTTP
114
+ MMi.( reactant, TK1_Thymidine_Km, enzyme, TK1_k_cat,
115
+ inhibitor_1 => 13.5, inhibitor_2 => 0.8, inhibitor_3 => 40.0 )
116
+ }
117
+
118
+ Transition name: :TYMS_DeoxyUMP_DeoxyTMP,
119
+ domain: [ DeoxyU12P, TYMS, AMP, ADP, ATP ],
120
+ stoichiometry: { DeoxyU12P: -1, DeoxyTMP: 1 },
121
+ rate: proc { |pool, enzyme, mono, di, tri|
122
+ reactant = pool * di / ( mono + di ) # conc. of DeoxyUMP
123
+ MMi.( reactant, TYMS_DeoxyUMP_Km, enzyme, TYMS_k_cat )
124
+ }
125
+
126
+ Transition name: :RNR_UDP_DeoxyUDP,
127
+ domain: [ U12P, RNR, DeoxyU12P, AMP, ADP, ATP ],
128
+ stoichiometry: { U12P: -1, DeoxyU12P: 1 },
129
+ rate: proc { |pool, enzyme, mono, di, tri|
130
+ reactant = pool * di / ( mono + di )
131
+ MMi.( reactant, RNR_UDP_Km, enzyme, RNR_k_cat )
132
+ }
133
+
134
+ Transition name: :DNA_polymerase_consumption_of_DeoxyTTP,
135
+ stoichiometry: { DeoxyT23P: -1 },
136
+ rate: proc { DNA_creation_speed / 4 }
137
+
138
+ Transition name: :TMPK_DeoxyTMP_DeoxyTDP,
139
+ domain: [ DeoxyTMP, TMPK, DeoxyT23P, DeoxyGMP, AMP, ADP, ATP ],
140
+ stoichiometry: { DeoxyTMP: -1, DeoxyT23P: 1 },
141
+ rate: proc { |reactant, enzyme, pool, inhibitor_4, mono, di, tri|
142
+ inhibitor_1 = di
143
+ inhibitor_2 = pool * di / ( di + tri ) # conc. of DeoxyTDP
144
+ inhibitor_3 = pool * tri / ( di + tri ) # conc. of DeoxyTTP
145
+ MMi.( reactant, TMPK_DeoxyTMP_Km, enzyme, TMPK_k_cat )
146
+ }
147
+
148
+ # execution
149
+ run!
150
+ plot_recording