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 07/16/2016 http://yazdan59.ir/scan %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 07/16/2016 http://yazdan59.ir/scan 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 Library text file and construct array of carriors of electrons , protons and energy 0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0038 fid = fopen('carr_mets.txt'); 0039 tline = fgetl(fid); 0040 i=1; 0041 Curr_met={}; 0042 while ischar(tline) 0043 Curr_met{i,1}=tline; 0044 tline = fgetl(fid); 0045 i=i+1; 0046 end 0047 fclose(fid); 0048 [h,g]=size(Curr_met); 0049 0050 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0051 % reading the SBML file using COBRA Toolbox Command 0052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0053 model=readCbModel(fileName); 0054 [m,n]=size(model.S); 0055 0056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0057 % building the output file name 0058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0059 outname=strrep(fileName,'.xml','_Metabolite_Cent_Dir_Index.dat') 0060 fout = fopen(outname, 'w+'); 0061 0062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0063 % finds non-zero elements of the S-matrix (in order to make the algorithm faster), 0064 % parses through each column, and considers an edge for every unlike-signs. 0065 % It also consider Reversibility for Enzyme-Enzyme network. 0066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0067 num=zeros(size(model.mets)); 0068 for j=1:n 0069 indices=find(model.S(:,j)); 0070 [a,b]=size(indices); 0071 r=0; 0072 if a~=0 0073 r=1; 0074 end 0075 while r<a 0076 i=1; 0077 while i<(a-r+1) 0078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0079 % reading every metabolite and check its availability in the carriors metabolites text file 0080 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0081 N=0; 0082 for k=1:h 0083 if strcmp(model.metNames{indices(r,1)},Curr_met{k,1})==1 0084 N=1; 0085 break 0086 elseif strcmp(model.metNames{indices(r+i,1)},Curr_met{k,1})==1 0087 N=1; 0088 break 0089 end 0090 end 0091 if model.S(indices(r,1),j)<0 && model.S(indices(r+i,1),j)>0 0092 if model.rev(j)==1 && N==0 0093 fprintf(fout,'%d\t%d\n',indices(r,1),indices(r+i,1)); 0094 fprintf(fout,'%d\t%d\n',indices(r+i,1),indices(r,1)); 0095 else 0096 fprintf(fout,'%d\t%d\n',indices(r,1),indices(r+i,1)); 0097 end 0098 elseif model.S(indices(r,1),j)>0 && model.S(indices(r+i,1),j)<0 0099 if model.rev(j)==1 && N==0 0100 fprintf(fout,'%d\t%d\n',indices(r+i,1),indices(r,1)); 0101 fprintf(fout,'%d\t%d\n',indices(r,1),indices(r+i,1)); 0102 else 0103 fprintf(fout,'%d\t%d\n',indices(r+i,1),indices(r,1)); 0104 end 0105 end 0106 i=i+1; 0107 end 0108 r=r+1; 0109 end 0110 end 0111 0112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0113 % building the output file name 0114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0115 outname2=strrep(fileName,'.xml','_Metabolite_Cent_Dir_Kavosh.dat') 0116 fout2=fopen(outname2,'w+'); 0117 0118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0119 % reading the constructed Metabolic-Metabolic network file and re-format it to a Kavosh-compatible file. 0120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0121 fid = fopen(outname); 0122 C=fscanf(fid,'%d'); 0123 i=1; 0124 while isinteger(fid) 0125 C(i)=fscanf(fid,'%d',C); 0126 i=i+1; 0127 end 0128 g=size(C); 0129 A=size(unique(C)); 0130 if g~=0 0131 n=1; 0132 else 0133 disp('Error in reading the file, No Edge detected') 0134 end 0135 k=1; 0136 j=2; 0137 last=g/2; 0138 fprintf(fout2,'%d\n',A(1,1)); % total number of uniques nodes in the network (needed for Kavosh Algorithm) 0139 for i=1:last 0140 fprintf(fout2,'%d\t%d\n ',C(k),C(j)); 0141 k=k+2; 0142 j=j+2; 0143 end 0144 fclose(fid); 0145 fclose(fout2); 0146 0147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0148 % End of time evaluation of program 0149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0150 toc; 0151