From 7a003eaaa6dc8df0240602e5ee8c5a5b53a4965d Mon Sep 17 00:00:00 2001 From: Ryan Spangler Date: Tue, 17 Aug 2021 13:59:10 -0700 Subject: [PATCH] got medyan process running! --- README.md | 6 + env.yml | 4 +- in/filaments/filament-system.txt | 209 ++++++++++++++++++ in/filaments/filaments.txt | 1 + vivarium_models/processes/medyan.py | 40 +++- vivarium_models/templates/filament-system.txt | 4 +- 6 files changed, 250 insertions(+), 14 deletions(-) create mode 100644 in/filaments/filament-system.txt create mode 100644 in/filaments/filaments.txt diff --git a/README.md b/README.md index afaa873..1ce5ae3 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ Install conda: https://docs.conda.io/en/latest/miniconda.html Using conda, you can run `conda env create -f env.yml`, which will create a conda environment called `vivarium_models` with all the required dependencies (including ReaDDy) installed. +To update: + +``` + +``` + ### MEDYAN To install MEDYAN: diff --git a/env.yml b/env.yml index 0ad176d..d958a7d 100644 --- a/env.yml +++ b/env.yml @@ -2,8 +2,8 @@ name: vivarium_models channels: - conda-forge dependencies: - - python=3.8 + - python=3.9.6 - readdy/label/dev::readdy - pip - pip: - - "-e .[dev]" \ No newline at end of file + - "-e .[dev]" diff --git a/in/filaments/filament-system.txt b/in/filaments/filament-system.txt new file mode 100644 index 0000000..5d91e34 --- /dev/null +++ b/in/filaments/filament-system.txt @@ -0,0 +1,209 @@ +################################################## +### Important notes: +### 1. Units in MEDYAN are nm, second, pN, and pN*nm +################################################## + +################################################## +### PART I: Basic simulation parameters +### Carefully check this section before running +################################################## + +### 1. Set network sizes and shape +# Set the number of compartments in x, y and z directions +# Network size = compartment size (500nm by default) * (NX, NY, NZ) + +NX: 2 +NY: 2 +NZ: 4 + +# Define network boundary geometry (CUBIC, SPHERICAL, CYLINDER) + +BOUNDARYSHAPE: CUBIC + +# Set diameter for SPHERICAL or CYLINDER type +# CUBIC: No need to set, boundary is the same as network size + +BOUNDARYDIAMETER: + +### 2. Set total running time + +RUNTIME: 1.0 + +### 3. Output simulation results every SNAPSHOTTIME + +SNAPSHOTTIME: 1.0 + +### 4. Set chemistry input file name + +CHEMISTRYFILE: chemistryinput.txt + +### 5. Initialize filaments +# Option 1: Random generation +# Set the number of filament and +# filament length (in number of cylinders) +# FILAMENTTYPE: use 0 if only one type of filaments + +NUMFILAMENTS: 0 +FILAMENTLENGTH: 1 +FILAMENTTYPE: 0 + +# Option 2: Initialize by setting input filament file + +FILAMENTFILE: filaments.txt + + +#################################################### +### PART II: Force field information +### Based on: actin filament, non-muscle myosin II, +### alpha-actinin, Arp2/3 +### Changes not recommended unless using a different +### species or have a different parameter source +#################################################### + +### 1. Minimize system energy every MINIMIZATIONTIME +# Use a lower value if: 1. simulation fails or generates warnings +# 2. has very fast chemical reactions +# Recommend value: 0.001 - 0.05 +# Please use the same value for NEIGHBORLISTTIME + +MINIMIZATIONTIME: 0.05 +NEIGHBORLISTTIME: 0.05 + +### 2. Actin filaments + +# Stretching: Popov et al, 2016, PLoS Comp Biol + +FSTRETCHINGFFTYPE: HARMONIC +FSTRETCHINGK: 100.0 + +# Bending: Ott et al, 1993, Phys Rev E + +FBENDINGFFTYPE: COSINE +FBENDINGK: 672.0 +FBENDINGTHETA: 0.0 + +# Volume exclusion: Popov et al, 2016, PLoS Comp Biol + +VOLUMEFFTYPE: REPULSION +VOLUMECUTOFF: 27.0 +VOLUMEK: 1E5 + +# Dynamic rate model - Brownian Ratchet: +# Footer et al, PNAS, 2007 + +DFPOLYMERIZATIONTYPE: BROWRATCHET +DFPOLYMERIZATIONLEN: 2.7 + +### 3. Non-muscle myosin IIA motor + +# Stretching: Vilfan, Biophys J, 2010 + +MSTRETCHINGFFTYPE: HARMONIC +MSTRETCHINGK: 2.5 + +# Number of heads: + +NUMMOTORHEADSMIN: 15 +NUMMOTORHEADSMAX: 30 + +# Step size: + +MOTORSTEPSIZE: 6.0 + +# Dynamic rate - motor catch-bond: +# Erdmann et al, JCP, 2013 + +DMUNBINDINGTYPE: LOWDUTYCATCH +DMUNBINDINGFORCE: 12.62 + +# Dynamic rate - motor walking +# Komianos & Papoian, PRX, 2018 +# Tunable parameters based on different studies +# recommended values 24pN - 100 pN + +DMWALKINGTYPE: LOWDUTYSTALL +DMWALKINGFORCE: 90.0 + +### 4. Alpha-actinin crosslinker + +# Stretching: Didonna et al, Phys Rev E, 2007 + +LSTRETCHINGFFTYPE: HARMONIC +LSTRETCHINGK: 8.0 + +# Dynamic rate - linker slip-bond: +# Ferrer et al, PNAS, 2008 + +DLUNBINDINGTYPE: SLIP +DLUNBINDINGLEN: 0.24 + +### 4. Arp2/3 brancher +# 4 force fields: Popov et al, Plos Comp Biol, 2016 +# No reliable literature values for this FF + +BRSTRETCHINGFFTYPE: HARMONIC +BRSTRETCHINGK: 100.0 +BRSTRETCHINGL: 6.0 + +BRBENDINGFFTYPE: COSINE +BRBENDINGK: 10.0 +BRBENDINGTHETA: 1.22 + +BRDIHEDRALFFTYPE: COSINE +BRDIHEDRALK: 10.0 + +BRPOSITIONFFTYPE: COSINE +BRPOSITIONK: 20.0 + +### 5. Boundary +# Repulsion: Popov et al, 2016, PLoS Comp Biol + +BOUNDARYFFTYPE: REPULSIONEXP +BOUNDARYCUTOFF: 300.0 +BOUNDARYINTERACTIONK: 41.0 +BOUNDARYSCREENLENGTH: 2.7 + +################################################## +### PART III: Advanced settings +### Changes not recommended +################################################## + +### 1. Cylinder setup + +MONOMERSIZE: 2.7 +CYLINDERSIZE: 108.0 + +### 2. Algorithm +# Minimization + +CONJUGATEGRADIENT: POLAKRIBIERE +GRADIENTTOLERANCE: 5.0 +MAXDISTANCE: 1.0 +LAMBDAMAX: 0.01 + +# Chemistry + +CALGORITHM: NRM + +### 3. Number of binding site per 108nm cylinder + +NUMBINDINGSITES: 4 + +### 4. The number of filament type +# I.e. actin filament, microtubule, intermediate filament + +NUMFILAMENTTYPES: 1 + +### 5. The compartment size +# Based on Kuramoto length, see Popov et al., PLoS Comp Biol, 2016 +# Some chemical reaction rates are scaled based on compartment size + +COMPARTMENTSIZEX: 500.0 +COMPARTMENTSIZEY: 500.0 +COMPARTMENTSIZEZ: 500.0 + +### 6. Others: DO NOT CHANGE + +NDIM: 3 +PROJECTIONTYPE: STRAIGHT +SAMEFILBINDINGSKIP: 100 \ No newline at end of file diff --git a/in/filaments/filaments.txt b/in/filaments/filaments.txt new file mode 100644 index 0000000..40f63f6 --- /dev/null +++ b/in/filaments/filaments.txt @@ -0,0 +1 @@ +FILAMENT A -70 0 0 10 0 0 \ No newline at end of file diff --git a/vivarium_models/processes/medyan.py b/vivarium_models/processes/medyan.py index 7be451b..08bb511 100644 --- a/vivarium_models/processes/medyan.py +++ b/vivarium_models/processes/medyan.py @@ -1,8 +1,10 @@ import os +import numpy as np +from vivarium.core.engine import pf from vivarium.core.process import Process from vivarium.core.composition import ( - # simulate_process, + simulate_process, PROCESS_OUT_DIR, ) from vivarium.plots.simulation_output import plot_simulation_output @@ -39,6 +41,7 @@ class MedyanProcess(Process): "system_template": "filament-system.txt", "system_file": "filament-system.txt", "filament_file": "filaments.txt", + "medyan_executable": "medyan", } def __init__(self, parameters=None): @@ -63,17 +66,18 @@ def ports_schema(self): } def initial_state(self, config): - initial_state = { - unique_id: {"type_name": "", "points": points} - for unique_id, points in config.get("points", {}).items() + initial_filaments = { + unique_id: {"type_name": "A", "points": points} + for unique_id, points in config.get("filaments", {}).items() } - return initial_state + return { + 'filaments': initial_filaments} def next_update(self, timestep, state): initial_filaments = state["filaments"] filament_lines = [ - filament_to_string(filament["type"], filament["points"]) + filament_to_string(filament["type_name"], filament["points"]) for filament in initial_filaments.values() ] @@ -87,7 +91,9 @@ def next_update(self, timestep, state): system_template = self.parameters["system_template"] template = env.get_template(system_template) - system_text = template.render(filament_file=filament_path) + system_text = template.render( + filament_file=self.parameters['filament_file'], + timestep=timestep) system_path = input_directory / self.parameters["system_file"] with open(system_path, "w") as system_file: @@ -96,13 +102,15 @@ def next_update(self, timestep, state): medyan_command = [ self.parameters["medyan_executable"], "-s", - system_file, + system_file.name, "-i", - input_directory, + str(input_directory), "-o", self.parameters["output_directory"], ] + import ipdb; ipdb.set_trace() + medyan_process = subprocess.Popen(medyan_command, stdout=subprocess.PIPE) output, error = medyan_process.communicate() @@ -114,7 +122,19 @@ def main(): if not os.path.exists(out_dir): os.makedirs(out_dir) - output = MedyanProcess.next_update() + medyan = MedyanProcess({ + 'medyan_executable': '/home/youdonotexist/Downloads/medyan-4.2.0/build/medyan'}) + initial_state = { + 'filaments': { + '1': { + 'type_name': 'A', + 'points': [ + np.array([-70, 0, 0]), + np.array([10, 0, 0])]}}} + + output = simulate_process(medyan, { + 'initial_state': initial_state, + 'total_time': 10}) # plot the simulation output plot_settings = {} diff --git a/vivarium_models/templates/filament-system.txt b/vivarium_models/templates/filament-system.txt index ee4deb4..05b35a3 100644 --- a/vivarium_models/templates/filament-system.txt +++ b/vivarium_models/templates/filament-system.txt @@ -27,11 +27,11 @@ BOUNDARYDIAMETER: ### 2. Set total running time -RUNTIME: 100.0 +RUNTIME: {{timestep}} ### 3. Output simulation results every SNAPSHOTTIME -SNAPSHOTTIME: 1.0 +SNAPSHOTTIME: {{timestep}} ### 4. Set chemistry input file name