Пример #1
0
def python_main():
    sys.path.append('../python')
    from training_data import TrainingData
    from component_contribution import ComponentContribution
    from kegg_model import KeggModel

    reaction_strings = open(REACTION_FNAME, 'r').readlines()
    model = KeggModel.from_formulas(reaction_strings)    

    td = TrainingData()
    cc = ComponentContribution(td)
    model.add_thermo(cc)
    
    dG0_prime, dG0_std = model.get_transformed_dG0(pH=7.5, I=0.2, T=298.15)
    
    sys.stdout.write('[' + 
                     ', '.join([str(x) for x in model.dG0.flat]) + '; ' + 
                     ', '.join([str(x) for x in dG0_prime.flat]) + 
                     ']')    
        params["contributions"] = [dG0_rc, dG0_gc]
        params["covariances"] = [V_rc, V_gc, V_inf]
        params["MSEs"] = [MSE_rc, MSE_gc, MSE_inf]
        params["projections"] = [P_R_rc, P_R_gc * G.T * P_N_rc, P_N_gc * G.T * P_N_rc, P_R_gc, P_N_rc, P_N_gc]
        params["inverses"] = [inv_S, inv_GS, inv_SWS, inv_GSWGS]

        # Calculate the total of the contributions and covariances
        cov_dG0 = V_rc * MSE_rc + V_gc * MSE_gc + V_inf * MSE_inf

        return dG0_cc, cov_dG0, params


if __name__ == "__main__":
    from kegg_model import KeggModel

    reaction_strings = sys.stdin.readlines()
    td = TrainingData()
    cc = ComponentContribution(td)
    model = KeggModel.from_formulas(reaction_strings)
    model_dG0, model_cov_dG0 = cc.estimate_kegg_model(model)

    model_dG0_prime = model_dG0 + model.get_transform_ddG0(pH=7.5, I=0.2, T=298.15)

    sys.stdout.write(
        "["
        + ", ".join([str(x) for x in model_dG0.flat])
        + "; "
        + ", ".join([str(x) for x in model_dG0_prime.flat])
        + "]"
    )
        params['contributions'] = [dG0_rc, dG0_gc]
        params['covariances']   = [V_rc, V_gc, V_inf]
        params['MSEs']          = [MSE_rc, MSE_gc, MSE_inf]
        params['projections']   = [P_R_rc,
                                   P_R_gc * G.T * P_N_rc,
                                   P_N_gc * G.T * P_N_rc,
                                   P_R_gc,
                                   P_N_rc,
                                   P_N_gc]
        params['inverses']      = [inv_S, inv_GS, inv_SWS, inv_GSWGS]

        # Calculate the total of the contributions and covariances
        cov_dG0 = V_rc * MSE_rc + V_gc * MSE_gc + V_inf * MSE_inf
        
        return dG0_cc, cov_dG0, params

if __name__ == '__main__':
    from kegg_model import KeggModel
    
    reaction_strings = sys.stdin.readlines()
    td = TrainingData()
    cc = ComponentContribution(td)
    model = KeggModel.from_formulas(reaction_strings)
    model_dG0, model_cov_dG0 = cc.estimate_kegg_model(model)
    
    model_dG0_prime = model_dG0 + model.get_transform_ddG0(pH=7.5, I=0.2, T=298.15)
    
    sys.stdout.write('[' + 
                     ', '.join([str(x) for x in model_dG0.flat]) + '; ' + 
                     ', '.join([str(x) for x in model_dG0_prime.flat]) + 
                     ']')