import set_path # Importing this module will add the project's home directory to sys.path
Added 'D:\Docs\- MY CODE\BioSimulations\life123-Win7' to sys.path
from life123 import ChemData
from life123 import UniformCompartment
# Initialize the system
chem_data = ChemData(names=["A", "B", "E"])
# Reaction A <-> B , with 1st-order kinetics, favorable thermodynamics in the forward direction,
# and a forward rate that is much slower than it would be with the enzyme - as seen in the next reaction, below
chem_data.add_reaction(reactants="A", products="B",
forward_rate=1., delta_G=-3989.73)
# Reaction A + E <-> B + E , with 1st-order kinetics, and a forward rate that is faster than it was without the enzyme
# Thermodynamically, there's no change from the reaction without the enzyme
chem_data.add_reaction(reactants=["A", "E"], products=["B", "E"],
forward_rate=10., delta_G=-3989.73)
chem_data.describe_reactions() # Notice how the enzyme `E` is noted in the printout below
Number of reactions: 2 (at temp. 25 C) 0: A <-> B (kF = 1 / kR = 0.2 / delta_G = -3,989.7 / K = 5) | 1st order in all reactants & products 1: A + E <-> B + E (kF = 10 / kR = 2 / delta_G = -3,989.7 / K = 5) | Enzyme: E | 1st order in all reactants & products Set of chemicals involved in the above reactions (not counting enzymes): {'A', 'B'} Set of enzymes involved in the above reactions: {'E'}
dynamics = UniformCompartment(chem_data=chem_data, preset="mid")
dynamics.set_conc(conc={"A": 20.},
snapshot=True) # Initially, no enzyme `E`
dynamics.describe_state()
SYSTEM STATE at Time t = 0: 3 species: Species 0 (A). Conc: 20.0 Species 1 (B). Conc: 0.0 Species 2 (E). Conc: 0.0 Set of chemicals involved in reactions (not counting enzymes): {'A', 'B'} Set of enzymes involved in reactions: {'E'}
dynamics.set_diagnostics() # To save diagnostic information about the call to single_compartment_react()
# Perform the reactions
dynamics.single_compartment_react(duration=0.25,
initial_step=0.05, variable_steps=True)
Some steps were backtracked and re-done, to prevent negative concentrations or excessively large concentration changes 7 total step(s) taken Number of step re-do's because of negative concentrations: 0 Number of step re-do's because of elective soft aborts: 0 Norm usage: {'norm_A': 1, 'norm_B': 2, 'norm_C': 1, 'norm_D': 1}
#dynamics.explain_time_advance()
dynamics.plot_history(colors=['darkorange', 'green', 'violet'], show_intervals=True, title_prefix="WITH zero enzyme")
dynamics.set_single_conc(30., species_name="E", snapshot=True) # Plenty of enzyme `E`
dynamics.describe_state()
SYSTEM STATE at Time t = 0.26: 3 species: Species 0 (A). Conc: 15.43679907511829 Species 1 (B). Conc: 4.56320092488171 Species 2 (E). Conc: 30.0 Set of chemicals involved in reactions (not counting enzymes): {'A', 'B'} Set of enzymes involved in reactions: {'E'}
dynamics.single_compartment_react(duration=0.04,
initial_step=0.005, variable_steps=True)
Some steps were backtracked and re-done, to prevent negative concentrations or excessively large concentration changes 30 total step(s) taken Number of step re-do's because of negative concentrations: 1 Number of step re-do's because of elective soft aborts: 2 Norm usage: {'norm_A': 22, 'norm_B': 20, 'norm_C': 20, 'norm_D': 20}
#dynamics.explain_time_advance()
dynamics.plot_history(colors=['darkorange', 'green', 'violet'], show_intervals=True, title_prefix="WITH enzyme added mid-reaction")
E
is added at t = 0.275!¶The reactions simulator automatically switches to small time steps is in order to handle the rapid amount of change
# Verify that the reaction has reached equilibrium
dynamics.is_in_equilibrium()
0: A <-> B Final concentrations: [A] = 3.333 ; [B] = 16.67 1. Ratio of reactant/product concentrations, adjusted for reaction orders: 5.00003 Formula used: [B] / [A] 2. Ratio of forward/reverse reaction rates: 5.00001 Discrepancy between the two values: 0.0005878 % Reaction IS in equilibrium (within 1% tolerance) 1: A + E <-> B + E Final concentrations: [A] = 3.333 ; [E] = 30 ; [B] = 16.67 1. Ratio of reactant/product concentrations, adjusted for reaction orders: 5.00003 Formula used: ([B][E]) / ([A][E]) 2. Ratio of forward/reverse reaction rates: 5.00001 Discrepancy between the two values: 0.0005878 % Reaction IS in equilibrium (within 1% tolerance)
True
dynamics.get_history()
SYSTEM TIME | A | B | E | caption | |
---|---|---|---|---|---|
0 | 0.000000 | 20.000000 | 0.000000 | 0.0 | Initialized state |
1 | 0.050000 | 19.000000 | 1.000000 | 0.0 | |
2 | 0.110000 | 17.872000 | 2.128000 | 0.0 | |
3 | 0.140000 | 17.348608 | 2.651392 | 0.0 | |
4 | 0.170000 | 16.844058 | 3.155942 | 0.0 | |
5 | 0.200000 | 16.357672 | 3.642328 | 0.0 | |
6 | 0.230000 | 15.888796 | 4.111204 | 0.0 | |
7 | 0.260000 | 15.436799 | 4.563201 | 0.0 | |
8 | 0.260000 | 15.436799 | 4.563201 | 30.0 | Set concentration of `E` |
9 | 0.260200 | 14.562445 | 5.437555 | 30.0 | |
10 | 0.260400 | 13.751254 | 6.248746 | 30.0 | |
11 | 0.260600 | 12.998663 | 7.001337 | 30.0 | |
12 | 0.260800 | 12.300439 | 7.699561 | 30.0 | |
13 | 0.261000 | 11.652656 | 8.347344 | 30.0 | |
14 | 0.261200 | 11.051668 | 8.948332 | 30.0 | |
15 | 0.261440 | 10.382581 | 9.617419 | 30.0 | |
16 | 0.261728 | 9.649278 | 10.350722 | 30.0 | |
17 | 0.262074 | 8.860854 | 11.139146 | 30.0 | |
18 | 0.262419 | 8.170849 | 11.829151 | 30.0 | |
19 | 0.262834 | 7.446204 | 12.553796 | 30.0 | |
20 | 0.263249 | 6.830109 | 13.169891 | 30.0 | |
21 | 0.263663 | 6.306303 | 13.693697 | 30.0 | |
22 | 0.264161 | 5.771892 | 14.228108 | 30.0 | |
23 | 0.264659 | 5.333546 | 14.666454 | 30.0 | |
24 | 0.265256 | 4.902084 | 15.097916 | 30.0 | |
25 | 0.265853 | 4.563692 | 15.436308 | 30.0 | |
26 | 0.266570 | 4.245215 | 15.754785 | 30.0 | |
27 | 0.267430 | 3.961966 | 16.038034 | 30.0 | |
28 | 0.268462 | 3.727647 | 16.272353 | 30.0 | |
29 | 0.269700 | 3.551273 | 16.448727 | 30.0 | |
30 | 0.271186 | 3.434292 | 16.565708 | 30.0 | |
31 | 0.272969 | 3.369263 | 16.630737 | 30.0 | |
32 | 0.275109 | 3.341490 | 16.658510 | 30.0 | |
33 | 0.277677 | 3.333922 | 16.666078 | 30.0 | |
34 | 0.280758 | 3.333264 | 16.666736 | 30.0 | |
35 | 0.284456 | 3.333353 | 16.666647 | 30.0 | |
36 | 0.288893 | 3.333317 | 16.666683 | 30.0 | |
37 | 0.294218 | 3.333343 | 16.666657 | 30.0 | |
38 | 0.300608 | 3.333314 | 16.666686 | 30.0 |