Home > BiKEGG > KEGG2BiGGMets.m

KEGG2BiGGMets

PURPOSE ^

KEGG2BiGGMets

SYNOPSIS ^

function [Metkegg,Metbigg] = KEGG2BiGGMets(D,CbModel)

DESCRIPTION ^

 KEGG2BiGGMets
 is a subfunction of MapAdjuster for displaying compound's
 data on created customized metabolic map by NetDraw. The function
 extracts all metabolite correspondences between KEGG and BiGG based on
 the current COBRA model and data in BiGG API generated by
 AllKEGG2BiGGmet. The structure is very similar to that of used in
 Bigg2Kegg with minor adjustments.
 
 Inputs:
 D: XML data of current COBRA model from BiGG
 CbModel: current COBRA model structure
 
 Outputs:
 Metkegg: All KEGG compounds' IDs
 Metbigg: All BiGG compounds' IDs

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [Metkegg,Metbigg] = KEGG2BiGGMets(D,CbModel)
0002 % KEGG2BiGGMets
0003 % is a subfunction of MapAdjuster for displaying compound's
0004 % data on created customized metabolic map by NetDraw. The function
0005 % extracts all metabolite correspondences between KEGG and BiGG based on
0006 % the current COBRA model and data in BiGG API generated by
0007 % AllKEGG2BiGGmet. The structure is very similar to that of used in
0008 % Bigg2Kegg with minor adjustments.
0009 %
0010 % Inputs:
0011 % D: XML data of current COBRA model from BiGG
0012 % CbModel: current COBRA model structure
0013 %
0014 % Outputs:
0015 % Metkegg: All KEGG compounds' IDs
0016 % Metbigg: All BiGG compounds' IDs
0017 
0018 % O. Jamialahmadi
0019 % TMU, Chem. Eng. Dept., Biotech. Group
0020 % July 2016
0021 % -------------------------------------------------------------------------
0022 
0023 Pth1 = which ('Bigg2Kegg.m');
0024 tind = find(Pth1=='\',1,'last');
0025 Pth = Pth1(1:tind-1);
0026 % Reading xml
0027 % Find listOfSpecies which contains metabolite annotations
0028 SpeciesLoci1 = strfind(D{1},'listOfSpecies');
0029 SpeciesLoci = find(~cellfun('isempty', SpeciesLoci1));
0030 % Discard other data in the model:
0031 SpeciesData = D{1}(SpeciesLoci(1):SpeciesLoci(2));
0032 clear D
0033 % Find each metabolite-------------------------------------------------
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 % Search for KEGG compounds for each BiGG metabolite. Note that each BiGG
0045 % metabolite may have more than one equivalent KEGG compund, and although
0046 % HMR and RECON2 (Thiele lab.) do not provide more than one KEGG compound
0047 % for each metabolite, here, we followed the format of BiGG models (i.e.
0048 % several equivalent KEGG compounds for a specific metabolite).
0049 Metkegg = {''}; % KEGG compounds will fill this cell!
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') % H2O
0061             Metkegg{count}= {'C00001'};
0062             break
0063         elseif strcmp(KeggCpdLoci{count1},'C00027') % H2O2
0064             Metkegg{count}= {'C00027'};
0065             break
0066         else
0067             Metkegg{count}{count1}= KeggCpdLoci{count1};
0068         end
0069     end
0070 end
0071 % Model modification: some metabolites have wrong/absent KEGG annotations.
0072 % Therefore, on the basis of modified KEGG compound IDs for RECON1.xml,
0073 % these metabolites will be added to Metkegg separately.
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'); % Remove compartments
0101 Metbigg = [Metbigg{:}];
0102 Mixdat = strcat(Metbigg,Metkegg);
0103 [~, N1] = unique(Mixdat);
0104 Metbigg = Metbigg(N1);
0105 Metkegg = Metkegg(N1);
0106 
0107 % Consensus Metkegg: Metkegg1 from BiGG API and Metkegg from COBRA models
0108 % are mixed to generate the most complete set of KEGG metabolites for a
0109 % SBML model.
0110 % for cp1 = 1:numel(Metkegg1)
0111 %     if isempty(Metkegg1{cp1}) || (numel(Metkegg1{cp1}) ~= numel(Metkegg{cp1}))
0112 %         for cp2 = 1:numel(Metkegg{cp1})
0113 %             Metkegg1{cp1}{cp2} = Metkegg{cp1}{cp2};
0114 %         end
0115 %     end
0116 % end
0117 
0118 
0119 function Metkegg = ModelMoidfy (Metkegg,MetAbr)
0120 % Read Metkegg data for RECON1.xml
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 % Metkegg(Fx2) = RECON1k(Fx1);
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

Generated on Sat 16-Jul-2016 20:21:30 by m2html © 2005