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>penalties = {}<EOL>if self._args.penalty is not None:<EOL><INDENT>for line in self._args.penalty:<EOL><INDENT>line, _, comment = line.partition('<STR_LIT:#>')<EOL>line = line.strip()<EOL>if line == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>rxnid, penalty = line.split(None, <NUM_LIT:1>)<EOL>penalties[rxnid] = float(penalty)<EOL><DEDENT><DEDENT>core = set(self._mm.reactions)<EOL>solver = self._get_solver(integer=True)<EOL>default_comp = self._model.default_compartment<EOL>epsilon = self._args.epsilon<EOL>v_max = float(self._model.default_flux_limit)<EOL>blocked = set()<EOL>for compound in self._args.compound:<EOL><INDENT>if compound.compartment is None:<EOL><INDENT>compound = compound.in_compartment(default_comp)<EOL><DEDENT>blocked.add(compound)<EOL><DEDENT>if len(blocked) > <NUM_LIT:0>:<EOL><INDENT>logger.info('<STR_LIT>'.format(<EOL>'<STR_LIT:U+002CU+0020>'.join(text_type(c) for c in sorted(blocked))))<EOL><DEDENT>else:<EOL><INDENT>logger.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>blocked = set(self._mm.compounds)<EOL><DEDENT>exclude = set()<EOL>if self._model.biomass_reaction is not None:<EOL><INDENT>exclude.add(self._model.biomass_reaction)<EOL><DEDENT>model_complete, weights = create_extended_model(<EOL>self._model,<EOL>db_penalty=self._args.db_penalty,<EOL>ex_penalty=self._args.ex_penalty,<EOL>tp_penalty=self._args.tp_penalty,<EOL>penalties=penalties)<EOL>implicit_sinks = not self._args.no_implicit_sinks<EOL>logger.info('<STR_LIT>')<EOL>try:<EOL><INDENT>added_reactions, no_bounds_reactions = gapfill(<EOL>model_complete, core, blocked, exclude, solver=solver,<EOL>epsilon=epsilon, v_max=v_max, weights=weights,<EOL>implicit_sinks=implicit_sinks,<EOL>allow_bounds_expansion=self._args.allow_bounds_expansion)<EOL><DEDENT>except GapFillError as e:<EOL><INDENT>self._log_epsilon_and_fail(epsilon, e)<EOL><DEDENT>for reaction_id in sorted(self._mm.reactions):<EOL><INDENT>rx = self._mm.get_reaction(reaction_id)<EOL>rxt = rx.translated_compounds(compound_name)<EOL>print('<STR_LIT>'.format(reaction_id, '<STR_LIT>', <NUM_LIT:0>, rxt))<EOL><DEDENT>for rxnid in sorted(added_reactions):<EOL><INDENT>rx = model_complete.get_reaction(rxnid)<EOL>rxt = rx.translated_compounds(compound_name)<EOL>print('<STR_LIT>'.format(<EOL>rxnid, '<STR_LIT>', weights.get(rxnid, <NUM_LIT:1>), rxt))<EOL><DEDENT>for rxnid in sorted(no_bounds_reactions):<EOL><INDENT>rx = model_complete.get_reaction(rxnid)<EOL>rxt = rx.translated_compounds(compound_name)<EOL>print('<STR_LIT>'.format(<EOL>rxnid, '<STR_LIT>', weights.get(rxnid, <NUM_LIT:1>), rxt))<EOL><DEDENT>
Run GapFill command