def __init__(self, name, reactants, products, rate):
SelfExporter.__init__(self, name)
if isinstance(reactants, MonomerPattern):
reactants = [reactants]
if isinstance(products, MonomerPattern):
products = [products]
if not all([isinstance(r, MonomerPattern) for r in reactants]):
After Change
// FIXME: This tuple thing is ugly (used to support >> and <> operators between ReactionPatterns).
// This is how the reactant and product ReactionPatterns are passed, along with is_reversible.
if not isinstance(reaction_pattern_set, tuple) and len(reaction_pattern_set) != 3:
raise Exception("reaction_pattern_set must be a tuple of (ReactionPattern, ReactionPattern, Boolean)")
try:
reactant_pattern = as_reaction_pattern(reaction_pattern_set[0])
except InvalidReactionPatternException as e:
raise type(e)("Reactant does not look like a reaction pattern")
try:
product_pattern = as_reaction_pattern(reaction_pattern_set[1])
except InvalidReactionPatternException as e:
raise type(e)("Product does not look like a reaction pattern")
self.is_reversible = reaction_pattern_set[2]
if not isinstance(rate_forward, Parameter):
raise Exception("Forward rate must be a Parameter")
if self.is_reversible and not isinstance(rate_reverse, Parameter):
raise Exception("Reverse rate must be a Parameter")
self.reactant_pattern = reactant_pattern
self.product_pattern = product_pattern
self.rate_forward = rate_forward
self.rate_reverse = rate_reverse
// TODO: ensure all numbered sites are referenced exactly twice within each of reactants and products
def __repr__(self):
ret = "%s(name=%s, reactants=%s, products=%s, rate_forward=%s" % \