chem

package
v1.4.31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: BSD-3-Clause Imports: 1 Imported by: 2

README

Docs: GoDoc

Package chem provides basic chemistry simulation algorithms, including:

  • React -- chemical reaction where 2 components bind into a compound, characterized by forward and backward rate constants, Kf, Kb.

  • Enz -- enzyme-catalyzed reaction based on the Michaelis-Menten kinetics that transforms S = substrate into P product via SE bound C complex.

  • Buffer -- provides a soft buffering driving deltas relative to a target N which can be set by concentration and volume.

  • Integrate -- performs basic forward Euler integration, using IntegrateDt rate constant.

  • CoFmN and CoToN convert concentration to / from numbers of molecules given a volume (just multiplication and division, but useful for documenting the purpose).

In general, all of this code just computes deltas (discrete derivatives) for moving numbers of molecules around -- complex systems of reactions can be constructed and all the different deltas summed up, and applied in a step-wise fashion. At bottom, it is really very simple, involving massive simplifications that nevertheless seem sufficient to capture the relevant phenomena. In effect, the all-important rate constants absorb and compensate for all of those simplifications.

Kinetikit

This code is based on Kinetikit by Upinder S. Bhalla and implemented in the Genesis simulation tool. See:

See the axon urakubo model of LTP / LTD for a re-implementation of the Urakubo et al, 2008 model using this code.

  • Urakubo, H., Honda, M., Froemke, R. C., & Kuroda, S. (2008). Requirement of an allosteric kinetics of NMDA receptors for spike timing-dependent plasticity. The Journal of Neuroscience, 28(13), 3310–3323. http://www.ncbi.nlm.nih.gov/pubmed/18367598

Here's another paper that Urakubo builds upon:

Reactions

React models a basic chemical reaction:

      Kf
A + B --> AB
     <-- Kb

where Kf is the forward and Kb is the backward time constant. The source Kf and Kb constants are in terms of concentrations μM-1 and sec-1 but calculations take place using N's, and the forward direction has two factors while reverse only has one, so a corrective volume factor needs to be divided out to set the actual forward factor.

Enzymes

Enz models an enzyme-catalyzed reaction based on the Michaelis-Menten kinetics that transforms S = substrate into P product via SE bound C complex:

      K1        K3
S + E --> C(SE) ---> P + E
     <-- K2

S = substrate, E = enzyme, C = SE complex, P = product. The source K constants are in terms of concentrations μM-1 and sec-1 but calculations take place using N's, and the forward direction has two factors while reverse only has one, so a corrective volume factor needs to be divided out to set the actual forward factor.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IntegrationDt = 5.0e-5

IntegrationDt is the time step of integration for Urakubo et al, 2008: uses 5e-5, 2e-4 is barely stable, 5e-4 is not The AC1act dynamics in particular are not stable due to large ATP, AMP numbers

Functions

func CoFmN

func CoFmN(n, vol float64) float64

CoFmN returns concentration from N, for given volume: co / vol

func CoToN

func CoToN(co, vol float64) float64

CoToN returns N based on concentration, for given volume: co * vol

func Integrate

func Integrate(c *float64, d float64)

Integrate adds delta to current value with integration rate constant IntegrationDt new value cannot go below 0

Types

type Buffer

type Buffer struct {

	// rate of buffering (akin to permeability / conductance of a channel)
	K float64 `desc:"rate of buffering (akin to permeability / conductance of a channel)"`

	// buffer target concentration -- drives delta relative to this
	Target float64 `desc:"buffer target concentration -- drives delta relative to this"`
}

Buffer provides a soft buffering driving deltas relative to a target N which can be set by concentration and volume.

func (*Buffer) SetTargVol

func (bf *Buffer) SetTargVol(targ, vol float64)

func (*Buffer) Step

func (bf *Buffer) Step(ca float64, da *float64)

Step computes da delta for current value ca relative to target value Target

type Diffuse

type Diffuse struct {

	// A -> B forward diffusion rate constant, sec-1
	Kf float64 `desc:"A -> B forward diffusion rate constant, sec-1"`

	// B -> A backward diffusion rate constant, sec-1
	Kb float64 `desc:"B -> A backward diffusion rate constant, sec-1"`
}

Diffuse models diffusion between two compartments A and B as a function of concentration in each and potentially asymmetric rate constants: A Kf -> B and B Kb -> A computes the difference between each direction and applies to each

func (*Diffuse) Set

func (rt *Diffuse) Set(kf, kb float64)

Set sets both diffusion rates

func (*Diffuse) SetSym

func (rt *Diffuse) SetSym(kfb float64)

