y_petri 2.1.50 → 2.1.51

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07695fc1b0877e3f17285581c526067846e37333
4
- data.tar.gz: 7c7445c48f5803b021e7d1689f51d0eae2adfff2
3
+ metadata.gz: c3896cb4a505575a8a8e087b846183a901be76fc
4
+ data.tar.gz: af87fbeae3c77dced19c699d8295b148452f5743
5
5
  SHA512:
6
- metadata.gz: 81b8ba81ab47a6782efdeef2e1add45ffebaec2112116aa3f85e0c1293b26521005ed3b7f394fb459e7a33c65172419170256da19c469a1693794a780d0e29d0
7
- data.tar.gz: 79a23f7e0c5e6fe82c24b037a3d3f8b44fb26ed03c55fb6d678b0b52c3977c3e65227a3be8679d4556bb5013575886eeaacb9fd08ff56f21863bc8ce07d27c8d
6
+ metadata.gz: 71c519d53c258dd1f1135ce270d31aeb17e1cf5ee416e3b3f6d0db1968bf4c49e519839ab9a576eaf118bc3f3f119ed6776bce130aaf743fa17bafd17cc6c3f1
7
+ data.tar.gz: c81ab243918a093e49f755cc5f4d8ca4ae2d2fdffbc3682562e88000dcafedc93e714eed347c71a6b0f641e186e62436971535711f5b4411cf21196e3b3242c6
@@ -78,21 +78,33 @@ module YPetri::Agent::PetriNetRelated
78
78
  # world. Rate closure has to be supplied as a block.
79
79
  #
80
80
  def TT( *ordered, **named, &block )
81
- fail ArgumentError, "Timed transition constructor requires a block " +
82
- "defining the rate function!" unless block
83
- world.Transition.send( :new, *ordered, **named.update( rate: block ) )
81
+ if named.has? :rate then
82
+ fail ArgumentError, "Block must not be given if :rate named argument " +
83
+ "is given!" if block
84
+ else
85
+ fail ArgumentError, "Timed transition constructor requires either " +
86
+ "a :rate argument, or a block!" unless block
87
+ named.update rate: block
88
+ end
89
+ world.Transition.send( :new, *ordered, **named )
84
90
  end
85
91
 
86
92
  # Timed stoichiometric transition constructor, that expects stoichiometry
87
93
  # given directly as hash-collected arguments. Two special keys allowed are
88
94
  # +:name+ (alias +:ɴ) and +:domain+. (Key +:codomain+ is not allowed.)
89
95
  #
90
- def TS **stoichiometry, &block
91
- args = { s: stoichiometry }
92
- args.update name: stoichiometry.delete( :name ) if
93
- stoichiometry.has? :name, syn!: :ɴn
94
- args.update domain: stoichiometry.delete( :domain ) if
95
- stoichiometry.has? :domain
96
+ def TS *domain, **stoichiometry, &block
97
+ nn = stoichiometry
98
+ args = { s: nn }
99
+ args.update name: nn.delete( :name ) if nn.has? :name, syn!: :ɴ
100
+ if domain.empty? then
101
+ args.update domain: nn.delete( :domain ) if nn.has? :domain
102
+ else
103
+ fail ArgumentError, "There must not be any ordered arguments if " +
104
+ "named argument :domain is given!" unless domain.empty?
105
+ args.update domain: domain
106
+ end
107
+ args.update rate: nn.delete( :rate ) if nn.has? :rate, syn!: :rate_closure
96
108
  TT **args, &block
97
109
  end
98
110
 
@@ -105,8 +117,7 @@ module YPetri::Agent::PetriNetRelated
105
117
  "defining the assignment function!" unless block
106
118
  world.Transition.send( :new,
107
119
  codomain: codomain,
108
- assignment: true,
109
- action: block,
120
+ assignment: block,
110
121
  **nn )
111
122
  end
112
123
 
