createModel

PURPOSE ^

createModel Create a COBRA model from inputs or an empty model

SYNOPSIS ^

function model = createModel(rxnAbrList,rxnNameList,rxnList,revFlagList,lowerBoundList,upperBoundList,subSystemList,grRuleList,geneNameList,systNameList)

DESCRIPTION ^

createModel Create a COBRA model from inputs or an empty model
structure if no inputs are provided.

 model = createModel(rxnAbrList,rxnNameList,rxnList,revFlagList,...
    lowerBoundList,upperBoundList,subSystemList,grRuleList,geneNameList,...
    systNameList)

INPUTS
 rxnAbrList            List of names of the new reactions
 rxnNameList           List of names of the new reactions
 rxnList               List of reactions: format: {'A -> B + 2 C'}
                       If the compartment of a metabolite is not
                       specified, it is assumed to be cytoplasmic, i.e. [c]

OPTIONAL INPUTS
 revFlagList           List of reversibility flag (opt, default = 1)
 lowerBoundList        List of lower bound (Default = 0 or -vMax)
 upperBoundList        List of upper bound (Default = vMax)
 subSystemList         List of subsystem (Default = '')
 grRuleList            List of gene-reaction rule in boolean format (and/or allowed)
                       (Default = '');
 geneNameList          List of gene names (used only for translation
                       from common gene names to systematic gene names)
 systNameList          List of systematic names

OUTPUT
 model                 COBRA model structure

 Ines Thiele 01/09

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function model = createModel(rxnAbrList,rxnNameList,rxnList,revFlagList,...
0002     lowerBoundList,upperBoundList,subSystemList,grRuleList,geneNameList,...
0003     systNameList)
0004 %createModel Create a COBRA model from inputs or an empty model
0005 %structure if no inputs are provided.
0006 %
0007 % model = createModel(rxnAbrList,rxnNameList,rxnList,revFlagList,...
0008 %    lowerBoundList,upperBoundList,subSystemList,grRuleList,geneNameList,...
0009 %    systNameList)
0010 %
0011 %INPUTS
0012 % rxnAbrList            List of names of the new reactions
0013 % rxnNameList           List of names of the new reactions
0014 % rxnList               List of reactions: format: {'A -> B + 2 C'}
0015 %                       If the compartment of a metabolite is not
0016 %                       specified, it is assumed to be cytoplasmic, i.e. [c]
0017 %
0018 %OPTIONAL INPUTS
0019 % revFlagList           List of reversibility flag (opt, default = 1)
0020 % lowerBoundList        List of lower bound (Default = 0 or -vMax)
0021 % upperBoundList        List of upper bound (Default = vMax)
0022 % subSystemList         List of subsystem (Default = '')
0023 % grRuleList            List of gene-reaction rule in boolean format (and/or allowed)
0024 %                       (Default = '');
0025 % geneNameList          List of gene names (used only for translation
0026 %                       from common gene names to systematic gene names)
0027 % systNameList          List of systematic names
0028 %
0029 %OUTPUT
0030 % model                 COBRA model structure
0031 %
0032 % Ines Thiele 01/09
0033 
0034 %create blank model
0035 model = struct();
0036 model.mets=cell(0,1);model.metNames=cell(0,1);model.metFormulas=cell(0,1);
0037 model.rxns=cell(0,1);model.rxnNames=cell(0,1);model.subSystems=cell(0,1);
0038 model.lb=zeros(0,1);model.ub=zeros(0,1);model.rev=zeros(0,1);
0039 model.c=zeros(0,1);model.b=zeros(0,1);
0040 model.S=sparse(0,0);
0041 model.rxnGeneMat=sparse(0,0);
0042 model.rules=cell(0,1);
0043 model.grRules=cell(0,1);
0044 model.genes=cell(0,1);
0045 
0046 if nargin < 1
0047     return;
0048 end
0049 
0050 nRxns = length(rxnNameList);
0051 if nargin < 9
0052     geneNameList(1:nRxns,1) = {''};
0053     systNameList(1:nRxns,1) = {''};
0054 end
0055 if nargin < 8
0056     grRuleList(1:nRxns,1) = {''};
0057 end
0058 if nargin < 7
0059     subSystemList(1:nRxns,1) = {''};
0060 end
0061 if nargin < 5
0062     lowerBoundList = -1000*ones(nRxns,1);
0063 end
0064 if nargin < 6
0065     upperBoundList = 1000*ones(nRxns,1);
0066 end
0067 if nargin < 4
0068     revFlagList = ones(nRxns,1);
0069 end
0070 if isempty(revFlagList)
0071     revFlagList = zeros(nRxns,1);
0072     revFlagList(find(lowerBoundList)< 0) = 1;
0073 end
0074 
0075 for i = 1 : nRxns
0076     if i==nRxns
0077         pause(eps)
0078     end
0079     if ~isempty(grRuleList{i})
0080         if ~isempty(strfind(grRuleList{i},','))
0081           grRuleList{i}= (regexprep(grRuleList{i},',',' or ')); 
0082         end
0083         if ~isempty(strfind(grRuleList{i},'&'))
0084            grRuleList{i} = (regexprep(grRuleList{i},'&',' and '));
0085         end
0086        if ~isempty(strfind(grRuleList{i},'+'))
0087           grRuleList{i}= (regexprep(grRuleList{i},'+',' and '));
0088        end
0089     end
0090     [metaboliteList,stoichCoeffList] = parseRxnFormula(rxnList{i});
0091     for q=1:length(metaboliteList)
0092         if length(metaboliteList{q})<=3 || ~strcmp(metaboliteList{q}(end-2),'[')
0093             %assuming the default compartment is cytoplasmic
0094             metaboliteList{q}=[metaboliteList{q},'[c]'];
0095         end
0096     end
0097     model = addReaction(model,{rxnAbrList{i},rxnNameList{i}},metaboliteList,stoichCoeffList,...
0098         revFlagList(i),lowerBoundList(i),upperBoundList(i),0,...
0099         subSystemList{i},grRuleList{i},geneNameList{i},systNameList{i},false);
0100 end

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