0001 function equationStrings=constructEquations(model,rxns,useComps,sortRevRxns,sortMetNames)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 if nargin<2
0026 rxns=model.rxns;
0027 end
0028 if nargin<3
0029 useComps=true;
0030 end
0031 if nargin<4
0032 sortRevRxns=false;
0033 end
0034 if nargin<5
0035 sortMetNames=false;
0036 end
0037
0038
0039 if sortRevRxns==true
0040 model=sortModel(model);
0041 end
0042
0043
0044 if sortMetNames==true
0045 model=sortModel(model,false,true);
0046 end
0047
0048 indexes=getIndexes(model,rxns,'rxns');
0049
0050 equationStrings=cell(numel(indexes),1);
0051
0052 for i=1:numel(indexes)
0053 reactants=find(model.S(:,indexes(i))<0);
0054 products=find(model.S(:,indexes(i))>0);
0055 eqn='';
0056
0057 for j=1:numel(reactants)
0058 if j==1
0059 plusString='';
0060 else
0061 plusString=' + ';
0062 end
0063
0064 stoich=num2str(model.S(reactants(j),indexes(i))*-1);
0065
0066 if str2double(stoich)==1
0067 stoich='';
0068 else
0069 stoich=[stoich ' '];
0070 end
0071
0072 if useComps==true
0073 eqn=[eqn plusString stoich model.metNames{reactants(j)} '[' model.comps{model.metComps(reactants(j))} ']'];
0074 else
0075 eqn=[eqn plusString stoich model.metNames{reactants(j)}];
0076 end
0077 end
0078
0079 if model.rev(indexes(i))==0
0080 eqn=[eqn ' => '];
0081 else
0082 eqn=[eqn ' <=> '];
0083 end
0084
0085 for j=1:numel(products)
0086 if j==1
0087 plusString='';
0088 else
0089 plusString=' + ';
0090 end
0091
0092 stoich=num2str(model.S(products(j),indexes(i)));
0093
0094 if str2double(stoich)==1
0095 stoich='';
0096 else
0097 stoich=[stoich ' '];
0098 end
0099
0100 if useComps==true
0101 eqn=[eqn plusString stoich model.metNames{products(j)} '[' model.comps{model.metComps(products(j))} ']'];
0102 else
0103 eqn=[eqn plusString stoich model.metNames{products(j)}];
0104 end
0105 end
0106 equationStrings{i}=eqn;
0107 end
0108 end