Skip to content

Commit

Permalink
updates to simularium
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Aug 16, 2024
1 parent 5ef8bae commit 0d503bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compose_worker/MinE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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 1 # stopping time
define TIME_STOP 5 # stopping time

#define KICK_START 1 # start with MinD_ATP at an end

Expand Down
23 changes: 18 additions & 5 deletions compose_worker/bigraph_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def set_uniform(
)


class SimulariumStep(Step):
class SimulariumSmoldynStep(Step):
"""
agent_data should have the following structure:
Expand Down Expand Up @@ -321,8 +321,7 @@ def update(self, inputs):
file_data = InputFileData(in_file)

# get species data for display data
species_data = inputs['species_counts']
species_names = list(species_data.keys())
species_names = inputs['species_names']

# generate simulariumio Smoldyn Data TODO: should display data be gen for each species type or n number of instances of that type?
display_data = self._generate_display_data(species_names)
Expand All @@ -340,7 +339,7 @@ def update(self, inputs):
io_data = translate_data_object(data=io_data, box_size=self.box_size, translation_magnitude=self.translation_magnitude)

# write data to simularium file
simularium_fp = os.path.join(self.output_dest, 'simulation.simularium')
simularium_fp = os.path.join(self.output_dest, 'simulation')
write_simularium_file(data=io_data, simularium_fp=simularium_fp, json=True, validate=True)

return {'simularium_file': simularium_fp}
Expand Down Expand Up @@ -378,11 +377,25 @@ def _generate_display_data(self, species_names) -> Dict | None:

REGISTERED_PROCESSES = [
('smoldyn_step', SmoldynStep),
('simularium_step', SimulariumStep)
('simularium_smoldyn_step', SimulariumSmoldynStep)
]
for process_name, process_class in REGISTERED_PROCESSES:
try:
CORE.process_registry.register(process_name, process_class)
except Exception as e:
print(f'{process_name} could not be registered because {str(e)}')


def generate_simularium_file(input_fp: str, dest: str, box_size: float):
species_names = []
with open(input_fp, 'r') as f:
output = [l.strip() for l in f.readlines()]
for line in output:
datum = line.split(' ')[0]
if not datum.isdigit():
species_names.append(datum)

simularium = SimulariumSmoldynStep(config={'output_dest': dest, 'box_size': box_size})
return simularium.update(inputs={'results_file': input_fp, 'species_names': species_names})


1 change: 1 addition & 0 deletions model-examples/smoldyn/simulation.simularium.simularium

Large diffs are not rendered by default.

0 comments on commit 0d503bd

Please sign in to comment.