0001 function [collect_v_all,collect_v_kinetic,c_stat,v_stat,collect_c,collect_v,collect_mu,mu_stat] = model_embedding_consistent_fluxes(network,kinetic_models,me_options,mapping_metabolites,mapping_reactions)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 collect_c_own= nan * ones(length(network.metabolites),length(kinetic_models));
0028 collect_v_own= nan * ones(length(network.actions), length(kinetic_models));
0029
0030
0031 collect_c = nan * ones(length(network.metabolites),length(kinetic_models));
0032 collect_v = nan * ones(length(network.actions), length(kinetic_models));
0033 collect_c_eq = nan * ones(length(network.metabolites),length(kinetic_models));
0034 collect_mu = nan * ones(length(network.metabolites),length(kinetic_models));
0035
0036
0037 collect_c_all = nan * ones(length(network.metabolites),1);
0038 collect_c_eq_all = nan * ones(length(network.metabolites),1);
0039 collect_v_all = nan * ones(length(network.actions),1);
0040 collect_v_kinetic= nan * ones(length(network.actions),1);
0041
0042
0043 if isfield(me_options,'v_network'),
0044 collect_v_all(1:length(me_options.v_network)) = me_options.v_network;
0045 end
0046
0047 for it = 1:length(kinetic_models),
0048
0049
0050
0051 nn = kinetic_models{it};
0052 c_stat_own{it} = nn.s_init;
0053 v_stat_own{it} = network_velocities(c_stat_own{it},nn);
0054 collect_c_own(mapping_metabolites{it},it) = c_stat_own{it};
0055 collect_v_own(mapping_reactions{it},it) = v_stat_own{it};
0056
0057
0058
0059 ind_predefined_c = find(isfinite(collect_c_all(mapping_metabolites{it})));
0060 predefined_c = collect_c_all(mapping_metabolites{it}(ind_predefined_c));
0061 predefined_c_eq = collect_c_eq_all(mapping_metabolites{it}(ind_predefined_c));
0062 nn.external(ind_predefined_c) = 1;
0063 c_stat{it} = c_stat_own{it};
0064 c_stat{it}(ind_predefined_c) = predefined_c;
0065 v_stat{it} = network_velocities(c_stat{it}, kinetic_models{it});
0066
0067 if me_options.enforce_stationarity,
0068 c_stat{it} = network_steady_state(nn,c_stat{it},10000);
0069 v_stat{it} = network_velocities(c_stat{it}, kinetic_models{it});
0070 v_stat{it} = es_make_fluxes_stationary(kinetic_models{it}, v_stat{it});
0071 v_stat{it} = es_make_fluxes_stationary(kinetic_models{it}, v_stat{it});
0072 end
0073
0074
0075 nnn = nn;
0076 nnn.external = 0 * nnn.external;
0077 c_eq{it} = c_stat{it};
0078 c_eq{it}(ind_predefined_c) = predefined_c_eq;
0079 c_eq{it} = real(network_steady_state(nnn, c_eq{it},10));
0080
0081
0082 c_eq{it} = real(c_eq{it});
0083 c_eq{it}(c_eq{it}<10^-15) = 10^-15;
0084
0085
0086
0087 mu_stat{it} = RT * log(c_stat{it}./c_eq{it});
0088
0089 collect_c(mapping_metabolites{it},it) = c_stat{it};
0090 collect_v(mapping_reactions{it},it) = v_stat{it};
0091 collect_c_eq(mapping_metabolites{it},it) = c_eq{it};
0092 collect_mu(mapping_metabolites{it},it) = mu_stat{it};
0093
0094 ind_undet = find(isnan(collect_c_all));
0095 collect_c_all(ind_undet) = collect_c(ind_undet,it);
0096 collect_c_eq_all(ind_undet) = collect_c_eq(ind_undet,it);
0097 ind_undet = find(isnan(collect_v_all));
0098 collect_v_all(ind_undet) = collect_v(ind_undet,it);
0099 ind_det = find(isfinite(collect_v(:,it)));
0100 collect_v_kinetic(ind_det) = collect_v(ind_det,it);
0101
0102 end
0103
0104
0105
0106
0107
0108 for it = 1:length(kinetic_models);
0109 if find([c_eq{it}==0]+[isfinite(c_eq{it})==0]), warning('Irreversible reaction encountered'); end
0110 end
0111
0112 for it = 1:length(network.metabolites),
0113 dum = isfinite(collect_c_eq(it,:));
0114 if length(unique(collect_c_eq(it,dum))) > 1,
0115 warning(sprintf('Inconsistent equilibrium concentration of metabolite %s',network.metabolites{it}));
0116 end
0117 end