def reaction_charge(reaction, compound_charge):
    """Calculate the overall charge for the specified reaction.

    Args:
        reaction: :class:`psamm.reaction.Reaction`.
        compound_charge: a map from each compound to charge values.
    """
    charge_sum = 0.0
    for compound, value in reaction.compounds:
        charge = compound_charge.get(compound.name, float('nan'))
        charge_sum += charge * float(value)
    return charge_sum