@@ -277,9 +277,7 @@ class YPetri::Transition
277
277
  #
278
278
  def to_s
279
279
  "#<Transition: %s>" %
280
- "#{name.nil? ? '' : '%s ' % name }(#{type}%s)%s" %
281
- [ "#{assignment_action? ? ' Assign.' : ''}",
282
- "#{name.nil? ? ' id:%s' % object_id : ''}" ]
280
+ "#{'%s ' % name if name}(#{type})#{' id:%s' % object_id unless name}"
283
281
  end
284
282
 
285
283
  def place id
@@ -1,4 +1,4 @@
1
1
  module YPetri
2
- VERSION = "2.1.50"
2
+ VERSION = "2.1.51"
3
3
  DEBUG = false
4
4
  end
@@ -0,0 +1,135 @@
1
+ #encoding: utf-8
2
+
3
+ require 'y_petri' and include YPetri
4
+ # require 'mathn'
5
+
6
+ Pieces_per_microM = 100_000
7
+ set_step 10
8
+ set_sampling 30
9
+ set_target_time 30 * 60
10
+
11
+ # === Places (all in µM)
12
+
13
+ AMP = Place m!: 8695.0
14
+ ADP = Place m!: 6521.0
15
+ ATP = Place m!: 3152.0
16
+ DeoxyCytidine = Place m!: 5.0
17
+ DeoxyCTP = Place m!: 20.0
18
+ DeoxyGMP = Place m!: 20.0
19
+ UMP_UDP_pool = Place m!: 2737.0
20
+ DeoxyUMP_DeoxyUDP_pool = Place m!: 10.0
21
+ DeoxyTMP = Place m!: 50.0
22
+ DeoxyTDP_DeoxyTTP_pool = Place m!: 100.0
23
+ Thymidine = Place m!: 10.0
24
+
25
+ TK1 = Place m!: 100_000 / Pieces_per_microM
26
+ TYMS = Place m!: 100_000 / Pieces_per_microM
27
+ RNR = Place m!: 100_000 / Pieces_per_microM
28
+ TMPK = Place m!: 100_000 / Pieces_per_microM
29
+
30
+ # === Molecular masses
31
+
32
+ TK1_kDa = 24.8
33
+ TYMS_kDa = 66.0
34
+ RNR_kDa = 140.0
35
+ TMPK_kDa = 50.0
36
+
37
+ # === Enzyme specific activities
38
+
39
+ TK1_a = 5.40
40
+ TYMS_a = 3.80
41
+ RNR_a = 1.00
42
+ TMPK_a = 0.83
43
+
44
+ # === Clamps (all in µM)
45
+
46
+ clamp AMP: 8695.0, ADP: 6521.0, ATP: 3152.0
47
+ clamp DeoxyCytidine: 5.0, DeoxyCTP: 20.0, DeoxyGMP: 20.0
48
+ clamp Thymidine: 20
49
+ clamp UMP_UDP_pool: 2737.0
50
+
51
+ # === Function closures
52
+
53
+ Vmax_per_min_per_enz_molecule =
54
+ lambda { |spec_act_microM_per_min_per_mg, kDa|
55
+ spec_act_microM_per_min_per_mg * kDa }
56
+ Vmax_per_min =
57
+ lambda { |spec_act, kDa, enz_molecules_per_cell|
58
+ Vmax_per_min_per_enz_molecule.( spec_act, kDa ) *
59
+ enz_molecules_per_cell }
60
+ Vmax_per_s =
61
+ lambda { |spec_act, kDa, enz_mol_per_cell|
62
+ Vmax_per_min.( spec_act, kDa, enz_mol_per_cell ) / 60 }
63
+ Km_reduced =
64
+ lambda { |km, ki_hash={}|
65
+ ki_hash.map { |c, ki| c / ki }.reduce( 1, :+ ) * km }
66
+ Occupancy =
67
+ lambda { |c, km, compet_inh_w_Ki_hash={}|
68
+ c / ( c + Km_reduced.( km, compet_inh_w_Ki_hash ) ) }
69
+ MM_with_inh_microM_per_second =
70
+ lambda { |c, spec_act, kDa, enz_mol_per_cell, km, ki_hash={}|
71
+ Vmax_per_s.( spec_act, kDa, enz_mol_per_cell ) *
72
+ Occupancy.( c, km, ki_hash ) }
73
+ MMi = MM_with_inh_microM_per_second
74
+
75
+ # === Michaelis constants (all in µM)
76
+
77
+ TK1_Thymidine_Km = 5.0
78
+ TYMS_DeoxyUMP_Km = 2.0
79
+ RNR_UDP_Km = 1.0
80
+ DNA_creation_speed = 3_000_000_000.0 / ( 12 * 3600 ) / 4 / Pieces_per_microM
81
+ TMPK_DeoxyTMP_Km = 12.0
82
+
83
+ # === Transitions
84
+
85
+ Transition name: :TK1_Thymidine_DeoxyTMP,
86
+ domain: [ Thymidine, TK1, DeoxyTDP_DeoxyTTP_pool, DeoxyCTP,
87
+ DeoxyCytidine, AMP, ADP, ATP ],
88
+ stoichiometry: { Thymidine: -1, DeoxyTMP: 1 },
89
+ rate: proc { |c, e, pool1, ci2, ci3, master1, master2, master3|
90
+ ci1 = pool1 * master3 / ( master2 + master3 )
91
+ MMi.( c, TK1_a, TK1_kDa, e, TK1_Thymidine_Km,
92
+ ci1 => 13.5, ci2 => 0.8, ci3 => 40.0 ) }
93
+
94
+ Transition name: :TYMS_DeoxyUMP_DeoxyTMP,
95
+ domain: [ DeoxyUMP_DeoxyUDP_pool, TYMS, AMP, ADP, ATP ],
96
+ stoichiometry: { DeoxyUMP_DeoxyUDP_pool: -1, DeoxyTMP: 1 },
97
+ rate: proc { |pool, e, mono, di, tri|
98
+ c = pool * di / ( mono + di )
99
+ MMi.( c, TYMS_a, TYMS_kDa, e, TYMS_DeoxyUMP_Km ) }
100
+
101
+ Transition name: :RNR_UDP_DeoxyUDP,
102
+ domain: [ UMP_UDP_pool, RNR, DeoxyUMP_DeoxyUDP_pool, AMP, ADP, ATP ],
103
+ stoichiometry: { UMP_UDP_pool: -1, DeoxyUMP_DeoxyUDP_pool: 1 },
104
+ rate: proc { |pool, e, mono, di, tri|
105
+ c = pool * di / ( mono + di )
106
+ MMi.( c, RNR_a, RNR_kDa, e, RNR_UDP_Km ) }
107
+
108
+ Transition name: :DNA_polymerase_consumption_of_DeoxyTTP,
109
+ stoichiometry: { DeoxyTDP_DeoxyTTP_pool: -1 },
110
+ rate: proc { DNA_creation_speed / 4 }
111
+
112
+ Transition name: :TMPK_DeoxyTMP_DeoxyTDP,
113
+ domain: [ DeoxyTMP, TMPK, DeoxyTDP_DeoxyTTP_pool, DeoxyGMP, AMP, ADP, ATP ],
114
+ stoichiometry: { DeoxyTMP: -1, TMPK: 0, DeoxyTDP_DeoxyTTP_pool: 1 },
115
+ rate: proc { |c, e, pool, ci4, mono, di, tri|
116
+ ci1 = di
117
+ ci2 = pool * di / ( di + tri )
118
+ ci3 = pool * tri / ( di + tri )
119
+ MMi.( c, TMPK_a, TMPK_kDa, e, TMPK_DeoxyTMP_Km,
120
+ ci1 => 250.0, ci2 => 30.0, ci3 => 750, ci4 => 117 ) }
121
+
122
+ Transition name: :PhosphataseI,
123
+ stoichiometry: { DeoxyTMP: -1, Thymidine: 1 },
124
+ rate: 0.04
125
+
126
+ Transition name: :PhosphataseII,
127
+ stoichiometry: { DeoxyTDP_DeoxyTTP_pool: -1, DeoxyTMP: 1 },
128
+ rate: 0.01
129
+
130
+ # === Transitions
131
+
132
+ net.visualize
133
+ run!
134
+ recording.plot
135
+ recording.flux.plot
@@ -0,0 +1,21 @@
1
+ #! /usr/bin/ruby
2
+ # encoding: utf-8
3
+
4
+ require 'y_petri' and include YPetri
5
+
6
+ A = Place m!: 10
7
+ B = Place m!: 10
8
+ AB = Place m!: 0
9
+ AB_association = TS A: -1, B: -1, AB: 1, rate: 0.1
10
+ AB_dissociation = TS AB: -1, A: 1, B: 1, rate: 0.1
11
+ A2B = TS A: -1, B: 1, rate: 0.05
12
+ B2A = TS A: 1, B: -1, rate: 0.07
13
+
14
+ set_step 1
15
+ set_target_time 50
16
+ set_sampling 1
17
+ set_simulation_method :gillespie
18
+
19
+ run!
20
+ print_recording
21
+ plot_state
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: y_petri
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.50
4
+ version: 2.1.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-31 00:00:00.000000000 Z
11
+ date: 2013-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: y_support
@@ -175,10 +175,10 @@ files:
175
175
  - test/agent_test.rb
