getAllowedBounds Returns the minimal and maximal fluxes through each reaction. Input: model a model structure rxns either a cell array of reaction IDs, a logical vector with the same number of elements as reactions in the model, or a vector of reaction indexes (optional, default model.rxns) runParallel speed up calculations by parallel processing. This is not beneficial if allowed bounds are calculated for only a few reactions, as the overhead of parallel processing will take longer. It requires MATLAB Parallel Computing Toolbox. If this is not installed, the calculations will not be parallelized, regardless what is indicated as runParallel. (optional, default true) Output: minFluxes minimal allowed fluxes maxFluxes maximal allowed fluxes exitFlags exit flags for min/max for each of the reactions. True if it was possible to calculate a flux In cases where no solution can be calculated, NaN is returned. Usage: [minFluxes, maxFluxes, exitFlags] = getAllowedBounds(model, rxns, runParallel)
0001 function [minFluxes, maxFluxes, exitFlags]=getAllowedBounds(model,rxns,runParallel) 0002 % getAllowedBounds 0003 % Returns the minimal and maximal fluxes through each reaction. 0004 % 0005 % Input: 0006 % model a model structure 0007 % rxns either a cell array of reaction IDs, a logical vector 0008 % with the same number of elements as reactions in the 0009 % model, or a vector of reaction indexes (optional, default 0010 % model.rxns) 0011 % runParallel speed up calculations by parallel processing. This is 0012 % not beneficial if allowed bounds are calculated for 0013 % only a few reactions, as the overhead of parallel 0014 % processing will take longer. It requires MATLAB 0015 % Parallel Computing Toolbox. If this is not installed, 0016 % the calculations will not be parallelized, regardless 0017 % what is indicated as runParallel. (optional, default true) 0018 % 0019 % Output: 0020 % minFluxes minimal allowed fluxes 0021 % maxFluxes maximal allowed fluxes 0022 % exitFlags exit flags for min/max for each of the reactions. True 0023 % if it was possible to calculate a flux 0024 % 0025 % In cases where no solution can be calculated, NaN is returned. 0026 % 0027 % Usage: [minFluxes, maxFluxes, exitFlags] = getAllowedBounds(model, rxns, runParallel) 0028 0029 if nargin<2 || isempty(rxns) 0030 rxns = 1:numel(model.rxns); 0031 elseif ~islogical(rxns) && ~isnumeric(rxns) 0032 rxns = convertCharArray(rxns); 0033 rxns = getIndexes(model,rxns, 'rxns'); 0034 end 0035 if nargin<3 0036 runParallel = true; 0037 end 0038 0039 [ps, oldPoolAutoCreateSetting] = parallelPoolRAVEN(runParallel); 0040 0041 minFluxes = zeros(numel(rxns),1); 0042 maxFluxes = zeros(numel(rxns),1); 0043 exitFlags = zeros(numel(rxns),2); 0044 c = zeros(numel(model.rxns),1); 0045 0046 PB = ProgressBar2(numel(rxns),'Running getAllowedBounds','cli'); 0047 parfor i = 1:numel(rxns) 0048 count(PB) 0049 tmpModel = model; 0050 tmpModel.c = c; 0051 0052 % Get maximal flux 0053 tmpModel.c(rxns(i)) = 1; 0054 [solMax,hsSol]=solveLP(tmpModel); 0055 if ~isempty(solMax.f) 0056 maxFluxes(i) = solMax.x(rxns(i)); 0057 else 0058 maxFluxes(i) = NaN; 0059 end 0060 0061 % Get minimal flux 0062 tmpModel.c(rxns(i)) = -1; 0063 solMin = solveLP(tmpModel,[],[],hsSol); 0064 if ~isempty(solMin.f) 0065 minFluxes(i) = solMin.x(rxns(i)); 0066 else 0067 minFluxes(i) = NaN; 0068 end 0069 exitFlags(i,:) = [solMin.stat solMax.stat]; 0070 0071 end 0072 % Reset original Parallel setting 0073 ps.Pool.AutoCreate = oldPoolAutoCreateSetting; 0074 end