0001 function [minFlux, maxFlux] = ecFVA(ecModel, model)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 rxnIDs = regexprep(ecModel.rxns,'(_REV)?(_EXP_\d+)?','');
0020 [rxnIDmap, convRxnID] = findgroups(rxnIDs);
0021
0022 solMaxAll = nan(numel(ecModel.rxns),numel(convRxnID));
0023 solMinAll = solMaxAll;
0024
0025 pool = gcp('nocreate');
0026 if isempty(pool)
0027 parpool;
0028 end
0029
0030 D = parallel.pool.DataQueue;
0031 progressbar('Running ecFVA');
0032 afterEach(D, @nUpdateProgressbar);
0033
0034 N = numel(convRxnID);
0035 p = 1;
0036
0037 parfor i=1:N
0038 tmpModel = ecModel;
0039 tmpModel.c = zeros(numel(tmpModel.rxns),1);
0040
0041 rxnsToOptim = find(rxnIDmap == i);
0042 rxnsOptIDs = ecModel.rxns(rxnsToOptim);
0043 rxnsToMin = endsWith(rxnsOptIDs,'_REV') | contains(rxnsOptIDs,'_REV_EXP_');
0044 rxnsToMax = rxnsToOptim(~rxnsToMin);
0045 rxnsToMin = rxnsToOptim(rxnsToMin);
0046
0047 tmpModel.c(rxnsToMax) = 1;
0048 tmpModel.c(rxnsToMin) = -1;
0049 solMax=solveLP(tmpModel);
0050 if ~isempty(solMax.x)
0051 solMaxAll(:,i)=solMax.x;
0052 end
0053 tmpModel.c(rxnsToMax) = -1;
0054 tmpModel.c(rxnsToMin) = 1;
0055 solMin=solveLP(tmpModel);
0056 if ~isempty(solMin.x)
0057 solMinAll(:,i)=solMin.x;
0058 end
0059 send(D, i);
0060 end
0061
0062 minFlux=min(solMinAll,[],2,'omitnan');
0063 maxFlux=max(solMaxAll,[],2,'omitnan');
0064
0065 mappedFlux = mapRxnsToConv(ecModel,model,[minFlux maxFlux]);
0066
0067 minFlux=mappedFlux(:,1);
0068 maxFlux=mappedFlux(:,2);
0069
0070
0071 swapDir = minFlux > maxFlux;
0072 if any(swapDir)
0073 tmpFlux = minFlux(swapDir);
0074 minFlux(swapDir) = maxFlux(swapDir);
0075 maxFlux(swapDir) = tmpFlux;
0076 end
0077
0078 function nUpdateProgressbar(~)
0079 progressbar(p/N);
0080 p = p + 1;
0081 end
0082 end