Builds Directed Enzyme-Enzyme Networks which could be used as an input for Kavosh Algorithm. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The function reads a Metabolic Network SBML file, and builds Directed Metabolite-Metabolite Networks which is compatible with Kavosh Algorithm. The Kavosh is one of the best motif finding algorithms. Its Cytoscape plugins is also called CytoKavosh. http://lbb.ut.ac.ir/Download/LBBsoft/Kavosh/ & http://www.ncbi.nlm.nih.gov/pubmed/19799800 http://lbb.ut.ac.ir/Download/LBBsoft/CytoKavosh/CytoKavosh-Manual/cytoKavoshTutorial.html So, one could easily use this algorithm in order to find motifs in different sizes for the metabolic network. Note: COBRA Toolbox must be installed in MATLAB before running this function [Output] = met_cent_dir_kavosh(fileName) INPUTS fileName The metabolic Network in the SBML format OUTPUTS *_Metabolite_Cent_Dir_Index.dat Matrix Indeces of Metabolite-Metabolite Connections *_Metabolite_Cent_Dir_Kavosh.dat Directed-Metabolite-Metabolite Network - Kavosh Compatible Yazdan Asgari 12/07/2012 http://lbb.ut.ac.ir %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [Output] = met_cent_dir_kavosh(fileName) 0002 % Builds Directed Enzyme-Enzyme Networks which could be used as an input for Kavosh Algorithm. 0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % The function reads a Metabolic Network SBML file, 0005 % and builds Directed Metabolite-Metabolite Networks which is compatible with Kavosh Algorithm. 0006 % The Kavosh is one of the best motif finding algorithms. Its Cytoscape plugins is also called CytoKavosh. 0007 % http://lbb.ut.ac.ir/Download/LBBsoft/Kavosh/ & http://www.ncbi.nlm.nih.gov/pubmed/19799800 0008 % http://lbb.ut.ac.ir/Download/LBBsoft/CytoKavosh/CytoKavosh-Manual/cytoKavoshTutorial.html 0009 % So, one could easily use this algorithm in order to find motifs in different sizes for the metabolic network. 0010 % Note: COBRA Toolbox must be installed in MATLAB before running this function 0011 % 0012 % [Output] = met_cent_dir_kavosh(fileName) 0013 % 0014 %INPUTS 0015 % fileName The metabolic Network in the SBML format 0016 % 0017 %OUTPUTS 0018 % *_Metabolite_Cent_Dir_Index.dat Matrix Indeces of Metabolite-Metabolite Connections 0019 % *_Metabolite_Cent_Dir_Kavosh.dat Directed-Metabolite-Metabolite Network - Kavosh Compatible 0020 % 0021 % Yazdan Asgari 12/07/2012 http://lbb.ut.ac.ir 0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0023 0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 % check validity of input file format 0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0027 check=regexp(fileName,'.xml'); 0028 assert(~isempty(check),'The SBML fileName must contain .xml at its end') 0029 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 % start time evaluation of program 0032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0033 tic; 0034 0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0036 % reading the SBML file using COBRA Toolbox Command 0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0038 model=readCbModel(fileName); 0039 [m,n]=size(model.S); 0040 0041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0042 % building the output file name 0043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0044 outname=strrep(fileName,'.xml','_Metabolite_Cent_Dir_Index.dat') 0045 fout = fopen(outname, 'w+'); 0046 0047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0048 % finds non-zero elements of the S-matrix (in order to make the algorithm faster), 0049 % parses through each column, and considers an edge for every unlike-signs, 0050 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0051 num=zeros(size(model.mets)); 0052 for j=1:n 0053 indices=find(model.S(:,j)); 0054 [a,b]=size(indices); 0055 r=0; 0056 if a~=0 0057 r=1; 0058 end 0059 while r<a 0060 i=1; 0061 while i<(a-r+1) 0062 if model.S(indices(r,1),j)<0 && model.S(indices(r+i,1),j)>0 0063 fprintf(fout,'%d\t%d\n',indices(r,1),indices(r+i,1)); 0064 num(indices(r,1),1)=1; 0065 num(indices(r+i,1),1)=1; 0066 elseif model.S(indices(r,1),j)>0 && model.S(indices(r+i,1),j)<0 0067 fprintf(fout,'%d\t%d\n',indices(r+i,1),indices(r,1)); 0068 num(indices(r,1),1)=1; 0069 num(indices(r+i,1),1)=1; 0070 end 0071 i=i+1; 0072 end 0073 r=r+1; 0074 end 0075 end 0076 0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0078 % considering nodes which do not contain any edges 0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0080 for k=1:m 0081 if num(k,1)==0 0082 fprintf(fout,'%d\n',k); 0083 end 0084 end 0085 fclose(fout); 0086 0087 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0088 % building the output file name 0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0090 outname2=strrep(fileName,'.xml','_Metabolite_Cent_Dir_Kavosh.dat') 0091 fout2=fopen(outname2,'w+'); 0092 0093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0094 % reading the constructed Metabolic-Metabolic network file and re-format it to a Kavosh-compatible file. 0095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0096 fid = fopen(outname); 0097 fgetl(fid); 0098 C=fscanf(fid,'%d'); 0099 i=1; 0100 while isinteger(fid) 0101 C(i)=fscanf(fid,'%d',C); 0102 i=i+1; 0103 end 0104 g=size(C); 0105 A=size(unique(C)); 0106 if g~=0 0107 n=1; 0108 else 0109 disp('Error in reading the file, No Edge detected') 0110 end 0111 k=1; 0112 j=2; 0113 last=g/2; 0114 fprintf(fout2,'%d\n',A(1,1)); % total number of uniques nodes in the network (needed for Kavosh Algorithm) 0115 for i=1:last 0116 fprintf(fout2,'%d\t%d\n ',C(k),C(j)); 0117 k=k+2; 0118 j=j+2; 0119 end 0120 fclose(fid); 0121 fclose(fout2); 0122 0123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0124 % End of time evaluation of program 0125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0126 toc; 0127