Home > . > enz_cent_Lib_single_node.m

enz_cent_Lib_single_node

PURPOSE ^

Builds Undirected Enzyme-Enzyme Network with Removing Currency Metabolites (based-on a Library file) and considering single nodes (without any edges)

SYNOPSIS ^

function [Output] = enz_cent_Lib_single_node(fileName1,fileName2)

DESCRIPTION ^

 Builds Undirected Enzyme-Enzyme Network with Removing Currency Metabolites (based-on a Library file) and considering single nodes (without any edges)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 The function reads a Metabolic Network SBML file and builds an Undirected Enzyme-Enzyme Network.
 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 Undirected Enzyme-Enzyme Network will be created.
 This file also contains single nodes (without any edges) in Cytoscape-compatible files.
 Note: COBRA Toolbox must be installed in MATLAB before running this function

 [Output] = enz_cent_Lib_single_node(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
 *_Removed_Mets_Lib.dat                  file contains removed metabolits from the original model
 *_Enzyme_Cent_Lib.dat                   Undirected-Enzyme-Enzyme Network (comma separated Format)
 *_Enzyme_Cent_Lib_Single_Node_Cyt.dat   Undirected-Enzyme-Enzyme Network - Cytoscape 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_single_node(fileName1,fileName2)
0002 % Builds Undirected Enzyme-Enzyme Network with Removing Currency Metabolites (based-on a Library file) and considering single nodes (without any edges)
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % The function reads a Metabolic Network SBML file and builds an Undirected Enzyme-Enzyme Network.
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 Undirected Enzyme-Enzyme Network will be created.
0007 % This file also contains single nodes (without any edges) in Cytoscape-compatible files.
0008 % Note: COBRA Toolbox must be installed in MATLAB before running this function
0009 %
0010 % [Output] = enz_cent_Lib_single_node(fileName1,fileName2)
0011 %
0012 %INPUTS
0013 % fileName1                               The Library file includes pre-defined currency metabolites (in .txt format)
0014 % Note: Library text file must include one metabolites per line (all in one column)
0015 % fileName2                               The metabolic Network in the SBML format
0016 %
0017 %OUTPUTS
0018 % *_Removed_Mets_Lib.dat                  file contains removed metabolits from the original model
0019 % *_Enzyme_Cent_Lib.dat                   Undirected-Enzyme-Enzyme Network (comma separated Format)
0020 % *_Enzyme_Cent_Lib_Single_Node_Cyt.dat   Undirected-Enzyme-Enzyme Network - Cytoscape Compatible
0021 %
0022 % Yazdan Asgari 12/07/2012         http://lbb.ut.ac.ir
0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0024 
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 % check validity of input files format
0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0028 check1=regexp(fileName1,'.txt');
0029 assert(~isempty(check1),'Error in the first input: The fileName1 must contain .txt at its end')
0030 check2=regexp(fileName2,'.xml');
0031 assert(~isempty(check2),'Error in the second input: The fileName2 must contain .xml at its end')
0032 
0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0034 % start time evaluation of program
0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0036 tic;
0037 
0038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0039 % reading the Library text file and construct array of currency metabolites
0040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0041 fid = fopen(fileName1);
0042 tline = fgetl(fid);
0043 i=1;
0044 Curr_met={};
0045 while ischar(tline)
0046     Curr_met{i,1}=tline;
0047     tline = fgetl(fid);
0048     i=i+1;
0049 end
0050 fclose(fid);
0051 [h,g]=size(Curr_met);
0052 
0053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0054 % reading the SBML file using COBRA Toolbox Command, and sets size of the S matrix
0055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0056 model=readCbModel(fileName2);
0057 [m,n]=size(model.S);
0058 
0059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0060 % reading the Metabolites array and check their availability in the library text file
0061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0062 N_curr=zeros(m,1);
0063 for q=1:m
0064     for i=1:h
0065         if strcmp(model.metNames{q},Curr_met{i,1})==1
0066             N_curr(q,1)=N_curr(q,1)+1;
0067         end
0068     end
0069 end
0070 
0071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0072 % building the output file name for writing removed metabolites
0073 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0074 outname1=strrep(fileName2,'.xml','_Removed_Mets_Lib.dat')
0075 fout1 = fopen(outname1, 'w+');
0076 fprintf(fout1, 'Metabolite\t\tMetabolite Name\n');
0077 fprintf(fout1, '------------------------------\n');
0078 
0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0080 % Remove metabolites which are in the input Currecny Metabolites list
0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0082 for q=1:m
0083     if N_curr(q,1)~=0
0084         for i=1:n
0085             model.S(q,i)=0;
0086         end
0087         fprintf(fout1,'%s\t\t%s\n',model.mets{q},model.metNames{q});
0088     end
0089 end
0090 
0091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0092 % construction of Binary Stoichiometric Matrix from the new S-matrix(comma separated Format)
0093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0094 S_bin=zeros(size(model.S));
0095 S_bin(find(model.S))=1;
0096 
0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0098 % construction of Undirected-Enzyme-Enzyme Network based on the binary S-matrix(comma separated Format)
0099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0100 Aenz=S_bin'*S_bin;
0101 outname2=strrep(fileName2,'.xml','_Enzyme_Cent_Lib.dat')
0102 dlmwrite(outname2,full(Aenz));
0103 
0104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0105 % re-format of Undirected-Enzyme-Enzyme Network it to a Cytoscape-compatible file.
0106 % One could import the file using "File/Import/Network from Table(Text/MS Excel)..."
0107 % Select "first column" as "Source Interaction" and "second column" as "Target Interaction"
0108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0109 [m,n]=size(Aenz);
0110 outname3=strrep(fileName2,'.xml','_Enzyme_Cent_Lib_single_node_Cyt.dat')
0111 fout2 = fopen(outname3, 'w+');
0112 for row=1:m
0113     num=0;
0114     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0115     % because cell(i,j)=cell(j,i) we must delete duplicate entries by putting
0116     % col=row:n in the second if command. since we must ignor diagonal elements,
0117     % the counter will be col=row+1:n
0118     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0119     for col=row+1:n
0120         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0121         % edge are those which includes number not equal to zero
0122         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0123          if Aenz(row,col)~=0
0124             fprintf(fout2, '%s\t%s\t%d\n',model.rxns{row},model.rxns{col},Aenz(row,col));
0125             num=num+1;       
0126         end
0127     end
0128     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0129     % considering nodes which do not contain any edges
0130     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0131     if num==0
0132         fprintf(fout2,'%s\n',model.rxns{row});
0133     end
0134 end
0135 fclose(fout1);
0136 fclose(fout2);
0137 
0138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0139 % End of time evaluation of program
0140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0141 toc;
0142

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