0001 function UniModel
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 Pth1 = which ('Bigg2Kegg.m');
0012 tind = find(Pth1=='\',1,'last');
0013 Pth = Pth1(1:tind-1);
0014 Pth2 = fullfile(Pth,'BiGG2KEGG\*.mat');
0015 Pth3 = fullfile(Pth,'BiGG2KEGG');
0016 BMatfiles = dir(Pth2);
0017 BNames = cell(numel(BMatfiles)-2,1);
0018 ct1 = 1; NewB = ({}); NewK = ({});
0019 for ct = 1:numel(BMatfiles)
0020 if ~strcmp(BMatfiles(ct).name,'BiGG2KEGG_HMRbased-RECON1.mat') && ...
0021 ~strcmp(BMatfiles(ct).name,'Multirxns.mat')
0022 BNames{ct1} = BMatfiles(ct).name;
0023 load(fullfile(Pth3,BNames{ct1}))
0024 B=B2Kegg.B;K=B2Kegg.K;
0025 Mlt = find(ismember(B,'MULTIR'));
0026 if ~isempty(Mlt)
0027 TB = B(1:Mlt-1); TK = K(1:Mlt-1);
0028 end
0029 if isempty(NewB)
0030 NewB = TB; NewK = TK;
0031 else
0032 NotB = TB(~ismember(TB,NewB));
0033 NotK = TK(~ismember(TB,NewB));
0034 NewLen = numel(NewB)+1:numel(NotB)+numel(NewB);
0035 NewB(NewLen) = NotB; NewK(NewLen) = NotK;
0036 end
0037 clear B2Kegg
0038 ct1 = ct1 + 1;
0039 end
0040 end
0041 Len1 = numel(NewB);
0042 NewB{Len1+1} = 'MULTIR';
0043 NewK{Len1+1} = 'MULTIR';
0044 load(fullfile(Pth3,'Multirxns.mat'))
0045 Pr = Multirxns.P; Cr = Multirxns.C;
0046 clear Multirxns
0047 for c1 = 1:numel(Pr)
0048 TempN = NewB(ismember(NewK,Pr{c1}));
0049 TempC = Cr{c1};
0050 Len = numel(TempC);
0051 for c2 = 1:numel(TempN)
0052 Len1 = numel(NewB);
0053 Len2 = Len1 + 1: Len1 + Len;
0054 NewB(Len2) = TempN(c2);
0055 NewK(Len2) = TempC;
0056 end
0057 end
0058 B2Kegg.B = NewB; B2Kegg.K = NewK;
0059 fname = fullfile(Pth3,'UniModelKEGG.mat');
0060 save (fname,'B2Kegg')