def extend_exchanges(model, cpd_ids, ex):
    model_exchanges = set(find_boundary_types(model, 'exchange', external_compartment=ex))
    new_ex_ids = set()
    for cpd in cpd_ids:
        cpd = model.metabolites.get_by_id(cpd)
        if (str(cpd.compartment) != ex):
            continue
        elif (bool((set(cpd.reactions) & model_exchanges)) == False):
            try:
                new_id = ('EX_' + cpd.id)
                model.add_boundary(cpd, type='exchange', reaction_id=new_id, lb=(- 1000.0), ub=1000.0)
                new_ex_ids |= set([new_id])
            except ValueError:
                pass
    return new_ex_ids
def extend_exchanges(model, cpd_ids, ex):
    model_exchanges = set(find_boundary_types(model, 'exchange', external_compartment=ex))
    new_ex_ids = set()
    for cpd in cpd_ids:
        cpd = model.metabolites.get_by_id(cpd)
        if (str(cpd.compartment) != ex):
            continue
        elif (bool((set(cpd.reactions) & model_exchanges)) == False):
            try:
                new_id = ('EX_' + cpd.id)
                model.add_boundary(cpd, type='exchange', reaction_id=new_id, lb=(- 1000.0), ub=1000.0)
                new_ex_ids |= set([new_id])
            except ValueError:
                pass
    return new_ex_ids