0001 function [biomassValues, targetValues] = runProductionEnvelope(model, targetRxn, biomassRxn, nPts)
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 
0013 
0014 
0015 
0016 
0017 
0018 
0019 
0020 if nargin < 4
0021     nPts = 20;
0022 end
0023 
0024 
0025 model   = setParam(model,'obj',biomassRxn,1);
0026 [solMax,hsSol]  = solveLP(model);
0027 solMax  = solMax.x(logical(model.c));
0028 model.c = -model.c;
0029 solMin  = solveLP(model,0,[],hsSol);
0030 solMin  = solMin.x(logical(model.c));
0031 
0032 
0033 biomassValues = linspace(solMin,solMax,nPts);
0034 targetUpperBound = nan(1,numel(biomassValues));
0035 targetLowerBound = nan(1,numel(biomassValues));
0036 
0037 PB = ProgressBar2(length(biomassValues),'Creating production envelope','cli');
0038 
0039 model = setParam(model,'obj',targetRxn,1);
0040 for i = 1:length(biomassValues)
0041     model1 = setParam(model,'eq',biomassRxn,biomassValues(i));
0042     sol = solveLP(model1,0,[],hsSol);
0043     if (sol.stat > 0)
0044         targetUpperBound(i) = sol.x(logical(model.c));
0045     else
0046         targetUpperBound(i) = NaN;
0047     end
0048     model1.c = -model1.c;
0049     sol = solveLP(model1,0,[],hsSol);
0050     if (sol.stat > 0)
0051         targetLowerBound(i) = sol.x(logical(model1.c));
0052     else
0053         targetLowerBound(i) = NaN;
0054     end
0055     count(PB);
0056 end
0057 
0058 
0059 plot([biomassValues fliplr(biomassValues)],[targetUpperBound fliplr(targetLowerBound)],'blue','LineWidth',2);
0060 axis tight;
0061 ylabel([strrep(targetRxn,'_','-') ' (mmol/gDW h)']);
0062 xlabel('Growth rate (1/h)');
0063 targetValues = [targetLowerBound; targetUpperBound];
0064 end