Skip to content

Commit 8d6588f

Browse files
authored
Merge pull request #63 from BrainAnnex/dev
Dev Beta32
2 parents f00dd4c + f70733c commit 8d6588f

27 files changed

+200956
-4352
lines changed

VERSION_NUMBER.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version 1.0.0-beta.31
1+
version 1.0.0-beta.32

experiments/reactions_single_compartment/cascade_1.ipynb

Lines changed: 55 additions & 96 deletions
Large diffs are not rendered by default.

experiments/reactions_single_compartment/cascade_1.log.htm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ <h3>List of reactions:</h3><span style='padding-left:4ch'>&nbsp;</span>0: A <->
2020

2121
<div id="vue-root-1"> <!-- DIV container for the VUE COMPONENTS below : Vue ROOT element -->
2222

23-
<vue_cytoscape_2 v-bind:graph_data="graph_data_json">
23+
<vue_cytoscape_2 v-bind:graph_data="graph_data_json"
24+
v-bind:component_id="1">
2425
</vue_cytoscape_2>
2526

2627
</div> <!-- ~~~~~~~~~~~~~~~~~~~~~ END of Vue root element ~~~~~~~~~~~~~~~~~ -->
@@ -37,7 +38,7 @@ <h3>List of reactions:</h3><span style='padding-left:4ch'>&nbsp;</span>0: A <->
3738
el: '#vue-root-1',
3839

3940
data: {
40-
graph_data_json: {"structure": [{"name": "RXN", "kF": "64", "kR": "8", "delta_G": "-5,154.85", "K": "8", "id": "R-0", "labels": ["Reaction"]}, {"name": "B", "diff_rate": null, "id": "C-1", "labels": ["Chemical"]}, {"name": "produces", "source": "R-0", "target": "C-1", "id": "edge-1", "stoich": 1, "rxn_order": 1}, {"name": "A", "diff_rate": null, "id": "C-0", "labels": ["Chemical"]}, {"name": "reacts", "source": "C-0", "target": "R-0", "id": "edge-2", "stoich": 1, "rxn_order": 1}, {"name": "RXN", "kF": "12", "kR": "2", "delta_G": "-4,441.69", "K": "6", "id": "R-1", "labels": ["Reaction"]}, {"name": "C", "diff_rate": null, "id": "C-2", "labels": ["Chemical"]}, {"name": "produces", "source": "R-1", "target": "C-2", "id": "edge-3", "stoich": 1, "rxn_order": 1}, {"name": "reacts", "source": "C-1", "target": "R-1", "id": "edge-4", "stoich": 1, "rxn_order": 1}], "color_mapping": {"Chemical": "#8DCC92", "Reaction": "#D9C8AD"}, "caption_mapping": {"Chemical": "name", "Reaction": "name"}, "component_id": 1}
41+
graph_data_json: {"structure": [{"name": "RXN", "kF": "64", "kR": "8", "delta_G": "-5,154.85", "K": "8", "id": "R-0", "labels": ["Reaction"]}, {"name": "B", "diff_rate": null, "id": "C-1", "labels": ["Chemical"]}, {"name": "produces", "source": "R-0", "target": "C-1", "id": "edge-1", "stoich": 1, "rxn_order": 1}, {"name": "A", "diff_rate": null, "id": "C-0", "labels": ["Chemical"]}, {"name": "reacts", "source": "C-0", "target": "R-0", "id": "edge-2", "stoich": 1, "rxn_order": 1}, {"name": "RXN", "kF": "12", "kR": "2", "delta_G": "-4,441.69", "K": "6", "id": "R-1", "labels": ["Reaction"]}, {"name": "C", "diff_rate": null, "id": "C-2", "labels": ["Chemical"]}, {"name": "produces", "source": "R-1", "target": "C-2", "id": "edge-3", "stoich": 1, "rxn_order": 1}, {"name": "reacts", "source": "C-1", "target": "R-1", "id": "edge-4", "stoich": 1, "rxn_order": 1}], "color_mapping": {"Chemical": "#8DCC92", "Reaction": "#D9C8AD"}, "caption_mapping": {"Chemical": "name", "Reaction": "name"}}
4142
}
4243

4344
});

experiments/reactions_single_compartment/cascade_1.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# In part2, some diagnotic insight is explored.
2525
# In part3, two identical runs ("adaptive variable steps" and "fixed small steps") are compared.
2626
#
27-
# LAST REVISED: May 5, 2024
27+
# LAST REVISED: May 27, 2024 (using v. 1.0beta32)
2828

2929
# %% [markdown]
3030
# ## Bathtub analogy:
@@ -46,6 +46,7 @@
4646
# %% tags=[]
4747
from experiments.get_notebook_info import get_notebook_basename
4848

49+
from src.modules.chemicals.chem_data import ChemData
4950
from src.modules.reactions.reaction_dynamics import ReactionDynamics
5051
from src.modules.visualization.plotly_helper import PlotlyHelper
5152

@@ -66,29 +67,31 @@
6667

6768
# %% tags=[]
6869
# Instantiate the simulator and specify the chemicals
69-
dynamics = ReactionDynamics(names=["A", "B", "C"])
70+
chem = ChemData(names=["A", "B", "C"])
7071

