def run_simulatedData(self):
     data_fva = data_dir_tests + '/test_fva.json'
     data_srd = data_dir_tests + '/test_srd.json'
     simulated_data = thermodynamics_simulatedData()
     simulated_data.generate_sra_data(self.cobra_model) # perform single reaction deletion analysis
     simulated_data.generate_fva_data(self.cobra_model) # perform flux variability analysis
     assert(simulated_data.fva_data['ENO']['maximum'] == 1000.0)
     assert(simulated_data.fva_data['ENO']['minimum'] == 18.0)
     assert(np.isnan(simulated_data.sra_data['ENO']['gr']))
     assert(np.isnan(simulated_data.sra_data['ENO']['gr_ratio']))
     assert(simulated_data.sra_data['H2Ot']['gr'] == 30.0)
     assert(simulated_data.sra_data['H2Ot']['gr_ratio'] == 1.0)
     test_fva_data = simulated_data._convert_fluxBounds2var(simulated_data.fva_data)
     assert(test_fva_data['ENO']['flux'] == 491.0)
     assert(test_fva_data['ENO']['flux_var'] == 259081.0)
     assert(test_fva_data['ENO']['flux_units'] == 'mmol*gDW-1*hr-1')
     assert(test_fva_data['ENO']['flux_ub'] == 1000.0)
     assert(test_fva_data['ENO']['flux_lb'] == 18.0)
     simulated_data.export_sra_data(data_srd) # save results for later use
     simulated_data.export_fva_data(data_fva) # save results for later use
     simulated_data.import_sra_data(data_srd)
     simulated_data.import_fva_data(data_fva)
     assert(simulated_data.fva_data['ENO']['flux_ub'] == 1000.0)
     assert(simulated_data.fva_data['ENO']['flux_lb'] == 18.0)
     assert(np.isnan(simulated_data.sra_data['ENO']['gr']))
     assert(np.isnan(simulated_data.sra_data['ENO']['gr_ratio']))
     assert(simulated_data.sra_data['H2Ot']['gr'] == 30.0)
     assert(simulated_data.sra_data['H2Ot']['gr_ratio'] == 1.0)
     simulated_data.check_data()
     self.simulated_data = simulated_data
