def parse_reaction_equation_string(equation, default_compartment):
    """Parse a string representation of a reaction equation.

    Converts undefined compartments to the default compartment.
    """
    def _translate_compartments(reaction, compartment):
        """Translate compound with missing compartments.

        These compounds will have the specified compartment in the output.
        """
        left = (((c.in_compartment(compartment), v)
                 if c.compartment is None else (c, v))
                for c, v in reaction.left)
        right = (((c.in_compartment(compartment), v)
                  if c.compartment is None else (c, v))
                 for c, v in reaction.right)
        return Reaction(reaction.direction, left, right)

    eq = _REACTION_PARSER.parse(equation).normalized()
    return _translate_compartments(eq, default_compartment)
def parse_reaction_equation_string ( equation , default_compartment ) : def _translate_compartments ( reaction , compartment ) : left = ( ( ( c . in_compartment ( compartment ) , v ) if c . compartment is None else ( c , v ) ) for c , v in reaction . left ) right = ( ( ( c . in_compartment ( compartment ) , v ) if c . compartment is None else ( c , v ) ) for c , v in reaction . right ) return Reaction ( reaction . direction , left , right ) eq = _REACTION_PARSER . parse ( equation ) . normalized ( ) return _translate_compartments ( eq , default_compartment )
Parse a string representation of a reaction equation.

    Converts undefined compartments to the default compartment.