def test_reduction_potential(self): kegg_id_to_coeff = {'C00036': -1, 'C00149': 1} # oxaloacetate = malate reaction = Reaction(kegg_id_to_coeff) cc = ComponentContribution(pH=7.0, ionic_strength=0.1) E0_prime_mV, E0_uncertainty = cc.E0_prime(reaction) self.assertAlmostEqual(E0_prime_mV, -175.2, 1) self.assertAlmostEqual(E0_uncertainty, 5.3, 1)
try: reaction = Reaction.parse_formula(args.reaction) except ValueError as e: logging.error(str(e)) sys.exit(-1) equilibrator = ComponentContribution(pH=args.ph, ionic_strength=args.i) n_e = reaction.check_half_reaction_balancing() if n_e is None: logging.error('reaction is not chemically balanced') sys.exit(-1) elif n_e == 0: dG0_prime, dG0_uncertainty = equilibrator.dG0_prime(reaction) sys.stdout.write(u'\u0394G\'\u00B0 = %.1f \u00B1 %.1f kJ/mol\n' % (dG0_prime, dG0_uncertainty)) ln_RI = equilibrator.reversibility_index(reaction) sys.stdout.write(u'ln(Reversibility Index) = %.1f\n' % ln_RI) else: # treat as a half-reaction logging.warning('This reaction isn\'t balanced, but can still be treated' ' as a half-reaction') E0_prime_mV, E0_uncertainty = equilibrator.E0_prime(reaction) sys.stdout.write(u'E\'\u00B0 = %.1f \u00B1 %.1f mV\n' % (E0_prime_mV, E0_uncertainty)) sys.stdout.flush() sys.stderr.write(r'* the range represents the 95% confidence interval' ' due to Component Contribution estimation uncertainty\n')