Builds Directed Enzyme-Enzyme Networks Removing Currency Metabolites (based-on a Library file) and considering single nodes (without any edges) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The function reads a Metabolic Network SBML file and builds Directed Enzyme-Enzyme Networks. The Remove Currency Metabolites based-on Library (RCMLib) algorithm removes currency metabolites in the metabolic network automatically IF AND ONLY IF the currency metabolits exists in the Library file. This file contains single nodes (without any edges) in Cytoscape-compatible files. Note: COBRA Toolbox must be installed in MATLAB before running this function [Output] = enz_cent_RCMLib_dir_single_node(fileName1,fileName2) INPUTS fileName1 The Library file includes pre-defined currency metabolites (in .txt format) Note: Library text file must include one metabolites per line (all in one column) fileName2 The metabolic Network in the SBML format OUTPUTS *_Enzyme_Cent_RCMLib_Dir_Single_Node_Cyt.sif Directed-Enzyme-Enzyme Network - Cytoscape Compatible Yazdan Asgari 12/07/2012 http://lbb.ut.ac.ir %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [Output] = enz_cent_RCMLib_dir_single_node(fileName1,fileName2) 0002 % Builds Directed Enzyme-Enzyme Networks Removing Currency Metabolites (based-on a Library file) and considering single nodes (without any edges) 0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % The function reads a Metabolic Network SBML file and builds Directed Enzyme-Enzyme Networks. 0005 % The Remove Currency Metabolites based-on Library (RCMLib) algorithm removes currency metabolites 0006 % in the metabolic network automatically IF AND ONLY IF the currency metabolits exists in the Library file. 0007 % This file contains single nodes (without any edges) in Cytoscape-compatible files. 0008 % Note: COBRA Toolbox must be installed in MATLAB before running this function 0009 % 0010 % [Output] = enz_cent_RCMLib_dir_single_node(fileName1,fileName2) 0011 % 0012 %INPUTS 0013 % fileName1 The Library file includes pre-defined currency metabolites (in .txt format) 0014 % Note: Library text file must include one metabolites per line (all in one column) 0015 % fileName2 The metabolic Network in the SBML format 0016 % 0017 %OUTPUTS 0018 % *_Enzyme_Cent_RCMLib_Dir_Single_Node_Cyt.sif Directed-Enzyme-Enzyme Network - Cytoscape Compatible 0019 % 0020 % Yazdan Asgari 12/07/2012 http://lbb.ut.ac.ir 0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0022 0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0024 % check validity of input files format 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 check1=regexp(fileName1,'.txt'); 0027 assert(~isempty(check1),'Error in the first input: The fileName1 must contain .txt at its end') 0028 check2=regexp(fileName2,'.xml'); 0029 assert(~isempty(check2),'Error in the second input: The fileName2 must contain .xml at its end') 0030 0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 % start time evaluation of program 0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0034 tic; 0035 0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0037 % reading the Library text file and construct array of currency metabolites 0038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0039 fid = fopen(fileName1); 0040 tline = fgetl(fid); 0041 i=1; 0042 Curr_met={}; 0043 while ischar(tline) 0044 Curr_met{i,1}=tline; 0045 tline = fgetl(fid); 0046 i=i+1; 0047 end 0048 fclose(fid); 0049 [h,g]=size(Curr_met); 0050 0051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0052 % reading the SBML file using COBRA Toolbox Command, and sets size of the S matrix 0053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0054 model=readCbModel(fileName2); 0055 [m,n]=size(model.S); 0056 0057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0058 % calculate summation of each columns (i.e. How many metabolites each enzyme correlates) 0059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0060 S_bin=zeros(size(model.S)); 0061 S_bin(find(model.S))=1; 0062 CB=sum(S_bin,1); 0063 A=zeros(m,n); 0064 B=zeros(m,1); 0065 N3=zeros(m,1); 0066 N_curr=zeros(m,1); 0067 0068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0069 % reading the Metabolites array and check their availability in the library text file 0070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0071 for q=1:m 0072 for i=1:h 0073 if strcmp(model.metNames{q},Curr_met{i,1})==1 0074 N_curr(q,1)=N_curr(q,1)+1; 0075 end 0076 end 0077 end 0078 0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0080 % for each binary S-matrix element, subtracts its value from the column summation and put the result in the A matrix. 0081 % A(q) means the metabolite q connects to how many other metabolites through the enzyme i. 0082 % for each row, sums the binary S-matrix over all columns. 0083 % B(q) means how many enzymes the metabolite q correlates. 0084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0085 for q=1:m 0086 for i=1:n 0087 if S_bin(q,i)~=0 0088 A(q,i)=CB(1,i)-S_bin(q,i); 0089 end 0090 B(q,1)=B(q,1)+S_bin(q,i); 0091 end 0092 end 0093 0094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0095 % Assumption: Generally, every metabolite is connected to the other one through a specific enzyme. 0096 % If a metabolite connects to more than one metabolite through an enzyme, this will be considered as a suspicious case. 0097 % Therefore, every N3(q) value equal to 3 will be marked for further analysis. 0098 % In addition, the availability of the metabolite in the library file will be checked. 0099 % So, the metabolites which do not exist in the library file, will not select for further analysis. 0100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0101 for q=1:m 0102 for i=1:n 0103 if A(q,i)==3 && N_curr(q,1)~=0 0104 N3(q,1)=N3(q,1)+1; 0105 end 0106 end 0107 end 0108 0109 s=0; 0110 for q=1:m 0111 if N3(q,1)~=0 0112 s=1; 0113 end 0114 end 0115 0116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0117 % If there is any value for N3 array, the RCM algorithm will be done. 0118 % This algorithm will be deleted the most probable metabolite among all (i.e. the one with the maximum value of N3 and C) 0119 % The selected metabolite will be deleted in the binary S-Matrix, and the "WHILE LOOP" repeated. 0120 % The algorithm is ended if there is not any suspicious case. 0121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0122 while s==1 0123 C=zeros(m,1); 0124 max1=max(N3,[],1); 0125 for q=1:m 0126 if N3(q,1)==max1 0127 C(q,1)=B(q,1); 0128 else 0129 C(q,1)=0; 0130 end 0131 end 0132 max2=max(C,[],1); 0133 for q=1:m 0134 if ( (N3(q,1)==max1) && (C(q,1)==max2) ) 0135 for i=1:n 0136 S_bin(q,i)=0; 0137 model.S(q,i)=0; 0138 end 0139 end 0140 end 0141 0142 CB=sum(S_bin,1); 0143 A=zeros(m,n); 0144 B=zeros(m,1); 0145 N3=zeros(m,1); 0146 for q=1:m 0147 for i=1:n 0148 if S_bin(q,i)~=0 0149 A(q,i)=CB(1,i)-S_bin(q,i); 0150 end 0151 B(q,1)=B(q,1)+S_bin(q,i); 0152 end 0153 end 0154 for q=1:m 0155 for i=1:n 0156 if A(q,i)==3 && N_curr(q,1)~=0 0157 N3(q,1)=N3(q,1)+1; 0158 end 0159 end 0160 end 0161 s=0; 0162 for q=1:m 0163 if N3(q,1)~=0 0164 s=1; 0165 end 0166 end 0167 end 0168 0169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0170 % building the output file name (Cytoscape compatble file) 0171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0172 outname=strrep(fileName2,'.xml','_Enzyme_Cent_RCMLib_Dir_Single_Node_Cyt.sif') 0173 fout = fopen(outname, 'w+'); 0174 0175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0176 % construction of Directed-Enzyme-Enzyme Network based on the new binary S-matrix 0177 % finds non-zero elements of the new S-matrix (in order to make the algorithm faster), 0178 % parses through each row, and considers an edge for every unlike-signs, 0179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0180 num=zeros(size(model.rxns)); 0181 for j=1:m 0182 indices=find(model.S(j,:)); 0183 [a,b]=size(indices); 0184 r=0; 0185 if b~=0 0186 r=1; 0187 end 0188 while r<b 0189 i=1; 0190 while i<(b-r+1) 0191 if model.S(j,indices(1,r))<0 && model.S(j,indices(1,r+i))>0 0192 fprintf(fout,'%s\t%s\t%s\n',model.rxns{indices(1,r)},'reaction-product',model.rxns{indices(1,r+i)}); 0193 num(1,indices(1,r))=1; 0194 num(1,indices(1,r+i))=1; 0195 elseif model.S(j,indices(1,r))>0 && model.S(j,indices(1,r+i))<0 0196 fprintf(fout,'%s\t%s\t%s\n',model.rxns{indices(1,r+i)},'reaction-product',model.rxns{indices(1,r)}); 0197 num(1,indices(1,r))=1; 0198 num(1,indices(1,r+i))=1; 0199 end 0200 i=i+1; 0201 end 0202 r=r+1; 0203 end 0204 end 0205 0206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0207 % considering nodes which do not contain any edges 0208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0209 for k=1:n 0210 if num(1,k)==0 0211 fprintf(fout,'%s\n',model.rxns{k}); 0212 end 0213 end 0214 fclose(fout); 0215 0216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0217 % End of time evaluation of program 0218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0219 toc;