changeRxnBounds

PURPOSE ^

changeRxnBounds Change upper or lower bounds of a reaction or a set of

SYNOPSIS ^

function model = changeRxnBounds(model,rxnNameList,value,boundType)

DESCRIPTION ^

changeRxnBounds Change upper or lower bounds of a reaction or a set of
reactions

 model = changeRxnBounds(model,rxnNameList,value,boundType)

INPUTS
 model         COBRA model structure
 rxnNameList   List of reactions (cell array or string)
 value         Bound values
               Can either be a vector or a single scalar value if the same
               bound value is to be assinged to all reactions

OPTIONAL INPUT
 boundType     'u' - upper, 'l' - lower, 'b' - both (Default = 'b')
               Bound type can either be a cell array of strings or a 
               string with as many letters as there are reactions in 
               rxnNameList

OUTPUT
 model         COBRA model structure with modified reaction bounds

 Markus Herrgard 4/21/06

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function model = changeRxnBounds(model,rxnNameList,value,boundType)
0002 %changeRxnBounds Change upper or lower bounds of a reaction or a set of
0003 %reactions
0004 %
0005 % model = changeRxnBounds(model,rxnNameList,value,boundType)
0006 %
0007 %INPUTS
0008 % model         COBRA model structure
0009 % rxnNameList   List of reactions (cell array or string)
0010 % value         Bound values
0011 %               Can either be a vector or a single scalar value if the same
0012 %               bound value is to be assinged to all reactions
0013 %
0014 %OPTIONAL INPUT
0015 % boundType     'u' - upper, 'l' - lower, 'b' - both (Default = 'b')
0016 %               Bound type can either be a cell array of strings or a
0017 %               string with as many letters as there are reactions in
0018 %               rxnNameList
0019 %
0020 %OUTPUT
0021 % model         COBRA model structure with modified reaction bounds
0022 %
0023 % Markus Herrgard 4/21/06
0024 
0025 if (nargin < 4)
0026     boundType = 'b';
0027 end
0028 
0029 if ((length(value) ~= length(rxnNameList) & length(value) > 1) | (length(boundType) ~= length(rxnNameList) & length(boundType) > 1))
0030    error('Inconsistent lenghts of arguments: rxnNameList, value & boundType'); 
0031 end
0032 
0033 rxnID = findRxnIDs(model,rxnNameList);
0034 
0035 % Remove reactions that are not in the model
0036 if (iscell(rxnNameList))
0037     missingRxns = rxnNameList(rxnID == 0);
0038     for i = 1:length(missingRxns)
0039         fprintf('Reaction %s not in model\n',missingRxns{i});    
0040     end
0041     if (length(boundType) > 1)
0042         boundType = boundType(rxnID ~= 0);
0043     end
0044     if (length(value) > 1)
0045         value = value(rxnID ~= 0);
0046     end
0047     rxnID = rxnID(rxnID ~= 0);    
0048 end
0049 
0050 if (isempty(rxnID) | sum(rxnID) == 0)
0051     warning('No such reaction in model');
0052 else
0053     nRxns = length(rxnID);
0054     if (length(boundType) > 1)
0055         if (length(value) == 1)
0056             value = repmat(value,nRxns,1);
0057         end
0058         for i = 1:nRxns
0059             switch lower(boundType{i})
0060                 case 'u'
0061                     model.ub(rxnID(i)) = value(i);
0062                 case 'l'
0063                     model.lb(rxnID) = value(i);
0064                 case 'b'
0065                     model.lb(rxnID) = value(i);
0066                     model.ub(rxnID) = value(i);
0067             end
0068         end
0069     else
0070         switch lower(boundType)
0071             case 'u'
0072                 model.ub(rxnID) = value;
0073             case 'l'
0074                 model.lb(rxnID) = value;
0075             case 'b'
0076                 model.lb(rxnID) = value;
0077                 model.ub(rxnID) = value;
0078         end
0079     end
0080 end

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003