from nist import Nist import pylab from alberty import Alberty, MissingCompoundFormationEnergy from hatzimanikatis import Hatzi from groups import GroupContribution from thermodynamic_constants import R import logging import sys from toolbox.database import SqliteDatabase from pygibbs.kegg_reaction import Reaction A = Alberty() H = Hatzi() db = SqliteDatabase('../res/gibbs.sqlite') gc = GroupContribution(db) gc.init() nist = Nist() def pH_dependence(): analyze_this_reaction = [] I_mid = [] I_tolerance = [] T_mid = [] T_tolerance = [] analyze_this_reaction += [Reaction(['glucose kinase'], {2:-1, 31:-1, 8:1, 92:1})] I_mid += [0.01] I_tolerance += [0.02] T_mid += [303.1] T_tolerance += [0.1]
from groups import GroupContribution from pygibbs.thermodynamic_constants import R from pylab import log, zeros, pinv, dot, plot, show, figure, NaN, isnan, find import csv from pygibbs.kegg_utils import unparse_reaction_formula from pygibbs.kegg_reaction import Reaction G = GroupContribution(sqlite_name="gibbs.sqlite", html_name="acetogens") G.init() reactions = [] # (RID, EC, sparse-reaction, dG0_r, pH, I, T # Drake 2006 #reactions.append([134, '1.2.1.43', {11:-1, 5:-1, 58:1, 6:1}, 22, 7.0, 0, 300]) reactions.append([ 934, '6.3.4.3', { 101: -1, 58: -1, 2: -1, 8: 1, 9: 1, 234: 1 }, -8, 7.0, 0, 300 ]) reactions.append([1655, '3.5.4.9', {234: -1, 445: 1, 1: 1}, -4, 7.0, 0, 300]) reactions.append( [1220, '1.5.1.5', { 445: -1, 5: -1, 143: 1, 6: 1
for n in range(n_begin, N): (sparse_reaction, pH, I, T, evaluation, dG0_obs) = grad.data[n] n_measurements = min( [nist.cid2count[cid] for cid in sparse_reaction.keys()]) reaction_str = gc.kegg().sparse_reaction_to_string(sparse_reaction, cids=True) dG0_est = grad.reaction_to_dG0(sparse_reaction, pH, I, T) csv_results.writerow([ n, dG0_obs, dG0_est, reaction_str, pH, I, T, evaluation, n_measurements ]) res_file.flush() ################################################################################ if (len(sys.argv) > 1): n_begin = int(sys.argv[1]) else: n_begin = 0 gc = GroupContribution(sqlite_name="gibbs.sqlite", html_name="dG0_test") gc.init() nist = Nist(gc.kegg()) alberty = Alberty() sensitivity_analysis_for_gradient_ascent(gc, nist, alberty.cid2pmap_dict, max_i=250, n_begin=n_begin) #evaluate(gc, nist, alberty.cid2pmap_dict)
grad = GradientAscent(gc) grad.cid2pmap_dict = deepcopy(cid2pmap) grad.load_nist_data(nist, skip_missing_reactions=True) res_file = open('../res/evaluation_report.csv', 'w') csv_results = csv.writer(res_file) csv_results.writerow(["N", "dG0_obs", "dG0_est", "reaction", "pH", "I", "T", "evaluation"]) N = len(grad.data) for n in range(n_begin, N): (sparse_reaction, pH, I, T, evaluation, dG0_obs) = grad.data[n] n_measurements = min([nist.cid2count[cid] for cid in sparse_reaction.keys()]) reaction_str = gc.kegg().sparse_reaction_to_string(sparse_reaction, cids=True) dG0_est = grad.reaction_to_dG0(sparse_reaction, pH, I, T) csv_results.writerow([n, dG0_obs, dG0_est, reaction_str, pH, I, T, evaluation, n_measurements]) res_file.flush() ################################################################################ if (len(sys.argv) > 1): n_begin = int(sys.argv[1]) else: n_begin = 0 gc = GroupContribution(sqlite_name="gibbs.sqlite", html_name="dG0_test") gc.init() nist = Nist(gc.kegg()) alberty = Alberty() sensitivity_analysis_for_gradient_ascent(gc, nist, alberty.cid2pmap_dict, max_i=250, n_begin=n_begin) #evaluate(gc, nist, alberty.cid2pmap_dict)
from groups import GroupContribution from pygibbs.thermodynamic_constants import R from pylab import log, zeros, pinv, dot, plot, show, figure, NaN, isnan, find import csv from pygibbs.kegg_utils import unparse_reaction_formula from pygibbs.kegg_reaction import Reaction G = GroupContribution(sqlite_name="gibbs.sqlite", html_name="acetogens") G.init() reactions = [] # (RID, EC, sparse-reaction, dG0_r, pH, I, T # Drake 2006 #reactions.append([134, '1.2.1.43', {11:-1, 5:-1, 58:1, 6:1}, 22, 7.0, 0, 300]) reactions.append([934, '6.3.4.3', {101:-1, 58:-1, 2:-1, 8:1, 9:1, 234:1}, -8, 7.0, 0, 300]) reactions.append([1655, '3.5.4.9', {234:-1, 445:1, 1:1}, -4, 7.0, 0, 300]) reactions.append([1220, '1.5.1.5', {445:-1, 5:-1, 143:1, 6:1}, -5, 7.0, 0, 300]) reactions.append([1224, '1.5.1.20', {143:-1, 5:-1, 440:1, 6:1}, -22, 7.0, 0, 300]) # NIST database reactions.append([134, '1.2.1.43', {288:1, 5:1, 58:-1, 6:-1, 1:-1}, -R * 328 * log(650), 7.5, 0, 328]) # Yamamoto 1983, Buffer: triethanolamine-maleate (0.1 M) reactions.append([934, '6.3.4.3', {101:-1, 58:-1, 2:-1, 8:1, 9:1, 234:1}, -R * 310 * log(41), 7.7, 0, 310]) # Himes 1962, Buffer: triethanolamine (0.1 M) reactions.append([1655, '3.5.4.9', {234:1, 445:-1, 1:-1}, -R * 298 * log(11), 7.0, 0, 298]) # Kay 1960, Buffer: acetate reactions.append([1655, '3.5.4.9', {234:1, 445:-1, 1:-1}, -R * 298 * log(1.84), 6.5, 0, 298]) # Lombrozo 1967, Buffer: potassium citrate (0.11 M) reactions.append([1655, '3.5.4.9', {234:1, 445:-1, 1:-1}, -R * 298 * log(4.2), 6.5, 0, 298]) # Greenberg 1963, Buffer: potassium maleate (1.0 M) reactions.append([1655, '3.5.4.9', {234:1, 445:-1, 1:-1}, -R * 298 * log(50), 7.0, 0, 298]) # Suzuki 1973, Buffer: potassium maleate reactions.append([1220, '1.5.1.5', {445:1, 5:1, 143:-1, 6:-1}, -R * 298 * log(0.14), 6.9, 0, 298]) # Uyeda 1967, Buffer: potassium maleate (0.05 M) reactions.append([1220, '1.5.1.5', {445:1, 5:1, 143:-1, 6:-1}, -R * 303 * log(16), 7.3, 0, 303]) # Pelletier 1995, Buffer: potassium phosphate (0.025 M) reactions.append([8550, '1.8.1.4', {2972:-1, 3:-1, 2051:1, 4:1}, -R * 295 * log(0.21), 7.1, 0, 295]) # Sanadi 1957, Buffer: phosphate (0.026 M) reactions.append([8550, '1.8.1.4', {2972:-1, 3:-1, 2051:1, 4:1}, -R * 295 * log(0.13), 7.1, 0, 295]) # Sanadi 1959, Buffer: phosphate (0.05 M) reactions.append([945, '2.1.2.1', {143:-1, 37:-1, 1:-1, 101:1, 65:1}, -R * 310 * log(0.067), 7.4, 0, 310]) # Besson 1993, Buffer: KH2PO4 (0.02 M)