def run(self):
<EOL>solver = self._get_solver()<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>def reaction_key(r):<EOL><INDENT>return r if isinstance(r, tuple) else (r,)<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>model_extended, 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>epsilon = self._args.epsilon<EOL>core = set()<EOL>if self._args.subset is None:<EOL><INDENT>for r in self._mm.reactions:<EOL><INDENT>if not self._mm.is_exchange(r):<EOL><INDENT>core.add(r)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for line in self._args.subset:<EOL><INDENT>line = line.strip()<EOL>if line == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>core.add(line)<EOL><DEDENT><DEDENT>induced = fastgapfill(model_extended, core, weights=weights,<EOL>epsilon=epsilon, solver=solver)<EOL>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(induced, key=reaction_key):<EOL><INDENT>if self._mm.has_reaction(rxnid):<EOL><INDENT>continue<EOL><DEDENT>rx = model_extended.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 FastGapFill command