def main():
    opt_parser = flags.MakeOpts()
    options, _ = opt_parser.parse_args(sys.argv)
    estimators = LoadAllEstimators()
    
    print ('Parameters: T=%f K, pH=%.2g, pMg=%.2g, '
           'I=%.2gmM, Median concentration=%.2gM' % 
           (default_T, options.ph, options.pmg, options.i_s, options.c_mid))

    for thermo in estimators.values():
        thermo.c_mid = options.c_mid
        thermo.pH = options.ph
        thermo.pMg = options.pmg
        thermo.I = options.i_s
        thermo.T = default_T
    
    kegg = Kegg.getInstance()
    while True:
        cid = GetReactionIdInput()        
        compound = kegg.cid2compound(cid)
        print 'Compound Name: %s' % compound.name
        print '\tKegg ID: C%05d' % cid
        print '\tFormula: %s' % compound.formula
        print '\tInChI: %s' % compound.inchi
        for key, thermo in estimators.iteritems():
            print "\t<< %s >>" % key
            try:
                print thermo.cid2PseudoisomerMap(cid),
                print '--> dG0\'f = %.1f kJ/mol' % compound.PredictFormationEnergy(thermo)
            except Exception as e: 
                print '\t\tError: %s' % (str(e))
示例#2
0
def main():
    options, _ = flags.MakeOpts().parse_args(sys.argv)
    kegg = Kegg.getInstance()
    estimators = LoadAllEstimators()
    
    print ('Parameters: T=%f K, pH=%.2g, pMg=%.2g, '
           'I=%.2gmM, Median concentration=%.2gM' % 
           (default_T, options.ph, options.pmg, options.i_s, options.c_mid))

    for thermo in estimators.values():
        thermo.c_mid = options.c_mid
        thermo.pH = options.ph
        thermo.pMg = options.pmg
        thermo.I = options.i_s
        thermo.T = default_T
    
    cmap = {}
    if not options.ignore_cofactors:
        print 'Fixing concentrations of co-factors'
        cmap = reversibility.GetConcentrationMap()
    else:
        print 'Not fixing concentrations of co-factors'

    while True:
        rid = GetReactionIdInput()        
        reaction = kegg.rid2reaction(rid)
        print 'Reaction Name: %s' % reaction.name
        print '\tKegg ID: R%05d' % rid
        print '\tEC: %s' % str(reaction.ec_list)
        for key, thermo in estimators.iteritems():
            print "\t<< %s >>" % key
            try:
                print '\t\tdG0\'f = %.1f kJ/mol' % reaction.PredictReactionEnergy(thermo)
                rev = reversibility.CalculateReversability(reaction, thermo, concentration_map=cmap)
                print '\t\tgamma = %.3g' % rev
            except Exception as e: 
                print '\tError: %s' % (str(e))
示例#3
0
def main():
    kegg = Kegg.getInstance()
    options, args = MakeOpts().parse_args(sys.argv)
    print ('Parameters: T=%f K, pMg=%.2g, I=%.2gM' % 
           (options.T, options.pMg, options.I))
    print "reaction:", args[-1]

    estimators = LoadAllEstimators()
    
    plt.rcParams['legend.fontsize'] = 8
    plt.rcParams['font.family'] = 'sans-serif'
    plt.rcParams['font.size'] = 12
    plt.rcParams['lines.linewidth'] = 2
    
    colormap = {}
    colormap['markers'] = (64.0/255, 111.0/255, 29.0/255, 3.0)
    #colormap['hatzi_gc'] = (54.0/255, 182.0/255, 202.0/255, 1.0)
    colormap['UGC'] = (202.0/255, 101.0/255, 54.0/255, 1.0)
    #colormap['alberty'] = (202.0/255, 54.0/255, 101.0/255, 1.0)
    colormap['PGC'] = (101.0/255, 202.0/255, 54.0/255, 1.0)
    
    fig = plt.figure(figsize=(6,6), dpi=90)
    
    fig.hold(True)
    if options.rid is None:
        reaction = GetSparseReactionInput(args[-1], kegg)
    else:
        reaction = kegg.rid2reaction(options.rid)
    reaction.Balance()
    print 'Reaction: %s' % reaction.FullReactionString()

    nist = Nist()
    nist_rows = nist.SelectRowsFromNist(reaction, check_reverse=True)

    pH_min = 7.0 - options.pH/2.0
    pH_max = 7.0 + options.pH/2.0
    
    if nist_rows:
        dG0_list = []
        pH_list = []
        for row_data in nist_rows:
            pH_list.append(row_data.pH)
            if row_data.reaction == reaction:
                dG0_list.append(row_data.dG0_r)
            else:
                dG0_list.append(-row_data.dG0_r)
    
        plt.plot(pH_list, dG0_list, marker='.', linestyle='none',
                   label='measured data', markeredgecolor='none',
                   markerfacecolor=colormap['markers'], markersize=5)
        pH_max = max(pH_list + [pH_max])
        pH_min = min(pH_list + [pH_min])
    
    pH_range = np.arange(pH_min-0.1, pH_max+0.1, 0.02)
    for key, thermo in estimators.iteritems():
        if key not in colormap:
            continue
        print key, 'dG0 at pH=7: %.2f' % reaction.PredictReactionEnergy(thermo, 
                pH=7.0, pMg=options.pMg, I=options.I, T=options.T)
        dG0 = []
        for pH in pH_range:
            dG0.append(reaction.PredictReactionEnergy(thermo, 
                pH=pH, pMg=options.pMg, I=options.I, T=options.T))
        plt.plot(pH_range, dG0, marker='None', linestyle='solid', color=colormap[key],
                   figure=fig, label=thermo.name)

    plt.xlabel('pH')
    plt.ylabel(r'$\Delta_r G^\circ$ [kJ/mol]')
    plt.title(kegg.reaction2string(reaction), fontsize=8)
    plt.legend(loc='lower left')

    if not options.output:
        plt.tight_layout()
        plt.show()
    else:
        fig.savefig(options.output, format='svg')