def is_charge_balanced(reaction):
    """Confirm that a reaction is charge balanced."""
    charge = 0
    for metabolite, coefficient in iteritems(reaction.metabolites):
        if metabolite.charge is None:
            return False
        charge += coefficient * metabolite.charge
    return charge == 0
def is_charge_balanced ( reaction ) : charge = 0 for metabolite , coefficient in iteritems ( reaction . metabolites ) : if metabolite . charge is None : return False charge += coefficient * metabolite . charge return charge == 0
Confirm that a reaction is charge balanced.