Beispiel #2
0
 def init_simulatedData(self):
     data_fva = data_dir_tests + '/test_fva.json'
     data_srd = data_dir_tests + '/test_srd.json'
     simulated_data = thermodynamics_simulatedData()
     simulated_data.import_sra_data(data_srd)
     simulated_data.import_fva_data(data_fva)
     simulated_data.check_data()
     self.simulated_data = simulated_data
    def execute_calculate_dG_r(self,experiment_id_I,models_I,model_ids_I = [],
                            time_points_I=[],sample_name_abbreviations_I=[],
                            inconsistent_dG_f_I=[],inconsistent_concentrations_I=[],
                            measured_concentration_coverage_criteria_I=0.5,
                            measured_dG_f_coverage_criteria_I=0.99):

        '''calculate dG0_r, dG_r, displacements, and perform a thermodynamic consistency check'''
        print('calculating dG_r for experiment_id ' + experiment_id_I);
        dG0_r_O = [];
        dG_r_O = [];
        tcc_O = [];
        # get the model ids:
        if model_ids_I:
            model_ids = model_ids_I;
        else:
            model_ids = [];
            model_ids = self.get_modelID_experimentID_dataStage03QuantificationSimulation(experiment_id_I);
        for model_id in model_ids:
            print('calculating dG_r for model_id ' + model_id);
            # get the cobra model
            cobra_model = models_I[model_id];
            # get simulated data
            fva_data,sra_data = {},{};
            fva_data,sra_data = self.get_rowsDict_experimentIDAndModelID_dataStage03QuantificationSimulatedData(experiment_id_I,model_id);
            # load simulated data
            simulated_data = thermodynamics_simulatedData(fva_data_I=fva_data,sra_data_I=sra_data);
            simulated_data.check_data();
            # get the time-points
            if time_points_I:
                time_points = time_points_I;
            else:
                time_points = [];
                time_points = self.get_timePoints_experimentIDAndModelID_dataStage03QuantificationSimulation(experiment_id_I,model_id);
            for tp in time_points:
                # get sample_name_abbreviations
                if sample_name_abbreviations_I:
                    sample_name_abbreviations = sample_name_abbreviations_I;
                else:
                    sample_name_abbreviations = [];
                    sample_name_abbreviations = self.get_sampleNameAbbreviations_experimentIDAndModelIDAndTimePoint_dataStage03QuantificationSimulation(experiment_id_I,model_id,tp);
                for sna in sample_name_abbreviations:
                    print('calculating dG_r for sample_name_abbreviation ' + sna);
                    # get otherData
                    pH,temperature,ionic_strength = {},{},{}
                    pH,temperature,ionic_strength = self.get_rowsFormatted_experimentIDAndTimePointAndSampleNameAbbreviation_dataStage03QuantificationOtherData(experiment_id_I,tp,sna);
                    # load pH, ionic_strength, and temperature parameters
                    other_data = thermodynamics_otherData(pH_I=pH,temperature_I=temperature,ionic_strength_I=ionic_strength);
                    other_data.check_data();
                    # get dG_f data:
                    dG_f = {};
                    dG_f = self.get_rowsDict_experimentIDAndModelIDAndTimePointAndSampleNameAbbreviations_dataStage03QuantificationDGf(experiment_id_I,model_id,tp,sna);
                    dG_f_data = thermodynamics_dG_f_data(dG_f_I=dG_f);
                    dG_f_data.format_dG_f();
                    dG_f_data.generate_estimated_dG_f(cobra_model)
                    dG_f_data.check_data(); 
                    # remove an inconsistent dGf values
                    if inconsistent_dG_f_I: dG_f_data.remove_measured_dG_f(inconsistent_dG_f_I)
                    # query metabolomicsData
                    concentrations = [];
                    concentrations = self.get_rowsDict_experimentIDAndTimePointAndSampleNameAbbreviations_dataStage03QuantificationMetabolomicsData(experiment_id_I,tp,sna);
                    # load metabolomicsData
                    metabolomics_data = thermodynamics_metabolomicsData(measured_concentrations_I=concentrations);
                    metabolomics_data.generate_estimated_metabolomics_data(cobra_model);
                    # remove an inconsistent concentration values
                    if inconsistent_concentrations_I: metabolomics_data.remove_measured_concentrations(inconsistent_concentrations_I);
                    # calculate dG0r, dGr, displacements, and perform a thermodynamic consistency check based on model simulations
                    tcc = thermodynamics_dG_r_data();
                    tcc.calculate_dG0_r_v3(cobra_model, dG_f_data.measured_dG_f, dG_f_data.estimated_dG_f, other_data.temperature); # calculate the change in free energy of reaction without accounting for metabolite concentrations
                    tcc.calculate_dG_r_v3(cobra_model,metabolomics_data.measured_concentrations, metabolomics_data.estimated_concentrations,
                                        other_data.pH, other_data.ionic_strength, other_data.temperature); # adjust the change in free energy of reaction for intracellular metabolite concentrations
                    tcc.check_thermodynamicConsistency(cobra_model,simulated_data.fva_data,
                                        metabolomics_data.measured_concentrations,
                                        metabolomics_data.estimated_concentrations,
                                        other_data.pH,other_data.ionic_strength,other_data.temperature,
                                        measured_concentration_coverage_criteria_I,
                                        measured_dG_f_coverage_criteria_I); # check the thermodynamic consistency of the data
                    tcc.calculate_displacement_v3(cobra_model,metabolomics_data.measured_concentrations, metabolomics_data.estimated_concentrations); # calculate the displacements from equillibrium
                    #tcc.simulate_infeasibleReactions(cobra_model); # simulate thermodynamically inconsistent data
                    #tcc.constrain_infeasibleReactions(cobra_model); # remove thermodynamically inconsistent reactions from the model
                    # upload dG0r, dGr, displacements, and results of tcc
                    for k,v in tcc.dG_r.items():
                        dG0_r_tmp = {'experiment_id':experiment_id_I,
                                'model_id':model_id,
                                'sample_name_abbreviation':sna,
                                'time_point':tp,
                                'rxn_id':k,
                                'Keq_lb':tcc.dG0_r[k]['Keq_lb'],
                                'Keq_ub':tcc.dG0_r[k]['Keq_ub'],
                                'dG0_r':tcc.dG0_r[k]['dG_r'],
                                'dG0_r_var':tcc.dG0_r[k]['dG_r_var'],
                                'dG0_r_units':tcc.dG0_r[k]['dG_r_units'],
                                'dG0_r_lb':tcc.dG0_r[k]['dG_r_lb'],
                                'dG0_r_ub':tcc.dG0_r[k]['dG_r_ub'],
                                'used_':True,
                                'comment_':None};
                        dG0_r_O.append(dG0_r_tmp);
                        dG_r_tmp = {'experiment_id':experiment_id_I,
                                'model_id':model_id,
                                'sample_name_abbreviation':sna,
                                'time_point':tp,
                                'rxn_id':k,
                                'Keq_lb':tcc.dG_r[k]['Keq_lb'],
                                'Keq_ub':tcc.dG_r[k]['Keq_ub'],
                                'dG_r':tcc.dG_r[k]['dG_r'],
                                'dG_r_var':tcc.dG_r[k]['dG_r_var'],
                                'dG_r_units':tcc.dG_r[k]['dG_r_units'],
                                'dG_r_lb':tcc.dG_r[k]['dG_r_lb'],
                                'dG_r_ub':tcc.dG_r[k]['dG_r_ub'],
                                'displacement_lb':tcc.displacement[k]['displacement_lb'],
                                'displacement_ub':tcc.displacement[k]['displacement_ub'],
                                'Q_lb':tcc.displacement[k]['Q_lb'],
                                'Q_ub':tcc.displacement[k]['Q_ub'],
                                'used_':True,
                                'comment_':None};
                        dG_r_O.append(dG_r_tmp);
                        tcc_tmp = {'experiment_id':experiment_id_I,
                                'model_id':model_id,
                                'sample_name_abbreviation':sna,
                                'time_point':tp,
                                'rxn_id':k,
                                'feasible':tcc.thermodynamic_consistency_check[k],
                                'measured_concentration_coverage_criteria':measured_concentration_coverage_criteria_I,
                                'measured_dG_f_coverage_criteria':measured_dG_f_coverage_criteria_I,
                                'measured_concentration_coverage':tcc.metabolomics_coverage[k],
                                'measured_dG_f_coverage':tcc.dG_r_coverage[k],
                                'used_':True,
                                'comment_':None};
                        tcc_O.append(tcc_tmp);
                        #try:
                        #    row = None;
                        #    row = data_stage03_quantification_dG0_r(experiment_id_I,
                        #            model_id,
                        #            sna,
                        #            tp,
                        #            k,
                        #            tcc.dG0_r[k]['Keq_lb'],
                        #            tcc.dG0_r[k]['Keq_ub'],
                        #            tcc.dG0_r[k]['dG_r'],
                        #            tcc.dG0_r[k]['dG_r_var'],
                        #            tcc.dG0_r[k]['dG_r_units'],
                        #            tcc.dG0_r[k]['dG_r_lb'],
                        #            tcc.dG0_r[k]['dG_r_ub'],
                        #            True,
                        #            None);
                        #    self.session.add(row);
                        #    row = None;
                        #    row = data_stage03_quantification_dG_r(experiment_id_I,
                        #            model_id,
                        #            sna,
                        #            tp,
                        #            k,
                        #            tcc.dG_r[k]['Keq_lb'],
                        #            tcc.dG_r[k]['Keq_ub'],
                        #            tcc.dG_r[k]['dG_r'],
                        #            tcc.dG_r[k]['dG_r_var'],
                        #            tcc.dG_r[k]['dG_r_units'],
                        #            tcc.dG_r[k]['dG_r_lb'],
                        #            tcc.dG_r[k]['dG_r_ub'],
                        #            tcc.displacement[k]['displacement_lb'],
                        #            tcc.displacement[k]['displacement_ub'],
                        #            tcc.displacement[k]['Q_lb'],
                        #            tcc.displacement[k]['Q_ub'],
                        #            True,
                        #            None);
                        #    self.session.add(row);
                        #    row = None;
                        #    row = data_stage03_quantification_tcc(experiment_id_I,
                        #            model_id,
                        #            sna,
                        #            tp,
                        #            k,
                        #            tcc.thermodynamic_consistency_check[k],
                        #            measured_concentration_coverage_criteria_I,
                        #            measured_dG_f_coverage_criteria_I,
                        #            tcc.metabolomics_coverage[k],
                        #            tcc.dG_r_coverage[k],
                        #            True,
                        #            None);
                        #    self.session.add(row);
                        #except sqlalchemy.exc.IntegrityError as e:
                        #    print(e);
                        #    print("Press any key to continue")
                        #    a=input();
                    #self.session.commit();  
        # add datat to the DB
        self.add_dataStage03QuantificationDG0r(dG0_r_O);
        self.add_dataStage03QuantificationDGr(dG_r_O);
        self.add_dataStage03QuantificationTcc(tcc_O);
