Skip to content

Instantly share code, notes, and snippets.

@kozo2
Created November 21, 2011 09:35
Show Gist options
  • Save kozo2/1382152 to your computer and use it in GitHub Desktop.
Save kozo2/1382152 to your computer and use it in GitHub Desktop.
mm.py
class MassActionFluxProcess:
def __init__(self, k_value, volume, reactants):
self.volume = volume
self.k_value = k_value
self.reactants = reactants
self.N_A = 6.0221367e+23
def __call__(self, variable_array, time):
velocity = self.k_value * self.volume * self.N_A
for r in self.reactants:
coefficient = r['coef']
value = variable_array[r['id']]
while coefficient > 0:
velocity *= value / (self.volume * self.N_A)
coefficient -= 1
return velocity
def __str__(self):
retval = 'MassAction('
retval += 'k=%f, ' % self.k_value
retval += 'reactants=%s' % self.reactants
retval += ')'
return retval
class MichaelisMentenFluxProcess:
def __init__(self, KcR, KcF, KmS, KmP, volume, substrate, product, effector):
self.volume = volume
self.KcF = KcF
self.KmS = KmS
self.kmP = KmP
KmSP = KmS * KmP
self.substrate = substrate
self.product = product
self.catalysts = effector
def __fire__(self, time):
self.KmP_S = KmP * conc(self.substrate)
self.KmS_P = KmS * conc(self.product)
velocity = KcF * KmP_S
velocity -= KcR * KmS_P
velocity *= conc(self.catalysts)
velocity /= KmS_P + KmP_S + KmSP
return velocity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment