diff --git a/.gitignore b/.gitignore index 9eed9c0..546f854 100644 --- a/.gitignore +++ b/.gitignore @@ -141,4 +141,5 @@ cython_debug/ .python-version /in /out +/working *.simularium diff --git a/vivarium_models/composites/actin_fiber.py b/vivarium_models/composites/actin_fiber.py index 8d2113a..e10e89b 100644 --- a/vivarium_models/composites/actin_fiber.py +++ b/vivarium_models/composites/actin_fiber.py @@ -1,6 +1,3 @@ -import numpy as np -import argparse - from vivarium.core.composer import Composer from vivarium.core.engine import Engine from vivarium.processes.alternator import Alternator, PeriodicEvent @@ -9,10 +6,10 @@ from vivarium_medyan import MedyanProcess from vivarium_models.processes.monomer_to_fiber import MonomerToFiber from vivarium_models.processes.fiber_to_monomer import FiberToMonomer -from vivarium_models.data.fibers import initial_fibers +from vivarium_models.data.fibers import centered_initial_fibers READDY_TIMESTEP = 0.0000001 -ALTERNATOR_PERIODS = [10.0, READDY_TIMESTEP] +ALTERNATOR_PERIODS = [2.0, READDY_TIMESTEP] class ActinFiber(Composer): @@ -22,7 +19,7 @@ class ActinFiber(Composer): "time_step": READDY_TIMESTEP, "_condition": ("choices", "readdy_active"), }, - "medyan": {"time_step": 5.0, "_condition": ("choices", "medyan_active")}, + "medyan": {"time_step": 2.0, "_condition": ("choices", "medyan_active")}, "fiber_to_monomer": {"_condition": ("choices", "medyan_active")}, "monomer_to_fiber": {"_condition": ("choices", "readdy_active")}, "alternator": {"choices": ["medyan_active", "readdy_active"]}, @@ -85,7 +82,7 @@ def generate_topology(self, config): def test_actin_fiber(): - initial_state = initial_fibers + initial_state = centered_initial_fibers() initial_state["choices"] = {"medyan_active": True, "readdy_active": False} medyan_config = { "template_directory": "vivarium_models/templates/", @@ -102,7 +99,7 @@ def test_actin_fiber(): emitter="simularium", emit_processes=True, ) - engine.update(15) + engine.update(5) engine.emitter.get_data() diff --git a/vivarium_models/composites/filament_alternatives.py b/vivarium_models/composites/filament_alternatives.py index 85956f0..ccfc1ed 100644 --- a/vivarium_models/composites/filament_alternatives.py +++ b/vivarium_models/composites/filament_alternatives.py @@ -1,12 +1,10 @@ -import numpy as np -import argparse - from vivarium.core.composer import Composer from vivarium.core.engine import Engine from vivarium.processes.alternator import Alternator, PeriodicEvent from vivarium_medyan import MedyanProcess from vivarium_cytosim import CytosimProcess +from vivarium_models.data.fibers import centered_initial_fibers ALTERNATOR_PERIODS = [2.0, 2.0] @@ -64,239 +62,23 @@ def generate_topology(self, config): def test_filament_alternatives(): - parser = argparse.ArgumentParser(description="Run a MEDYAN simulation") - parser.add_argument( - "medyan_executable_path", - help="the file path to the MEDYAN executable", - ) - args = parser.parse_args() - initial_state = { - "choices": {"medyan_active": False, "cytosim_active": True}, - "fibers": { - "1": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 912.50000000, 1000.00000000]), - np.array([3160.00000000, 912.50000000, 1000.00000000]), - ], - }, - "2": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 947.50000000, 939.37822174]), - np.array([3160.00000000, 947.50000000, 939.37822174]), - ], - }, - "3": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 930.00000000, 969.68911087]), - np.array([3160.00000000, 930.00000000, 969.68911087]), - ], - }, - "4": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 947.50000000, 1000.00000000]), - np.array([3160.00000000, 947.50000000, 1000.00000000]), - ], - }, - "5": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 930.00000000, 1030.31088913]), - np.array([3160.00000000, 930.00000000, 1030.31088913]), - ], - }, - "6": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 947.50000000, 1060.62177826]), - np.array([3160.00000000, 947.50000000, 1060.62177826]), - ], - }, - "7": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 965.00000000, 909.06733260]), - np.array([3160.00000000, 965.00000000, 909.06733260]), - ], - }, - "8": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 982.50000000, 939.37822174]), - np.array([3160.00000000, 982.50000000, 939.37822174]), - ], - }, - "9": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 965.00000000, 969.68911087]), - np.array([3160.00000000, 965.00000000, 969.68911087]), - ], - }, - "10": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 982.50000000, 1000.00000000]), - np.array([3160.00000000, 982.50000000, 1000.00000000]), - ], - }, - "11": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 965.00000000, 1030.31088913]), - np.array([3160.00000000, 965.00000000, 1030.31088913]), - ], - }, - "12": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 982.50000000, 1060.62177826]), - np.array([3160.00000000, 982.50000000, 1060.62177826]), - ], - }, - "13": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 965.00000000, 1090.93266740]), - np.array([3160.00000000, 965.00000000, 1090.93266740]), - ], - }, - "14": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1000.00000000, 909.06733260]), - np.array([3160.00000000, 1000.00000000, 909.06733260]), - ], - }, - "15": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1017.50000000, 939.37822174]), - np.array([3160.00000000, 1017.50000000, 939.37822174]), - ], - }, - "16": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1000.00000000, 969.68911087]), - np.array([3160.00000000, 1000.00000000, 969.68911087]), - ], - }, - "17": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1017.50000000, 1000.00000000]), - np.array([3160.00000000, 1017.50000000, 1000.00000000]), - ], - }, - "18": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1000.00000000, 1030.31088913]), - np.array([3160.00000000, 1000.00000000, 1030.31088913]), - ], - }, - "19": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1017.50000000, 1060.62177826]), - np.array([3160.00000000, 1017.50000000, 1060.62177826]), - ], - }, - "20": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1000.00000000, 1090.93266740]), - np.array([3160.00000000, 1000.00000000, 1090.93266740]), - ], - }, - "21": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1035.00000000, 909.06733260]), - np.array([3160.00000000, 1035.00000000, 909.06733260]), - ], - }, - "22": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1052.50000000, 939.37822174]), - np.array([3160.00000000, 1052.50000000, 939.37822174]), - ], - }, - "23": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1035.00000000, 969.68911087]), - np.array([3160.00000000, 1035.00000000, 969.68911087]), - ], - }, - "24": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1052.50000000, 1000.00000000]), - np.array([3160.00000000, 1052.50000000, 1000.00000000]), - ], - }, - "25": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1035.00000000, 1030.31088913]), - np.array([3160.00000000, 1035.00000000, 1030.31088913]), - ], - }, - "26": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1052.50000000, 1060.62177826]), - np.array([3160.00000000, 1052.50000000, 1060.62177826]), - ], - }, - "27": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1035.00000000, 1090.93266740]), - np.array([3160.00000000, 1035.00000000, 1090.93266740]), - ], - }, - "28": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1070.00000000, 969.68911087]), - np.array([3160.00000000, 1070.00000000, 969.68911087]), - ], - }, - "29": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1087.50000000, 1000.00000000]), - np.array([3160.00000000, 1087.50000000, 1000.00000000]), - ], - }, - "30": { - "type_name": "Actin-Polymer", - "points": [ - np.array([1000.00000000, 1070.00000000, 1030.31088913]), - np.array([3160.00000000, 1070.00000000, 1030.31088913]), - ], - }, - }, - } - + initial_state = centered_initial_fibers() + initial_state["choices"] = {"medyan_active": False, "cytosim_active": True} medyan_config = { - "medyan_executable": args.medyan_executable_path, # "...../medyan/build/medyan" - "transform_points": [2000, 1000, 1000], + "template_directory": "vivarium_models/templates/", + "transform_points": [2000.0, 1000.0, 1000.0], + "filament_projection_type": "PREDEFINED", + } + cytosim_config = { + "template_directory": "vivarium_models/templates/", + } + filament_alternatives_config = { + "medyan": medyan_config, + "cytosim": cytosim_config, } - - filament_alternatives_config = {"medyan": medyan_config} filament_alternatives = FilamentAlternatives(filament_alternatives_config) - composite = filament_alternatives.generate() composite["initial_state"] = initial_state - engine = Engine( processes=composite["processes"], topology=composite["topology"], @@ -304,11 +86,7 @@ def test_filament_alternatives(): emitter="simularium", emit_processes=True, ) - - # import ipdb; ipdb.set_trace() - - engine.update(10) - + engine.update(6) engine.emitter.get_data() diff --git a/vivarium_models/data/fibers.py b/vivarium_models/data/fibers.py index adfc9c7..909d895 100644 --- a/vivarium_models/data/fibers.py +++ b/vivarium_models/data/fibers.py @@ -215,3 +215,14 @@ }, }, } + + +def centered_initial_fibers(): + result = initial_fibers + for fiber_id in initial_fibers["fibers"]: + fiber_points = initial_fibers["fibers"][fiber_id]["points"] + for point_index in range(len(fiber_points)): + result["fibers"][fiber_id]["points"][point_index] = ( + fiber_points[point_index] - 0.5 * initial_fibers["fibers_box_extent"] + ) + return result diff --git a/vivarium_models/library/scan.py b/vivarium_models/library/scan.py index 1928007..9def22b 100644 --- a/vivarium_models/library/scan.py +++ b/vivarium_models/library/scan.py @@ -1,4 +1,4 @@ -from vivarium.core.engine import Engine, pf +from vivarium.core.engine import Engine class Scan: diff --git a/vivarium_models/processes/fiber_to_monomer.py b/vivarium_models/processes/fiber_to_monomer.py index 8043999..931e4cd 100644 --- a/vivarium_models/processes/fiber_to_monomer.py +++ b/vivarium_models/processes/fiber_to_monomer.py @@ -36,7 +36,7 @@ def ports_schema(self): }, "monomers": { "box_center": { - "_default": np.array([3000.0, 1000.0, 1000.0]), + "_default": np.array([1000.0, 0.0, 0.0]), "_updater": "set", "_emit": True, }, diff --git a/vivarium_models/processes/monomer_to_fiber.py b/vivarium_models/processes/monomer_to_fiber.py index 2e359ab..2ed52a9 100644 --- a/vivarium_models/processes/monomer_to_fiber.py +++ b/vivarium_models/processes/monomer_to_fiber.py @@ -36,7 +36,7 @@ def ports_schema(self): }, "monomers": { "box_center": { - "_default": np.array([3000.0, 1000.0, 1000.0]), + "_default": np.array([1000.0, 0.0, 0.0]), "_updater": "set", "_emit": True, }, @@ -85,13 +85,11 @@ def next_update(self, timestep, states): print("in monomer to fiber deriver next update") monomers = states["monomers"] - monomer_box_center = monomers["box_center"] monomer_box_size = monomers["box_size"] previous_fibers = states["fibers"] - print(f"box_size = {monomer_box_size}") monomer_fibers = MonomerToFiber.generate_fibers_from_monomers( - monomers, monomer_box_center, monomer_box_size + monomers, monomer_box_size ) fiber_update = agents_update(previous_fibers, monomer_fibers) @@ -113,7 +111,7 @@ def get_next_actin_id(prev_actin_id, neighbor_ids): @staticmethod def get_actin_monomer_positions( - start_actin_id, particles, box_center, prev_actin_id=-1, result=None + start_actin_id, particles, prev_actin_id=-1, result=None ): """ Get monomer positions for an actin chain starting @@ -122,14 +120,14 @@ def get_actin_monomer_positions( if result is None: result = [] start_actin = particles[start_actin_id] - result.append(start_actin["position"] + box_center) + result.append(start_actin["position"]) next_actin_id = MonomerToFiber.get_next_actin_id( prev_actin_id, start_actin["neighbor_ids"] ) if next_actin_id < 0: return result return MonomerToFiber.get_actin_monomer_positions( - next_actin_id, particles, box_center, start_actin_id, result + next_actin_id, particles, start_actin_id, result ) @staticmethod @@ -149,12 +147,12 @@ def get_fiber_end_point(end_direction, positions, box_size): return axis_pos1 - 1.5 * (axis_pos2 - axis_pos1) @staticmethod - def get_fiber(topology_id, pointed_actin_id, monomers, box_center, box_size): + def get_fiber(topology_id, pointed_actin_id, monomers, box_size): """ Get data for a fiber from a chain of particles """ positions = MonomerToFiber.get_actin_monomer_positions( - pointed_actin_id, monomers["particles"], box_center + pointed_actin_id, monomers["particles"] ) return { "type_name": monomers["topologies"][topology_id]["type_name"], @@ -165,7 +163,7 @@ def get_fiber(topology_id, pointed_actin_id, monomers, box_center, box_size): } @staticmethod - def generate_fibers_from_monomers(monomers, box_center, box_size=500.0): + def generate_fibers_from_monomers(monomers, box_size=500.0): """ Transform monomer data into fiber data """ @@ -181,7 +179,6 @@ def generate_fibers_from_monomers(monomers, box_center, box_size=500.0): topology_id, pointed_actin_ids[topology_id], monomers, - box_center, box_size, ) return result diff --git a/vivarium_models/processes/readdy_actin_process.py b/vivarium_models/processes/readdy_actin_process.py index 7f29d56..68cad36 100644 --- a/vivarium_models/processes/readdy_actin_process.py +++ b/vivarium_models/processes/readdy_actin_process.py @@ -2,7 +2,6 @@ from vivarium.core.process import Process from vivarium.core.engine import Engine, pf -from vivarium.core.composition import simulate_process from vivarium.core.control import run_library_cli from tqdm import tqdm @@ -20,7 +19,7 @@ test_monomer_data = { "monomers": { - "box_center": np.array([3000.0, 1000.0, 1000.0]), # to be chosen by alternator + "box_center": np.array([1000.0, 0.0, 0.0]), "box_size": 500.0, "topologies": { 1: { @@ -35,17 +34,17 @@ "particles": { 0: { "type_name": "actin#free_ATP", - "position": np.array([2, 0, 0]), + "position": np.array([1002, 0, 0]), "neighbor_ids": [], }, 1: { "type_name": "arp2", - "position": np.array([0, 0, 0]), + "position": np.array([1000, 0, 0]), "neighbor_ids": [2], }, 2: { "type_name": "arp3#ATP", - "position": np.array([0, 0, 4]), + "position": np.array([1000, 0, 4]), "neighbor_ids": [1], }, }, @@ -128,7 +127,7 @@ def ports_schema(self): return { "monomers": { "box_center": { - "_default": np.array([3000.0, 1000.0, 1000.0]), + "_default": np.array([1000.0, 0.0, 0.0]), "_updater": "set", "_emit": True, }, @@ -221,8 +220,17 @@ def next_update(self, timestep, states): readdy_monomers = ReaddyUtil.get_current_monomers( self.readdy_simulation.current_topologies ) + transformed_monomers = ReaddyActinProcess._transform_monomers( + readdy_monomers, states["monomers"]["box_center"] + ) + + return create_monomer_update(states["monomers"], transformed_monomers) - return create_monomer_update(states["monomers"], readdy_monomers) + @staticmethod + def _transform_monomers(monomers, box_center): + for particle_id in monomers["particles"]: + monomers["particles"][particle_id]["position"] += box_center + return monomers # functions to configure and run the process def run_readdy_actin_process(): @@ -232,21 +240,25 @@ def run_readdy_actin_process(): Returns: The simulation output. """ - # initialize the process - readdy_actin_process = ReaddyActinProcess({}) - - # run the simulation - sim_settings = { - "total_time": 0.000000005, # 50 steps - "initial_state": test_monomer_data, - } - output = simulate_process(readdy_actin_process, sim_settings) + engine = Engine( + **{ + "processes": {"readdy_actin_process": ReaddyActinProcess()}, + "topology": { + "readdy_actin_process": { + "monomers": ("monomers",), + }, + }, + "initial_state": test_monomer_data, + } + ) + engine.update(0.000000005) # 50 steps + output = engine.emitter.get_data() return output def get_monomer_data(): monomer_data = ActinTestData.linear_actin_monomers() - monomer_data["box_center"] = np.array([3000.0, 1000.0, 1000.0]) + monomer_data["box_center"] = np.zeros(3) monomer_data["box_size"] = 500.0 return {"monomers": monomer_data} @@ -396,12 +408,8 @@ def filament_straightness(results): } scan = Scan(parameters, ReaddyActinProcess, 0.0000001, metrics=metrics) - results = scan.run_scan() - - import ipdb - - ipdb.set_trace() + print(results) library = {"0": test_readdy_actin_process, "1": test_scan_readdy} diff --git a/vivarium_models/processes/simularium_emitter.py b/vivarium_models/processes/simularium_emitter.py index 73a3bd6..6253088 100644 --- a/vivarium_models/processes/simularium_emitter.py +++ b/vivarium_models/processes/simularium_emitter.py @@ -35,9 +35,7 @@ def emit(self, data: Dict[str, Any]) -> None: key: value for key, value in emit_data.items() if key not in ["time"] } - def get_simularium_fibers( - self, time, fibers, actin_radius, position_offset, trajectory - ): + def get_simularium_fibers(self, time, fibers, actin_radius, trajectory): """ Shape fiber state data into Simularium fiber agents """ @@ -50,23 +48,18 @@ def get_simularium_fibers( trajectory["subpoints"].append([]) for fiber_id in fibers: fiber = fibers[fiber_id] - fiber_points = [ - np.array(point) + position_offset for point in fiber["points"] - ] n_agents += 1 trajectory["unique_ids"][time_index].append(int(fiber_id)) trajectory["type_names"][time_index].append(fiber["type_name"]) - trajectory["n_subpoints"][time_index].append(len(fiber_points)) - trajectory["subpoints"][time_index].append(fiber_points) + trajectory["n_subpoints"][time_index].append(len(fiber["points"])) + trajectory["subpoints"][time_index].append(fiber["points"]) trajectory["n_agents"].append(n_agents) trajectory["viz_types"].append(n_agents * [1001.0]) trajectory["positions"].append(n_agents * [[0.0, 0.0, 0.0]]) trajectory["radii"].append(n_agents * [actin_radius]) return trajectory - def get_simularium_monomers( - self, time, monomers, actin_radius, position_offset, trajectory - ): + def get_simularium_monomers(self, time, monomers, actin_radius, trajectory): """ Shape monomer state data into Simularium agents """ @@ -81,9 +74,7 @@ def get_simularium_monomers( particle = monomers["particles"][particle_id] trajectory["unique_ids"][time_index].append(int(particle_id)) trajectory["type_names"][time_index].append(particle["type_name"]) - trajectory["positions"][time_index].append( - np.array(particle["position"]) + position_offset - ) + trajectory["positions"][time_index].append(np.array(particle["position"])) # visualize edges between particles for neighbor_id in particle["neighbor_ids"]: neighbor_id_str = str(neighbor_id) @@ -96,9 +87,10 @@ def get_simularium_monomers( edge_ids.append(edge) edge_positions.append( [ - np.array(particle["position"]) + position_offset, - np.array(monomers["particles"][neighbor_id_str]["position"]) - + position_offset, + np.array(particle["position"]), + np.array( + monomers["particles"][neighbor_id_str]["position"] + ), ] ) n_agents = len(trajectory["unique_ids"][time_index]) @@ -225,10 +217,16 @@ def get_active_simulator(choices) -> str: """ Use choices from state to determine which simulator ran """ - if choices["medyan_active"] and not choices["readdy_active"]: + medyan_active = "medyan_active" in choices and choices["medyan_active"] + readdy_active = "readdy_active" in choices and choices["readdy_active"] + cytosim_active = "cytosim_active" in choices and choices["cytosim_active"] + + if medyan_active and not readdy_active and not cytosim_active: return "medyan" - elif not choices["medyan_active"] and choices["readdy_active"]: + elif readdy_active and not medyan_active and not cytosim_active: return "readdy" + elif cytosim_active and not medyan_active and not readdy_active: + return "cytosim" def get_data(self) -> dict: """ @@ -267,52 +265,47 @@ def get_data(self) -> dict: """visualize the first frame in the simulator that started first then subsequent frames according the the simulator that ran right before that time point""" - if prev_simulator == "medyan": - print(" visualize medyan") - if box_dimensions is None: - box_dimensions = np.array(state["fibers_box_extent"]) - trajectory = self.get_simularium_fibers( - vizualize_time_index, - state["fibers"], - actin_radius, - -0.5 * box_dimensions, - trajectory, - ) - vizualize_time_index += 1 - if prev_simulator == "readdy": - print(" visualize readdy") - trajectory = self.get_simularium_monomers( - vizualize_time_index, - state["monomers"], - actin_radius, - np.array(state["monomers"]["box_center"]) - 0.5 * box_dimensions, - trajectory, - ) - vizualize_time_index += 1 - if prev_simulator != current_simulator: - if current_simulator == "medyan": - print(" visualize medyan") + if prev_simulator == "none": + if current_simulator == "medyan" or current_simulator == "cytosim": + print(f" visualize current {current_simulator}") if box_dimensions is None: box_dimensions = np.array(state["fibers_box_extent"]) trajectory = self.get_simularium_fibers( vizualize_time_index, state["fibers"], actin_radius, - -0.5 * box_dimensions, trajectory, ) vizualize_time_index += 1 if current_simulator == "readdy": - print(" visualize readdy") + print(" visualize current readdy") trajectory = self.get_simularium_monomers( vizualize_time_index, state["monomers"], actin_radius, - np.array(state["monomers"]["box_center"]) - - 0.5 * box_dimensions, trajectory, ) vizualize_time_index += 1 + elif prev_simulator == "medyan" or prev_simulator == "cytosim": + print(f" visualize previous {prev_simulator}") + if box_dimensions is None: + box_dimensions = np.array(state["fibers_box_extent"]) + trajectory = self.get_simularium_fibers( + vizualize_time_index, + state["fibers"], + actin_radius, + trajectory, + ) + vizualize_time_index += 1 + elif prev_simulator == "readdy": + print(" visualize readdy") + trajectory = self.get_simularium_monomers( + vizualize_time_index, + state["monomers"], + actin_radius, + trajectory, + ) + vizualize_time_index += 1 simularium_converter = SimulariumEmitter.get_simularium_converter( trajectory, box_dimensions, 0.1 ) diff --git a/vivarium_models/tests/test_readdy_actin.py b/vivarium_models/tests/test_readdy_actin.py index 2deaea0..0ad39e5 100644 --- a/vivarium_models/tests/test_readdy_actin.py +++ b/vivarium_models/tests/test_readdy_actin.py @@ -8,52 +8,31 @@ from vivarium_models import ReaddyActinProcess -def remove_extra_dim(list): - # TODO figure out how to prevent the extra dim from being added - return list[0] - - def test_readdy_actin_process(): """ Test the initial ReaDDy actin process """ - output = ReaddyActinProcess.run_readdy_actin_process()["monomers"] - + output = ReaddyActinProcess.run_readdy_actin_process()[5e-09]["monomers"] found_monomer = False found_dimer = False assert len(output["topologies"]) == 2 for t in output["topologies"]: top = output["topologies"][t] - if top["type_name"][0] == "Actin-Monomer": + if top["type_name"] == "Actin-Monomer": found_monomer = True - particle_ids = remove_extra_dim(top["particle_ids"]) + particle_ids = top["particle_ids"] assert len(particle_ids) == 1 - assert "actin#free" in remove_extra_dim( - output["particles"][str(particle_ids[0])]["type_name"] - ) assert ( - len( - remove_extra_dim( - output["particles"][str(particle_ids[0])]["neighbor_ids"] - ) - ) - == 0 + "actin#free" in output["particles"][str(particle_ids[0])]["type_name"] ) - if top["type_name"][0] == "Arp23-Dimer": + assert len(output["particles"][str(particle_ids[0])]["neighbor_ids"]) == 0 + if top["type_name"] == "Arp23-Dimer": found_dimer = True - particle_ids = remove_extra_dim(top["particle_ids"]) + particle_ids = top["particle_ids"] assert len(particle_ids) == 2 - assert "arp2" in remove_extra_dim( - output["particles"][str(particle_ids[0])]["type_name"] - ) - assert remove_extra_dim( - output["particles"][str(particle_ids[0])]["neighbor_ids"] - ) == [2] - assert "arp3" in remove_extra_dim( - output["particles"][str(particle_ids[1])]["type_name"] - ) - assert remove_extra_dim( - output["particles"][str(particle_ids[1])]["neighbor_ids"] - ) == [1] + assert "arp2" in output["particles"][str(particle_ids[0])]["type_name"] + assert output["particles"][str(particle_ids[0])]["neighbor_ids"] == [1] + assert "arp3" in output["particles"][str(particle_ids[1])]["type_name"] + assert output["particles"][str(particle_ids[1])]["neighbor_ids"] == [0] assert found_monomer assert found_dimer