Calculate the overall charge for all reactions in the model.

    Yield (reaction, charge) pairs.

    Args:
        model: :class:`psamm.datasource.native.NativeModel`.

def charge_balance(model):
    """Calculate the overall charge for all reactions in the model.

    Yield (reaction, charge) pairs.

    Args:
        model: :class:`psamm.datasource.native.NativeModel`.
    """

    compound_charge = {}
    for compound in model.compounds:
        if compound.charge is not None:
            compound_charge[compound.id] = compound.charge

    for reaction in model.reactions:
        charge = reaction_charge(reaction.equation, compound_charge)
        yield reaction, charge