Home > src > geckomat > gather_kcats > selectKcatValue.m

selectKcatValue

PURPOSE ^

selectKcatValue

SYNOPSIS ^

function [model, rxnIdx] = selectKcatValue(model,kcatList,criteria,overwrite)

DESCRIPTION ^

 selectKcatValue
   From a kcatList with predicted or suggested kcat values, where each
   reaction may have multiple entries, one kcat value is selected and
   written to model.ec.kcat. Zero values are discarded from the start. By
   default, the maximum value is chosen, but alternatives are available.
   The kcatList structure is an output of e.g. readDLKcatOutput,
   readGotEnzymesOutput, readManualKcatList.

 Input:
   model       an ecModel in GECKO 3 format (with ecModel.ec structure)
   kcatList    structure array with separate entries for each kcat value
               source      e.g. 'DLKcat' or 'gotenzymes'           
               rxns        reaction identifiers, matching model.rxns
               genes       gene identifiers, matching model.genes
               substrate   substrates, matching model.mets
               kcat        predicted kcat value in /sec
   criteria    which kcat value should be selected if multiple values are
               provided. Options: 'max', 'min', 'median', 'mean'. (Opt,
               default 'max')
   overwrite   whether existing kcat values should be overwritten.
               Options: 'true', 'false', 'ifHigher'. The last option will
               overwrite only if the new kcat value is higher. (Opt,
               default 'true')

 Output:
   model       ecModel with updated model.ec.kcat and model.ec.source
   rxnIdx      list of reaction indices (matching model.ec.rxns), to
               indicate which kcat values have been changed.
 Usage:
   [model, rxnIdx] = selectKcatValue(model,kcatList,criteria,overwrite)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [model, rxnIdx] = selectKcatValue(model,kcatList,criteria,overwrite)
0002 % selectKcatValue
0003 %   From a kcatList with predicted or suggested kcat values, where each
0004 %   reaction may have multiple entries, one kcat value is selected and
0005 %   written to model.ec.kcat. Zero values are discarded from the start. By
0006 %   default, the maximum value is chosen, but alternatives are available.
0007 %   The kcatList structure is an output of e.g. readDLKcatOutput,
0008 %   readGotEnzymesOutput, readManualKcatList.
0009 %
0010 % Input:
0011 %   model       an ecModel in GECKO 3 format (with ecModel.ec structure)
0012 %   kcatList    structure array with separate entries for each kcat value
0013 %               source      e.g. 'DLKcat' or 'gotenzymes'
0014 %               rxns        reaction identifiers, matching model.rxns
0015 %               genes       gene identifiers, matching model.genes
0016 %               substrate   substrates, matching model.mets
0017 %               kcat        predicted kcat value in /sec
0018 %   criteria    which kcat value should be selected if multiple values are
0019 %               provided. Options: 'max', 'min', 'median', 'mean'. (Opt,
0020 %               default 'max')
0021 %   overwrite   whether existing kcat values should be overwritten.
0022 %               Options: 'true', 'false', 'ifHigher'. The last option will
0023 %               overwrite only if the new kcat value is higher. (Opt,
0024 %               default 'true')
0025 %
0026 % Output:
0027 %   model       ecModel with updated model.ec.kcat and model.ec.source
0028 %   rxnIdx      list of reaction indices (matching model.ec.rxns), to
0029 %               indicate which kcat values have been changed.
0030 % Usage:
0031 %   [model, rxnIdx] = selectKcatValue(model,kcatList,criteria,overwrite)
0032 
0033 if nargin < 4
0034     overwrite = 'true';
0035 elseif islogical(overwrite)
0036     if overwrite
0037         overwrite = 'true';
0038     else
0039         overwrite = 'false';
0040     end
0041 end
0042 if nargin < 3
0043     criteria = 'max';
0044 end
0045 
0046 % Remove zero kcat values. Only adjusting fields that are used later.
0047 removeZero                      = kcatList.kcats == 0;
0048 kcatList.kcats(removeZero)      = [];
0049 kcatList.rxns(removeZero)       = [];
0050 
0051 % Map to model.ec.rxns
0052 [sanityCheck,idxInModel] = ismember(kcatList.rxns,model.ec.rxns);
0053 if ~all(sanityCheck)
0054     error('Not all reactions in kcatList are found in model.ec.rxns')
0055 end
0056 % Make vector with single kcat value per reaction
0057 idxInModelUnique = unique(idxInModel);
0058 selectedKcats    = zeros(numel(idxInModelUnique),1);
0059 selectedSource   = cell(numel(selectedKcats),1);
0060 if ~isfield(kcatList,'kcatSource')
0061     kcatList.kcatSource = cell(numel(kcatList.kcats),1);
0062     kcatList.kcatSource(:) = {kcatList.source};
0063 end
0064 for i=1:numel(idxInModelUnique)
0065     ind = idxInModelUnique(i);
0066     idxMatch = find(idxInModel == ind);
0067     % Choose the maximum number
0068     switch criteria
0069         case 'max'
0070             [selectedKcats(i),j] = max(kcatList.kcats(idxMatch));
0071         case 'min'
0072             [selectedKcats(i),j] = min(kcatList.kcats(idxMatch));
0073         case 'median'
0074             [selectedKcats(i),j] = median(kcatList.kcats(idxMatch));
0075         case 'mean'
0076             [selectedKcats(i),j] = mean(kcatList.kcats(idxMatch));
0077         otherwise
0078             error('Invalid criteria specified')
0079     end
0080     selectedSource(i)    = kcatList.kcatSource(idxMatch(j));
0081 end
0082 
0083 % Populate model.ec.kcat
0084 switch overwrite
0085     case 'true'
0086         model.ec.kcat(idxInModelUnique) = selectedKcats;
0087         model.ec.source(idxInModelUnique) = selectedSource;
0088     case 'false'
0089         emptyKcats = find(model.ec.kcat == 0);
0090         [idxInModelUnique,whickKcats] = intersect(idxInModelUnique,emptyKcats,'stable');
0091         model.ec.kcat(idxInModelUnique) = selectedKcats(whickKcats);
0092         model.ec.source(idxInModelUnique) = selectedSource(whickKcats);
0093         
0094     case 'ifHigher'
0095         higherKcats = model.ec.kcat(idxInModelUnique) < selectedKcats;
0096         selectedKcats(~higherKcats) = [];
0097         selectedSource(~higherKcats) = [];
0098         idxInModelUnique(~higherKcats) = [];
0099         model.ec.kcat(idxInModelUnique) = selectedKcats;
0100         model.ec.source(idxInModelUnique) = selectedSource;
0101     otherwise
0102         error('Invalid overwrite flag specified')
0103 end
0104 rxnIdx = idxInModelUnique;
0105 end

Generated by m2html © 2005