Example #1
0
def calculate_deltaG0s(model,
                       kegg_compounds,
                       pH=default_pH,
                       I=default_I,
                       T=default_T):
    """ Calculate standard Gibbs Energy for reactions in model (as many as possible) using eQuilibrator.

    Args:
        model (CBModel): model
        kegg_compounds (list): KEGG compounds accepted by eQuilibrator
        pH (float): pH (default: 7.0)
        I (float): ionic strenght (default: 0.25)
        T (float): temperature (default: 298.15 K (25.0 C))

    Returns:
        dict: standard Gibbs Energies indexed by reaction ids
        dict: estimation error indexed by reaction ids

    """
    kegg_rxns = build_kegg_reactions(model, kegg_compounds)
    kmodel = KeggModel.from_formulas(kegg_rxns.values(), raise_exception=True)
    kmodel.add_thermo(CC.init())
    dG0, sdG0, _ = kmodel.get_transformed_dG0(pH, I, T)

    dG0 = dict(zip(kegg_rxns.keys(), dG0.A1))
    sdG0 = dict(zip(kegg_rxns.keys(), sdG0.A1))

    return dG0, sdG0
Example #2
0
    def __init__(self, reactions):

        self.cc = ComponentContribution.init()
        self.pH = 7.5
        self.I = 0.2
        self.T = default_T
        self.R = R
        self._not_balanced = []
        self.reactions = []
        self.Kmodel = self.generate_kegg_model(reactions)
        self.dG0_prime = self.add_thermodynamics(reactions)
    def __init__(self, reactions):

        self.cc = ComponentContribution.init()
        self.pH = 7.5
        self.I = 0.2
        self.T = default_T
        self.R = R
        self._not_balanced = []
        self.reactions = []    
        self.Kmodel = self.generate_kegg_model(reactions)
        self.dG0_prime = self.add_thermodynamics(reactions)
Example #4
0
    def __init__(self):
        self.prepare_mappings()

        reactions = self.get_reactions_from_model()
        self.reactions = []
        self._not_balanced = []

        self.rstrings = []
        for r in reactions:
            k = r.kegg_reaction
            if k:
                if k.is_balanced() and not k.is_empty():
                    self.rstrings.append(k.write_formula())
                    self.reactions.append(r)
            else:
                self._not_balanced.append(r)
        self.Kmodel = KeggModel.from_formulas(self.rstrings)

        self.cc = ComponentContribution.init()
        self.pH = 7.3
        self.I = 0.25
        self.RT = R * default_T
    def __init__(self):
        self.prepare_mappings()

        reactions = self.get_reactions_from_model()
        self.reactions = []
        self._not_balanced = []

        self.rstrings = []
        for r in reactions:
            k = r.kegg_reaction
            if k:
                if k.is_balanced() and not k.is_empty():
                    self.rstrings.append(k.write_formula())
                    self.reactions.append(r)
            else:
                self._not_balanced.append(r)
        self.Kmodel = KeggModel.from_formulas(self.rstrings)

        self.cc = ComponentContribution.init()
        self.pH = 7.3
        self.I = 0.25
        self.RT = R * default_T
        model.rids = rids
        pH = fields.GetFloatField('PH', 7.5)
        I = fields.GetFloatField('I', 0.2)
        T = fields.GetFloatField('T', 298.15)
        pathways.append({'entry': entry, 'model': model, 'fluxes': fluxes,
                         'bounds': bounds, 'pH': pH, 'I': I, 'T': T})
    return pathways

if __name__ == '__main__':
    #fname = sys.argv[1]
    fname = 'mdf_pathways'
    
    REACTION_FNAME = 'scripts/%s.txt' % fname
    pathways = KeggFile2ModelList(REACTION_FNAME)
    html_writer = HtmlWriter('res/%s.html' % fname)
    cc = ComponentContribution.init()

    matdict = {}
    for p in pathways:
        html_writer.write('<h2>%s</h2>' % p['entry'])

        p['model'].add_thermo(cc)

        mdf = MaxMinDrivingForce(p['model'], p['fluxes'], p['bounds'],
                                 pH=p['pH'], I=p['I'], T=p['T'],
                                 html_writer=html_writer)

        mdf_solution, dGm_prime, dG0_std = mdf.Solve()
        logging.info('Pathway %s: MDF = %.1f' % (p['entry'], mdf_solution))
        
        matdict[p['entry'] + '.dGm_prime'] = dGm_prime
Example #7
0
 def _CalcGibbsEnerigesFromComponentContribution(self):
     cc = ComponentContribution.init()
     self.kegg_model.add_thermo(cc)
     dG0_prime, dG0_std, sqrt_Sigma = self.kegg_model.get_transformed_dG0(
         pH=7.5, I=0.1, T=298.15)
     self.rid2dG0 = dict(zip(self.kegg_model.rids, dG0_prime.flat))