MEDYAN.add_fila_reaction!

Tuple{MEDYAN.SysDef}

add_fila_reaction!(s::SysDef; fila_type, name, match_states, ...)

Add a filament monomer reaction. The reaction fires at monomers whose local neighborhood matches a pattern of states. When it fires, the matched monomers can be changed to new_states, or a custom affect! callback can handle arbitrary side effects.

All pattern positions must lie on the filament. Monomers near the ends where the pattern would extend past the boundary are automatically skipped. Use add_fila_tip_reaction! for reactions at filament ends.

Keyword Arguments

Required

  • fila_type::Symbol: Filament type (e.g., :actin).

  • name::Symbol: Unique name for this reaction site.

  • match_states::Vector: Pattern of monomer states to match, ordered minus → plus end. Each element can be:

    • Symbol — exact state (e.g., :a)
    • Vector{Symbol} — any of these states (e.g., [:a, :b])
    • anystate — any state

State change (provide exactly one)

  • new_states::Vector{Symbol}: States to assign to the matched monomers after firing. Must be the same length as match_states. Cannot be used with affect!.
  • affect!: Custom callback (c::Context; chem_voxel::Int, center::FilaMonoIdx, kwargs...) -> Int. Called instead of automatic state changes. The returned Int is a status code. Cannot be used with new_states.

Rate

  • base_rate::Float64: Rate constant. Units: (nm³)^invvolumepower / s.
  • invvolumepower::Int = 0: Set to 0 for unimolecular, 1 for bimolecular.
  • reactants_extra::String = "": Additional reactant species that contribute to propensity (e.g., "diffusing.ligand"). The species is not consumed automatically.

Geometry

  • center::Int = cld(length(match_states), 2): Which position in match_states is the center of the reaction. Determines which chem_voxel the reaction is assigned to.

Examples

using MEDYAN
s = MEDYAN.SysDef()
add_fila_type!(s; name=:actin, mono_states=[:a, :b, :c], param=MEDYAN.ACTIN_TWIST_PARAMS)

# Aging: every :a monomer transitions to :b
add_fila_reaction!(s;
    fila_type = :actin, name = :aging,
    match_states = [:a],
    new_states = [:b],
    base_rate = 2.4,
)

# Cooperative transition: :a next to :b on the minus side becomes :b
add_fila_reaction!(s;
    fila_type = :actin, name = :cooperate,
    match_states = [:b, :a],
    new_states = [:b, :b],
    center = 2,
    base_rate = 0.4,
)

# Bimolecular binding with a diffusing ligand
add_diffusing_species!(s, :ligand; coeff=2.5e7)
add_fila_reaction!(s;
    fila_type = :actin, name = :bind,
    match_states = [:a],
    affect! = (c; center, chem_voxel, kwargs...) -> let
        update_fila_mono_state!(c, center, :b)
        add_diffusing_count!(c; species=:ligand, chem_voxel, amount=-1)
        1
    end,
    base_rate = 1e6,
    invvolumepower = 1,
    reactants_extra = "diffusing.ligand",
)

# Match a set of states: :a or :b → :c
add_fila_reaction!(s;
    fila_type = :actin, name = :a_or_b,
    match_states = [[:a, :b]],
    new_states = [:c],
    base_rate = 1.0,
)

# anystate with neighbor constraint: any monomer whose plus neighbor is :a
add_fila_reaction!(s;
    fila_type = :actin, name = :any_then_a,
    match_states = [anystate, :a],
    new_states = [:a, :b],
    center = 2,
    base_rate = 1.0,
)