7172
# Reaction A <-> B (fast)
72-
dynamics.add_reaction(reactants=["A"], products=["B"],
73+
chem.add_reaction(reactants=["A"], products=["B"],
7374
forward_rate=64., reverse_rate=8.)
7475

7576
# Reaction B <-> C (slow)
76-
dynamics.add_reaction(reactants=["B"], products=["C"],
77+
chem.add_reaction(reactants=["B"], products=["C"],
7778
forward_rate=12., reverse_rate=2.)
7879

79-
print("Number of reactions: ", dynamics.number_of_reactions())
80+
print("Number of reactions: ", chem.number_of_reactions())
8081

8182
# %%
82-
dynamics.describe_reactions()
83+
chem.describe_reactions()
8384

8485
# %%
8586
# Send a plot of the network of reactions to the HTML log file
86-
dynamics.plot_reaction_network("vue_cytoscape_2")
87+
chem.plot_reaction_network("vue_cytoscape_2")
8788

8889
# %% [markdown]
8990
# ## Run the simulation
9091

9192
# %%
93+
dynamics = ReactionDynamics(chem_data=chem, preset="fast")
94+
9295
dynamics.set_conc([50., 0, 0.], snapshot=True) # Set the initial concentrations of all the chemicals, in their index order
9396
dynamics.describe_state()
9497

@@ -101,10 +104,6 @@
101104
# %%
102105
dynamics.set_diagnostics() # To save diagnostic information about the call to single_compartment_react()
103106

104-
# These settings can be tweaked to make the time resolution finer or coarser.
105-
# Here we use a "fast" heuristic: less conservative about taking larger steps
106-
dynamics.use_adaptive_preset(preset="fast")
107-
108107
dynamics.single_compartment_react(initial_step=0.02, reaction_duration=0.4,
109108
snapshots={"initial_caption": "1st reaction step",
110109
"final_caption": "last reaction step"},
@@ -119,13 +118,13 @@
119118
colors=['blue', 'orange', 'green'], show_intervals=True)
120119

121120
# %%
122-
dynamics.curve_intersection("A", "B", t_start=0, t_end=0.05)
121+
dynamics.curve_intersect("A", "B", t_start=0, t_end=0.05)
123122

124123
# %%
125-
dynamics.curve_intersection("A", "C", t_start=0, t_end=0.05)
124+
dynamics.curve_intersect("A", "C", t_start=0, t_end=0.05)
126125

127126
# %%
128-
dynamics.curve_intersection("B", "C", t_start=0.05, t_end=0.1)
127+
dynamics.curve_intersect("B", "C", t_start=0.05, t_end=0.1)
129128

130129
# %%
131130
dynamics.get_history()
@@ -195,12 +194,13 @@
195194
# We'll use **constant steps of size 0.0005** , which is 1/4 of the smallest steps (the "substep" size) previously used in the variable-step run
196195

197196
# %%
198-
dynamics2 = ReactionDynamics(shared=dynamics) # Re-use the same chemicals and reactions of the previous simulation
197+
dynamics2 = ReactionDynamics(chem_data=chem) # Re-use the same chemicals and reactions of the previous simulation
199198

200199
# %% tags=[]
201200
dynamics2.set_conc([50., 0, 0.], snapshot=True)
202201

203202
# %%
203+
# Notice that we're using FIXED steps this time
204204
dynamics2.single_compartment_react(initial_step=0.0005, reaction_duration=0.4,
205205
variable_steps=False,
206206
snapshots={"initial_caption": "1st reaction step",
@@ -215,13 +215,13 @@
215215
# _(Notice that the vertical steps are now equally spaced - and that there are so many of them that we're only showing some)_
216216

217217
# %%
218-
dynamics2.curve_intersection(t_start=0, t_end=0.05, chem1="A", chem2="B")
218+
dynamics2.curve_intersect(t_start=0, t_end=0.05, chem1="A", chem2="B")
219219

220220
# %%
221-
dynamics2.curve_intersection(t_start=0, t_end=0.05, chem1="A", chem2="C")
221+
dynamics2.curve_intersect(t_start=0, t_end=0.05, chem1="A", chem2="C")
222222

223223
# %%
224-
dynamics2.curve_intersection(t_start=0.05, t_end=0.1, chem1="B", chem2="C")
224+
dynamics2.curve_intersect(t_start=0.05, t_end=0.1, chem1="B", chem2="C")
225225

226226
# %%
227227
df2 = dynamics2.get_history()
@@ -251,6 +251,7 @@
251251
curve_labels=["B (adaptive variable steps)", "B (fixed small steps)"])
252252

253253
# %% [markdown]
254-
# #### They overlap fairly well! The 800 fixed-timestep points vs. the 48 adaptable variable-timestep ones
254+
# #### They overlap fairly well! The 800 fixed-timestep points vs. the 48 adaptable variable-timestep ones.
255+
# The adaptive algorithms avoided 752 extra steps of limited benefit...
255256

256257
# %%

experiments/reactions_single_compartment/cycles_1.ipynb

Lines changed: 3 additions & 1 deletion
Large diffs are not rendered by default.

experiments/reactions_single_compartment/cycles_1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# %% [markdown]
1717
# ## A cycle of reactions `A <-> B <-> C <-> A`
18-
# #### the "closing" of the above cycle (the "return" parth from `C` to `A`) is coupled with an "energy donor" reaction:
18+
# #### the "closing" of the above cycle (the "return" path from `C` to `A`) is coupled with an "energy donor" reaction:
1919
# #### `C + E_High <-> A + E_Low`
2020
# #### where `E_High` and `E_Low` are, respectively, the high- and low- energy molecules that drive the cycle (for example, think of ATP/ADP).
2121
# Comparisons are made between results obtained with 3 different time resolutions.

experiments/reactions_single_compartment/enzyme_3.ipynb

Lines changed: 182 additions & 246 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)