Skip to content

Commit

Permalink
added format emit data method
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Dec 1, 2023
1 parent 89bbc94 commit d5c8539
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 0 deletions.
15 changes: 15 additions & 0 deletions process_bigraph/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ def __init__(self, config: Dict[str, Any]) -> None:

self.fallback_serializer = make_fallback_serializer_function()

@staticmethod
def format_emit_data(
table_id: str,
times: Union[Tuple, List, Dict, np.ndarray],
values: Union[Tuple, List, Dict, np.ndarray]
) -> Dict[str, Union[Tuple, List, Dict, np.ndarray]]:
"""Format the given data for mongo db emit."""
return {
'table': {
'id': table_id
},
'time': times,
'values': values
}

def emit(self, data: Dict[str, Any]) -> None:
"""Emit data to the Mongo instance.
Expand Down
115 changes: 115 additions & 0 deletions process_bigraph/experiments/model.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# File Min1.txt, by Steve Andrews, 11/2009.
# E. coli Min system, based on Huang, Meir, Wingreen (HMW)
# This file is HMW system exactly, plus surface diffusion
# units are micron, second

define D_D 2.5 # MinD diffusion coefficient (um^2/s)
define D_E 2.5 # MinE diffusion coefficient (um^2/s)
define D_d 0.01 # MinD_ATP(front) diff. coeff. (um^2/s)
define D_de 0.01 # MinDMinE(front) diff. coeff. (um^2/s)
define SIGMA_D_D2T 1 # MinD phosphorylation rate (s^-1)
define SIGMA_D 0.025 # MinD_ATP adsorption coeff. (um/s)
define SIGMA_dD 0.0015 # cooperative adsorption coeff. (um^3/s)
define SIGMA_de 0.7 # desorption rate of MinDMinE (s^-1)
define SIGMA_E 0.093 # MinE binding to surface-bound MinD (um^3/s)

define UNBINDRAD 0.01 # MinD separation on surface (um)

define R 0.5 # cell radius
define L_PARAM 2 # half of cell length
define L_PARAM2 1.5 # half of cell length minus radius

define NUMBER_MIND 4000 # number of MinD in cell
define NUMBER_MINE 1400 # number of MinE in cell

define TIME_STOP 500 # stopping time

#define KICK_START 1 # start with MinD_ATP at an end

random_seed 1

#graphics opengl
#graphic_iter 100

#tiff_name movie/MinMovie
#tiff_iter 200
#tiff_min 1
#tiff_max 200

dim 3
boundaries 0 -L_PARAM L_PARAM
boundaries 1 -R R
boundaries 2 -R R
frame_thickness 0
time_start 0
time_stop TIME_STOP
time_step 0.002 # 2 millisecond time step

accuracy 5
molperbox 4

species MinD_ATP
species MinD_ADP
species MinE
species MinDMinE

molecule_lists list1 list2 list3 list4 list5
mol_list MinD_ATP(soln) list1
mol_list MinD_ATP(front) list2
mol_list MinD_ADP(all) list3
mol_list MinE(all) list4
mol_list MinDMinE(all) list5

difc MinD_ATP(solution) D_D
difc MinD_ATP(front) D_d
difc MinD_ADP(solution) D_D
difc MinE(solution) D_E
difc MinDMinE(front) D_de

color MinD_ATP(soln) 0 0 0.6 # MinD_ATP(solution) is dark blue
color MinD_ATP(front) 0 0.6 0 # MinD_ATP(front) is dark green
color MinD_ADP(soln) 0.4 0.6 1 # MinD_ADP is light blue
color MinE(soln) 1 0 0 # MinE is red
color MinDMinE(front) 0.2 1 0.2 # MinDMinE is bright green
display_size all(solution) 2
display_size all(front) 4

start_surface membrane
action both all reflect
rate MinD_ATP fsoln front SIGMA_D # reaction 1a
polygon both edge
panel cylinder -L_PARAM2 0 0 L_PARAM2 0 0 -R 20 10 cyl0
panel hemi -L_PARAM2 0 0 -R 1 0 0 20 5 hemi0
panel hemi L_PARAM2 0 0 -R -1 0 0 20 5 hemi1
neighbors cyl0 hemi0 hemi1
neighbors hemi0 cyl0
neighbors hemi1 cyl0
end_surface

start_compartment cell
surface membrane
point 0 0 0
end_compartment

reaction rxn1b MinD_ATP(fsoln) + MinD_ATP(front) -> MinD_ATP(front) + MinD_ATP(front) SIGMA_dD
product_placement rxn1b unbindrad UNBINDRAD
reaction rxn1c MinD_ATP(fsoln) + MinDMinE(front) -> MinD_ATP(front) + MinDMinE(front) SIGMA_dD
product_placement rxn1c unbindrad UNBINDRAD
reaction rxn2 MinE(fsoln) + MinD_ATP(front) -> MinDMinE(front) SIGMA_E
reaction rxn3 MinDMinE(front) -> MinD_ADP(fsoln) + MinE(fsoln) SIGMA_de
reaction rxn4 MinD_ADP -> MinD_ATP SIGMA_D_D2T

ifundefine KICK_START
surface_mol NUMBER_MIND MinD_ATP(front) membrane all all
else
surface_mol NUMBER_MIND MinD_ATP(front) membrane hemi hemi1
endif
compartment_mol NUMBER_MINE MinE cell


#output_files FILEROOTout.txt
#cmd i 0 TIME_STOP 1 executiontime FILEROOTout.txt
#cmd i 0 TIME_STOP 1 listmols FILEROOTout.txt

end_file

24 changes: 24 additions & 0 deletions process_bigraph/experiments/smoldyn_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,27 @@
"""


import os
from typing import *
from smoldyn import Simulation
from process_bigraph.emitter import MongoDatabaseEmitter


def run_smoldyn_simulation():
model_fp = 'process_bigraph/experiments/model.txt'
simulation = Simulation.fromFile(model_fp)
simulation.addOutputData('time')
simulation.addOutputData('molecules')
simulation.addCommand(cmd='executiontime time', cmd_type='E')
simulation.addCommand(cmd='listmols molecules', cmd_type='E')

interval = 10
simulation.run(interval, simulation.dt)

time_output = simulation.getOutputData('time')
mol_output = simulation.getOutputData('molecules')





0 comments on commit d5c8539

Please sign in to comment.