0001 function metaCycModel=getModelFromMetaCyc(metacycPath,keepTransportRxns,keepUnbalanced,keepUndetermined)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 if nargin<1
0037 ravenPath=findRAVENroot();
0038 metacycPath=fullfile(ravenPath,'external','metacyc');
0039 else
0040 metacycPath=char(metacycPath);
0041 end
0042 if nargin<2
0043 keepTransportRxns=false;
0044 end
0045 if nargin<3
0046 keepUnbalanced=false;
0047 end
0048 if nargin<4
0049 keepUndetermined=false;
0050 end
0051
0052
0053 metaCycModel=getRxnsFromMetaCyc(metacycPath,keepTransportRxns,keepUnbalanced,keepUndetermined);
0054
0055
0056 metaCycEnzymes=getEnzymesFromMetaCyc(metacycPath);
0057
0058
0059 [a, b]=ismember(metaCycModel.rxns,metaCycEnzymes.rxns);
0060 a=find(a);
0061 b=b(a);
0062 metaCycModel.rxnNames(a)=metaCycEnzymes.rxnNames(b);
0063
0064 fprintf('Reorganizing reaction-enzyme associations... ')
0065
0066
0067 rxnNum=numel(metaCycModel.rxns);
0068 metaCycModel.genes=metaCycEnzymes.enzymes;
0069 metaCycModel.rxnGeneMat=sparse(rxnNum,numel(metaCycEnzymes.enzymes));
0070 metaCycModel.grRules=cell(rxnNum,1);
0071
0072
0073
0074 for i=1:rxnNum
0075
0076 metaCycModel.grRules{i}='';
0077
0078 [a, b]=ismember(metaCycModel.rxns(i),metaCycEnzymes.rxns);
0079 if a
0080 I=[];
0081 I=find(metaCycEnzymes.rxnEnzymeMat(b,:));
0082 if ~isempty(I)
0083
0084 grRule='';
0085 for j=1:numel(I)
0086
0087 subgrRule='';
0088 [c, d]=ismember(metaCycEnzymes.enzymes(I(j)),metaCycEnzymes.cplxs);
0089 if c
0090
0091 if numel(metaCycEnzymes.cplxComp{d}.subunit)==1
0092 subgrRule=metaCycEnzymes.cplxComp{d}.subunit{1};
0093
0094 else
0095 subgrRule=strjoin(metaCycEnzymes.cplxComp{d}.subunit,' and ');
0096 subgrRule=strcat('(',subgrRule,')');
0097 end
0098 [x, geneIndex]=ismember(metaCycEnzymes.cplxComp{d}.subunit,metaCycModel.genes);
0099 metaCycModel.rxnGeneMat(i,geneIndex)=1;
0100
0101 else
0102 subgrRule=metaCycEnzymes.enzymes(I(j));
0103 metaCycModel.rxnGeneMat(i,I(j))=1;
0104 end
0105
0106
0107 if ~strcmp(subgrRule,'')
0108 if ~strcmp(grRule,'')
0109 grRule=strcat(grRule,{' or '},subgrRule);
0110 else
0111 grRule=subgrRule;
0112 end
0113 end
0114
0115 end
0116 if iscell(grRule)
0117 metaCycModel.grRules{i}=grRule{1};
0118 else
0119 metaCycModel.grRules{i}=grRule;
0120 end
0121
0122 end
0123
0124 end
0125 end
0126 fprintf('done\n')
0127
0128 metaCycMets=getMetsFromMetaCyc(metacycPath);
0129
0130
0131 [a, b]=ismember(metaCycModel.mets,metaCycMets.mets);
0132 a=find(a);
0133 b=b(a);
0134
0135 if ~isfield(metaCycModel,'metNames')
0136 metaCycModel.metNames=cell(numel(metaCycModel.mets),1);
0137 metaCycModel.metNames(:)={''};
0138 end
0139 metaCycModel.metNames(a)=metaCycMets.metNames(b);
0140
0141 if ~isfield(metaCycModel,'metFormulas')
0142 metaCycModel.metFormulas=cell(numel(metaCycModel.mets),1);
0143 metaCycModel.metFormulas(:)={''};
0144 end
0145 metaCycModel.metFormulas(a)=metaCycMets.metFormulas(b);
0146
0147 if ~isfield(metaCycModel,'metCharges')
0148 metaCycModel.metCharges=zeros(numel(metaCycModel.mets),1);
0149 end
0150 metaCycModel.metCharges(a)=metaCycMets.metCharges(b);
0151
0152 if ~isfield(metaCycModel,'inchis')
0153 metaCycModel.inchis=cell(numel(metaCycModel.mets),1);
0154 metaCycModel.inchis(:)={''};
0155 end
0156 metaCycModel.inchis(a)=metaCycMets.inchis(b);
0157
0158 if ~isfield(metaCycModel,'metMiriams')
0159 metaCycModel.metMiriams=cell(numel(metaCycModel.mets),1);
0160 end
0161 metaCycModel.metMiriams(a)=metaCycMets.metMiriams(b);
0162
0163 if ~isfield(metaCycModel,'keggid')
0164 metaCycModel.keggid=cell(numel(metaCycModel.mets),1);
0165 end
0166 metaCycModel.keggid(a)=metaCycMets.keggid(b);
0167
0168
0169
0170 metaCycModel.comps={'s'};
0171 metaCycModel.compNames={'System'};
0172 metaCycModel.metComps=ones(numel(metaCycModel.mets),1);
0173
0174
0175
0176
0177 I=cellfun(@isempty,metaCycModel.metNames);
0178 metaCycModel.metNames(I)=metaCycModel.mets(I);
0179 I=cellfun(@isempty,metaCycModel.rxnNames);
0180 metaCycModel.rxnNames(I)=metaCycModel.rxns(I);
0181
0182 end