extractMiriam This function unpacks the information kept in metMiriams, rxnMiriams, geneMiriams or compMiriams to make the annotation more human-readable. The obtained cell array looks the same like in Excel format, just the columns are split to have particular miriam name in corresponding column modelMiriams a miriam structure (e.g. model.metMiriams) for one or multiple metabolites miriamNames cell array with miriam names to be extracted (optional, default 'all', meaning that annotation for all miriam names found in modelMiriams will be extracted) miriams a cell array with extracted miriams. if several miriam names are requested, the corresponding information is saved in different columns. if there are several ids available for the same entity (metabolite, gene, reaction or compartment), they are concatenated into one column. the total number of column represent the number of unique miriam names per entity extractedMiriamNames cell array with extracted miriam names Usage: miriam=extractMiriam(modelMiriams,miriamName)
0001 function [miriams,extractedMiriamNames]=extractMiriam(modelMiriams,miriamNames) 0002 % extractMiriam 0003 % This function unpacks the information kept in metMiriams, rxnMiriams, 0004 % geneMiriams or compMiriams to make the annotation more 0005 % human-readable. The obtained cell array looks the same like in Excel 0006 % format, just the columns are split to have particular miriam name in 0007 % corresponding column 0008 % 0009 % modelMiriams a miriam structure (e.g. model.metMiriams) 0010 % for one or multiple metabolites 0011 % miriamNames cell array with miriam names to be 0012 % extracted (optional, default 'all', meaning 0013 % that annotation for all miriam names found 0014 % in modelMiriams will be extracted) 0015 % 0016 % miriams a cell array with extracted miriams. if 0017 % several miriam names are requested, the 0018 % corresponding information is saved in 0019 % different columns. if there are several ids 0020 % available for the same entity (metabolite, 0021 % gene, reaction or compartment), they are 0022 % concatenated into one column. the total 0023 % number of column represent the number of 0024 % unique miriam names per entity 0025 % extractedMiriamNames cell array with extracted miriam names 0026 % 0027 % Usage: miriam=extractMiriam(modelMiriams,miriamName) 0028 0029 if nargin<2 || (ischar(miriamNames) && strcmp(miriamNames,'all')) 0030 extractAllTypes=true; 0031 else 0032 extractAllTypes=false; 0033 miriamNames=convertCharArray(miriamNames); 0034 end 0035 0036 %The annotation for all miriam names should be extracted 0037 if extractAllTypes 0038 miriamNames={''}; 0039 for i=1:numel(modelMiriams) 0040 if ~isempty(modelMiriams{i,1}) 0041 for j=1:numel(modelMiriams{i,1}.name) 0042 miriamNames{numel(miriamNames)+1,1}=modelMiriams{i,1}.name{j}; 0043 end 0044 end 0045 end 0046 miriamNames=sort(unique(miriamNames)); 0047 end 0048 0049 %Aggregate the final cell array table with extracted miriam information 0050 miriams=cell(numel(modelMiriams),0); 0051 for i=1:numel(miriamNames) 0052 miriams=[miriams, extractMiriamType(modelMiriams,miriamNames{i})]; 0053 end 0054 extractedMiriamNames=miriamNames; 0055 0056 end 0057 0058 function miriams=extractMiriamType(modelMiriams,miriamName) 0059 %Create an empty cell array for ids vector 0060 tempMiriams = cell([size(modelMiriams,1) 1]); 0061 %Firstly obtain the list of relevant miriam ids. Several entries may have 0062 %several miriam ids, such ids are kept in additional columns 0063 for i=1:numel(modelMiriams) 0064 if (~isempty(modelMiriams{i,1})) && any(strcmp(modelMiriams{i,1}.name,miriamName)) 0065 for j=1:numel(modelMiriams{i,1}.name) 0066 if strcmp(modelMiriams{i,1}.name(j),miriamName) 0067 tempMiriams(i,j) = modelMiriams{i,1}.value(j); 0068 end 0069 end 0070 else 0071 modelMiriams{i,1} = ''; 0072 end 0073 end 0074 0075 %Concatenate multiple ids per miriam name in one column with semicolon as 0076 %separator 0077 miriams = cell([size(tempMiriams,1) 1]); 0078 notEmpty=~cellfun(@isempty,tempMiriams); 0079 for i=1:size(miriams,1) 0080 miriams{i}=strjoin(tempMiriams(i,notEmpty(i,:)),{'; '}); 0081 end 0082 end