Home > scan_toolbox > met_cent_dir_quatexelero.m

met_cent_dir_quatexelero

PURPOSE ^

Builds Directed Enzyme-Enzyme Networks which could be used as an input for QuateXelero Algorithm.

SYNOPSIS ^

function [Output] = met_cent_dir_quatexelero(fileName)

DESCRIPTION ^

 Builds Directed Enzyme-Enzyme Networks which could be used as an input for QuateXelero Algorithm.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 The function reads a Metabolic Network SBML file,
 and builds Directed Metabolite-Metabolite Networks which is compatible with QuateXelero Algorithm.
 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] = met_cent_dir_quatexelero(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_QuateXelero.dat    Directed-Metabolite-Metabolite Network - QuateXelero Compatible
 
 Yazdan Asgari 07/16/2016          http://yazdan59.ir/scan
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Output] = met_cent_dir_quatexelero(fileName)
0002 % Builds Directed Enzyme-Enzyme Networks which could be used as an input for QuateXelero Algorithm.
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % The function reads a Metabolic Network SBML file,
0005 % and builds Directed Metabolite-Metabolite Networks which is compatible with QuateXelero Algorithm.
0006 % The QuateXelero is one of the best motif finding algorithms which is recently developed by Kavosh developer team.
0007 % http://lbb.ut.ac.ir/Download/LBBsoft/QuateXelero
0008 % So, one could easily use this algorithm in order to find motifs in different sizes for the metabolic network.
0009 % Note: COBRA Toolbox must be installed in MATLAB before running this function
0010 %
0011 % [Output] = met_cent_dir_quatexelero(fileName)
0012 %
0013 %INPUTS
0014 % fileName                                 The metabolic Network in the SBML format
0015 %
0016 %OUTPUTS
0017 % *_Metabolite_Cent_Dir_Index.dat          Matrix Indeces of Metabolite-Metabolite Connections
0018 % *_Metabolite_Cent_Dir_QuateXelero.dat    Directed-Metabolite-Metabolite Network - QuateXelero Compatible
0019 %
0020 % Yazdan Asgari 07/16/2016          http://yazdan59.ir/scan
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 
0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0024 % check validity of input file format
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 check=regexp(fileName,'.xml');
0027 assert(~isempty(check),'The SBML fileName must contain .xml at its end')
0028 
0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0030 % start time evaluation of program
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 tic;
0033 
0034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0035 % reading the Library text file and construct array of carriors of electrons , protons and energy
0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0037 fid = fopen('carr_mets.txt');
0038 tline = fgetl(fid);
0039 i=1;
0040 Curr_met={};
0041 while ischar(tline)
0042     Curr_met{i,1}=tline;
0043     tline = fgetl(fid);
0044     i=i+1;
0045 end
0046 fclose(fid);
0047 [h,g]=size(Curr_met);
0048 
0049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0050 % reading the SBML file using COBRA Toolbox Command
0051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0052 model=readCbModel(fileName);
0053 [m,n]=size(model.S);
0054 
0055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0056 % building the output file name
0057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0058 outname=strrep(fileName,'.xml','_Metabolite_Cent_Dir_Index.dat')
0059 fout = fopen(outname, 'w+');
0060 
0061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0062 % finds non-zero elements of the S-matrix (in order to make the algorithm faster),
0063 % parses through each column, and considers an edge for every unlike-signs.
0064 % It also consider Reversibility for Enzyme-Enzyme network.
0065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0066 num=zeros(size(model.mets));
0067 for j=1:n
0068     indices=find(model.S(:,j));
0069     [a,b]=size(indices);
0070     r=0;
0071     if a~=0
0072         r=1;
0073     end
0074     while r<a
0075         i=1;
0076         while i<(a-r+1)
0077             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0078             % reading every metabolite and check its availability in the carriors metabolites text file
0079             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0080             N=0;
0081             for k=1:h
0082                 if strcmp(model.metNames{indices(r,1)},Curr_met{k,1})==1
0083                     N=1;
0084                     break
0085                 elseif strcmp(model.metNames{indices(r+i,1)},Curr_met{k,1})==1
0086                     N=1;
0087                     break
0088                 end
0089             end
0090             if model.S(indices(r,1),j)<0 && model.S(indices(r+i,1),j)>0
0091                 if model.rev(j)==1 && N==0
0092                     fprintf(fout,'%d\t%d\n',indices(r,1),indices(r+i,1));
0093                     fprintf(fout,'%d\t%d\n',indices(r+i,1),indices(r,1));
0094                 else
0095                     fprintf(fout,'%d\t%d\n',indices(r,1),indices(r+i,1));
0096                 end
0097             elseif model.S(indices(r,1),j)>0 && model.S(indices(r+i,1),j)<0
0098                 if model.rev(j)==1 && N==0
0099                     fprintf(fout,'%d\t%d\n',indices(r+i,1),indices(r,1));
0100                     fprintf(fout,'%d\t%d\n',indices(r,1),indices(r+i,1));
0101                 else
0102                     fprintf(fout,'%d\t%d\n',indices(r+i,1),indices(r,1));
0103                 end
0104             end
0105             i=i+1;
0106         end
0107         r=r+1;
0108     end
0109 end
0110 
0111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0112 % building the output file name
0113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0114 outname2=strrep(fileName,'.xml','_Metabolite_Cent_Dir_QuateXelero.dat')    
0115 fout2=fopen(outname2,'w+');
0116 
0117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0118 % reading the constructed Metabolic-Metabolic network file and re-format it to a QuateXelero-compatible file.
0119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0120 fid = fopen(outname);
0121 C=fscanf(fid,'%d');
0122 i=1;
0123 while isinteger(fid)
0124     C(i)=fscanf(fid,'%d',C);
0125     i=i+1;
0126 end
0127 g=size(C);
0128 A=size(unique(C));
0129 if g~=0
0130     n=1;
0131 else
0132     disp('Error in reading the file, No Edge detected')
0133 end
0134 k=1;
0135 j=2;
0136 last=g/2;
0137 fprintf(fout2,'%d\n',A(1,1));   % total number of uniques nodes in the network (needed for QuateXelero Algorithm)
0138 for i=1:last
0139     fprintf(fout2,'%d\t%d\n ',C(k),C(j));
0140     k=k+2;
0141     j=j+2;
0142 end
0143 fclose(fid);
0144 fclose(fout2);
0145 
0146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0147 % End of time evaluation of program
0148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0149 toc;
0150

Generated on Sat 16-Jul-2016 17:47:22 by m2html © 2003