def convert_reaction_entry(self, reaction):
d = OrderedDict()<EOL>d['<STR_LIT:id>'] = reaction.id<EOL>def is_equation_valid(equation):<EOL><INDENT>return (equation is not None and (<EOL>not isinstance(equation, Reaction) or<EOL>len(equation.compounds) > <NUM_LIT:0>))<EOL><DEDENT>order = {<EOL>key: i for i, key in enumerate(<EOL>['<STR_LIT:name>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])}<EOL>prop_keys = (set(reaction.properties) -<EOL>{'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'})<EOL>for prop in sorted(prop_keys, key=lambda x: (order.get(x, <NUM_LIT:1000>), x)):<EOL><INDENT>if reaction.properties[prop] is None:<EOL><INDENT>continue<EOL><DEDENT>d[prop] = reaction.properties[prop]<EOL>if prop == '<STR_LIT>' and not is_equation_valid(d[prop]):<EOL><INDENT>del d[prop]<EOL><DEDENT><DEDENT>return d<EOL>
Convert reaction entry to YAML dict.