0001 function constrOptIrrev = setConstraintsIrrevModel(constrOpt,model,modelIrrev,rev2irrev)
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
0027
0028
0029
0030
0031
0032
0033
0034
0035 constrIndIrrev = [];
0036 constrValIrrev = [];
0037 constrSenseIrrev = '';
0038
0039
0040 constrProcessed = false*ones(length(constrOpt.rxnList),1);
0041
0042 for i = 1:length(constrOpt.rxnList)
0043
0044
0045 if (~constrProcessed(i))
0046
0047
0048 rxnName = constrOpt.rxnList{i};
0049
0050 rxnID = find(ismember(model.rxns,rxnName));
0051
0052
0053 thisConstrInd = find(strcmp(constrOpt.rxnList,rxnName));
0054
0055 nThisConstr = length(thisConstrInd);
0056
0057 constrProcessed(thisConstrInd) = true;
0058
0059
0060 thisConstrValue = constrOpt.values(thisConstrInd);
0061
0062 thisConstrSense = constrOpt.sense(thisConstrInd);
0063
0064 if (~isempty(rxnID))
0065
0066 irrevRxnID = rev2irrev{rxnID};
0067
0068
0069 if (length(irrevRxnID) == 1)
0070 irrevRxnName = modelIrrev.rxns{irrevRxnID};
0071 if length(rxnName)>2 && ~strcmp(irrevRxnName(end-1:end),'_r')
0072
0073 for j = 1:nThisConstr
0074 constrIndIrrev(end+1) = irrevRxnID;
0075 constrValIrrev(end+1) = thisConstrValue(j);
0076 constrSenseIrrev(end+1) = thisConstrSense(j);
0077 end
0078 else
0079 for j = 1:nThisConstr
0080 constrIndIrrev(end+1) = irrevRxnID;
0081 constrValIrrev(end+1) = -thisConstrValue(j);
0082 constrSenseIrrev(end+1) = thisConstrSense(j);
0083 end
0084 end
0085 else
0086
0087
0088 if (nThisConstr == 1 | (thisConstrValue(1) == thisConstrValue(2)))
0089
0090 if (nThisConstr == 2)
0091 thisConstrSense = 'E';
0092 end
0093
0094 constrIndIrrev(end+1) = irrevRxnID(1);
0095 constrIndIrrev(end+1) = irrevRxnID(2);
0096 if (thisConstrValue(1) >= 0)
0097 constrValIrrev(end+1) = thisConstrValue(1);
0098 constrValIrrev(end+1) = 0;
0099
0100 switch thisConstrSense
0101 case 'E'
0102 constrSenseIrrev(end+1) = 'E';
0103 constrSenseIrrev(end+1) = 'E';
0104 case 'G'
0105 constrSenseIrrev(end+1) = 'G';
0106 constrSenseIrrev(end+1) = 'E';
0107 case 'L'
0108 constrSenseIrrev(end+1) = 'L';
0109 constrSenseIrrev(end+1) = 'G';
0110 end
0111 else
0112 constrValIrrev(end+1) = 0;
0113 constrValIrrev(end+1) = -thisConstrValue(1);
0114 switch thisConstrSense
0115 case 'E'
0116 constrSenseIrrev(end+1) = 'E';
0117 constrSenseIrrev(end+1) = 'E';
0118 case 'G'
0119 constrSenseIrrev(end+1) = 'G';
0120 constrSenseIrrev(end+1) = 'L';
0121 case 'L'
0122 constrSenseIrrev(end+1) = 'E';
0123 constrSenseIrrev(end+1) = 'G';
0124 end
0125 end
0126 else
0127 lowestConstrVal = min(thisConstrValue);
0128 highestConstrVal = max(thisConstrValue);
0129
0130 if ((lowestConstrVal > 0) & (highestConstrVal > 0))
0131 constrIndIrrev(end+1:end+3) = irrevRxnID([1 1 2]);
0132 constrValIrrev(end+1:end+3) = [lowestConstrVal highestConstrVal 0];
0133 constrSenseIrrev(end+1:end+3) = 'GLE';
0134 elseif ((lowestConstrVal < 0) & (highestConstrVal < 0))
0135 constrIndIrrev(end+1:end+3) = irrevRxnID([1 2 2]);
0136 constrValIrrev(end+1:end+3) = [0 -highestConstrVal -lowestConstrVal];
0137 constrSenseIrrev(end+1:end+3) = 'EGL';
0138 else
0139 constrIndIrrev(end+1:end+2) = irrevRxnID([1 2]);
0140 constrValIrrev(end+1:end+2) = [highestConstrVal -lowestConstrVal];
0141 constrSenseIrrev(end+1:end+2) = 'LL';
0142 end
0143 end
0144 end
0145 end
0146 end
0147 end
0148
0149 constrOptIrrev.rxnList = columnVector(modelIrrev.rxns(constrIndIrrev));
0150 constrOptIrrev.rxnInd = columnVector(constrIndIrrev);
0151 constrOptIrrev.values = columnVector(constrValIrrev);
0152 constrOptIrrev.sense = columnVector(constrSenseIrrev);