Home > . > enz_cent_Lib_dir_kavosh.m

enz_cent_Lib_dir_kavosh

PURPOSE ^

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

SYNOPSIS ^

function [Output] = enz_cent_Lib_dir_kavosh(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 Kavosh Algorithm.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 The function reads a Metabolic Network SBML file and builds an Directed Enzyme-Enzyme Network which is compatible with Kavosh 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 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] = enz_cent_Lib_dir_kavosh(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_Kavosh.dat    Directed-Enzyme-Enzyme Network - QuateXelero Compatible
 
 Yazdan Asgari 12/07/2012         http://lbb.ut.ac.ir
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Thu 13-Dec-2012 14:17:37 by m2html © 2005