def _main_():
    ##PART 1: Working
    #-------
    # Read in the model sbml file and define the model conditions
    # Aerobic specific changes
    cobra_model_oxic = load_thermoModel(anoxic = False)
    convert_to_irreversible(cobra_model_oxic)

    ##PART 2: Working
    #-------
    # make/load simulated data for aerobic conditions
    data_fva_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_fva_irrev_oxic.json'
    data_srd_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_srd_irrev_oxic.json'
    simulated_data_oxic = thermodynamics_simulatedData()
    # simulated_data_oxic.generate_sra_data(cobra_model_oxic) # perform single reaction deletion analysis
    # simulated_data_oxic.generate_fva_data(cobra_model_oxic) # perform flux variability analysis
    # simulated_data_oxic.export_sra_data(data_srd_oxic) # save results for later use
    # simulated_data_oxic.export_fva_data(data_fva_oxic) # save results for later use
    simulated_data_oxic.import_sra_data(data_srd_oxic)
    simulated_data_oxic.import_fva_data(data_fva_oxic)
    simulated_data_oxic.check_data()

    ##PART 3: Working
    #-------
    # load pH, ionic_strength, and temperature parameters
    other_data = thermodynamics_otherData()
    other_data.load_defaultData()
    other_data.check_data()

    # generate dG_f data for all model compounds
    # calculate the dG_f for each compound in each compartment
    # export/load and check the dG_f data
    #data_dG0_transformed = 'thermodynamics_data/ijo1366_dG_f.json'
    data_dG0_transformed = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_dG_f01.json'
    dG_f_data = thermodynamics_dG_f_data(id2KEGGID_filename_I='/home/user/code/thermodynamics/thermodynamics_data/id2KEGGID.csv')
    # # # dG_f_data.make_dG0_f_pH0() # only if the data has not been generated previously!
    # dG_f_data.get_transformed_dG_f('/home/user/code/thermodynamics/thermodynamics_data/compounds_dG0_f.json',cobra_model_oxic,other_data.pH,other_data.temperature,other_data.ionic_strength) # adjust the non-transformed dG0_f data to physiological pH, temperature, and ionic strength (this step has already been completed)
    #dG_f_data.export_dG_f(data_dG0_transformed) # save results for later use
    dG_f_data.import_dG_f(data_dG0_transformed)
    dG_f_data.format_dG_f()
    dG_f_data.generate_estimated_dG_f(cobra_model_oxic)
    dG_f_data.check_data()

    ##PART 4: Working
    #-------
    # load metabolomics data for oxic conditions
    data_concentrations_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_geo01.json'
    metabolomics_data_oxic = thermodynamics_metabolomicsData()
    metabolomics_data_oxic.import_metabolomics_data(data_concentrations_oxic)
    metabolomics_data_oxic.format_metabolomics_data() # add compartment identifiers to metabolite ids
    metabolomics_data_oxic.generate_estimated_metabolomics_data(cobra_model_oxic)

    ##PART 5: Working
    #-------
    # calculate dG_r and perform a consistency check based on model simulations for oxic conditions
    data_ta_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_ta.csv'
    data_dG0_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_orrev_dG0.json'
    data_dG_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_dG.json'
    data_tcc_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_tcc.json'
    tcc_oxic = thermodynamics_dG_r_data()
    tcc_oxic.import_dG0_r_json(data_dG0_oxic)
    tcc_oxic.import_dG_r_json(data_dG_oxic)
    tcc_oxic.import_tcc_json(data_tcc_oxic)
    # tcc_oxic.calculate_dG0_r(cobra_model_oxic, dG_f_data.measured_dG_f, dG_f_data.estimated_dG_f, other_data.temperature) # calculate the change in free energy of reaction without accounting for metabolite concentrations
    # tcc_oxic.calculate_dG_r(cobra_model_oxic,metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
    #                    other_data.pH, other_data.ionic_strength, other_data.temperature) # adjust the change in free energy of reaction for intracellular metabolite concentrations
    # tcc_oxic.check_thermodynamicConsistency(cobra_model_oxic,simulated_data_oxic.fva_data,
    #                    metabolomics_data_oxic.measured_concentrations,
    #                    metabolomics_data_oxic.estimated_concentrations,
    #                    other_data.pH,other_data.ionic_strength,other_data.temperature) # check the thermodynamic consistency of the data
    # tcc_oxic.export_dG0_r_json(data_dG0_oxic) # save for later use
    # tcc_oxic.export_dG_r_json(data_dG_oxic) # save for later use
    # tcc_oxic.export_tcc_json(data_tcc_oxic) # save for later use
    # tcc_oxic.export_summary(cobra_model_oxic,simulated_data_oxic.fva_data,data_ta_oxic) # write summary of the analysis to csv file    
    
    ##PART 8:
    #-------
	# Diagnose model variables and constraints prior to FBA, FVA, and sampling (Oxic condition only)

    # identified inconsistent concentrations/dG_f/tcc values
    inconsistent_concentrations_I = []
    inconsistent_dG_f_I = []
    inconsistent_tcc_I = ['EX_glc_LPAREN_e_RPAREN__reverse']
    # remove an inconsistent dGf values
    dG_f_data.remove_measured_dG_f(inconsistent_dG_f_I)
    # remove an inconsistent concentration values
    metabolomics_data_oxic.remove_measured_concentrations(inconsistent_concentrations_I)
    # remove an inconcsistent tcc
    tcc_oxic.change_feasibleReactions(inconsistent_tcc_I)    
    # diagnose tfba constraints
    tfba = thermodynamics_tfba()
    # thermodynamic_constraints_check,\
    #     inconsistent_tcc,diagnose_variables_1,\
    #     diagnose_variables_2,\
    #     diagnose_variables_3 = tfba.check_conc_ln_constraints_transport(
    #         cobra_model_oxic,
    #         metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
    #         tcc_oxic.dG0_r, other_data.pH,other_data.temperature,tcc_oxic.metabolomics_coverage,
    #         tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
    #         0.5, 0.99,n_checks_I = 0,
    #         diagnose_solver_I=None,diagnose_threshold_I=0.98,diagnose_break_I=0.1)        
    # tfba._add_conc_ln_constraints_transport(cobra_model_oxic,
    #         metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
    #         tcc_oxic.dG0_r, other_data.pH,other_data.temperature,tcc_oxic.metabolomics_coverage,
    #         tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
    #         0.5, 0.99)
    # # cobra_model_oxic.optimize()
    # from cobra.flux_analysis import flux_variability_analysis
    # fva_data = flux_variability_analysis(cobra_model_oxic, fraction_of_optimum=0.9,
    #                                   objective_sense='maximize',
    #                                   reaction_list=[cobra_model_oxic.reactions.get_by_id('conc_lnv_fum_c')],
    #                                   )
    
    # #PART 9:
    # -------
	# perform thermodynamic FBA and FVA (Oxic condition only)

    # # run TFBA
    # cobra_model_copy = cobra_model_oxic.copy()
    # tfba.tfba(cobra_model_copy,
    #     tcc_oxic.dG0_r,other_data.temperature,
    #     tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
    #     use_measured_dG_r=True, solver='glpk',)

    # cobra_model_copy = cobra_model_oxic.copy()
    # tfba.tfba_conc_ln(cobra_model_copy, 
    #     metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
    #     tcc_oxic.dG0_r,other_data.temperature,tcc_oxic.metabolomics_coverage,
    #     tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
    #     measured_concentration_coverage_criteria = 0.5, measured_dG_f_coverage_criteria = 0.99,
    #     use_measured_concentrations=True,use_measured_dG0_r=True, solver='glpk',)
    
    # run TFVA
    data_tfva_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_tfva.csv'
    data_tfva_analysis_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_tfva_analysis.csv'
    data_tfva_dG_r_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_orrev_tfva_dG_r.json'
    data_tfva_concentrations_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_tfva_concentrations.json'
    cobra_model_copy = cobra_model_oxic.copy()
    tfba.tfva(cobra_model_copy, 
        tcc_oxic.dG0_r,other_data.temperature,
        tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
        use_measured_dG0_r=True, reaction_list=None,fraction_of_optimum=1.0, solver='glpk',
        objective_sense="maximize")
    tfba.export_tfva_data(data_tfva_oxic)
    tfba.analyze_tfva_results(flux_threshold=1e-6)
    tfba.export_tfva_analysis(data_tfva_analysis_oxic)

    cobra_model_copy = cobra_model_oxic.copy()
    tfba.tfva_dG_r(cobra_model_copy, 
        tcc_oxic.dG0_r,other_data.temperature,
        tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
        use_measured_dG0_r=True, fraction_of_optimum=1.0, solver='glpk',
        objective_sense="maximize")
    tfba.export_tfva_dG_r_data(data_tfva_dG_r_oxic)

    cobra_model_copy = cobra_model_oxic.copy()
    tfba.tfva_concentrations(cobra_model_copy, 
        metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
        tcc_oxic.dG0_r,other_data.temperature,tcc_oxic.metabolomics_coverage,
        tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
        measured_concentration_coverage_criteria = 0.5, measured_dG_f_coverage_criteria = 0.99,
        use_measured_concentrations=True,use_measured_dG0_r=True,fraction_of_optimum=1.0, solver='glpk',
        objective_sense="maximize")
    tfba.export_tfva_concentrations_data(data_tfva_concentrations_oxic)
    
    # ##PART 10:
    # #-------
	# # perform thermodynamic Tsampling (Oxic condition only)
    # # NOTE: requires optGpSampler
    
    # # run Tsampling
    # data_dir = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo'
    # sampling = optGpSampler_sampling(data_dir_I = data_dir);
    # simulation_id_I = 'aerobicAnaerobic01_oxic_tsampling'
    # filename_model = simulation_id_I + '.json';
    # filename_script = simulation_id_I + '.py';
    # filename_points = simulation_id_I + '_points' + '.json';
    # filename_warmup = simulation_id_I + '_warmup' + '.json';
    # sampling.export_sampling_optGpSampler(cobra_model=cobra_model_oxic,
    #     filename_model=filename_model,
    #     filename_script=filename_script,
    #     filename_points=filename_points,
    #     filename_warmup=filename_warmup,
    #     solver_id_I = 'optGpSampler',
    #     n_points_I = 2*len(cobra_model_oxic.reactions),
    #     n_steps_I = 5000,
    #     n_threads_I = 2)
    
    ##PART 11:
    #-------
	# Analyze thermodynamic sampling (Oxic condition only)

    sampling = optGpSampler_sampling(
        data_dir_I = data_dir,
        model_I=cobra_model_oxic);
    sampling.get_points_json(filename_points);
    sampling.get_warmup_json(filename_warmup);
    sampling.calculate_mixFraction();
    # check if the model contains loops
    #loops_bool = self.sampling.check_loops();
    sampling.simulate_loops(
        data_fva='/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/loops_fva_tmp.json',
        solver_I = 'optGpSampler');
    sampling.find_loops(data_fva='/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/loops_fva_tmp.json');
    sampling.remove_loopsFromPoints();
    # calculate the flux descriptive statistics
    sampling.descriptive_statistics(points_I='flux');
    # calculate descriptive stats for metabolites
    sampling.convert_points2MetabolitePoints();
    sampling.descriptive_statistics(points_I='metabolite');
    # calculate descriptive stats for subsystems
    sampling.convert_points2SubsystemPoints();
    sampling.descriptive_statistics(points_I='subsystem');
    

    # visualize the results
    ##TODO: methods are defined, but an example is not yet given
