def model_exchange(model):
<EOL>lower_default, upper_default = None, None<EOL>if model.default_flux_limit is not None:<EOL><INDENT>lower_default = -model.default_flux_limit<EOL>upper_default = model.default_flux_limit<EOL><DEDENT>compounds = []<EOL>for compound, reaction_id, lower, upper in sorted(<EOL>itervalues(model.exchange)):<EOL><INDENT>d = OrderedDict([('<STR_LIT:id>', compound.name)])<EOL>if reaction_id is not None:<EOL><INDENT>d['<STR_LIT>'] = reaction_id<EOL><DEDENT>lower = _get_output_limit(lower, lower_default)<EOL>upper = _get_output_limit(upper, upper_default)<EOL>d.update(_generate_limit_items(lower, upper))<EOL>compounds.append(d)<EOL><DEDENT>return OrderedDict([('<STR_LIT>', compounds)])<EOL>
Return exchange definition as YAML dict.