def run(self):
<EOL>def compound_name(id):<EOL><INDENT>if id not in self._model.compounds:<EOL><INDENT>return id<EOL><DEDENT>return self._model.compounds[id].properties.get('<STR_LIT:name>', id)<EOL><DEDENT>reaction = self._get_objective()<EOL>if not self._mm.has_reaction(reaction):<EOL><INDENT>self.fail(<EOL>'<STR_LIT>'.format(reaction))<EOL><DEDENT>loop_removal = self._get_loop_removal_option()<EOL>enable_tfba = loop_removal == '<STR_LIT>'<EOL>if enable_tfba:<EOL><INDENT>solver = self._get_solver(integer=True)<EOL><DEDENT>else:<EOL><INDENT>solver = self._get_solver()<EOL><DEDENT>start_time = time.time()<EOL>try:<EOL><INDENT>fba_fluxes = dict(fluxanalysis.flux_balance(<EOL>self._mm, reaction, tfba=False, solver=solver))<EOL><DEDENT>except fluxanalysis.FluxBalanceError as e:<EOL><INDENT>self.report_flux_balance_error(e)<EOL><DEDENT>threshold = self._args.threshold<EOL>if threshold.relative:<EOL><INDENT>threshold.reference = fba_fluxes[reaction]<EOL><DEDENT>logger.info('<STR_LIT>'.format(<EOL>threshold))<EOL>handler_args = (<EOL>self._mm, solver, enable_tfba, float(threshold), reaction)<EOL>executor = self._create_executor(<EOL>FVATaskHandler, handler_args, cpus_per_worker=<NUM_LIT:2>)<EOL>def iter_results():<EOL><INDENT>results = {}<EOL>with executor:<EOL><INDENT>for (reaction_id, direction), value in executor.imap_unordered(<EOL>product(self._mm.reactions, (<NUM_LIT:1>, -<NUM_LIT:1>)), <NUM_LIT:16>):<EOL><INDENT>if reaction_id not in results:<EOL><INDENT>results[reaction_id] = value<EOL>continue<EOL><DEDENT>other_value = results[reaction_id]<EOL>if direction == -<NUM_LIT:1>:<EOL><INDENT>bounds = value, other_value<EOL><DEDENT>else:<EOL><INDENT>bounds = other_value, value<EOL><DEDENT>yield reaction_id, bounds<EOL><DEDENT><DEDENT>executor.join()<EOL><DEDENT>for reaction_id, (lower, upper) in iter_results():<EOL><INDENT>rx = self._mm.get_reaction(reaction_id)<EOL>rxt = rx.translated_compounds(compound_name)<EOL>print('<STR_LIT>'.format(reaction_id, lower, upper, rxt))<EOL><DEDENT>logger.info('<STR_LIT>'.format(<EOL>time.time() - start_time))<EOL>
Run flux variability command