diff --git a/maud/getting_stan_inputs.py b/maud/getting_stan_inputs.py index 9836970d..d2d228a2 100644 --- a/maud/getting_stan_inputs.py +++ b/maud/getting_stan_inputs.py @@ -133,6 +133,7 @@ def get_network_properties_input( metabolite_codes = codify_maud_object(kinetic_model.metabolites) mic_codes = codify_maud_object(mics) enzyme_codes = codify_maud_object(enzymes) + ers_codes = codify_maud_object(kinetic_model.ers) km_ids = parameters.km.ids[0] km_codes = dict(zip(km_ids, range(1, len(km_ids) + 1))) if allosteries is not None: @@ -177,6 +178,10 @@ def get_network_properties_input( enzyme_codes[er.enzyme_id] if isinstance(er, EnzymeReaction) else 0 for er in edges ] + edge_ers_code = [ + ers_codes[er.id] if isinstance(er, EnzymeReaction) else 0 + for er in edges + ] edge_drain_code = [ drain_codes[d.id] if isinstance(d, Reaction) else 0 for d in edges ] @@ -338,6 +343,7 @@ def get_network_properties_input( "N_edge": len(S.columns), "N_unbalanced": len(unbalanced_mic_codes), "N_enzyme": len(enzymes), + "N_er": len(kinetic_model.ers), "N_phosphorylation": len(phosphorylation_codes), "N_pme": len(pme_codes), "N_competitive_inhibition": len(ci_ix_long), @@ -355,6 +361,7 @@ def get_network_properties_input( "ci_mic_ix": ci_mic_codes, "edge_type": edge_mechanism_code, "edge_to_enzyme": edge_enzyme_code, + "edge_to_er": edge_ers_code, "edge_to_tc": edge_tc_code, "edge_to_drain": edge_drain_code, "edge_to_reaction": edge_reaction_code, diff --git a/maud/stan/functions.stan b/maud/stan/functions.stan index d1ffc3c9..cf792183 100644 --- a/maud/stan/functions.stan +++ b/maud/stan/functions.stan @@ -297,12 +297,12 @@ functions { } vector get_vmax_by_edge(vector enzyme, vector kcat, - array[] int edge_to_enzyme, array[] int edge_type) { + array[] int edge_to_enzyme, array[] int edge_to_er, array[] int edge_type) { int N_edge = size(edge_to_enzyme); vector[N_edge] out = rep_vector(1, N_edge); for (f in 1 : N_edge) { if (edge_type[f] != 3) { - out[f] = enzyme[edge_to_enzyme[f]] * kcat[edge_to_enzyme[f]]; + out[f] = enzyme[edge_to_enzyme[f]] * kcat[edge_to_er[f]]; } } return out; @@ -313,7 +313,7 @@ functions { vector kcat_pme, vector conc_pme, vector drain, real temperature, real drain_small_conc_corrector, matrix S, vector subunits, array[] int edge_type, - array[] int edge_to_enzyme, array[] int edge_to_drain, + array[] int edge_to_enzyme, array[] int edge_to_er, array[] int edge_to_drain, array[] int ci_mic_ix, array[] int sub_km_ix_by_edge_long, array[,] int sub_km_ix_by_edge_bounds, @@ -333,6 +333,7 @@ functions { array[] int phosphorylation_pme) { int N_edge = cols(S); vector[N_edge] vmax = get_vmax_by_edge(enzyme, kcat, edge_to_enzyme, + edge_to_er, edge_type); vector[N_edge] reversibility = get_reversibility(dgr, temperature, S, conc, edge_type); @@ -382,7 +383,7 @@ functions { vector conc_pme, vector drain, real temperature, real drain_small_conc_corrector, matrix S, vector subunits, array[] int edge_type, - array[] int edge_to_enzyme, array[] int edge_to_drain, + array[] int edge_to_enzyme, array[] int edge_to_er, array[] int edge_to_drain, array[] int ci_mic_ix, array[] int sub_km_ix_by_edge_long, array[,] int sub_km_ix_by_edge_bounds, @@ -410,7 +411,7 @@ functions { temperature, drain_small_conc_corrector, S, subunits, edge_type, - edge_to_enzyme, edge_to_drain, + edge_to_enzyme, edge_to_er, edge_to_drain, ci_mic_ix, sub_km_ix_by_edge_long, sub_km_ix_by_edge_bounds, @@ -443,6 +444,7 @@ functions { matrix S, vector subunits, array[] int edge_type, array[] int edge_to_enzyme, + array[] int edge_to_er, array[] int edge_to_drain, array[] int ci_mic_ix, array[] int sub_km_ix_by_edge_long, @@ -467,6 +469,7 @@ functions { int N_edge = cols(S); complex_vector[N_edge] vmax = get_complex_vmax_by_edge(enzyme, kcat, edge_to_enzyme, + edge_to_er, edge_type); vector[N_edge] reversibility = get_reversibility(dgr, temperature, S, conc, edge_type); @@ -511,12 +514,13 @@ functions { complex_vector get_complex_vmax_by_edge(complex_vector enzyme, vector kcat, array[] int edge_to_enzyme, + array[] int edge_to_er, array[] int edge_type) { int N_edge = size(edge_to_enzyme); complex_vector[N_edge] out = rep_vector(1, N_edge); for (f in 1 : N_edge) { if (edge_type[f] != 3) { - out[f] = enzyme[edge_to_enzyme[f]] * kcat[edge_to_enzyme[f]]; + out[f] = enzyme[edge_to_enzyme[f]] * kcat[edge_to_er[f]]; } } return out; @@ -552,6 +556,7 @@ functions { matrix S, vector subunits, array[] int edge_type, array[] int edge_to_enzyme, + array[] int edge_to_er, array[] int edge_to_drain, array[] int ci_mic_ix, array[] int sub_km_ix_by_edge_long, @@ -574,7 +579,7 @@ functions { array[] int phosphorylation_type, array[] int phosphorylation_pme) { int N_edge = cols(S); - vector[N_edge] vmax = get_vmax_by_edge(enzyme, kcat, edge_to_enzyme, + vector[N_edge] vmax = get_vmax_by_edge(enzyme, kcat, edge_to_enzyme,edge_to_er, edge_type); complex_vector[N_edge] reversibility = get_reversibility_complex(dgr, temperature, @@ -810,7 +815,7 @@ vector maud_ae_system(vector conc, vector conc_pme, vector drain, real temperature, real drain_small_conc_corrector, matrix S, vector subunits, array[] int edge_type, - array[] int edge_to_enzyme, array[] int edge_to_drain, + array[] int edge_to_enzyme, array[] int edge_to_er, array[] int edge_to_drain, array[] int ci_mic_ix, array[] int sub_km_ix_by_edge_long, array[,] int sub_km_ix_by_edge_bounds, @@ -843,7 +848,7 @@ vector maud_ae_system(vector conc, temperature, drain_small_conc_corrector, S, subunits, edge_type, - edge_to_enzyme, edge_to_drain, + edge_to_enzyme, edge_to_er, edge_to_drain, ci_mic_ix, sub_km_ix_by_edge_long, sub_km_ix_by_edge_bounds, prod_km_ix_by_edge_long, diff --git a/maud/stan/model.stan b/maud/stan/model.stan index f338e96e..e9af4a45 100644 --- a/maud/stan/model.stan +++ b/maud/stan/model.stan @@ -11,6 +11,7 @@ data { int N_prod_km; int N_reaction; int N_enzyme; + int N_er; int N_drain; int N_edge; int N_allostery; @@ -25,6 +26,7 @@ data { array[N_competitive_inhibition] int ci_mic_ix; array[N_edge] int edge_type; // 1 = reversible modular rate law, 2 = drain array[N_edge] int edge_to_enzyme; // 0 if drain + array[N_edge] int edge_to_er; // 0 if drain array[N_edge] int edge_to_tc; // 0 if non-allosteric array[N_edge] int edge_to_drain; // 0 if enzyme array[N_edge] int edge_to_reaction; @@ -201,7 +203,7 @@ transformed parameters { temperature_train[e], drain_small_conc_corrector, S, subunits, edge_type, - edge_to_enzyme, edge_to_drain, + edge_to_enzyme, edge_to_er, edge_to_drain, ci_mic_ix, sub_km_ix_by_edge_long, sub_km_ix_by_edge_bounds, prod_km_ix_by_edge_long, @@ -231,7 +233,7 @@ transformed parameters { temperature_train[e], drain_small_conc_corrector, S, subunits, edge_type, - edge_to_enzyme, edge_to_drain, + edge_to_enzyme, edge_to_er, edge_to_drain, ci_mic_ix, sub_km_ix_by_edge_long, sub_km_ix_by_edge_bounds, @@ -388,6 +390,7 @@ generated quantities { subunits, edge_type, edge_to_enzyme, + edge_to_er, edge_to_drain, ci_mic_ix, sub_km_ix_by_edge_long, @@ -431,6 +434,7 @@ generated quantities { subunits, edge_type, edge_to_enzyme, + edge_to_er, edge_to_drain, ci_mic_ix, sub_km_ix_by_edge_long, diff --git a/maud/stan/out_of_sample_model.stan b/maud/stan/out_of_sample_model.stan index 68cfc820..713c0fa8 100644 --- a/maud/stan/out_of_sample_model.stan +++ b/maud/stan/out_of_sample_model.stan @@ -10,6 +10,7 @@ data { int N_sub_km; int N_prod_km; int N_reaction; + int N_er; // enzyme reactions int N_enzyme; int N_drain; int N_edge; @@ -24,6 +25,7 @@ data { array[N_competitive_inhibition] int ci_mic_ix; array[N_edge] int edge_type; // 1 = reversible modular rate law, 2 = drain array[N_edge] int edge_to_enzyme; // 0 if drain + array[N_edge] int edge_to_er; // 0 if drain array[N_edge] int edge_to_tc; // 0 if non-allosteric array[N_edge] int edge_to_drain; // 0 if enzyme array[N_edge] int edge_to_reaction; @@ -152,7 +154,7 @@ generated quantities { temperature_test[e], drain_small_conc_corrector, S, subunits, edge_type, - edge_to_enzyme, edge_to_drain, + edge_to_enzyme, edge_to_er, edge_to_drain, ci_mic_ix, sub_km_ix_by_edge_long, sub_km_ix_by_edge_bounds, prod_km_ix_by_edge_long, @@ -181,7 +183,7 @@ generated quantities { temperature_test[e], drain_small_conc_corrector, S, subunits, edge_type, - edge_to_enzyme, edge_to_drain, + edge_to_enzyme, edge_to_er, edge_to_drain, ci_mic_ix, sub_km_ix_by_edge_long, sub_km_ix_by_edge_bounds,