Home > src > geckomat > get_enzyme_data > getECfromGEM.m

getECfromGEM

PURPOSE ^

getECfromGEM

SYNOPSIS ^

function [model, invalidEC, invalidECpos] = getECfromGEM(model, ecRxns)

DESCRIPTION ^

 getECfromGEM
   Use the model.eccodes to populates the model.ec.eccodes field. EC
   numbers that are not formatted as four numbers separated by periods,
   possibly with trailing wildcards. Examples: 1.2.3.4 or 1.2.3.- while
   invalid EC numbers are 1.2.3 or 1_2_3_4. Multiple EC numbers are
   separated by ; for instance 1.2.3.4;1.2.3.5 not 1.2.3.4|1.2.3.5.

 Input:
   model           an ecModel in GECKO 3 format (with ecModel.ec structure)
   ecRxns          logical of length model.ec.rxns that specifies for
                   which reactions the existing model.ec.eccodes entry
                   should be kept and not modified by this function
                   (optional, by default all model.ec.eccodes entries
                   are populated by this function)

 Output:
   model           ecModel with populated model.ec.eccodes
   invalidEC       incorrectly formatted EC numbers
   invalidECpos    position of invalidEC in model.eccodes

 Usage:
   [model, invalidEC, invalidECpos] = getECfromGEM(model, ecRxns)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [model, invalidEC, invalidECpos] = getECfromGEM(model, ecRxns)
0002 % getECfromGEM
0003 %   Use the model.eccodes to populates the model.ec.eccodes field. EC
0004 %   numbers that are not formatted as four numbers separated by periods,
0005 %   possibly with trailing wildcards. Examples: 1.2.3.4 or 1.2.3.- while
0006 %   invalid EC numbers are 1.2.3 or 1_2_3_4. Multiple EC numbers are
0007 %   separated by ; for instance 1.2.3.4;1.2.3.5 not 1.2.3.4|1.2.3.5.
0008 %
0009 % Input:
0010 %   model           an ecModel in GECKO 3 format (with ecModel.ec structure)
0011 %   ecRxns          logical of length model.ec.rxns that specifies for
0012 %                   which reactions the existing model.ec.eccodes entry
0013 %                   should be kept and not modified by this function
0014 %                   (optional, by default all model.ec.eccodes entries
0015 %                   are populated by this function)
0016 %
0017 % Output:
0018 %   model           ecModel with populated model.ec.eccodes
0019 %   invalidEC       incorrectly formatted EC numbers
0020 %   invalidECpos    position of invalidEC in model.eccodes
0021 %
0022 % Usage:
0023 %   [model, invalidEC, invalidECpos] = getECfromGEM(model, ecRxns)
0024 
0025 if ~isfield(model,'eccodes')
0026     error('The model has no model.eccodes field.')
0027 end
0028 
0029 %Need to remove the prefix of GECKO light rxn names in the ec structure
0030 if ~model.ec.geckoLight
0031     rxnNames = model.ec.rxns;
0032 else
0033     rxnNames = extractAfter(model.ec.rxns, 4);
0034 end
0035 
0036 [~,rxnIdxs] = ismember(rxnNames,model.rxns);
0037 
0038 % Check if eccodes are valid
0039 eccodes = model.eccodes;
0040 invalidEC = regexprep(eccodes,'(\d\.(\w|-)+\.(\w|-)+\.(\w|-)+)(;\w+\.(\w|-)+\.(\w|-)+\.(\w|-)+)*(.*)','$3');
0041 invalidEC = ~cellfun(@isempty,invalidEC);
0042 invalidECpos = find(invalidEC);
0043 if any(invalidECpos)
0044     invalidEC = model.eccodes(invalidEC);
0045     if nargout<2
0046         fprintf('Skipped incorrectly formatted EC numbers, rerun getECfromGEM with all outputs to get a list.\n')
0047     else
0048         fprintf('Skipped incorrectly formatted EC numbers.\n')
0049     end
0050     eccodes(invalidECpos)={''};
0051 else
0052     invalidEC = [];
0053 end
0054 if nargin<2 || all(ecRxns)
0055     model.ec.eccodes = eccodes(rxnIdxs);
0056 else
0057     if ~isfield(model.ec,'eccodes')
0058         model.ec.eccodes(1:numel(model.ec.rxns),1) = {''};
0059     end
0060     model.ec.eccodes(ecRxns) = eccodes(rxnIdxs(ecRxns));
0061 end
0062 end

Generated by m2html © 2005