Home > scan_toolbox > enz_cent_Lib_dir_quatexelero.m

enz_cent_Lib_dir_quatexelero

PURPOSE ^

Builds Directed Enzyme-Enzyme Network with Removing Currency Metabolites (based-on a Library file) which could be used as an input for QuateXelero Algorithm.

SYNOPSIS ^

function [Output] = enz_cent_Lib_dir_quatexelero(fileName1,fileName2)

DESCRIPTION ^

 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 07/16/2016         http://yazdan59.ir/scan
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 07/16/2016         http://yazdan59.ir/scan
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 % It also consider Reversibility for Enzyme-Enzyme network.
0093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0094 num=zeros(size(model.rxns));
0095 for j=1:m
0096     indices=find(model.S(j,:));
0097     [a,b]=size(indices);
0098     r=0;
0099     if b~=0
0100         r=1;
0101     end
0102     while r<b
0103         i=1;
0104         while i<(b-r+1)
0105             if model.S(j,indices(1,r))>0 && model.S(j,indices(1,r+i))<0
0106                 if model.rev(indices(r+i))==1 && model.rev(indices(r))==1
0107                     fprintf(fout1,'%d\t%d\n',indices(1,r),indices(1,r+i));
0108                     fprintf(fout1,'%d\t%d\n',indices(1,r+i),indices(1,r));
0109                     num(1,indices(1,r))=1;
0110                     num(1,indices(1,r+i))=1;
0111                 else
0112                     fprintf(fout1,'%d\t%d\n',indices(1,r),indices(1,r+i));
0113                     num(1,indices(1,r))=1;
0114                     num(1,indices(1,r+i))=1;
0115                 end
0116             elseif model.S(j,indices(1,r))<0 && model.S(j,indices(1,r+i))>0
0117                 if model.rev(indices(r+i))==1 && model.rev(indices(r))==1
0118                     fprintf(fout1,'%d\t%d\n',indices(1,r+i),indices(1,r));
0119                     fprintf(fout1,'%d\t%d\n',indices(1,r),indices(1,r+i));
0120                     num(1,indices(1,r))=1;
0121                     num(1,indices(1,r+i))=1;
0122                 else
0123                     fprintf(fout1,'%d\t%d\n',indices(1,r+i),indices(1,r));
0124                     num(1,indices(1,r))=1;
0125                     num(1,indices(1,r+i))=1;
0126                 end
0127             end
0128             i=i+1;
0129         end
0130         r=r+1;
0131     end
0132 end
0133 
0134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0135 % building the output file name
0136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0137 outname2=strrep(fileName2,'.xml','_Enzyme_Cent_Dir_QuateXelero.dat')    
0138 fout2=fopen(outname2,'w+');
0139 
0140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0141 % reading the constructed Enzyme-Enzyme network file and re-format it to a QuateXelero-compatible file.
0142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0143 fid = fopen(outname1);
0144 C=fscanf(fid,'%d');
0145 i=1;
0146 while isinteger(fid)
0147     C(i)=fscanf(fid,'%d',C);
0148     i=i+1;
0149 end
0150 g=size(C);
0151 A=size(unique(C));
0152 if g~=0
0153     n=1;
0154 else
0155     disp('Error in reading the file, No Edge detected')
0156 end
0157 k=1;
0158 j=2;
0159 last=g/2;
0160 fprintf(fout2,'%d\n',A(1,1));   % total number of uniques nodes in the network (needed for QuateXelero Algorithm)
0161 for i=1:last
0162     fprintf(fout2,'%d\t%d\n ',C(k),C(j));
0163     k=k+2;
0164     j=j+2;
0165 end
0166 fclose(fid);
0167 fclose(fout2);
0168 
0169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0170 % End of time evaluation of program
0171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0172 toc;

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