def _main_():
    ##PART 1: Working
    #-------
    # Read in the model sbml file and define the model conditions
    # Aerobic specific changes
    cobra_model_oxic = load_thermoModel(anoxic=False)
    convert_to_irreversible(cobra_model_oxic)

    ##PART 2: Working
    #-------
    # make/load simulated data for aerobic conditions
    data_fva_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_fva_irrev_oxic.json'
    data_srd_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_srd_irrev_oxic.json'
    simulated_data_oxic = thermodynamics_simulatedData()
    # simulated_data_oxic.generate_sra_data(cobra_model_oxic) # perform single reaction deletion analysis
    # simulated_data_oxic.generate_fva_data(cobra_model_oxic) # perform flux variability analysis
    # simulated_data_oxic.export_sra_data(data_srd_oxic) # save results for later use
    # simulated_data_oxic.export_fva_data(data_fva_oxic) # save results for later use
    simulated_data_oxic.import_sra_data(data_srd_oxic)
    simulated_data_oxic.import_fva_data(data_fva_oxic)
    simulated_data_oxic.check_data()

    ##PART 3: Working
    #-------
    # load pH, ionic_strength, and temperature parameters
    other_data = thermodynamics_otherData()
    other_data.load_defaultData()
    other_data.check_data()

    # generate dG_f data for all model compounds
    # calculate the dG_f for each compound in each compartment
    # export/load and check the dG_f data
    #data_dG0_transformed = 'thermodynamics_data/ijo1366_dG_f.json'
    data_dG0_transformed = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_dG_f01.json'
    dG_f_data = thermodynamics_dG_f_data(
        id2KEGGID_filename_I=
        '/home/user/code/thermodynamics/thermodynamics_data/id2KEGGID.csv')
    # # # dG_f_data.make_dG0_f_pH0() # only if the data has not been generated previously!
    # dG_f_data.get_transformed_dG_f('/home/user/code/thermodynamics/thermodynamics_data/compounds_dG0_f.json',cobra_model_oxic,other_data.pH,other_data.temperature,other_data.ionic_strength) # adjust the non-transformed dG0_f data to physiological pH, temperature, and ionic strength (this step has already been completed)
    #dG_f_data.export_dG_f(data_dG0_transformed) # save results for later use
    dG_f_data.import_dG_f(data_dG0_transformed)
    dG_f_data.format_dG_f()
    dG_f_data.generate_estimated_dG_f(cobra_model_oxic)
    dG_f_data.check_data()

    ##PART 4: Working
    #-------
    # load metabolomics data for oxic conditions
    data_concentrations_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_geo01.json'
    metabolomics_data_oxic = thermodynamics_metabolomicsData()
    metabolomics_data_oxic.import_metabolomics_data(data_concentrations_oxic)
    metabolomics_data_oxic.format_metabolomics_data(
    )  # add compartment identifiers to metabolite ids
    metabolomics_data_oxic.generate_estimated_metabolomics_data(
        cobra_model_oxic)

    ##PART 5: Working
    #-------
    # calculate dG_r and perform a consistency check based on model simulations for oxic conditions
    data_ta_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_ta.csv'
    data_dG0_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_orrev_dG0.json'
    data_dG_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_dG.json'
    data_tcc_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_tcc.json'
    tcc_oxic = thermodynamics_dG_r_data()
    tcc_oxic.import_dG0_r_json(data_dG0_oxic)
    tcc_oxic.import_dG_r_json(data_dG_oxic)
    tcc_oxic.import_tcc_json(data_tcc_oxic)
    # tcc_oxic.calculate_dG0_r(cobra_model_oxic, dG_f_data.measured_dG_f, dG_f_data.estimated_dG_f, other_data.temperature) # calculate the change in free energy of reaction without accounting for metabolite concentrations
    # tcc_oxic.calculate_dG_r(cobra_model_oxic,metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
    #                    other_data.pH, other_data.ionic_strength, other_data.temperature) # adjust the change in free energy of reaction for intracellular metabolite concentrations
    # tcc_oxic.check_thermodynamicConsistency(cobra_model_oxic,simulated_data_oxic.fva_data,
    #                    metabolomics_data_oxic.measured_concentrations,
    #                    metabolomics_data_oxic.estimated_concentrations,
    #                    other_data.pH,other_data.ionic_strength,other_data.temperature) # check the thermodynamic consistency of the data
    # tcc_oxic.export_dG0_r_json(data_dG0_oxic) # save for later use
    # tcc_oxic.export_dG_r_json(data_dG_oxic) # save for later use
    # tcc_oxic.export_tcc_json(data_tcc_oxic) # save for later use
    # tcc_oxic.export_summary(cobra_model_oxic,simulated_data_oxic.fva_data,data_ta_oxic) # write summary of the analysis to csv file

    ##PART 8:
    #-------
    # Diagnose model variables and constraints prior to FBA, FVA, and sampling (Oxic condition only)

    # identified inconsistent concentrations/dG_f/tcc values
    inconsistent_concentrations_I = []
    inconsistent_dG_f_I = []
    inconsistent_tcc_I = ['EX_glc_LPAREN_e_RPAREN__reverse']
    # remove an inconsistent dGf values
    dG_f_data.remove_measured_dG_f(inconsistent_dG_f_I)
    # remove an inconsistent concentration values
    metabolomics_data_oxic.remove_measured_concentrations(
        inconsistent_concentrations_I)
    # remove an inconcsistent tcc
    tcc_oxic.change_feasibleReactions(inconsistent_tcc_I)
    # diagnose tfba constraints
    tfba = thermodynamics_tfba()
    # thermodynamic_constraints_check,\
    #     inconsistent_tcc,diagnose_variables_1,\
    #     diagnose_variables_2,\
    #     diagnose_variables_3 = tfba.check_conc_ln_constraints_transport(
    #         cobra_model_oxic,
    #         metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
    #         tcc_oxic.dG0_r, other_data.pH,other_data.temperature,tcc_oxic.metabolomics_coverage,
    #         tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
    #         0.5, 0.99,n_checks_I = 0,
    #         diagnose_solver_I=None,diagnose_threshold_I=0.98,diagnose_break_I=0.1)
    # tfba._add_conc_ln_constraints_transport(cobra_model_oxic,
    #         metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
    #         tcc_oxic.dG0_r, other_data.pH,other_data.temperature,tcc_oxic.metabolomics_coverage,
    #         tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
    #         0.5, 0.99)
    # # cobra_model_oxic.optimize()
    # from cobra.flux_analysis import flux_variability_analysis
    # fva_data = flux_variability_analysis(cobra_model_oxic, fraction_of_optimum=0.9,
    #                                   objective_sense='maximize',
    #                                   reaction_list=[cobra_model_oxic.reactions.get_by_id('conc_lnv_fum_c')],
    #                                   )

    # #PART 9:
    # -------
    # perform thermodynamic FBA and FVA (Oxic condition only)

    # # run TFBA
    # cobra_model_copy = cobra_model_oxic.copy()
    # tfba.tfba(cobra_model_copy,
    #     tcc_oxic.dG0_r,other_data.temperature,
    #     tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
    #     use_measured_dG_r=True, solver='glpk',)

    # cobra_model_copy = cobra_model_oxic.copy()
    # tfba.tfba_conc_ln(cobra_model_copy,
    #     metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
    #     tcc_oxic.dG0_r,other_data.temperature,tcc_oxic.metabolomics_coverage,
    #     tcc_oxic.dG_r_coverage, tcc_oxic.thermodynamic_consistency_check,
    #     measured_concentration_coverage_criteria = 0.5, measured_dG_f_coverage_criteria = 0.99,
    #     use_measured_concentrations=True,use_measured_dG0_r=True, solver='glpk',)

    # run TFVA
    data_tfva_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_tfva.csv'
    data_tfva_analysis_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_tfva_analysis.csv'
    data_tfva_dG_r_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_orrev_tfva_dG_r.json'
    data_tfva_concentrations_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_irrev_tfva_concentrations.json'
    cobra_model_copy = cobra_model_oxic.copy()
    tfba.tfva(cobra_model_copy,
              tcc_oxic.dG0_r,
              other_data.temperature,
              tcc_oxic.dG_r_coverage,
              tcc_oxic.thermodynamic_consistency_check,
              use_measured_dG0_r=True,
              reaction_list=None,
              fraction_of_optimum=1.0,
              solver='glpk',
              objective_sense="maximize")
    tfba.export_tfva_data(data_tfva_oxic)
    tfba.analyze_tfva_results(flux_threshold=1e-6)
    tfba.export_tfva_analysis(data_tfva_analysis_oxic)

    cobra_model_copy = cobra_model_oxic.copy()
    tfba.tfva_dG_r(cobra_model_copy,
                   tcc_oxic.dG0_r,
                   other_data.temperature,
                   tcc_oxic.dG_r_coverage,
                   tcc_oxic.thermodynamic_consistency_check,
                   use_measured_dG0_r=True,
                   fraction_of_optimum=1.0,
                   solver='glpk',
                   objective_sense="maximize")
    tfba.export_tfva_dG_r_data(data_tfva_dG_r_oxic)

    cobra_model_copy = cobra_model_oxic.copy()
    tfba.tfva_concentrations(cobra_model_copy,
                             metabolomics_data_oxic.measured_concentrations,
                             metabolomics_data_oxic.estimated_concentrations,
                             tcc_oxic.dG0_r,
                             other_data.temperature,
                             tcc_oxic.metabolomics_coverage,
                             tcc_oxic.dG_r_coverage,
                             tcc_oxic.thermodynamic_consistency_check,
                             measured_concentration_coverage_criteria=0.5,
                             measured_dG_f_coverage_criteria=0.99,
                             use_measured_concentrations=True,
                             use_measured_dG0_r=True,
                             fraction_of_optimum=1.0,
                             solver='glpk',
                             objective_sense="maximize")
    tfba.export_tfva_concentrations_data(data_tfva_concentrations_oxic)

    # ##PART 10:
    # #-------
    # # perform thermodynamic Tsampling (Oxic condition only)
    # # NOTE: requires optGpSampler

    # # run Tsampling
    # data_dir = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo'
    # sampling = optGpSampler_sampling(data_dir_I = data_dir);
    # simulation_id_I = 'aerobicAnaerobic01_oxic_tsampling'
    # filename_model = simulation_id_I + '.json';
    # filename_script = simulation_id_I + '.py';
    # filename_points = simulation_id_I + '_points' + '.json';
    # filename_warmup = simulation_id_I + '_warmup' + '.json';
    # sampling.export_sampling_optGpSampler(cobra_model=cobra_model_oxic,
    #     filename_model=filename_model,
    #     filename_script=filename_script,
    #     filename_points=filename_points,
    #     filename_warmup=filename_warmup,
    #     solver_id_I = 'optGpSampler',
    #     n_points_I = 2*len(cobra_model_oxic.reactions),
    #     n_steps_I = 5000,
    #     n_threads_I = 2)

    ##PART 11:
    #-------
    # Analyze thermodynamic sampling (Oxic condition only)

    sampling = optGpSampler_sampling(data_dir_I=data_dir,
                                     model_I=cobra_model_oxic)
    sampling.get_points_json(filename_points)
    sampling.get_warmup_json(filename_warmup)
    sampling.calculate_mixFraction()
    # check if the model contains loops
    #loops_bool = self.sampling.check_loops();
    sampling.simulate_loops(
        data_fva=
        '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/loops_fva_tmp.json',
        solver_I='optGpSampler')
    sampling.find_loops(
        data_fva=
        '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/loops_fva_tmp.json'
    )
    sampling.remove_loopsFromPoints()
    # calculate the flux descriptive statistics
    sampling.descriptive_statistics(points_I='flux')
    # calculate descriptive stats for metabolites
    sampling.convert_points2MetabolitePoints()
    sampling.descriptive_statistics(points_I='metabolite')
    # calculate descriptive stats for subsystems
    sampling.convert_points2SubsystemPoints()
    sampling.descriptive_statistics(points_I='subsystem')
