def create_extended_model(model, db_penalty=None, ex_penalty=None,<EOL>tp_penalty=None, penalties=None):
<EOL>model_extended = model.create_metabolic_model()<EOL>extra_compartment = model.extracellular_compartment<EOL>compartment_ids = set(c.id for c in model.compartments)<EOL>if len(compartment_ids) > <NUM_LIT:0>:<EOL><INDENT>logger.info(<EOL>'<STR_LIT>'.format(<EOL>'<STR_LIT:U+002CU+0020>'.join('<STR_LIT:{}>'.format(c) for c in compartment_ids)))<EOL>db_added = add_all_database_reactions(model_extended, compartment_ids)<EOL><DEDENT>else:<EOL><INDENT>logger.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>db_added = set()<EOL><DEDENT>logger.info(<EOL>'<STR_LIT>'.format(<EOL>extra_compartment))<EOL>ex_added = add_all_exchange_reactions(<EOL>model_extended, extra_compartment, allow_duplicates=True)<EOL>boundaries = model.compartment_boundaries<EOL>if len(boundaries) > <NUM_LIT:0>:<EOL><INDENT>logger.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>'<STR_LIT>'.join('<STR_LIT>'.format(c1, c2) for c1, c2 in boundaries)))<EOL>tp_added = add_all_transport_reactions(<EOL>model_extended, boundaries, allow_duplicates=True)<EOL><DEDENT>else:<EOL><INDENT>logger.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>tp_added = set()<EOL><DEDENT>weights = {}<EOL>if db_penalty is not None:<EOL><INDENT>weights.update((rxnid, db_penalty) for rxnid in db_added)<EOL><DEDENT>if tp_penalty is not None:<EOL><INDENT>weights.update((rxnid, tp_penalty) for rxnid in tp_added)<EOL><DEDENT>if ex_penalty is not None:<EOL><INDENT>weights.update((rxnid, ex_penalty) for rxnid in ex_added)<EOL><DEDENT>if penalties is not None:<EOL><INDENT>for rxnid, penalty in iteritems(penalties):<EOL><INDENT>weights[rxnid] = penalty<EOL><DEDENT><DEDENT>return model_extended, weights<EOL>
Create an extended model for gap-filling.

    Create a :class:`psamm.metabolicmodel.MetabolicModel` with
    all reactions added (the reaction database in the model is taken
    to be the universal database) and also with artificial exchange
    and transport reactions added. Return the extended
    :class:`psamm.metabolicmodel.MetabolicModel`
    and a weight dictionary for added reactions in that model.

    Args:
        model: :class:`psamm.datasource.native.NativeModel`.
        db_penalty: penalty score for database reactions, default is `None`.
        ex_penalty: penalty score for exchange reactions, default is `None`.
        tb_penalty: penalty score for transport reactions, default is `None`.
        penalties: a dictionary of penalty scores for database reactions.