Home > . > met_comp.m

met_comp

PURPOSE ^

reads two Metabolic Network SBML files, compares them and finds Metabolites which are not in common

SYNOPSIS ^

function [Output] = met_comp(fileName1,fileName2)

DESCRIPTION ^

 reads two Metabolic Network SBML files, compares them and finds Metabolites which are not in common
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 The function reads two Metabolic Network SBML files,
 compares them and finds metabolites which are not in common among these models.
 Then, write the differences in output files.
 Note: COBRA Toolbox must be installed in MATLAB before running this function

 [Output] = met_comp(fileName1,fileName2)

INPUTS
 fileName1                               The first metabolic Network in the SBML format
 fileName2                               The second metabolic Network in the SBML format
 
OUTPUTS
 *_mets_filename1_not_in_filename2.dat   Metabolites in the first SBML file which do not exist in the second SBML file
 *_mets_filename2_not_in_filename1.dat   Metabolites in the second SBML file which do not exist in the first SBML file
 
 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] = met_comp(fileName1,fileName2)
0002 % reads two Metabolic Network SBML files, compares them and finds Metabolites which are not in common
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 % The function reads two Metabolic Network SBML files,
0005 % compares them and finds metabolites which are not in common among these models.
0006 % Then, write the differences in output files.
0007 % Note: COBRA Toolbox must be installed in MATLAB before running this function
0008 %
0009 % [Output] = met_comp(fileName1,fileName2)
0010 %
0011 %INPUTS
0012 % fileName1                               The first metabolic Network in the SBML format
0013 % fileName2                               The second metabolic Network in the SBML format
0014 %
0015 %OUTPUTS
0016 % *_mets_filename1_not_in_filename2.dat   Metabolites in the first SBML file which do not exist in the second SBML file
0017 % *_mets_filename2_not_in_filename1.dat   Metabolites in the second SBML file which do not exist in the first SBML file
0018 %
0019 % Yazdan Asgari 12/07/2012                http://lbb.ut.ac.ir
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 % check validity of input files format
0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0025 check1=regexp(fileName1,'.xml');
0026 assert(~isempty(check1),'Error in the first input: The fileName1 must contain .xml at its end')
0027 check2=regexp(fileName2,'.xml');
0028 assert(~isempty(check2),'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 files using COBRA Toolbox Command and calculate size of them
0037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0038 model1=readCbModel(fileName1);
0039 model2=readCbModel(fileName2);
0040 [m,mm]=size(model1.metNames);
0041 [n,nn]=size(model2.metNames);
0042 
0043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0044 % building the output file name
0045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0046 outname1=strrep(fileName1,'.xml','');
0047 outname2=strrep(fileName2,'.xml','.dat');
0048 outname3=strcat('Mets_in_',outname1);
0049 outname4=strcat(outname3,'_not_in_');
0050 outname5=strcat(outname4,outname2);
0051 fout = fopen(outname5, 'w+');
0052 
0053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0054 % compares two files and finds metabolites in the first file which are not in the second one
0055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0056 for i=1:m
0057     a=0;
0058     for j=1:n
0059         if strcmp(model1.metNames{i},model2.metNames{j})==1
0060             a=a+1;
0061         end
0062     end
0063     if a==0
0064         fprintf(fout,'%s\t\t%s\n',model1.mets{i},model1.metNames{i});
0065     end
0066 end
0067 fclose(fout);
0068 
0069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0070 % building the output file name
0071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0072 outname6=strrep(fileName2,'.xml','');
0073 outname7=strrep(fileName1,'.xml','.dat');
0074 outname8=strcat('Mets_in_',outname6);
0075 outname9=strcat(outname8,'_not_in_');
0076 outname10=strcat(outname9,outname7);
0077 fout2 = fopen(outname10, 'w+');
0078 
0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0080 % compares two files and finds metabolites in the second file which are not in the first one
0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0082 for j=1:n
0083     b=0;
0084     for i=1:m
0085         if strcmp(model2.metNames{j},model1.metNames{i})==1
0086             b=b+1;
0087         end
0088     end
0089     if b==0
0090         fprintf(fout2,'%s\t\t%s\n',model2.mets{j},model2.metNames{j});
0091     end
0092 end
0093 fclose(fout2);
0094 
0095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0096 % End of time evaluation of program
0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0098 toc;
0099

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