def create_convert_sbml_id_function(
        compartment_prefix='C_', reaction_prefix='R_',
        compound_prefix='M_', decode_id=entry_id_from_cobra_encoding):
    """Create function for converting SBML IDs.

    The returned function will strip prefixes, decode the ID using the provided
    function. These prefixes are common on IDs in SBML models because the IDs
    live in a global namespace.
    """
    def convert_sbml_id(entry):
        if isinstance(entry, BaseCompartmentEntry):
            prefix = compartment_prefix
        elif isinstance(entry, BaseReactionEntry):
            prefix = reaction_prefix
        elif isinstance(entry, BaseCompoundEntry):
            prefix = compound_prefix

        new_id = entry.id
        if decode_id is not None:
            new_id = decode_id(new_id)
        if prefix is not None and new_id.startswith(prefix):
            new_id = new_id[len(prefix):]

        return new_id

    return convert_sbml_id
def create_convert_sbml_id_function ( compartment_prefix = 'C_' , reaction_prefix = 'R_' , compound_prefix = 'M_' , decode_id = entry_id_from_cobra_encoding ) : def convert_sbml_id ( entry ) : if isinstance ( entry , BaseCompartmentEntry ) : prefix = compartment_prefix elif isinstance ( entry , BaseReactionEntry ) : prefix = reaction_prefix elif isinstance ( entry , BaseCompoundEntry ) : prefix = compound_prefix new_id = entry . id if decode_id is not None : new_id = decode_id ( new_id ) if prefix is not None and new_id . startswith ( prefix ) : new_id = new_id [ len ( prefix ) : ] return new_id return convert_sbml_id
Create function for converting SBML IDs.

    The returned function will strip prefixes, decode the ID using the provided
    function. These prefixes are common on IDs in SBML models because the IDs
    live in a global namespace.