Home > RAVEN > 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)

   Rasmus Agren, 2013-08-01

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 %
0018 %   Rasmus Agren, 2013-08-01
0019 %
0020 
0021 if nargin<3
0022    graphType='rc';
0023 end
0024 
0025 if nargin<4
0026    rxnLabels=model.rxns;
0027 end
0028 if nargin<5
0029    metLabels=model.mets;
0030 end
0031 if isempty(rxnLabels)
0032    rxnLabels=model.rxns;
0033 end
0034 if isempty(metLabels)
0035    metLabels=model.mets;
0036 end
0037 
0038 if ~strcmpi(graphType,'rc') && ~strcmpi(graphType,'rr') && ~strcmpi(graphType,'cc')
0039    dispEM('The graph type is incorrect'); 
0040 end
0041 
0042 if numel(rxnLabels)~=numel(unique(rxnLabels))
0043     dispEM('Not all reaction labels are unique',false); 
0044 end
0045 if numel(metLabels)~=numel(unique(metLabels))
0046     dispEM('Not all metabolite labels are unique',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 participates in
0061    %If G=model.S*model.S' then all connections will be double, which looks
0062    %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 crap]=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 on Mon 06-Jan-2014 14:58:12 by m2html © 2005