0001 function targets=FSEOF(model,biomassRxn,targetRxn,iterations,coefficient,outputFile)
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 biomassRxn=char(biomassRxn);
0027 targetRxn=char(targetRxn);
0028
0029 if nargin<4
0030 iterations=10;
0031 coefficient=0.9;
0032 end
0033
0034 if nargin <5
0035 coefficient=0.9;
0036 end
0037
0038 if nargin == 6
0039 output=1;
0040 else
0041 output=0;
0042 end
0043
0044
0045 model=setParam(model,'obj',targetRxn,1);
0046 sol=solveLP(model,1);
0047 targetMax=abs(sol.f*coefficient);
0048
0049 model=setParam(model,'obj',biomassRxn,1);
0050
0051 fseof.results=zeros(length(model.rxns),iterations);
0052 fseof.target=zeros(length(model.rxns),1);
0053 rxnDirection=zeros(length(model.rxns),1);
0054
0055
0056 for i=1:iterations
0057 n=i*targetMax/iterations;
0058 model=setParam(model,'lb',targetRxn,n);
0059
0060 sol=solveLP(model,1);
0061
0062 fseof.results(:,i)=sol.x;
0063
0064
0065
0066 for j=1:length(fseof.results)
0067 if fseof.results(j,1) > 0
0068
0069 if i == 1
0070 rxnDirection(j,1)=1;
0071 fseof.target(j,1)=1;
0072 else
0073
0074 if (fseof.results(j,i) > fseof.results(j,i-1)) & fseof.target(j,1)
0075 fseof.target(j,1)=1;
0076 else
0077 fseof.target(j,1)=0;
0078 end
0079 end
0080
0081 elseif fseof.results(j,1) < 0
0082
0083 if i == 1
0084 rxnDirection(j,1)=-1;
0085 fseof.target(j,1)=1;
0086 else
0087 if (fseof.results(j,i) < fseof.results(j,i-1)) & fseof.target(j,1)
0088 fseof.target(j,1)=1;
0089 else
0090 fseof.target(j,1)=0;
0091 end
0092 end
0093
0094 end
0095
0096 end
0097 end
0098
0099
0100 formatSpec='%s\t%s\t%s\t%s\t%s\t%s\t%s\n';
0101 if output == 1
0102 outputFile=char(outputFile);
0103 fid=fopen(outputFile,'w');
0104 fprintf(fid,formatSpec,'Slope','rowID','Enzyme ID','Enzyme Name','Subsystems','Direction','Gr Rule');
0105 else
0106 fprintf(formatSpec,'Slope','rowID','Enzyme ID','Enzyme Name','Subsystems','Direction','Gr Rule');
0107 end
0108
0109 for num=1:length(fseof.target)
0110 if fseof.target(num,1) == 1
0111 A0=num2str(abs(fseof.results(num,iterations)-fseof.results(num,1))/abs(targetMax-targetMax/iterations));
0112 A1=num2str(num);
0113 A2=char(model.rxns(num));
0114 A3=char(model.rxnNames(num));
0115 if isfield(model,'subSystems') && ~isempty(model.subSystems{num});
0116 A4=char(strjoin(model.subSystems{num,1},';'));
0117 else
0118 A4='';
0119 end
0120 A5=num2str(model.rev(num)*rxnDirection(num,1));
0121 A6=char(model.grRules(num));
0122 if output == 1
0123 fprintf(fid,formatSpec,A0,A1,A2,A3,A4,A5,A6);
0124 else
0125 fprintf(formatSpec,A0,A1,A2,A3,A4,A5,A6);
0126 end
0127 end
0128 end
0129
0130 if output == 1
0131 fclose(fid);
0132 end
0133
0134 if nargout == 1
0135 targets.logical=logical(fseof.target);
0136 targets.slope=abs(fseof.results(:,iterations)-fseof.results(:,1))/abs(targetMax-targetMax/iterations);
0137 end
0138 end