def run_reaction_production_check(self, model, solver, threshold,<EOL>implicit_sinks=True):
prob = solver.create_problem()<EOL>v = prob.namespace()<EOL>for reaction_id in model.reactions:<EOL><INDENT>lower, upper = model.limits[reaction_id]<EOL>v.define([reaction_id], lower=lower, upper=upper)<EOL><DEDENT>massbalance_lhs = {compound: <NUM_LIT:0> for compound in model.compounds}<EOL>for spec, value in iteritems(model.matrix):<EOL><INDENT>compound, reaction_id = spec<EOL>massbalance_lhs[compound] += v(reaction_id) * value<EOL><DEDENT>for compound, lhs in iteritems(massbalance_lhs):<EOL><INDENT>if implicit_sinks:<EOL><INDENT>prob.add_linear_constraints(lhs >= <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>prob.add_linear_constraints(lhs == <NUM_LIT:0>)<EOL><DEDENT><DEDENT>confirmed_production = set()<EOL>for reaction in model.reactions:<EOL><INDENT>if all(c in confirmed_production for c, _ in<EOL>model.get_reaction_values(reaction)):<EOL><INDENT>continue<EOL><DEDENT>prob.set_objective(v(reaction))<EOL>for sense in (lp.ObjectiveSense.Maximize,<EOL>lp.ObjectiveSense.Minimize):<EOL><INDENT>try:<EOL><INDENT>result = prob.solve(sense)<EOL><DEDENT>except lp.SolverError as e:<EOL><INDENT>self.fail(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(compound, reaction, e))<EOL><DEDENT>flux = result.get_value(v(reaction))<EOL>for compound, value in model.get_reaction_values(reaction):<EOL><INDENT>if compound in confirmed_production:<EOL><INDENT>continue<EOL><DEDENT>production = <NUM_LIT:0><EOL>if sense == lp.ObjectiveSense.Maximize and flux > <NUM_LIT:0>:<EOL><INDENT>production = float(value) * flux<EOL><DEDENT>elif sense == lp.ObjectiveSense.Minimize and flux < <NUM_LIT:0>:<EOL><INDENT>production = float(value) * flux<EOL><DEDENT>if production >= threshold:<EOL><INDENT>confirmed_production.add(compound)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for compound in sorted(model.compounds):<EOL><INDENT>if compound not in confirmed_production:<EOL><INDENT>yield compound<EOL><DEDENT><DEDENT>
Run reaction production check method.