Builds Directed Enzyme-Enzyme Network with Removing Currency Metabolites (based-on a Library file) which could be used as an input for QuateXelero Algorithm. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The function reads a Metabolic Network SBML file and builds an Directed Enzyme-Enzyme Network which is compatible with QuateXelero Algorithm. For every metabolite, the algorithm checks availability in the Library file which has been prepared by user as input in .txt format). and removes if it exists in the library file. Then the Directed Enzyme-Enzyme Network will be created. The QuateXelero is one of the best motif finding algorithms which is recently developed by Kavosh developer team. http://lbb.ut.ac.ir/Download/LBBsoft/QuateXelero 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] = enz_cent_Lib_dir_quatexelero(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_Lib_Dir_Index.dat Matrix Indeces of Enzyme-Enzyme Connections *_Enzyme_Cent_Lib_Dir_QuateXelero.dat Directed-Enzyme-Enzyme Network - QuateXelero Compatible Yazdan Asgari 12/07/2012 http://lbb.ut.ac.ir %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [Output] = enz_cent_Lib_dir_quatexelero(fileName1,fileName2) 0002 % Builds Directed Enzyme-Enzyme Network with Removing Currency Metabolites (based-on a Library file) which could be used as an input for QuateXelero Algorithm. 0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % The function reads a Metabolic Network SBML file and builds an Directed Enzyme-Enzyme Network which is compatible with QuateXelero Algorithm. 0005 % For every metabolite, the algorithm checks availability in the Library file which has been prepared by user as input in .txt format). 0006 % and removes if it exists in the library file. Then the Directed Enzyme-Enzyme Network will be created. 0007 % The QuateXelero is one of the best motif finding algorithms which is recently developed by Kavosh developer team. 0008 % http://lbb.ut.ac.ir/Download/LBBsoft/QuateXelero 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] = enz_cent_Lib_dir_quatexelero(fileName1,fileName2) 0013 % 0014 %INPUTS 0015 % fileName1 The Library file includes pre-defined currency metabolites (in .txt format) 0016 % Note: Library text file must include one metabolites per line (all in one column) 0017 % fileName2 The metabolic Network in the SBML format 0018 % 0019 %OUTPUTS 0020 % *_Enzyme_Cent_Lib_Dir_Index.dat Matrix Indeces of Enzyme-Enzyme Connections 0021 % *_Enzyme_Cent_Lib_Dir_QuateXelero.dat Directed-Enzyme-Enzyme Network - QuateXelero Compatible 0022 % 0023 % Yazdan Asgari 12/07/2012 http://lbb.ut.ac.ir 0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0027 % check validity of input files format 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 check1=regexp(fileName1,'.txt'); 0030 assert(~isempty(check1),'Error in the first input: The fileName1 must contain .txt at its end') 0031 check2=regexp(fileName2,'.xml'); 0032 assert(~isempty(check2),'Error in the second input: The fileName2 must contain .xml at its end') 0033 0034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0035 % start time evaluation of program 0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0037 tic; 0038 0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0040 % reading the Library text file and construct array of currency metabolites 0041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0042 fid = fopen(fileName1); 0043 tline = fgetl(fid); 0044 i=1; 0045 Curr_met={}; 0046 while ischar(tline) 0047 Curr_met{i,1}=tline; 0048 tline = fgetl(fid); 0049 i=i+1; 0050 end 0051 fclose(fid); 0052 [h,g]=size(Curr_met); 0053 0054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0055 % reading the SBML file using COBRA Toolbox Command, and sets size of the S matrix 0056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0057 model=readCbModel(fileName2); 0058 [m,n]=size(model.S); 0059 0060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0061 % reading the Metabolites array and check their availability in the library text file 0062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0063 N_curr=zeros(m,1); 0064 for q=1:m 0065 for i=1:h 0066 if strcmp(model.metNames{q},Curr_met{i,1})==1 0067 N_curr(q,1)=N_curr(q,1)+1; 0068 end 0069 end 0070 end 0071 0072 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0073 % Remove metabolites which are in the input Currecny Metabolites list 0074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0075 for q=1:m 0076 if N_curr(q,1)~=0 0077 for i=1:n 0078 model.S(q,i)=0; 0079 end 0080 end 0081 end 0082 0083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0084 % building the output file name 0085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0086 outname1=strrep(fileName2,'.xml','_Enzyme_Cent_Lib_Dir_Index.dat') 0087 fout1 = fopen(outname1, 'w+'); 0088 0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0090 % finds non-zero elements of the S-matrix (in order to make the algorithm faster), 0091 % parses through each row, and considers an edge for every unlike-signs, 0092 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0093 num=zeros(size(model.rxns)); 0094 for j=1:m 0095 indices=find(model.S(j,:)); 0096 [a,b]=size(indices); 0097 r=0; 0098 if b~=0 0099 r=1; 0100 end 0101 while r<b 0102 i=1; 0103 while i<(b-r+1) 0104 if model.S(j,indices(1,r))<0 && model.S(j,indices(1,r+i))>0 0105 fprintf(fout1,'%d\t%d\n',indices(1,r),indices(1,r+i)); 0106 num(1,indices(1,r))=1; 0107 num(1,indices(1,r+i))=1; 0108 elseif model.S(j,indices(1,r))>0 && model.S(j,indices(1,r+i))<0 0109 fprintf(fout1,'%d\t%d\n',indices(1,r+i),indices(1,r)); 0110 num(1,indices(1,r))=1; 0111 num(1,indices(1,r+i))=1; 0112 end 0113 i=i+1; 0114 end 0115 r=r+1; 0116 end 0117 end 0118 0119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0120 % considering nodes which do not contain any edges 0121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0122 for k=1:n 0123 if num(k,1)==0 0124 fprintf(fout1,'%d\n',k); 0125 end 0126 end 0127 fclose(fout1); 0128 0129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0130 % building the output file name 0131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0132 outname2=strrep(fileName2,'.xml','_Enzyme_Cent_Dir_QuateXelero.dat') 0133 fout2=fopen(outname2,'w+'); 0134 0135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0136 % reading the constructed Enzyme-Enzyme network file and re-format it to a QuateXelero-compatible file. 0137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0138 fid = fopen(outname1); 0139 fgetl(fid); 0140 C=fscanf(fid,'%d'); 0141 i=1; 0142 while isinteger(fid) 0143 C(i)=fscanf(fid,'%d',C); 0144 i=i+1; 0145 end 0146 g=size(C); 0147 A=size(unique(C)); 0148 if g~=0 0149 n=1; 0150 else 0151 disp('Error in reading the file, No Edge detected') 0152 end 0153 k=1; 0154 j=2; 0155 last=g/2; 0156 fprintf(fout2,'%d\n',A(1,1)); % total number of uniques nodes in the network (needed for QuateXelero Algorithm) 0157 for i=1:last 0158 fprintf(fout2,'%d\t%d\n ',C(k),C(j)); 0159 k=k+2; 0160 j=j+2; 0161 end 0162 fclose(fid); 0163 fclose(fout2); 0164 0165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0166 % End of time evaluation of program 0167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0168 toc;