Package SloppyCell :: Package ReactionNetworks :: Module Reactions
[hide private]

Source Code for Module SloppyCell.ReactionNetworks.Reactions

  1  import sets 
  2  import SloppyCell.ExprManip as ExprManip 
  3   
4 -class Reaction:
5 - def __init__(self, id, stoichiometry, kineticLaw = '', name = '', 6 reactant_stoichiometry = None, product_stoichiometry = None):
7 self.id = id 8 self.stoichiometry = stoichiometry 9 # self.reactant_stoichiometry and self.product_stoichiometry 10 # are defined to help repserve the stoichiometry defined in an 11 # SBML model 12 self.reactant_stoichiometry = reactant_stoichiometry 13 self.product_stoichiometry = product_stoichiometry 14 self.kineticLaw = kineticLaw 15 self.name = name 16 17 variables = ExprManip.extract_vars(kineticLaw) 18 self.parameters = variables.difference(sets.Set(stoichiometry.keys()))
19
20 - def __eq__(self, other):
21 return self.__class__ == other.__class__ and \ 22 self.kineticLaw == other.kineticLaw and \ 23 self.stoichiometry == other.stoichiometry
24
25 - def __ne__(self, other):
26 return not (self == other)
27
28 - def doKwargsSubstitution(self, kwargs):
29 oldStoichiometry = self.stoichiometry 30 self.stoichiometry = {} 31 for base in oldStoichiometry: 32 self.stoichiometry[kwargs[base]] = oldStoichiometry[base] 33 34 self.kineticLaw = ExprManip.sub_for_vars(self.kineticLaw, kwargs)
35
36 - def change_stoichiometry(self, species, stoich):
37 """ 38 Change stoichiometry will update self.stoichiometry. 39 It also updates self.reactant_stoichiometry and self.product_stoichiometry, 40 if they are defined, to keep the two stoichiometry tracking systems in sync. 41 """ 42 self.stoichiometry[species] = stoich 43 if self.reactant_stoichiometry != None and self.product_stoichiometry != None: 44 if species in self.reactant_stoichiometry.keys(): 45 del self.reactant_stoichiometry[species] 46 self.product_stoichiometry[species] = [stoich]
47 48
49 -class HomodimerizationReaction(Reaction):
50 - def __init__(self, id, **kwargs):
51 self.kineticLaw = 'rate * reactant**2' 52 self.stoichiometry = {'reactant': -2, 53 'dimer': +1} 54 self.doKwargsSubstitution(kwargs) 55 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
56
57 -class HeterodimerizationReaction(Reaction):
58 - def __init__(self, id, **kwargs):
59 self.kineticLaw = 'rate * A * B' 60 self.stoichiometry = {'A': -1, 61 'B': -1, 62 'dimer': +1} 63 self.doKwargsSubstitution(kwargs) 64 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
65
66 -class HomodimerDissociationReaction(Reaction):
67 - def __init__(self, id, **kwargs):
68 self.kineticLaw = 'rate * dimer' 69 self.stoichiometry = {'reactant': +2, 70 'dimer': -1} 71 self.doKwargsSubstitution(kwargs) 72 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
73
74 -class HeterodimerDissociationReaction(Reaction):
75 - def __init__(self, id, **kwargs):
76 self.kineticLaw = 'rate * dimer' 77 self.stoichiometry = {'A': +1, 78 'B': +1, 79 'dimer': -1} 80 self.doKwargsSubstitution(kwargs) 81 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
82
83 -class ExponentialDecayReaction(Reaction):
84 - def __init__(self, id, **kwargs):
85 self.kineticLaw = 'rate * species' 86 self.stoichiometry = {'species': -1} 87 self.doKwargsSubstitution(kwargs) 88 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
89
90 -class MichaelisMentenReaction(Reaction):
91 - def __init__(self, id, **kwargs):
92 self.kineticLaw = 'k * E * S / (S + Km)' 93 self.stoichiometry = {'E': 0, 94 'S': -1, 95 'P': 1} 96 self.doKwargsSubstitution(kwargs) 97 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
98
99 -class ConstructionReaction(Reaction):
100 - def __init__(self, id, **kwargs):
101 self.kineticLaw = 'rate * template' 102 self.stoichiometry = {'product': 1, 103 'template': 0} 104 self.doKwargsSubstitution(kwargs) 105 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
106
107 -class TransformationReaction(Reaction):
108 - def __init__(self, id, **kwargs):
109 self.kineticLaw = 'rate * old' 110 self.stoichiometry = {'old': -1, 111 'new': +1} 112 self.doKwargsSubstitution(kwargs) 113 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
114
115 -class ProductionReaction(Reaction):
116 - def __init__(self, id, **kwargs):
117 self.kineticLaw = 'rate' 118 self.stoichiometry = {'product': 1} 119 self.doKwargsSubstitution(kwargs) 120 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
121
122 -class PromoterReaction(Reaction):
123 - def __init__(self, id, **kwargs):
124 self.kineticLaw = 'vmax * kP * P / (kP * P + ((kR1 * R1)**h) + ((kR2 * R2)**h) + 1.0)' 125 self.stoichiometry = {'P': 0, 126 'R1': 0, 127 'R2': 0, 128 'mRNA': +1} 129 self.doKwargsSubstitution(kwargs) 130 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
131
132 -class CoPromoterReaction(Reaction):
133 - def __init__(self, id, **kwargs):
134 self.kineticLaw = 'vmax * (kP1 + kP2_1 * P) / (kP1 + kP2_2 * P + ((kR1 * R1 / (1 + kR2 * R2))**h) + 1.0)' 135 self.stoichiometry = {'P': 0, 136 'R1': 0, 137 'R2': 0, 138 'mRNA': +1} 139 self.doKwargsSubstitution(kwargs) 140 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
141
142 -class MichaelisMentenDegradationReaction(Reaction):
143 - def __init__(self, id, **kwargs):
144 self.kineticLaw = 'k * S / (S + Km)' 145 self.stoichiometry = {'S': -1} 146 self.doKwargsSubstitution(kwargs) 147 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
148
149 -class SelfCatalyticMichaelisMentenReaction(Reaction):
150 - def __init__(self, id, **kwargs):
151 self.kineticLaw = 'k * S / (S + Km)' 152 self.stoichiometry = {'S': -1, 153 'P': +1} 154 self.doKwargsSubstitution(kwargs) 155 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
156
157 -class FirstOrderReaction(Reaction):
158 - def __init__(self, id, **kwargs):
159 self.kineticLaw = 'rate * reactant' 160 self.stoichiometry = {'product': 1, 161 'reactant': -1} 162 self.doKwargsSubstitution(kwargs) 163 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
164
165 -class TwoProductFirstOrderReaction(Reaction):
166 - def __init__(self, id, **kwargs):
167 self.kineticLaw = 'rate * reactant' 168 self.stoichiometry = {'product_1': 1, 169 'product_2': 1, 170 'reactant': -1} 171 self.doKwargsSubstitution(kwargs) 172 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
173
174 -class SecondOrderReaction(Reaction):
175 - def __init__(self, id, **kwargs):
176 self.kineticLaw = 'rate * reactant_1 * reactant_2' 177 self.stoichiometry = {'product': 1, 178 'reactant_1': -1, 179 'reactant_2': -1} 180 self.doKwargsSubstitution(kwargs) 181 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
182
183 -class HillDegradationReaction(Reaction):
184 - def __init__(self, id, **kwargs):
185 self.kineticLaw = 'vmax * (S**h) / ((Km**h) + (S**h))' 186 self.stoichiometry = {'S': -1} 187 self.doKwargsSubstitution(kwargs) 188 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
189
190 -class HillTransportReaction(Reaction):
191 - def __init__(self, id, **kwargs):
192 self.kineticLaw = 'vmax * (S**h) / ((Km**h) + (S**h))' 193 self.stoichiometry = {'S': -1, 194 'P': +1} 195 self.doKwargsSubstitution(kwargs) 196 Reaction.__init__(self, id, self.stoichiometry, self.kineticLaw)
197