def _main_():
    ##PART 1: Working
    #-------
    # Read in the model sbml file and define the model conditions
    # Anaerobic specific changes:
    cobra_model_anoxic = load_thermoModel(anoxic = True)
    #convert_to_irreversible(cobra_model_anoxic)
    # Aerobic specific changes
    cobra_model_oxic = load_thermoModel(anoxic = False)
    #convert_to_irreversible(cobra_model_oxic)

    ##PART 2: Working
    #-------
    # make/load simulated data for anaerobic conditions
    data_fva_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_fva_anoxic.json'
    data_srd_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_srd_anoxic.json'
    simulated_data_anoxic = thermodynamics_simulatedData()
    # simulated_data_anoxic.generate_sra_data(cobra_model_anoxic) # perform single reaction deletion analysis
    # simulated_data_anoxic.generate_fva_data(cobra_model_anoxic) # perform flux variability analysis
    # simulated_data_anoxic.export_sra_data(data_srd_anoxic) # save results for later use
    # simulated_data_anoxic.export_fva_data(data_fva_anoxic) # save results for later use
    simulated_data_anoxic.import_sra_data(data_srd_anoxic)
    simulated_data_anoxic.import_fva_data(data_fva_anoxic)
    simulated_data_anoxic.check_data()

    # make/load simulated data for aerobic conditions
    data_fva_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_fva_oxic.json'
    data_srd_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_srd_oxic.json'
    simulated_data_oxic = thermodynamics_simulatedData()
    # simulated_data_oxic.generate_sra_data(cobra_model_oxic) # perform single reaction deletion analysis
    # simulated_data_oxic.generate_fva_data(cobra_model_oxic) # perform flux variability analysis
    # simulated_data_oxic.export_sra_data(data_srd_oxic) # save results for later use
    # simulated_data_oxic.export_fva_data(data_fva_oxic) # save results for later use
    simulated_data_oxic.import_sra_data(data_srd_oxic)
    simulated_data_oxic.import_fva_data(data_fva_oxic)
    simulated_data_oxic.check_data()

    ##PART 3: Working
    #-------
    # load pH, ionic_strength, and temperature parameters
    other_data = thermodynamics_otherData()
    other_data.load_defaultData()
    other_data.check_data()

    # generate dG_f data for all model compounds
    # calculate the dG_f for each compound in each compartment
    # export/load and check the dG_f data
    #data_dG0_transformed = 'thermodynamics_data/ijo1366_dG_f.json'
    data_dG0_transformed = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_dG_f01.json'
    dG_f_data = thermodynamics_dG_f_data(id2KEGGID_filename_I='/home/user/code/thermodynamics/thermodynamics_data/id2KEGGID.csv')
    # # # dG_f_data.make_dG0_f_pH0() # only if the data has not been generated previously!
    # dG_f_data.get_transformed_dG_f('/home/user/code/thermodynamics/thermodynamics_data/compounds_dG0_f.json',cobra_model_oxic,other_data.pH,other_data.temperature,other_data.ionic_strength) # adjust the non-transformed dG0_f data to physiological pH, temperature, and ionic strength (this step has already been completed)
    #dG_f_data.export_dG_f(data_dG0_transformed) # save results for later use
    dG_f_data.import_dG_f(data_dG0_transformed)
    dG_f_data.format_dG_f()
    dG_f_data.generate_estimated_dG_f(cobra_model_oxic)
    dG_f_data.check_data()

    ##PART 4: Working
    #-------
    # load metabolomics data for anoxic conditions
    data_concentrations_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_geo01.json'
    metabolomics_data_anoxic = thermodynamics_metabolomicsData()
    metabolomics_data_anoxic.import_metabolomics_data(data_concentrations_anoxic)
    metabolomics_data_anoxic.format_metabolomics_data() # add compartment identifiers to metabolite ids
    metabolomics_data_anoxic.generate_estimated_metabolomics_data(cobra_model_anoxic)
    # load metabolomics data for oxic conditions
    data_concentrations_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_geo01.json'
    metabolomics_data_oxic = thermodynamics_metabolomicsData()
    metabolomics_data_oxic.import_metabolomics_data(data_concentrations_oxic)
    metabolomics_data_oxic.format_metabolomics_data() # add compartment identifiers to metabolite ids
    metabolomics_data_oxic.generate_estimated_metabolomics_data(cobra_model_oxic)

    #PART 5: Working
    #-------
    # calculate dG_r and perform a consistency check based on model simulations for anoxic conditions
    data_ta_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_ta.csv'
    data_dG0_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_dG0.json'
    data_dG_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_dG.json'
    data_tcc_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_tcc.json'
    tcc_anoxic = thermodynamics_dG_r_data()
    tcc_anoxic.calculate_dG0_r(cobra_model_anoxic, dG_f_data.measured_dG_f, dG_f_data.estimated_dG_f, other_data.temperature) # calculate the change in free energy of reaction without accounting for metabolite concentrations
    tcc_anoxic.calculate_dG_r(cobra_model_anoxic,metabolomics_data_anoxic.measured_concentrations, metabolomics_data_anoxic.estimated_concentrations,
                       other_data.pH, other_data.ionic_strength, other_data.temperature) # adjust the change in free energy of reaction for intracellular metabolite concentrations
    tcc_anoxic.check_thermodynamicConsistency(cobra_model_anoxic,simulated_data_anoxic.fva_data,
                       metabolomics_data_anoxic.measured_concentrations,
                       metabolomics_data_anoxic.estimated_concentrations,
                       other_data.pH,other_data.ionic_strength,other_data.temperature) # check the thermodynamic consistency of the data
    tcc_anoxic.export_dG0_r_json(data_dG0_anoxic) # save for later use
    tcc_anoxic.export_dG_r_json(data_dG_anoxic) # save for later use
    tcc_anoxic.export_tcc_json(data_ta_anoxic) # save for later use
    tcc_anoxic.export_summary(cobra_model_anoxic,simulated_data_anoxic.fva_data,data_ta_anoxic) # write summary of the analysis to csv file

    # calculate dG_r and perform a consistency check based on model simulations for oxic conditions
    data_ta_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_ta.csv'
    data_dG0_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_dG0.json'
    data_dG_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_dG.json'
    data_tcc_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_tcc.json'
    tcc_oxic = thermodynamics_dG_r_data()
    # tcc_oxic.import_dG0_r_json(data_dG0_oxic)
    # tcc_oxic.import_dG_r_json(data_dG_oxic)
    # tcc_oxic.import_tcc_json(data_tcc_oxic)
    tcc_oxic.calculate_dG0_r(cobra_model_oxic, dG_f_data.measured_dG_f, dG_f_data.estimated_dG_f, other_data.temperature) # calculate the change in free energy of reaction without accounting for metabolite concentrations
    tcc_oxic.calculate_dG_r(cobra_model_oxic,metabolomics_data_oxic.measured_concentrations, metabolomics_data_oxic.estimated_concentrations,
                       other_data.pH, other_data.ionic_strength, other_data.temperature) # adjust the change in free energy of reaction for intracellular metabolite concentrations
    tcc_oxic.check_thermodynamicConsistency(cobra_model_oxic,simulated_data_oxic.fva_data,
                       metabolomics_data_oxic.measured_concentrations,
                       metabolomics_data_oxic.estimated_concentrations,
                       other_data.pH,other_data.ionic_strength,other_data.temperature) # check the thermodynamic consistency of the data
    tcc_oxic.export_dG0_r_json(data_dG0_oxic) # save for later use
    tcc_oxic.export_dG_r_json(data_dG_oxic) # save for later use
    tcc_oxic.export_tcc_json(data_tcc_oxic) # save for later use
    tcc_oxic.export_summary(cobra_model_oxic,simulated_data_oxic.fva_data,data_ta_oxic) # write summary of the analysis to csv file

    ##PART 6: Working
    #-------
    # inspect the thermodynamic analysis results

    # constrain the model solution and simulate optimal growth
    gr_analysis_anoxic = simulate_thermoConstraints(cobra_model_anoxic,['PGCD','ACACT1r','NDPK2'])
    gr_analysis_oxic = simulate_thermoConstraints(cobra_model_oxic,['PGCD','ACACT1r'])

    # expand the reaction set of the anoxic model to reflect the enzyme permiscuity of pykA
    add_pykA(cobra_model_anoxic)
    gr_analysis_anoxic = simulate_thermoConstraints(cobra_model_anoxic,['PGCD','ACACT1r','NDPK2'])

    ##PART 7: Working
    #-------
    # calculate the dG for biosynthetic pathways

    # calculate the dG for biosynthetic pathways for anoxic conditions
    tccp_anoxic = thermodynamics_dG_p_data()
    tccp_anoxic.calculate_dG_p(cobra_model_anoxic,tcc_anoxic.dG0_r,tcc_anoxic.dG_r)
    # calculate the dG for biosynthetic pathways for oxic conditions
    tccp_oxic = thermodynamics_dG_p_data()
    tccp_oxic.calculate_dG_p(cobra_model_oxic,tcc_oxic.dG0_r,tcc_oxic.dG_r)    

    # visualize the results
    ##TODO: methods are defined, but an example is not yet given
