def _component_contribution_wrapper(self, reaction_list_I, pH_I,
                                        temperature_I, ionic_strength_I):
        """wrapper for component contribution"""

        # Orginal implementation involves an input of a reaction list
        # the dG_prime and dG_std for each reaction are then calculated.
        # Because we are interested in accounting for transportation
        # and metabolite concentration,
        # we need to extraction out the dG_prime and dG_std
        # of formation and calculated the dG_prime and
        # dG_std for each reaction after accounting for
        # transportation and metabolite concentration.
        # TODO: change input from reaction list to metabolite list
        # however this may be problematic due to the implementation
        # of component_contribution (i.e., the group contribution
        # and reactant contribution are calculated along orthoganol planes
        # in order to gain greater coverage and accuracy of predicted
        # dG_f values)

        # Debugging:
        #wolf = ['C00049 + C00002 <=> C03082 + C00008',
        #        'C00026 + C00049 <=> C00025 + C00036',
        #        'C00158 <=> C00311',
        #        'C00631 <=> C00001 + C00074',
        #        'C00354 <=> C00111 + C00118',
        #        'C00020 + C00002 <=> 2 C00008',
        #        'C00002 + C00001 <=> C00008 + C00009',
        #        'C00015 + C00002 <=> C00075 + C00008',
        #        'C00033 + C00002 + C00010 <=> C00024 + C00020 + C00013']
        #model = KeggModel.from_formulas(wolf)

        model = KeggModel.from_formulas(reaction_list_I)

        td = TrainingData()
        cc = ComponentContribution(td)
        model.add_thermo(cc)

        dG0_prime_f, dG0_var_f = model.get_transformed_dG0(pH=pH_I,
                                                           I=ionic_strength_I,
                                                           T=temperature_I)

        return dG0_prime_f, dG0_var_f
Example #2
0
# -*- coding: utf-8 -*-
"""
Created on Wed Jun  3 15:25:49 2015

@author: noore
"""
from component_contribution.component_contribution_trainer import ComponentContribution
from scipy.io import savemat
import argparse

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description=
        'Prepare all thermodynamic training data in a .mat file for running '
        'component contribution.')
    parser.add_argument('out_file',
                        type=argparse.FileType('wb'),
                        help='path to the .mat file that should be written '
                        'containing the training data')

    args = parser.parse_args()
    cc = ComponentContribution()

    mdict = {
        'w': cc.train_w,
        'b': cc.train_b,
        'G': cc.create_group_incidence_matrix(),
        'cids': cc.train_cids,
        'S': cc.train_S
    }
    savemat(args.out_file, mdict, do_compression=True)