0001 function [MapChoice, Outflx, RxnCds] = GetKegg(Bigg, Inflx, ModelName)
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 Pth1 = which('GetKegg.m');
0028 tind = find(Pth1=='\',1,'last');
0029 Pth2 = Pth1(1:tind-1);
0030 Nme = [ModelName,'KEGG.mat'];
0031 TargetPth = fullfile(Pth2,'BIGG2KEGG',Nme);
0032 load(TargetPth);
0033 Brxns1 = B2Kegg.B; Krxns1 = B2Kegg.K;
0034
0035
0036
0037 MultiB1 = Brxns1(find(strcmp(Brxns1,'MULTIR'))+1:end);
0038 MultiK1 = Krxns1(find(strcmp(Brxns1,'MULTIR'))+1:end);
0039 MultiK = MultiK1(ismember(MultiB1, Bigg));
0040 MultiB = MultiB1(ismember(MultiB1, Bigg));
0041 [~,Fx22] = ismember(MultiB1, Bigg);
0042 Fx22(Fx22==0) = [];
0043 MultiFlx = Inflx(Fx22,:);
0044 setappdata(0,'MultiB',MultiB);
0045 setappdata(0,'MultiK',MultiK);
0046 setappdata(0,'MultiFlx',MultiFlx);
0047
0048 Brxns = Brxns1(1:find(strcmp(Brxns1,'MULTIR'))-1);
0049 Krxns = Krxns1(1:find(strcmp(Brxns1,'MULTIR'))-1);
0050 RxnCdsI = Krxns(ismember(Brxns, Bigg));
0051 BiGGI = Brxns(ismember(Brxns, Bigg));
0052 [~,Fx2] = ismember(Brxns, Bigg);
0053 Fx2(Fx2==0) = [];
0054 FlxI = Inflx(Fx2,:);
0055
0056 if any(~ismember(Bigg,Brxns))
0057 disp('Some KEGG rxns cannot be found for input BiGG IDs')
0058 disp('Insert them manually')
0059 disp('NOTE: Exchange reactions are not displayed!')
0060 NotData = Bigg(~ismember(Bigg,Brxns));
0061
0062 NoDataIdf = regexp(NotData,'\<EX_\w*');
0063 NoDataIdf1 = ~cellfun('isempty', NoDataIdf);
0064 NotData(NoDataIdf1) = [];
0065
0066 setappdata(0,'NotData',NotData)
0067 waitfor(GetKeggTable)
0068 ModfdTab = getappdata(0,'Final');
0069 FindUndfnd = ModfdTab(:,2);
0070 BiGGUndfnd = ModfdTab(:,1);
0071 DfinedLoci = ~strcmpi(FindUndfnd,'Unknown');
0072 RxnCdsII = FindUndfnd(DfinedLoci);
0073 BiGGII = BiGGUndfnd(DfinedLoci);
0074 Flxs = Inflx(~ismember(Bigg,Brxns),:);
0075 FlxII = Flxs(DfinedLoci,:);
0076 RxnCds = [RxnCdsI';RxnCdsII];
0077 BiGG4KeggDraw = [BiGGI';BiGGII];
0078 setappdata(0,'BiGG4KeggDraw',BiGG4KeggDraw);
0079 Outflx = [FlxI;FlxII];
0080 else
0081 RxnCds = RxnCdsI;
0082 Outflx = FlxI;
0083 end
0084
0085
0086 Fileid1 = fopen('rxn2map.txt','r');
0087 rxn2map = textscan(Fileid1,'%s %s');
0088 RawRxns = rxn2map{1};
0089 RawMaps = rxn2map{2};
0090 [Loci1,~] = regexp(RawMaps, 'path:rn');
0091 Loci2 = ~cellfun('isempty', Loci1);
0092 RawMaps(Loci2) = [];
0093 RawRxns(Loci2) = [];
0094 Maps = strrep(RawMaps,'path:map','');
0095 Rxns = strrep(RawRxns,'rn:','');
0096 RxnTemp = Rxns(ismember(Rxns,RxnCds));
0097 MapTemp = Maps(ismember(Rxns,RxnCds));
0098 count=1;
0099 RxnList = {0}; MapList = {0}; SortTemp = (0);
0100 RmvMaps = {'01100','01110','01120','01130','01200','01210','01212',...
0101 '01220','01230','00121'};
0102 while numel(MapTemp)
0103 Loci3 = ismember(MapTemp,MapTemp(1));
0104 if ~ismember(MapTemp(1),RmvMaps)
0105 RxnList{count} = RxnTemp(Loci3);
0106 SortTemp(count) = numel(RxnList{count});
0107 MapList(count) = MapTemp(1);
0108 count=count+1;
0109 end
0110 RxnTemp(Loci3)=[];
0111 MapTemp(Loci3)=[];
0112 end
0113
0114 [~,ST] = sort(SortTemp,'descend');
0115 RxnList = RxnList(ST);
0116 MapList = MapList(ST);
0117
0118 Fileid2 = fopen('KEGGmaps.txt','r');
0119 TempMaps = textscan(Fileid2,'%s %[^\n]');
0120 TempMaps1 = cell(size(TempMaps{1},1),1);
0121 for count = 1:size(TempMaps{1},1)
0122 TempMaps1{count}=[TempMaps{1}{count},' ',TempMaps{2}{count}];
0123 end
0124 TempMaps1 = strrep(TempMaps1,'path:map','');
0125 MapNames2 = cell(numel(MapList),1);
0126 for count = 1:numel(MapList)
0127 Loci4 = regexp(TempMaps1,MapList{count});
0128 MapNames2{count} = TempMaps1{~cellfun('isempty', Loci4)};
0129 end
0130
0131 setappdata(0,'MapNames2',MapNames2)
0132 setappdata(0,'RxnList',RxnList)
0133 waitfor(GetKeggMaps)
0134 MapChoiceLoci = getappdata(0,'AllChoices');
0135 MapChoice = MapList(MapChoiceLoci);
0136
0137 AT=getappdata(0);
0138 AT1 = fieldnames(AT);
0139 for co = 1:length(AT1)
0140 if strcmp(AT1{co},'BiGGModel') || strcmp(AT1{co},'Mdl') || ...
0141 strcmp(AT1{co},'CRxns')
0142 rmappdata(0,AT1{co});
0143 end
0144 end