Ab initio computation of pKa values and redox potentials