def get_default_compartment(model):
    """Return what the default compartment should be set to.

    If some compounds have no compartment, unique compartment
    name is returned to avoid collisions.
    """
    default_compartment = 'c'
    default_key = set()
    for reaction in model.reactions:
        equation = reaction.equation
        if equation is None:
            continue

        for compound, _ in equation.compounds:
            default_key.add(compound.compartment)

    if None in default_key and default_compartment in default_key:
        suffix = 1
        while True:
            new_key = '{}_{}'.format(default_compartment, suffix)
            if new_key not in default_key:
                default_compartment = new_key
                break
            suffix += 1

    if None in default_key:
        logger.warning(
            'Compound(s) found without compartment, default'
            ' compartment is set to {}.'.format(default_compartment))
    return default_compartment
def get_default_compartment ( model ) : default_compartment = 'c' default_key = set ( ) for reaction in model . reactions : equation = reaction . equation if equation is None : continue for compound , _ in equation . compounds : default_key . add ( compound . compartment ) if None in default_key and default_compartment in default_key : suffix = 1 while True : new_key = '{}_{}' . format ( default_compartment , suffix ) if new_key not in default_key : default_compartment = new_key break suffix += 1 if None in default_key : logger . warning ( 'Compound(s) found without compartment, default' ' compartment is set to {}.' . format ( default_compartment ) ) return default_compartment
Return what the default compartment should be set to.

    If some compounds have no compartment, unique compartment
    name is returned to avoid collisions.