0001 function [Metkegg,Metbigg] = KEGG2BiGGMets(D,CbModel)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 Pth1 = which ('Bigg2Kegg.m');
0024 tind = find(Pth1=='\',1,'last');
0025 Pth = Pth1(1:tind-1);
0026
0027
0028 SpeciesLoci1 = strfind(D{1},'listOfSpecies');
0029 SpeciesLoci = find(~cellfun('isempty', SpeciesLoci1));
0030
0031 SpeciesData = D{1}(SpeciesLoci(1):SpeciesLoci(2));
0032 clear D
0033
0034 SpeciesStart1 = strfind(SpeciesData,'<species');
0035 SpeciesStart = find(~cellfun('isempty', SpeciesStart1));
0036 SpeciesEnd1 = strfind(SpeciesData,'</species>');
0037 SpeciesEnd = find(~cellfun('isempty', SpeciesEnd1));
0038 if numel(SpeciesStart) ~= numel(SpeciesEnd)
0039 msgbox('SBML format error:Species have wrong format!','Error',...
0040 'error');
0041 return
0042 end
0043
0044
0045
0046
0047
0048
0049 Metkegg = {''};
0050 for count = 1:numel(SpeciesStart)
0051 SpeciesTempStr = SpeciesData(SpeciesStart(count):SpeciesEnd(count));
0052 SpeciesTempStr = [SpeciesTempStr{:}];
0053 KeggCpdLoci = regexp(SpeciesTempStr,...
0054 '(?<=http://identifiers.org/kegg.compound/)[CG]\d{5}','match');
0055 if isempty(KeggCpdLoci)
0056 Metkegg{count} = '';
0057 continue
0058 end
0059 for count1 = 1:numel(KeggCpdLoci)
0060 if strcmp(KeggCpdLoci{count1},'C00001')
0061 Metkegg{count}= {'C00001'};
0062 break
0063 elseif strcmp(KeggCpdLoci{count1},'C00027')
0064 Metkegg{count}= {'C00027'};
0065 break
0066 else
0067 Metkegg{count}{count1}= KeggCpdLoci{count1};
0068 end
0069 end
0070 end
0071
0072
0073
0074 D = CbModel;
0075 ModelName = D.description;
0076 tind1 = find(ModelName=='\',1,'last');
0077 ModelName1 = ModelName(tind1+1:end-4);
0078 if ~strcmp(ModelName1,'RECON1')
0079 MetAbr = CbModel.mets;
0080 Metkegg = ModelMoidfy (Metkegg,MetAbr);
0081 end
0082
0083 load(fullfile(Pth,'AllKEGG2BiGGmet.mat'))
0084 Metkegg1 = AllKEGG2BiGGmet.Metkegg; Metkegg1 = [Metkegg1{:}];
0085 Metbigg1 = AllKEGG2BiGGmet.Metbigg; Metbigg1 = [Metbigg1{:}];
0086 MetAbr = strrep(MetAbr,'[','_'); MetAbr = strrep(MetAbr,']','');
0087 Metkegg2 = ({}); ct = 1; MetAbr1 = ({});
0088 for i1 = 1:numel(Metkegg)
0089 if isempty(Metkegg{i1})
0090 continue
0091 end
0092 for i2 = 1:numel(Metkegg{i1})
0093 Metkegg2{ct} = Metkegg{i1}{i2};
0094 MetAbr1{ct} = MetAbr{i1};
0095 ct = ct + 1;
0096 end
0097 end
0098 clear Metkegg
0099 Metbigg = [Metbigg1,MetAbr1]; Metkegg = [Metkegg1,Metkegg2];
0100 Metbigg = regexp(Metbigg,'\w*(?=_\w{1}\>)','match');
0101 Metbigg = [Metbigg{:}];
0102 Mixdat = strcat(Metbigg,Metkegg);
0103 [~, N1] = unique(Mixdat);
0104 Metbigg = Metbigg(N1);
0105 Metkegg = Metkegg(N1);
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 function Metkegg = ModelMoidfy (Metkegg,MetAbr)
0120
0121 Mdat = load('RECON1Metkegg.mat');
0122 RECON1k = Mdat.RECON1meta.K;
0123 RECON1m = Mdat.RECON1meta.B;
0124 [Fx1,Fx2] = ismember(RECON1m,MetAbr);
0125 Fx2(Fx2==0) = [];
0126
0127 Fx3 = find(Fx1);
0128 for i1 = 1:numel(Fx2)
0129 if numel(Metkegg{Fx2(i1)}) > numel(RECON1k{Fx3(i1)})
0130 Tempmet = Metkegg{Fx2(i1)};
0131 whrc = ismember(Tempmet,RECON1k{Fx3(i1)});
0132 if isempty(whrc)
0133 Metkegg{Fx2(i1)} = RECON1k(Fx3(i1));
0134 end
0135 else
0136 Metkegg{Fx2(i1)} = RECON1k{Fx3(i1)};
0137 end
0138 end
0139