Parse a structured exchange definition as obtained from a YAML file.

    Returns in iterator of compound, reaction, lower and upper bounds.

def parse_exchange(exchange_def, default_compartment):
    """Parse a structured exchange definition as obtained from a YAML file.

    Returns in iterator of compound, reaction, lower and upper bounds.
    """

    default_compartment = exchange_def.get('compartment', default_compartment)

    for compound_def in exchange_def.get('compounds', []):
        compartment = compound_def.get('compartment', default_compartment)
        compound = Compound(compound_def['id'], compartment=compartment)
        reaction = compound_def.get('reaction')
        lower, upper = get_limits(compound_def)
        yield compound, reaction, lower, upper