changeObjective Changes the objective function of a constraint-based model model = changeObjective(model,rxnNameList,objectiveCoeff) INPUTS model COBRA structure rxnNameList List of reactions (cell array or string) OPTIONAL INPUT objectiveCoeff Value of objective coefficient for each reaction (Default = 1) OUTPUT model COBRA model structure with new objective Monica Mo & Markus Herrgard - 8/21/06
0001 function model = changeObjective(model,rxnNameList,objectiveCoeff) 0002 %changeObjective Changes the objective function of a constraint-based model 0003 % 0004 % model = changeObjective(model,rxnNameList,objectiveCoeff) 0005 % 0006 %INPUTS 0007 % model COBRA structure 0008 % rxnNameList List of reactions (cell array or string) 0009 % 0010 %OPTIONAL INPUT 0011 % objectiveCoeff Value of objective coefficient for each reaction 0012 % (Default = 1) 0013 % 0014 %OUTPUT 0015 % model COBRA model structure with new objective 0016 % 0017 % Monica Mo & Markus Herrgard - 8/21/06 0018 0019 if (nargin < 3) 0020 objectiveCoeff = 1; 0021 end 0022 0023 rxnID = findRxnIDs(model,rxnNameList); 0024 0025 model.c = zeros(size(model.c)); 0026 0027 if iscell(rxnNameList) 0028 missingRxns = rxnNameList(rxnID == 0); 0029 for i = 1:length(missingRxns) 0030 fprintf('%s not in model\n',missingRxns{i}); 0031 end 0032 rxnID = rxnID(rxnID ~= 0); 0033 if (length(objectiveCoeff) > 1) 0034 objectiveCoeff = objectiveCoeff(rxnID ~= 0); 0035 end 0036 end 0037 0038 if (isempty(rxnID) | rxnID == 0) 0039 error('Objective reactions not found in model!'); 0040 else 0041 model.c(rxnID) = objectiveCoeff; 0042 end