176
176
  - test/examples/demonstrator.rb
177
177
  - test/examples/demonstrator_2.rb
178
- - test/examples/demonstrator_3.rb
179
178
  - test/examples/demonstrator_4.rb
180
179
  - test/examples/example_2.rb
181
- - test/examples/gillespie.rb
180
+ - test/examples/example_IV.rb
181
+ - test/examples/example_VI_gillespie.rb
182
182
  - test/examples/manual_examples.rb
183
183
  - test/net_test.rb
184
184
  - test/place_test.rb
@@ -223,10 +223,10 @@ test_files:
223
223
  - test/agent_test.rb
224
224
  - test/examples/demonstrator.rb
225
225
  - test/examples/demonstrator_2.rb
226
- - test/examples/demonstrator_3.rb
227
226
  - test/examples/demonstrator_4.rb
228
227
  - test/examples/example_2.rb
229
- - test/examples/gillespie.rb
228
+ - test/examples/example_IV.rb
229
+ - test/examples/example_VI_gillespie.rb
230
230
  - test/examples/manual_examples.rb
231
231
  - test/net_test.rb
232
232
  - test/place_test.rb
@@ -1,150 +0,0 @@
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
@@ -1,26 +0,0 @@
1
- #! /usr/bin/ruby
2
- # encoding: utf-8
3
-
4
- require 'y_petri'
5
- require 'sy'
6
- require 'mathn'
7
- include YPetri
8
-
9
- A = Place m!: 10
10
- B = Place m!: 10
11
- AB = Place m!: 0
12
- AB_association = Transition s: { A: -1, B: -1, AB: 1 }, rate: 0.1
13
- AB_dissociation = Transition s: { AB: -1, A: 1, B: 1 }, rate: 0.1
14
- A2B = Transition s: { A: -1, B: 1 }, rate: 0.05
15
- B2A = Transition s: { A: 1, B: -1 }, rate: 0.07
16
-
17
- set_step 1
18
- set_target_time 50
19
- set_sampling 1
20
- set_simulation_method :gillespie
21
-
22
- run!
23
-
24
- print_recording
25
-
26
- plot_state