-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMbarkeri_simulations.py
More file actions
104 lines (79 loc) · 3.83 KB
/
Mbarkeri_simulations.py
File metadata and controls
104 lines (79 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 15 16:01:45 2024
@author: mre283
"""
import pandas as pd
import separate_cat_ana as sca
import PrecursorSeparator as ps
import os
#%%
cwd = os.getcwd()
result_path = cwd+'\Results\\Mbarkeri'
input_files = cwd+r'\input_files/'
#%%
acetate = sca.separate_cat_ana(input_files+'readfile_acetate_Mbarkeri.xlsx', all_cofactors=False)
acetate.do_cat_ana_split()
dfs = acetate.generate_dfs()
result_df, atp_df, cofactor_df = dfs
mceq_dict_biomass = acetate.generate_MCEQs(result_df, additional_active_metabolites=['M_atp_c', 'M_nadph_c', 'M_adp_c', 'M_nadp_c'])
df_mceqs = pd.DataFrame.from_records(mceq_dict_biomass, index=['overall']).T
model = acetate.active_model.clone()
prec = ps.PrecursorSeparator(model, result_df, biomass_reac=acetate.biomass_reac)
fluxes, mceq, fva_df, kos = prec.run(acetate)
energy_obj = sca.energy_generation(model)
split_names = True
atp_consumption, atp_production = energy_obj.calculate_energy(fluxes, split_names=split_names)
nadh_prod, nadh_cons = energy_obj.calculate_NADH_prod(fluxes, split_names=split_names)
nadph_prod, nadph_cons = energy_obj.calculate_NADPH_prod(fluxes, split_names=split_names)
info_dict = {}
info_dict['mceq'] = mceq
info_dict['atp production'] = atp_production
info_dict['atp consumption'] = atp_consumption
info_dict['nadh production'] = nadh_prod
info_dict['nadh consumption'] = nadh_cons
info_dict['nadph production'] = nadph_prod
info_dict['nadph consumption'] = nadph_cons
with pd.ExcelWriter(result_path+"\\acetate.xlsx") as writer:
# use to_excel function and specify the sheet_name and index
# to store the dataframe in specified sheet
result_df.to_excel(writer, sheet_name="overall")
atp_df.to_excel(writer, sheet_name="atp_overall")
cofactor_df.to_excel(writer, sheet_name="cofactor_overall")
df_mceqs.to_excel(writer, sheet_name="mceqs")
pd.Series(fluxes).to_excel(writer, sheet_name="fluxes_BP")
pd.Series(info_dict).to_excel(writer, sheet_name="info_BP")
fva_df.to_excel(writer, sheet_name="fva_BP")
#%%
bicarbonate = sca.separate_cat_ana(input_files+'readfile_bicarbonateH2_Mbarkeri.xlsx', all_cofactors=False)
bicarbonate.do_cat_ana_split()
dfs = bicarbonate.generate_dfs()
result_df, atp_df, cofactor_df = dfs
mceq_dict_biomass = bicarbonate.generate_MCEQs(result_df, additional_active_metabolites=['M_atp_c', 'M_f420_DASH_2h2_c', 'M_adp_c', 'M_f420_DASH_2_c'])
df_mceqs = pd.DataFrame.from_records(mceq_dict_biomass, index=['overall']).T
model = bicarbonate.active_model.clone()
prec = ps.PrecursorSeparator(model, result_df, biomass_reac=bicarbonate.biomass_reac)
fluxes, mceq, fva_df, kos = prec.run(bicarbonate)
energy_obj = sca.energy_generation(model)
split_names = True
atp_consumption, atp_production = energy_obj.calculate_energy(fluxes, split_names=split_names)
nadh_prod, nadh_cons = energy_obj.calculate_NADH_prod(fluxes, split_names=split_names)
nadph_prod, nadph_cons = energy_obj.calculate_NADPH_prod(fluxes, split_names=split_names)
info_dict = {}
info_dict['mceq'] = mceq
info_dict['atp production'] = atp_production
info_dict['atp consumption'] = atp_consumption
info_dict['nadh production'] = nadh_prod
info_dict['nadh consumption'] = nadh_cons
info_dict['nadph production'] = nadph_prod
info_dict['nadph consumption'] = nadph_cons
with pd.ExcelWriter(result_path+"\\bicarbonateH2.xlsx") as writer:
# use to_excel function and specify the sheet_name and index
# to store the dataframe in specified sheet
result_df.to_excel(writer, sheet_name="overall")
atp_df.to_excel(writer, sheet_name="atp_overall")
cofactor_df.to_excel(writer, sheet_name="cofactor_overall")
df_mceqs.to_excel(writer, sheet_name="mceqs")
pd.Series(fluxes).to_excel(writer, sheet_name="fluxes_BP")
pd.Series(info_dict).to_excel(writer, sheet_name="info_BP")
fva_df.to_excel(writer, sheet_name="fva_BP")