Home > . > postprocess_NeMo.m

postprocess_NeMo

PURPOSE ^

Reads an output of the NeMo and construct a new output file which has been added the name of the related SBML metabolites or reactions

SYNOPSIS ^

function [Output] = postprocess_NeMo(fileName1,fileName2)

DESCRIPTION ^

 Reads an output of the NeMo and construct a new output file which has been added the name of the related SBML metabolites or reactions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 The "PostProcess" Functions in this toolbox do some changes on some useful structural plugins in the Cytoscape software.
 This function reads an output of the NeMo (a Cytoscape plugin),
 and construct a new output file which has been added the name of the related SBML metabolites or reactions.
 http://apps.cytoscape.org/apps/nemo
 Note: COBRA Toolbox must be installed in MATLAB before running this function
 Note: This function is applicable for MCODE analysis on Bipartite, Metabolite-Metabolite, and Enzyme-Enzyme networks (both Directed and Undirected).

 [Output] = postprocess_NeMo(fileName1,fileName2)

INPUTS
 fileName1                                text file includes NeMo results for network clustering
 fileName2                                The metabolic Network in the SBML format
 
OUTPUTS
 *_fileName_fileName2_NeMo_clusters.dat   The output file which includes the name of the related SBML metabolites or reactions.
 *_fileName_fileName2_NeMo.dat            This output file saves some data which will be used for the main output file in this program 
 
 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] = postprocess_NeMo(fileName1,fileName2)
0002 % Reads an output of the NeMo and construct a new output file which has been added the name of the related SBML metabolites or reactions
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % The "PostProcess" Functions in this toolbox do some changes on some useful structural plugins in the Cytoscape software.
0005 % This function reads an output of the NeMo (a Cytoscape plugin),
0006 % and construct a new output file which has been added the name of the related SBML metabolites or reactions.
0007 % http://apps.cytoscape.org/apps/nemo
0008 % Note: COBRA Toolbox must be installed in MATLAB before running this function
0009 % Note: This function is applicable for MCODE analysis on Bipartite, Metabolite-Metabolite, and Enzyme-Enzyme networks (both Directed and Undirected).
0010 %
0011 % [Output] = postprocess_NeMo(fileName1,fileName2)
0012 %
0013 %INPUTS
0014 % fileName1                                text file includes NeMo results for network clustering
0015 % fileName2                                The metabolic Network in the SBML format
0016 %
0017 %OUTPUTS
0018 % *_fileName_fileName2_NeMo_clusters.dat   The output file which includes the name of the related SBML metabolites or reactions.
0019 % *_fileName_fileName2_NeMo.dat            This output file saves some data which will be used for the main output file in this program
0020 %
0021 % Yazdan Asgari 12/07/2012                 http://lbb.ut.ac.ir
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 
0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0025 % check validity of input files format
0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0027 check=regexp(fileName2,'.xml');
0028 assert(~isempty(check),'Error in the second input: The fileName2 must contain .xml at its end')
0029 
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 % start time evaluation of program
0032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0033 tic;
0034 
0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0036 % reading the SBML file using COBRA Toolbox Command
0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0038 model=readCbModel(fileName2);
0039 
0040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0041 % reading an output of the MCODE and write first 10 lines to the new output file.
0042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0043 fid = fopen(fileName1);
0044 outname1=strrep(fileName2,'.xml','_');
0045 outname2=strcat(outname1,fileName1);
0046 outname3=strcat(outname2,'_NeMo_clusters.dat')
0047 fout = fopen(outname3, 'w+');
0048 B={};
0049 for i=1:10
0050     B{i}=fgetl(fid);
0051     fprintf(fout,'%s\n',B{i});
0052 end
0053 
0054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0055 % reading the rest of the NeMo output file and construct a new output file,
0056 % which has been added the name of the related SBML metabolites or reactions.
0057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0058 i=1;
0059 A={};
0060 line={};
0061 while ~feof(fid)
0062     A{i} = fscanf(fid,'%d %f %d %d');
0063     line{i} = fgetl(fid);
0064     i=i+1;
0065 end
0066 
0067 M={};
0068 for j=1:i-1
0069     M{1,j}=regexp(line{1,j},',','split');
0070 end
0071 fclose(fid);
0072 
0073 outname4=strrep(fileName2,'.xml','_');
0074 outname5=strcat(outname4,fileName1);
0075 outname6=strcat(outname5,'_NeMo.dat')
0076 fout2 = fopen(outname6, 'w+');
0077 [h,hh]=size(model.mets);
0078 [r,rr]=size(model.rxns);
0079 for k=1:i-1
0080     k;
0081     [ee,e]=size(M{1,k});
0082     g=1;
0083     while g<e+1
0084         M{1,k}{1,g};
0085         if g==1
0086             p=0;
0087             if strncmp(M{1,k}{1,g},'E_',2)==1
0088                 fprintf(fout2,'%s\t\t',M{1,k}{1,g});
0089                 p=p+1;
0090             end
0091             if p==0
0092                 for jj=1:r
0093                     Raddition=strcat('R_',model.rxns{jj});
0094                     if strcmp(M{1,k}{1,g},Raddition)==1
0095                         fprintf(fout2,'%s\t\t',model.rxnNames{jj});
0096                         p=p+1;
0097                         break;
0098                     end
0099                 end
0100             end
0101             if p==0
0102                 for jj=1:h
0103                     Maddition=strcat('M_',model.mets{jj});
0104                     if strcmp(M{1,k}{1,g},Maddition)==1
0105                         fprintf(fout2,'%s\t\t',model.metNames{jj});
0106                         p=p+1;
0107                         break;
0108                     end
0109                 end
0110             end
0111             if p==0
0112                 fprintf(fout2,'%s\t\t',M{1,k}{1,g});
0113             end
0114             g=g+1;
0115         elseif g~=1
0116             p=0;
0117             if strncmp(M{1,k}{1,g},' E_',2)==1
0118                 fprintf(fout2,'%s\t\t',M{1,k}{1,g});
0119                 p=p+1;
0120             end
0121             if p==0
0122                 for jj=1:r
0123                     Raddition=strcat(' R_',model.rxns{jj});
0124                     if strcmp(M{1,k}{1,g},Raddition)==1
0125                         fprintf(fout2,'%s\t\t',model.rxnNames{jj});
0126                         p=p+1;
0127                         break;
0128                     end
0129                 end
0130             end
0131             if p==0
0132                 for jj=1:h
0133                     Maddition=strcat(' M_',model.mets{jj});
0134                     if strcmp(M{1,k}{1,g},Maddition)==1
0135                         fprintf(fout2,'%s\t\t',model.metNames{jj});
0136                         p=p+1;
0137                         break;
0138                     end
0139                 end
0140             end
0141             if p==0
0142                 fprintf(fout2,'%s\t\t',M{1,k}{1,g});
0143             end
0144             g=g+1;
0145         end
0146     end
0147     fprintf(fout2,'\n');
0148 end
0149 fclose(fout2);
0150 
0151 fid2 = fopen(outname6);
0152 y=1;
0153 while ~feof(fid2)
0154     E{y}=fgetl(fid2);
0155     y=y+1;
0156 end
0157 fclose(fid2);
0158 
0159 for i=1:i-1
0160     C=A{1,i};
0161     fprintf(fout,'%d\t%f\t%d\t%d\t%s\n',C(1),C(2),C(3),C(4),line{1,i});
0162     fprintf(fout,'%s\n\n',E{i});
0163 end
0164 fclose(fout);
0165 
0166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0167 % End of time evaluation of program
0168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0169 toc;

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