def parse_reaction_equation(equation_def, default_compartment):
def parse_compound_list(l, compartment):<EOL><INDENT>"""<STR_LIT>"""<EOL>for compound_def in l:<EOL><INDENT>compound_id = compound_def.get('<STR_LIT:id>')<EOL>_check_id(compound_id, '<STR_LIT>')<EOL>value = compound_def.get('<STR_LIT:value>')<EOL>if value is None:<EOL><INDENT>raise ParseError('<STR_LIT>'.format(<EOL>compound_id))<EOL><DEDENT>compound_compartment = compound_def.get('<STR_LIT>')<EOL>if compound_compartment is None:<EOL><INDENT>compound_compartment = compartment<EOL><DEDENT>compound = Compound(compound_id, compartment=compound_compartment)<EOL>yield compound, value<EOL><DEDENT><DEDENT>if isinstance(equation_def, string_types):<EOL><INDENT>return parse_reaction_equation_string(<EOL>equation_def, default_compartment)<EOL><DEDENT>else:<EOL><INDENT>compartment = equation_def.get('<STR_LIT>', default_compartment)<EOL>reversible = bool(equation_def.get('<STR_LIT>', True))<EOL>left = equation_def.get('<STR_LIT:left>', [])<EOL>right = equation_def.get('<STR_LIT:right>', [])<EOL>if len(left) == <NUM_LIT:0> and len(right) == <NUM_LIT:0>:<EOL><INDENT>raise ParseError('<STR_LIT>')<EOL><DEDENT>return Reaction(Direction.Both if reversible else Direction.Forward,<EOL>parse_compound_list(left, compartment),<EOL>parse_compound_list(right, compartment))<EOL><DEDENT>
Parse a structured reaction equation as obtained from a YAML file

    Returns a Reaction.