Home > io > exportModelToSIF.m

exportModelToSIF

PURPOSE ^

exportModelToSIF

SYNOPSIS ^

function exportModelToSIF(model,fileName,graphType,rxnLabels,metLabels)

DESCRIPTION ^

 exportModelToSIF
   Exports a constraint-based model to a SIF file

   model         a model structure
   fileName      the filename  to export the model to
   graphType     the type of graph to export to (opt, default 'rc')
                 'rc'  reaction-compound
                 'rr'  reaction-reaction
                 'cc'  compound-compound
   rxnLabels     cell array with labels for reactions (opt, default
                 model.rxns)
   metLabels     cell array with labels for metabolites (opt, default
                 model.mets)

   Usage: exportModelToSIF(model,fileName,graphType,rxnLabels,metLabels)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function exportModelToSIF(model,fileName,graphType,rxnLabels,metLabels)
0002 % exportModelToSIF
0003 %   Exports a constraint-based model to a SIF file
0004 %
0005 %   model         a model structure
0006 %   fileName      the filename  to export the model to
0007 %   graphType     the type of graph to export to (opt, default 'rc')
0008 %                 'rc'  reaction-compound
0009 %                 'rr'  reaction-reaction
0010 %                 'cc'  compound-compound
0011 %   rxnLabels     cell array with labels for reactions (opt, default
0012 %                 model.rxns)
0013 %   metLabels     cell array with labels for metabolites (opt, default
0014 %                 model.mets)
0015 %
0016 %   Usage: exportModelToSIF(model,fileName,graphType,rxnLabels,metLabels)
0017 fileName=char(fileName);
0018 if nargin<3
0019     graphType='rc';
0020 else
0021     graphType=char(graphType);
0022 end
0023 
0024 if nargin<4 || isempty(rxnLabels)
0025     rxnLabels=model.rxns;
0026 else
0027     rxnLabels=convertCharArray(rxnLabels);
0028 end
0029 if nargin<5 || isempty(metLabels)
0030     metLabels=model.mets;
0031 else
0032     metLabels=convertCharArray(metLabels);
0033 end
0034 
0035 if ~strcmpi(graphType,'rc') && ~strcmpi(graphType,'rr') && ~strcmpi(graphType,'cc')
0036     EM='The graph type is incorrect';
0037     dispEM(EM);
0038 end
0039 
0040 if numel(rxnLabels)~=numel(unique(rxnLabels))
0041     EM='Not all reaction labels are unique';
0042     dispEM(EM,false);
0043 end
0044 if numel(metLabels)~=numel(unique(metLabels))
0045     EM='Not all metabolite labels are unique';
0046     dispEM(EM,false);
0047 end
0048 
0049 if strcmpi(graphType,'rc')
0050     G=model.S;
0051     A=rxnLabels;
0052     B=metLabels;
0053 end
0054 if strcmpi(graphType,'rr')
0055     G=model.S'*model.S;
0056     A=rxnLabels;
0057     B=rxnLabels;
0058 end
0059 if strcmpi(graphType,'cc')
0060     %A metabolite is linked to all products of the reactions that it
0061     %participates in If G=model.S*model.S' then all connections will be
0062     %double, which looks weird
0063     irrevModel=convertToIrrev(model);
0064     G=sparse(numel(model.mets),numel(model.mets));
0065     for i=1:numel(model.mets)
0066         I=irrevModel.S(i,:)<0; %Get the reactions in which it is a substrate
0067         [J, ~]=find(irrevModel.S(:,I)>0);
0068         G(J,i)=1;
0069     end
0070     A=metLabels;
0071     B=metLabels;
0072 end
0073 
0074 fid=fopen(fileName,'w');
0075 
0076 for i=1:size(G,2)
0077     I=G(:,i)~=0;
0078     nodes=setdiff(B(I),A(i)); %Don't include connection to itself
0079     if ~isempty(nodes)
0080         nNodes=numel(nodes);
0081         nodes(1:nNodes-1)=strcat(nodes(1:nNodes-1),{'\t'});
0082         fullString=[nodes{:}];
0083         fprintf(fid,[A{i} '\t' graphType '\t' fullString '\n']);
0084     end
0085 end
0086 fclose(fid);
0087 end

Generated by m2html © 2005