SetSym sets symmetric diffusion rate (Kf == Kb)

func (*Diffuse) Step

func (rt *Diffuse) Step(ca, cb, va, vb float64, da, db *float64)

Step computes delta A and B values based on current A, B values inputs are numbers, converted to concentration to drive rate

type Enz

type Enz struct {

	// S+E forward rate constant, in μM-1 msec-1
	K1 float64 `desc:"S+E forward rate constant, in μM-1 msec-1"`

	// SE backward rate constant, in μM-1 msec-1
	K2 float64 `desc:"SE backward rate constant, in μM-1 msec-1"`

	// SE -> P + E catalyzed rate constant, in μM-1 msec-1
	K3 float64 `desc:"SE -> P + E catalyzed rate constant, in μM-1 msec-1"`

	// Michaelis constant = (K2 + K3) / K1
	Km float64 `inactive:"+" desc:"Michaelis constant = (K2 + K3) / K1"`
}

Enz models an enzyme-catalyzed reaction based on the Michaelis-Menten kinetics that transforms S = substrate into P product via SE-bound C complex

K1         K3

S + E --> C(SE) ---> P + E

<-- K2

S = substrate, E = enzyme, C = SE complex, P = product The source K constants are in terms of concentrations μM-1 and sec-1 but calculations take place using N's, and the forward direction has two factors while reverse only has one, so a corrective volume factor needs to be divided out to set the actual forward factor.

func (*Enz) Set

func (rt *Enz) Set(k1, k2, k3 float64)

Set sets time constants in seconds directly

func (*Enz) SetKm

func (rt *Enz) SetKm(km, k2, k3 float64)

SetKm sets time constants in seconds using Km, K2, K3

func (*Enz) SetKmVol

func (rt *Enz) SetKmVol(km, vol, k2, k3 float64)

SetKmVol sets time constants in seconds using Km, K2, K3 dividing forward K1 by volume to compensate for 2 volume-based concentrations occurring in forward component (s * e), vs just 1 in back

func (*Enz) Step

func (rt *Enz) Step(cs, ce, cc, cp float64, ds, de, dc, dp *float64)

Step computes delta values based on current S, E, C, and P values

func (*Enz) StepK

func (rt *Enz) StepK(kf, cs, ce, cc, cp float64, ds, de, dc, dp *float64)

StepK computes delta values based on current S, E, C, and P values K version has additional rate multiplier for Kf = K1

func (*Enz) Update

func (rt *Enz) Update()

type EnzRate added in v1.1.47

type EnzRate struct {

	// S+E forward rate constant, in μM-1 msec-1
	K1 float64 `desc:"S+E forward rate constant, in μM-1 msec-1"`

	// SE backward rate constant, in μM-1 msec-1
	K2 float64 `desc:"SE backward rate constant, in μM-1 msec-1"`

	// SE -> P + E catalyzed rate constant, in μM-1 msec-1
	K3 float64 `desc:"SE -> P + E catalyzed rate constant, in μM-1 msec-1"`

	// Michaelis constant = (K2 + K3) / K1 -- goes into the rate
	Km float64 `inactive:"+" desc:"Michaelis constant = (K2 + K3) / K1 -- goes into the rate"`
}

EnzRate models an enzyme-catalyzed reaction based on the Michaelis-Menten kinetics that transforms S = substrate into P product via SE bound C complex

K1         K3

S + E --> C(SE) ---> P + E

<-- K2

S = substrate, E = enzyme, C = SE complex, P = product This version does NOT consume the E enzyme or directly use the C complex as an accumulated factor: instead it directly computes an overall rate for the end-to-end S <-> P reaction based on the K constants: rate = S * E * K3 / (S + Km) This amount is added to the P and subtracted from the S, and recorded in the C complex variable as rate / K3 -- it is just directly set. In some situations this C variable can be used for other things. The source K constants are in terms of concentrations μM-1 and sec-1 but calculations take place using N's, and the forward direction has two factors while reverse only has one, so a corrective volume factor needs to be divided out to set the actual forward factor.

func (*EnzRate) Set added in v1.1.47

func (rt *EnzRate) Set(k1, k2, k3 float64)

Set sets time constants in seconds directly

func (*EnzRate) SetKm added in v1.1.47

func (rt *EnzRate) SetKm(km, k2, k3 float64)

SetKm sets time constants in seconds using Km, K2, K3

func (*EnzRate) SetKmVol added in v1.1.47

func (rt *EnzRate) SetKmVol(km, vol, k2, k3 float64)

SetKmVol sets time constants in seconds using Km, K2, K3 dividing forward K1 by volume to compensate for 2 volume-based concentrations occurring in forward component (s * e), vs just 1 in back

