Skip to content

Commit

Permalink
got medyan process running!
Browse files Browse the repository at this point in the history
  • Loading branch information
prismofeverything committed Aug 17, 2021
1 parent b541f14 commit 7a003ea
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 14 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
- "-e .[dev]"
209 changes: 209 additions & 0 deletions in/filaments/filament-system.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions in/filaments/filaments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FILAMENT A -70 0 0 10 0 0
40 changes: 30 additions & 10 deletions vivarium_models/processes/medyan.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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()
]

Expand All @@ -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:
Expand All @@ -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()

Expand All @@ -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 = {}
Expand Down
4 changes: 2 additions & 2 deletions vivarium_models/templates/filament-system.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7a003ea

Please sign in to comment.