def main(): td = TrainingData() cc = ComponentContribution.init() G1 = np.matrix(cc.params['G1']) G2 = np.matrix(cc.params['G2']) G3 = np.matrix(cc.params['G3']) ############################################################################ #reaction = KeggReaction.parse_formula('C00002 + C00001 <=> C00008 + C00009'); fname = 'atpase'; reaction = KeggReaction.parse_formula('C00149 <=> C00122 + C00001') fname = 'fumarase' x, g = cc._decompose_reaction(reaction) weights_rc = (x.T * G1).round(5) weights_gc = (x.T * G2 + g.T * G3).round(5) weights = weights_rc + weights_gc orders = sorted(range(weights.shape[1]), key=lambda j: abs(weights[0, j]), reverse=True) output = csv.writer(open('res/%s_analysis.csv' % fname, 'w')) output.writerow(('Weight', 'dG\'0', 'dG0', 'reference', 'reaction')) for j in orders: if abs(weights[0, j]) < 1e-7: continue output.writerow((weights_rc[0, j], td.dG0_prime[j], td.dG0[j], td.reference[j], td.description[j]))
def main(): td = TrainingData() cc = ComponentContribution.init() G1 = np.matrix(cc.params['G1']) G2 = np.matrix(cc.params['G2']) G3 = np.matrix(cc.params['G3']) ############################################################################ #reaction = KeggReaction.parse_formula('C00002 + C00001 <=> C00008 + C00009'); fname = 'atpase'; reaction = KeggReaction.parse_formula('C00149 <=> C00122 + C00001'); fname = 'fumarase'; x, g = cc._decompose_reaction(reaction) weights_rc = (x.T * G1).round(5) weights_gc = (x.T * G2 + g.T * G3).round(5) weights = weights_rc + weights_gc orders = sorted(range(weights.shape[1]), key=lambda j:abs(weights[0, j]), reverse=True) output = csv.writer(open('res/%s_analysis.csv' % fname, 'w')) output.writerow(('Weight', 'dG\'0', 'dG0', 'reference', 'reaction')) for j in orders: if abs(weights[0, j]) < 1e-7: continue output.writerow((weights_rc[0, j], td.dG0_prime[j], td.dG0[j], td.reference[j], td.description[j]))
@author: eladn """ from python.component_contribution import ComponentContribution from python.kegg_reaction import KeggReaction #pH = 7 I = 0.2 T = 298.15 F = 96.48 / 1000.0 # kJ/mol / mV cc = ComponentContribution.init() #formula = 'C00033 + C00282 <=> C00084 + C00001' #formula = 'C00067 + C00001 <=> C00058 + C00010' formula = 'C00003 + C00282 <=> C00004' ############################################################################# reaction = KeggReaction.parse_formula(formula) reaction_atom_bag = reaction._get_reaction_atom_bag() n_e = 0 if 'e-' in reaction_atom_bag: n_e = reaction_atom_bag['e-'] del reaction_atom_bag['e-'] if len(reaction_atom_bag) != 0: raise Exception('Reaction is not balanced (not only with respect to e-)') dG0_r, u_r = cc.get_dG0_r(reaction) for pH in xrange(6, 9): ddG0_r = reaction.get_transform_ddG0(pH=pH, I=I, T=T) dG0_r_prime = dG0_r+ddG0_r E0_prime = -dG0_r_prime / (n_e*F) print 'pH = %4.1f, E\'0 = %6.0f' % (pH, E0_prime)