def _main_():
    ##PART 1: Working
    #-------
    # Read in the model sbml file and define the model conditions
    # Anaerobic specific changes:
    cobra_model_anoxic = load_thermoModel(anoxic=True)
    #convert_to_irreversible(cobra_model_anoxic)
    # Aerobic specific changes
    cobra_model_oxic = load_thermoModel(anoxic=False)
    #convert_to_irreversible(cobra_model_oxic)

    ##PART 2: Working
    #-------
    # make/load simulated data for anaerobic conditions
    data_fva_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_fva_anoxic.json'
    data_srd_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_srd_anoxic.json'
    simulated_data_anoxic = thermodynamics_simulatedData()
    # simulated_data_anoxic.generate_sra_data(cobra_model_anoxic) # perform single reaction deletion analysis
    # simulated_data_anoxic.generate_fva_data(cobra_model_anoxic) # perform flux variability analysis
    # simulated_data_anoxic.export_sra_data(data_srd_anoxic) # save results for later use
    # simulated_data_anoxic.export_fva_data(data_fva_anoxic) # save results for later use
    simulated_data_anoxic.import_sra_data(data_srd_anoxic)
    simulated_data_anoxic.import_fva_data(data_fva_anoxic)
    simulated_data_anoxic.check_data()

    # make/load simulated data for aerobic conditions
    data_fva_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_fva_oxic.json'
    data_srd_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_srd_oxic.json'
    simulated_data_oxic = thermodynamics_simulatedData()
    # simulated_data_oxic.generate_sra_data(cobra_model_oxic) # perform single reaction deletion analysis
    # simulated_data_oxic.generate_fva_data(cobra_model_oxic) # perform flux variability analysis
    # simulated_data_oxic.export_sra_data(data_srd_oxic) # save results for later use
    # simulated_data_oxic.export_fva_data(data_fva_oxic) # save results for later use
    simulated_data_oxic.import_sra_data(data_srd_oxic)
    simulated_data_oxic.import_fva_data(data_fva_oxic)
    simulated_data_oxic.check_data()

    ##PART 3: Working
    #-------
    # load pH, ionic_strength, and temperature parameters
    other_data = thermodynamics_otherData()
    other_data.load_defaultData()
    other_data.check_data()

    # generate dG_f data for all model compounds
    # calculate the dG_f for each compound in each compartment
    # export/load and check the dG_f data
    #data_dG0_transformed = 'thermodynamics_data/ijo1366_dG_f.json'
    data_dG0_transformed = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_dG_f01.json'
    dG_f_data = thermodynamics_dG_f_data(
        id2KEGGID_filename_I=
        '/home/user/code/thermodynamics/thermodynamics_data/id2KEGGID.csv')
    # # # dG_f_data.make_dG0_f_pH0() # only if the data has not been generated previously!
    # dG_f_data.get_transformed_dG_f('/home/user/code/thermodynamics/thermodynamics_data/compounds_dG0_f.json',cobra_model_oxic,other_data.pH,other_data.temperature,other_data.ionic_strength) # adjust the non-transformed dG0_f data to physiological pH, temperature, and ionic strength (this step has already been completed)
    #dG_f_data.export_dG_f(data_dG0_transformed) # save results for later use
    dG_f_data.import_dG_f(data_dG0_transformed)
    dG_f_data.format_dG_f()
    dG_f_data.generate_estimated_dG_f(cobra_model_oxic)
    dG_f_data.check_data()

    ##PART 4: Working
    #-------
    # load metabolomics data for anoxic conditions
    data_concentrations_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_geo01.json'
    metabolomics_data_anoxic = thermodynamics_metabolomicsData()
    metabolomics_data_anoxic.import_metabolomics_data(
        data_concentrations_anoxic)
    metabolomics_data_anoxic.format_metabolomics_data(
    )  # add compartment identifiers to metabolite ids
    metabolomics_data_anoxic.generate_estimated_metabolomics_data(
        cobra_model_anoxic)
    # load metabolomics data for oxic conditions
    data_concentrations_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_geo01.json'
    metabolomics_data_oxic = thermodynamics_metabolomicsData()
    metabolomics_data_oxic.import_metabolomics_data(data_concentrations_oxic)
    metabolomics_data_oxic.format_metabolomics_data(
    )  # add compartment identifiers to metabolite ids
    metabolomics_data_oxic.generate_estimated_metabolomics_data(
        cobra_model_oxic)

    #PART 5: Working
    #-------
    # calculate dG_r and perform a consistency check based on model simulations for anoxic conditions
    data_ta_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_ta.csv'
    data_dG0_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_dG0.json'
    data_dG_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_dG.json'
    data_tcc_anoxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_anoxic_tcc.json'
    tcc_anoxic = thermodynamics_dG_r_data()
    tcc_anoxic.calculate_dG0_r(
        cobra_model_anoxic, dG_f_data.measured_dG_f, dG_f_data.estimated_dG_f,
        other_data.temperature
    )  # calculate the change in free energy of reaction without accounting for metabolite concentrations
    tcc_anoxic.calculate_dG_r(
        cobra_model_anoxic, metabolomics_data_anoxic.measured_concentrations,
        metabolomics_data_anoxic.estimated_concentrations, other_data.pH,
        other_data.ionic_strength, other_data.temperature
    )  # adjust the change in free energy of reaction for intracellular metabolite concentrations
    tcc_anoxic.check_thermodynamicConsistency(
        cobra_model_anoxic, simulated_data_anoxic.fva_data,
        metabolomics_data_anoxic.measured_concentrations,
        metabolomics_data_anoxic.estimated_concentrations, other_data.pH,
        other_data.ionic_strength, other_data.temperature
    )  # check the thermodynamic consistency of the data
    tcc_anoxic.export_dG0_r_json(data_dG0_anoxic)  # save for later use
    tcc_anoxic.export_dG_r_json(data_dG_anoxic)  # save for later use
    tcc_anoxic.export_tcc_json(data_ta_anoxic)  # save for later use
    tcc_anoxic.export_summary(
        cobra_model_anoxic, simulated_data_anoxic.fva_data,
        data_ta_anoxic)  # write summary of the analysis to csv file

    # calculate dG_r and perform a consistency check based on model simulations for oxic conditions
    data_ta_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_ta.csv'
    data_dG0_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_dG0.json'
    data_dG_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_dG.json'
    data_tcc_oxic = '/home/user/code/thermodynamics/thermodynamics_data/aerobicAnaerobic01_geo/aerobicAnaerobic01_oxic_tcc.json'
    tcc_oxic = thermodynamics_dG_r_data()
    # tcc_oxic.import_dG0_r_json(data_dG0_oxic)
    # tcc_oxic.import_dG_r_json(data_dG_oxic)
    # tcc_oxic.import_tcc_json(data_tcc_oxic)
    tcc_oxic.calculate_dG0_r(
        cobra_model_oxic, dG_f_data.measured_dG_f, dG_f_data.estimated_dG_f,
        other_data.temperature
    )  # calculate the change in free energy of reaction without accounting for metabolite concentrations
    tcc_oxic.calculate_dG_r(
        cobra_model_oxic, metabolomics_data_oxic.measured_concentrations,
        metabolomics_data_oxic.estimated_concentrations, other_data.pH,
        other_data.ionic_strength, other_data.temperature
    )  # adjust the change in free energy of reaction for intracellular metabolite concentrations
    tcc_oxic.check_thermodynamicConsistency(
        cobra_model_oxic, simulated_data_oxic.fva_data,
        metabolomics_data_oxic.measured_concentrations,
        metabolomics_data_oxic.estimated_concentrations, other_data.pH,
        other_data.ionic_strength, other_data.temperature
    )  # check the thermodynamic consistency of the data
    tcc_oxic.export_dG0_r_json(data_dG0_oxic)  # save for later use
    tcc_oxic.export_dG_r_json(data_dG_oxic)  # save for later use
    tcc_oxic.export_tcc_json(data_tcc_oxic)  # save for later use
    tcc_oxic.export_summary(
        cobra_model_oxic, simulated_data_oxic.fva_data,
        data_ta_oxic)  # write summary of the analysis to csv file

    ##PART 6: Working
    #-------
    # inspect the thermodynamic analysis results

    # constrain the model solution and simulate optimal growth
    gr_analysis_anoxic = simulate_thermoConstraints(
        cobra_model_anoxic, ['PGCD', 'ACACT1r', 'NDPK2'])
    gr_analysis_oxic = simulate_thermoConstraints(cobra_model_oxic,
                                                  ['PGCD', 'ACACT1r'])

    # expand the reaction set of the anoxic model to reflect the enzyme permiscuity of pykA
    add_pykA(cobra_model_anoxic)
    gr_analysis_anoxic = simulate_thermoConstraints(
        cobra_model_anoxic, ['PGCD', 'ACACT1r', 'NDPK2'])

    ##PART 7: Working
    #-------
    # calculate the dG for biosynthetic pathways

    # calculate the dG for biosynthetic pathways for anoxic conditions
    tccp_anoxic = thermodynamics_dG_p_data()
    tccp_anoxic.calculate_dG_p(cobra_model_anoxic, tcc_anoxic.dG0_r,
                               tcc_anoxic.dG_r)
    # calculate the dG for biosynthetic pathways for oxic conditions
    tccp_oxic = thermodynamics_dG_p_data()
    tccp_oxic.calculate_dG_p(cobra_model_oxic, tcc_oxic.dG0_r, tcc_oxic.dG_r)