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

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