func (*EnzRate) Step added in v1.1.47

func (rt *EnzRate) Step(cs, ce float64, ds, dp, cc *float64)

Step computes delta values based on current S, E values, setting dS, dP and C = rate

func (*EnzRate) StepK added in v1.1.47

func (rt *EnzRate) StepK(kf, cs, ce float64, ds, dp, cc *float64)

Step computes delta values based on current S, E values, setting dS, dP and C = rate K version has additional rate multiplier for Kf = K1

func (*EnzRate) Update added in v1.1.47

func (rt *EnzRate) Update()

type Paramer added in v1.1.48

type Paramer interface {
	// Defaults sets default parameters
	Defaults()

	// Step computes deltas d based on current values c
	Step(c, d Paramer)
}

The Paramer interface defines functions implemented for Params structures, containing chem React, Enz, etc functions. This interface is largely for documentation purposes.

type React

type React struct {

	// forward rate constant for N / sec assuming 2 forward factors
	Kf float64 `desc:"forward rate constant for N / sec assuming 2 forward factors"`

	// backward rate constant for N / sec assuming 1 backward factor
	Kb float64 `desc:"backward rate constant for N / sec assuming 1 backward factor"`
}

React models a basic chemical reaction:

Kf

A + B --> AB

<-- Kb

where Kf is the forward and Kb is the backward time constant. The source Kf and Kb constants are in terms of concentrations μM-1 and sec-1 but calculations take place using N's, and the forward direction has two factors while reverse only has one, so a corrective volume factor needs to be divided out to set the actual forward factor.

func (*React) Set

func (rt *React) Set(f, b float64)

Set sets reaction forward / backward time constants in seconds

func (*React) SetVol

func (rt *React) SetVol(f, vol, b float64)

SetVol sets reaction forward / backward time constants in seconds, dividing forward Kf by volume to compensate for 2 volume-based concentrations occurring in forward component, vs just 1 in back

func (*React) Step

func (rt *React) Step(ca, cb, cab float64, da, db, dab *float64)

Step computes delta A, B, AB values based on current A, B, and AB values

func (*React) StepCB added in v1.1.51

func (rt *React) StepCB(ca, cb, cab float64, da, dab *float64)

StepCB computes delta A, AB values based on current A, B, and AB values assumes B does not change -- does not compute db

func (*React) StepK

func (rt *React) StepK(kf, ca, cb, cab float64, da, db, dab *float64)

StepK computes delta A, B, AB values based on current A, B, and AB values K version has additional rate multiplier for Kf

type SimpleEnz

type SimpleEnz struct {

	// S->P forward rate constant, in μM-1 msec-1
	Kf float64 `desc:"S->P forward rate constant, in μM-1 msec-1"`
}

SimpleEnz models a simple enzyme-catalyzed reaction that transforms S = substrate into P product via E which is not consumed assuming there is much more E than S and P -- E effectively acts as a rate constant multiplier

Kf*E

S ----> P

S = substrate, E = enzyme, P = product, Kf is the rate of the reaction

func (*SimpleEnz) SetVol added in v1.1.47

func (rt *SimpleEnz) SetVol(f, vol float64)

SetVol sets reaction forward / backward time constants in seconds, dividing forward Kf by volume to compensate for 2 volume-based concentrations occurring in forward component, vs just 1 in back

func (*SimpleEnz) Step

func (rt *SimpleEnz) Step(cs, ce float64, ds, dp *float64)

Step computes delta S and P values based on current S, E values

func (*SimpleEnz) StepCo added in v1.1.47

func (rt *SimpleEnz) StepCo(cs, ce, vol float64, ds, dp *float64)

StepCo computes delta S and P values based on current S, E values based on concentration

func (*SimpleEnz) StepK added in v1.1.47

func (rt *SimpleEnz) StepK(kf, cs, ce float64, ds, dp *float64)

StepK computes delta S and P values based on current S, E values K version has additional rate multiplier for Kf

type Stater added in v1.1.48

type Stater interface {
	// Init Initializes the state to starting default values (concentrations)
	Init()

	// Zero sets all state variables to zero -- called for deltas after integration
	Zero()

	// Integrate is called with the deltas -- each state value calls Integrate()
	// to update from deltas.
	Integrate(d Stater)

	// Log records relevant state variables in given table at given row
	Log(dt *etable.Table, row int)

	// ConfigLog configures the table Schema to add column(s) for what is logged
	ConfigLog(sch *etable.Schema)
}

The Stater interface defines the functions implemented for State structures containing chem state variables. This interface is largely for documentation purposes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL