def setUp(self): self.vm1 = m.Species("vm1", 1e-6) self.vm1_down = m.OrientedSpecies(self.vm1, m.Orient.down) self.sm1 = m.Species("sm1", 1e-6, surface=True) self.sm1_up = m.OrientedSpecies(self.sm1, m.Orient.up) self.vm2 = m.Species("vm2", 1e-6) self.vm2_down = m.OrientedSpecies(self.vm2, m.Orient.down)
def main(): a = m.Species("a", dc=1e-6) b = m.Species("b", volume=False, dc=1e-6) c = m.Species("c", volume=False, dc=1e-6) a_mix = (a, m.Orient.mix) b_up = (b, m.Orient.up) c_up = (c, m.Orient.up) bimol_irrev = m.Reaction([a_mix, b_up], [c_up], rate=1e4) box = m.import_obj(Path("./box.obj")) sim = m.Simulation(dt=1e-6, meshes=[box], reactions=[bimol_irrev]) sim.create_molecules_obj(a, box, 100) sim.create_molecules_obj(b, box, 100) sim.run_iterations(100)
def main(): a = m.Species("a", dc=1e-6) b = m.Species("b", dc=1e-6) c = m.Species("c", dc=1e-6) a_mix = (a, m.Orient.mix) b_mix = (b, m.Orient.mix) c_mix = (c, m.Orient.mix) bimol_irrev = m.Reaction([a_mix, b_mix], [c_mix], rate=0) box = m.create_box("box", 1.0, (0, 0, 0)) sim = m.Simulation(dt=1e-6, meshes=[box], reactions=[bimol_irrev]) sim.create_molecules_obj(a, box, 100) sim.create_molecules_obj(b, box, 100) for i in range(100): offs = 1e6 bimol_irrev.rate = math.sin(i * 0.1) * offs + offs sim.run_iteration()
def main(): a = m.Species("a", dc=1e-6) reg = m.Region("tube_reg", tube.reg_indices) tube_obj = m.MeshObject("tube", tube.verts, tube.faces, [reg]) mesh_objs = [tube_obj] sim = m.Simulation(dt=1e-6, meshes=mesh_objs) sim.create_molecules_reg(a, reg, 100) sim.run_iterations(100)
def main(): a = m.Species("a", dc=1e-6) b = m.Species("b", dc=1e-6) c = m.Species("c", dc=1e-6) a_mix = (a, m.Orient.mix) b_mix = (b, m.Orient.mix) c_mix = (c, m.Orient.mix) unimol1 = m.Reaction([a_mix], [b_mix], rate=1e4) unimol2 = m.Reaction([a_mix], rate=1e4) bimol_irrev = m.Reaction([a_mix, b_mix], [c_mix], rate=1e4) bimol_rev = m.Reaction([a_mix, b_mix], [c_mix], reversible=True, rate=1e4) rxns = [unimol1, unimol2, bimol_irrev, bimol_rev] box = m.import_obj(Path("./box.obj")) sim = m.Simulation(dt=1e-6, meshes=[box], reactions=rxns) sim.create_molecules_obj(a, box, 100) sim.create_molecules_obj(b, box, 100) sim.run_iterations(100)
def main(): a = m.Species("a", dc=1e-6) plane_top = m.create_plane("top", 1.0, (0, 0, 0.1)) plane_bottom = m.create_plane("bottom", 1.0, (0, 0, -0.1)) mesh_objs = [plane_top, plane_bottom] sim = m.Simulation(dt=1e-6, meshes=mesh_objs) for i in range(-10, 11): sim.create_molecule(a, (i*0.1, 0, 0)) sim.run_iterations(100)
def main(): a = m.Species("a", dc=1e-6) b = m.Species("b", dc=1e-6) c = m.Species("c", dc=1e-6) a_mix = (a, m.Orient.mix) b_mix = (b, m.Orient.mix) c_mix = (c, m.Orient.mix) bimol_irrev = m.Reaction([a_mix, b_mix], [c_mix], rate=1e4, name="rxn") box = m.create_box("box", 1.0, (0, 0, 0)) count_a_box = m.CountMolecules(a, box) count_a_rxn = m.CountReaction(bimol_irrev, box) sim_counts = [count_a_box, count_a_rxn] sim = m.Simulation(dt=1e-6, meshes=[box], reactions=[bimol_irrev], counts=sim_counts) sim.create_molecules_obj(a, box, 100) sim.create_molecules_obj(b, box, 100) sim.run_iterations(100)
def main(): a = m.Species("a", volume=False, dc=1e-6) box = m.create_box("box", 1.0, (0, 0, 0)) sim = m.Simulation(dt=1e-6, meshes=[box]) sim.create_molecules_reg(a, box.regions["top"], 100, conc_dens=True, orient=m.Orient.up) sim.run_iterations(100)
def create_species_from_dm(data_model: Dict[str, Any]) -> Dict[str, m.Species]: """ Create a dictionary of Species from a CB data model """ logging.info("Creating species from data model") species_dm_list = data_model['mcell']['define_molecules']['molecule_list'] species_dict = {} for species_dm in species_dm_list: species_name = species_dm['mol_name'] dc = float(species_dm['diffusion_constant']) species_type = species_dm['mol_type'] surface = False if species_type == '2D': surface = True species_dm = m.Species(species_name, dc, surface) species_dict[species_name] = species_dm return species_dict
def main(): a = m.Species("a", dc=1e-6) a_up = (a, m.Orient.up) a_down = (a, m.Orient.down) transp_a = m.SurfaceProperty("transp_a", m.SP.transp, a_down) absorb_a = m.SurfaceProperty("absorb_a", m.SP.absorb, a_down) clamp_a = m.SurfaceProperty("clamp_a", m.SP.clamp, a_up, clamp_val=1e-8) box = m.create_box("box", 1.0, (0, 0, 0)) box.add_surface_property(transp_a, box.regions["left"]) box.add_surface_property(absorb_a, box.regions["right"]) box.add_surface_property(clamp_a, box.regions["top"]) box.add_surface_property(absorb_a, box.regions["top"]) sim = m.Simulation(dt=1e-6, meshes=[box]) sim.create_molecules_obj(a, box, 100) sim.run_iterations(100)
def create_my_model(): #Some parameters: V = 0.125*1e-15 # um^3 -> liters NA = 6.022e23/1e6 #Rate Constants (The numbers used here are taken from the SBML file available online) k_on1C = 4/(NA*V) #1/uM 1/s k_off1C = 40 #1/s (10-70) k_on2C = 10/(NA*V) #1/uM 1/s k_off2C = 9.25 #1/s (8.5-10) k_on1N = 100/(NA*V) #1/uM 1/s k_off1N = 2500 #1/s k_on2N = 150/(NA*V) #1/uM 1/s k_off2N = 750 #1/s k_onCaM1C1N = 3.3/(NA*V) #1/uM 1/s k_offCaM1C1N = 3.4 #1/s k_onCaMKII = 50/(NA*V) #1/uM 1/s k_offCaMKII = 60 #1/s k_pCaM1C1N = 0.094 #1/s # Add some geometries a001 = pymcell.Geometry.fromFile("a001.ply") print(a001) C = pymcell.Sites( states = [0,1,2] ) N = pymcell.Sites( states = [0,1,2] ) Y286 = pymcell.Sites( states = ['0','P'] ) b_site = pymcell.Sites( states = [0,1] int bond_N = 0 ) # the way I envision this whenver bond_N > 1 (optional feature, present only for binding sutes) states becomes 1 ca = pymcell.Species( name="ca", diff_const=10.0 ) CaM = pymcell.Species( name = "CaM", diff_const =10.0, sites = [C,N,b_site] ) CaMKII = pymcell.Species( name = "CaM", diff_const =10.0, sites = [b_site,Y286,rb_site,lb_site] ) Complex = pymcell.Complex( name = "Complex", components = [], diff_const =10.0, # calculated from components? ) bng_rxn = BNGRxn(...) rxn_volume = pymcell.Rxn( name="first rxn", fwd_rate=k_on1C, bkwd_rate=k_off1C, reactants=[ CaM(sites(C[0],b_stie.state[0])), ca ], products=[ CaM(sites(C[1],b_stie.state[0])) ] ) rxn_volume = pymcell.Rxn( name="second rxn", fwd_rate=k_on2C, bkwd_rate=k_off2C, reactants=[ CaM(sites(C[1],b_stie.state[0])), ca ], products=[ CaM(sites(C[2],b_stie.state[0])) ] ) rxn_volume = pymcell.Rxn( name="third rxn", fwd_rate=k_on1N, bkwd_rate=k_off1N, reactants=[ CaM(sites(N[0],b_stie.state[0])), ca ], products=[ CaM(sites(N[1],b_stie.state[0])) ] ) rxn_volume = pymcell.Rxn( name="fourth rxn", fwd_rate=k_on2N, bkwd_rate=k_off2N, reactants=[ CaM(sites(N[1],b_stie.state[0])), ca ], products=[ CaM(sites(N[2],b_stie.state[0])) ] ) rxn_volume = pymcell.Rxn( name="fifth rxn", fwd_rate=k_onCaM1C1N, bkwd_rate=k_offCaM1C1N, reactants=[ CaM(sites(C[1],N[1],b_stie.state[0])), CaMKII(sites(b_stie.state[0],Y286['0'])) ], products=[ Complex(components = [CaM(sites(C[1],N[1],b_site.N_bond=1)),CaMKII(sites(b_site.N_bond=1,Y286['0']))]) ] ) rxn_volume = pymcell.Rxn( name="sixth rxn", fwd_rate=k_onCaMKII, bkwd_rate=k_offCaMKII reactants=[ Complex(components = [ CaMKII(sites(b_site.state[1],Y286['0'],rb_stie.state[0],lb_stie.state[0])), ]) Complex(components =[ CaMKII(sites(b_site.state[1],rb_stie.state[0],lb_stie.state[0])) ]) ] products=[ Complex(components = [ CaMKII(sites(b_site.state[1],Y286['0'],lb_site.bond_N=1,rb_stie.state[0])), CaMKII(sites(b_site.state[1],lb_stie.state[0],rb_site.bond_N=1)) ]) ] ) rxn_volume = pymcell.Rxn( name="seventh rxn", fwd_rate=k_pCaM1C1N, reactants=[ Complex(components = [ CaMKII(sites(b_site.state[1],Y286['0'],lb_site.bond_N=1)), CaM(sites(C[1],N[1],b_site.bond_N=2)), CaMKII(sites(b_site.bond_N=2,Y286['0'],rb_site.bond_N=1)) ]) ] products=[ Complex(components = [ CaM, CaMKII(sites(b_site.state[1],Y286['0'],lb_site.bond_N=1)), CaM(sites(C[1],N[1],b_site.bond_N=2)), CaMKII(sites(b_site.bond_N=2,Y286['P'],rb_site.bond_N=1)) ]) ] ) # Create releases release_1 = pymcell.ReleaseSite( name="Ca", type=pymcell.RELEASE_TYPE.OBJECT, species=ca, quantity=10*(NA*V), release_probability=1, object=a001.get_volume_region("dendritic_spine") ) release_2 = pymcell.ReleaseSite( name="CaM", type=pymcell.RELEASE_TYPE.OBJECT, species=CaM(sites(C[0],N[0],b_stie.state[0])), quantity=30*(NA*V), release_probability=1, object=a001.get_volume_region("dendritic_spine") ) release_3 = pymcell.ReleaseSite( name="CaMKII", type=pymcell.RELEASE_TYPE.OBJECT, species=CaMKII(sites(b_stie.state[0],Y286['0'],rb_stie.state[0],lb_stie.state[0])), quantity=80*(NA*V), release_probability=1, object=a001.get_volume_region("dendritic_spine") ) # Finally: add all that to a model m = pymcell.Model() m.add_geometry(a001) m.add_species(ca) m.add_species(CaM) m.add_species(CaMKII) m.add_rxn(rxn_volume) m.add_release_site(release_1,release_2,release_3) m.add_rxn(bng_rxn) return m
def create_my_model(): # Add some geometries a001 = pymcell.Geometry.fromFile("a001.ply") print(a001) # Make a species pmca_p0 = pymcell.Species( name="pmca_p0", diff_const=10.0 ) pmca_po.set_diff_const(5) ca = pymcell.Species( name="ca", diff_const=10.0 ) pmca_p1 = pymcell.Species( name="pmca_p1", diff_const=10.0 ) bng_rxn = BNGRxn(...) # Make a surface reaction # pmca_p0' + ca, <-> pmca_p1' rxn_surface = pymcell.Rxn( name="first rxn", fwd_rate=1.0, bkwd_rate=2.0, reactants=[ pymcell.oriented_species(pmca_p0, pymcell.ORIENT.UP), pymcell.oriented_species(ca, pymcell.ORIENT.DOWN) ], products=[ pymcell.oriented_species(pmca_p1, pymcell.ORIENT.UP) ] ) # Make a volume reaction # calbindin_h0m0 + ca <-> calbindin_h1m0 rxn_volume = pymcell.Rxn( name="second rxn", fwd_rate=1.0, bkwd_rate=2.0, reactants=[ calbindin_h0m0, ca ], products=[ calbindin_h1m0 ] ) # Create releases release_1 = pymcell.ReleaseSite( name="pmca_p0_pre_rel", type=pymcell.RELEASE_TYPE.OBJECT, species=pmca_p0, quantity=100, release_probability=1, object=a001.get_surface_region("axon_membrane") ) # Finally: add all that to a model m = pymcell.Model() m.add_geometry(a001) m.add_species(pmca_p0) m.add_species(ca) m.add_species(pmca_p1) m.add_rxn(rxn_volume) m.add_rxn(rxn_surface) m.add_release_site(release_1) m2 = pymcell.Model() m2.add_geometry(a001) m2.add_species(pmca_p0) m2.add_species(ca) m2.add_species(pmca_p1) m2.add_rxn(rxn_volume) m2.add_rxn(rxn_surface) m2.add_release_site(release_1) m.add_rxn(bng_rxn) return m
def main(): world = m.MCellSim(seed=1) world.set_time_step(time_step=1e-5) world.set_iterations(iterations=1000) world.enable_logging() world.silence_notifications() world.set_output_freq(1) slow_dc = 1e-9 fast_dc = 1e-5 # define species vm1 = m.Species("vm1", fast_dc) vm2 = m.Species("vm2", fast_dc) vm3 = m.Species("vm3", slow_dc) sm_list = [] for i in range(1, 11): sm_list.append(m.Species("sm{}".format(i), fast_dc, surface=True)) sm1 = sm_list[0] sm2 = sm_list[1] spec_orient_list = [sm.up() for sm in sm_list] all_mols = sm_list + [vm1, vm2, vm3] world.add_species(all_mols) # define reaction rxn = m.Reaction(sm1.up(), sm2.down(), 1e3, name="create_sm2") world.add_reaction(rxn) # create torus object torus_obj = m.MeshObj( "Torus", t.vert_list, t.face_list, translation=(0, 0, 0)) torus_reg = m.SurfaceRegion(torus_obj, 'half', t.surf_reg_face_list) world.add_geometry(torus_obj) # create box object box_obj = m.MeshObj( "Box", b.vert_list, b.face_list, translation=(0, 0, 0)) box_reg = m.SurfaceRegion(box_obj, 'top', b.surf_reg_face_list) world.add_geometry(box_obj) # create surface class to absorb vm1 # sc = m.SurfaceClass(SC.absorb, sm1.mix()) # world.assign_surf_class(sc, torus_reg) # world.assign_surf_class_to_all_surface_mols("abs_all_surfs", SC.absorb, torus_reg) world.assign_surface_property_to_all_mols( "abs_all_vols", SC.absorb, torus_reg, moltype=MolType.surface_mols) # release vm1, vm2, and sm1 molecules into/onto torus vm1_torus_rel = m.ObjectRelease(vm1, number=1000, mesh_obj=torus_obj) world.release(vm1_torus_rel) vm2_torus_rel = m.ObjectRelease(vm2, number=1000, mesh_obj=torus_obj) world.release(vm2_torus_rel) sm1_torus_rel = m.ObjectRelease(sm1.up(), number=1000, region=torus_reg) world.release(sm1_torus_rel) # release vm3 molecules in a line (list based release) vm3_pos = [(x*0.01, 0, 0) for x in range(-5, 5)] vm3_list_release = m.ListRelease(vm3, vm3_pos) world.release(vm3_list_release) # release sm molecules in a line on top of box (list based release) sm_pos = [(x*0.01, 0, 0.1) for x in range(-5, 5)] sm_list_release = m.ListRelease(spec_orient_list, sm_pos) world.release(sm_list_release) # pos_vec3 = m.Vector3() # diam_vec3 = m.Vector3(0.015, 0.015, 0.015) # world.create_release_site(vm1, 100, "spherical", diam_vec3=diam_vec3) # viz and reaction data world.add_viz(all_mols) world.add_count(vm1, torus_obj) world.add_count(vm2, torus_obj) world.add_count(sm1, torus_obj) # set partitions world.add_partitions('x', -1.3, 1.3, 0.05) world.add_partitions('y', -1.3, 1.3, 0.05) world.add_partitions('z', -0.275, 0.275, 0.05) # run the simulation! :) # for i in range(iterations+1): # vm3_count = world.get_species_count(vm3, torus_obj) # if (vm3_count > 50): # world.modify_rate_constant(rxn, 1e12) # world.run_iteration() world.run_sim() world.end_sim()
def create_vector3(x=0., y=0., z=0.): v = m.vector3() v.x = x v.y = y v.z = z return v m.initialize_electric_field() m.update_electric_field(new_electric_field) world = m.MCellSim(2) world.set_time_step(dt) world.set_iterations(iterations=N) spec = m.Species("Ca", 4e-6) spec.z = 2 world.add_species(spec) shape = 'spherical' quantity = 10000 diam = create_vector3() pos = create_vector3() world.create_release_site(spec, quantity, shape, pos, diam) f_n = 'results/output_' + str(mode) + '/' world.add_count(spec, folder_name=f_n) world.add_viz([spec], step=1, folder_name=f_n) for i in range(world._iterations): world.run_iteration() world.end_sim()
def main(): a = m.Species("a", dc=1e-6) sim = m.Simulation(dt=1e-6) sim.create_molecules_shape(a, 100, (0, 0, 0)) sim.run_iterations(100)
def main(): a = m.Species("a", dc=1e-6) box = m.create_box("box", 1.0, (0, 0, 0)) sim = m.Simulation(dt=1e-6) sim.create_molecules_obj(a, box, 100) sim.run_iterations(100)
def create_my_model(): # Add some geometries a001 = pymcell.Geometry.fromFile("a001.ply") print(a001) C = pymcell.Sites( states = [0,1,2] ) N = pymcell.Sites( states = [0,1,2] ) Y286 = pymcell.Sites( states = ['0','P'] ) b_site = pymcell.Sites( states = [0,1] ) # # Make a species # pmca_p0 = pymcell.Species( # name="pmca_p0", # diff_const=10.0 # ) # pmca_po.set_diff_const(5) ca = pymcell.Species( name="ca", diff_const=10.0 ) # pmca_p1 = pymcell.Species( # name="pmca_p1", # diff_const=10.0 # ) CaM = pymcell.Species( name = "CaM", diff_const =10.0, states = [C,N,b_site] ) CaMKII = pymcell.Species( name = "CaM", diff_const =10.0, states = [b_site,Y286] ) Complex = pymcell.Complex( name = "Complex", components = [], diff_const =10.0, # calculated from components? ) bng_rxn = BNGRxn(...) # Make a surface reaction # pmca_p0' + ca, <-> pmca_p1' # rxn_surface = pymcell.Rxn( # name="first rxn", # fwd_rate=1.0, # bkwd_rate=2.0, # reactants=[ # pymcell.oriented_species(pmca_p0, pymcell.ORIENT.UP), # pymcell.oriented_species(ca, pymcell.ORIENT.DOWN) # ], # products=[ # pymcell.oriented_species(pmca_p1, pymcell.ORIENT.UP) # ] # ) # Make a volume reaction # calbindin_h0m0 + ca <-> calbindin_h1m0 # rxn_volume = pymcell.Rxn( # name="second rxn", # fwd_rate=1.0, # bkwd_rate=2.0, # reactants=[ # calbindin_h0m0, # ca # ], # products=[ # calbindin_h1m0 # ] rxn_volume = pymcell.Rxn( name="third rxn", fwd_rate=1.0, bkwd_rate=2.0, reactants=[ CaM(states(C[0],b_site[0])), ca ], products=[ CaM(states(C[1],b_site[0])) ] ) rxn_volume = pymcell.Rxn( name="third rxn", fwd_rate=1.5, bkwd_rate=1.5, reactants=[ CaM(states(C[1],b_site[0])), ca ], products=[ CaM(states(C[2],b_site[0])) ] ) rxn_volume = pymcell.Rxn( name="fourth rxn", fwd_rate=1.0, bkwd_rate=2.0, reactants=[ CaM(states(C[0],b_site[0])), CaMKII(states(b_site[0],Y286[0])) ], products=[ Complex(components = [CaM(states(C[1],b_site[1])),CaMKII(states(b_site[1],Y286[0]))]) ] ) rxn_volume = pymcell.Rxn( name="fourth rxn", fwd_rate=1.0, reactants=[ Complex(components = [ CaM, CaMKII(states(b_site[1],Y286[0],d_site[1])), CaM(states(C[1],N[2],b_site[1])), CaMKII(states(b_site[1],Y286[0],d_site[1])) ]) ] products=[ Complex(components = [ CaM, CaMKII(states(b_site[1],Y286[0],d_site[1])), CaM(states(C[1],N[2],b_site[1])), CaMKII(states(b_site[1],Y286[P],d_site[1])) ]) ] ) # Create releases release_1 = pymcell.ReleaseSite( name="pmca_p0_pre_rel", type=pymcell.RELEASE_TYPE.OBJECT, species=pmca_p0, quantity=100, release_probability=1, object=a001.get_surface_region("axon_membrane") ) release_2 = CaM.ReleaseSite( name="pmca_p0_pre_rel", type=pymcell.RELEASE_TYPE.OBJECT, species=CaM(CaM_states(C[0],N[0],Y286[0])), quantity=100, release_probability=1, object=a001.get_volume_region("dendritic_spine") ) # Finally: add all that to a model m = pymcell.Model() m.add_geometry(a001) m.add_species(pmca_p0) m.add_species(ca) m.add_species(pmca_p1) m.add_rxn(rxn_volume) m.add_rxn(rxn_surface) m.add_release_site(release_1) m2 = pymcell.Model() m2.add_geometry(a001) m2.add_species(pmca_p0) m2.add_species(ca) m2.add_species(pmca_p1) m2.add_rxn(rxn_volume) m2.add_rxn(rxn_surface) m2.add_release_site(release_1) m.add_rxn(bng_rxn) return m