1 import logging
2 logger = logging.getLogger('ReactionNetworks.Components')
3
4 import sets
5
6 import SloppyCell.ExprManip as ExprManip
7
8
9
10
11
13 - def __init__(self, id, variables, math, name = ''):
14 self.id = id
15 self.variables = variables
16 self.math = math
17 self.name = name
18
20 return self.__class__ == other.__class__ and \
21 (self.__dict__ == other.__dict__)
22
24 return not (self == other)
25
27 - def __init__(self, id, value,
28 name, typicalValue,
29 is_constant, is_optimizable):
30
31 if typicalValue is None:
32 if value and not isinstance(value, str):
33 typicalValue = abs(value)
34 else:
35 typicalValue = 1
36
37 self.id, self.name = id, name
38 self.value, self.initialValue = value, value
39 self.typicalValue = typicalValue
40 self.is_constant, self.is_optimizable = is_constant, is_optimizable
41
43 return self.__class__ == other.__class__ and \
44 (self.__dict__ == other.__dict__)
45
47 - def __init__(self, id, initial_size, name, typical_value,
48 is_constant, is_optimizable):
49 Variable.__init__(self, id, initial_size, name, typical_value,
50 is_constant, is_optimizable)
51
53 - def __init__(self, id, compartment, initial_conc,
54 name, typical_value,
55 is_boundary_condition,
56 is_constant, is_optimizable, uniprot_ids=set()):
57 self.compartment = compartment
58 self.is_boundary_condition = is_boundary_condition
59 self.uniprot_ids = uniprot_ids
60
61 Variable.__init__(self, id, initial_conc,
62 name, typical_value,
63 is_constant, is_optimizable)
64
66 - def __init__(self, id, value, name,
67 is_constant, typical_value, is_optimizable):
68 Variable.__init__(self, id, value,
69 name, typical_value,
70 is_constant, is_optimizable)
71
73 - def __init__(self, id, trigger, event_assignments, delay, name,
74 buffer):
75 self.id, self.name = id, name
76 self.delay = delay
77 self.is_terminal = (len(event_assignments) > 0)
78
79 self.timeTriggered = False
80 self.parseTrigger(trigger)
81
82 self.event_assignments = event_assignments
83 self.new_values = {}
84
85 self.buffer=buffer
86 if (self.buffer > 0 and self.delay != 0):
87 logger.warn('Event %s has buffer > 0 and delay != 0. This case '
88 'has not been tested.')
89
90
92
93
94
95 attrs_to_compare = ['__class__', 'id', 'trigger', 'event_assignments',
96 'delay', 'name']
97 for attr in attrs_to_compare:
98 if getattr(self, attr) != getattr(other, attr):
99 return False
100 return True
101
103 return not (self == other)
104
106 if '<' in trigger or '>' in trigger or '=' in trigger:
107 raise ValueError('Event triggers must use the functions gt and lt, '
108 'rather than the symbols > and <. For example, '
109 'to trigger when B becomes less than A, use '
110 'lt(B,A).')
111
112
113
114
115
116 trigger = trigger.replace('and(', 'and_func(')
117
118 self.trigger = trigger
119
120 if ExprManip.extract_vars(trigger) == sets.Set(['time']):
121 self.timeTriggered = True
122 ast = ExprManip.AST.strip_parse(trigger)
123 firstArg = ExprManip.AST.ast2str(ast.args[0])
124 secondArg = ExprManip.AST.ast2str(ast.args[1])
125
126 if firstArg == 'time':
127 self.triggeringTime = eval(secondArg)
128 elif secondArg == 'time':
129 self.triggeringTime = eval(firstArg)
130 else:
131 raise 'Problem in time triggered events'
132
134 - def __init__(self, id, trigger, message, name):
135 self.id, self.name = id, name
136 self.delay = 0.0
137 self.is_terminal = True
138 self.event_assignments = {}
139 self.message = message
140
141 self.timeTriggered = False
142 self.parseTrigger(trigger)
143 self.buffer=0.0
144
145
146
147
148
149
150
153