convertModelToEX

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function convertModelToEX(model,filename,rxnzero)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 convert Matlab Model to XPA format
 Inputs:
     model       Model Structure
     filename    Filename of Output File (make sure to include '.txt' or
     '.xpa')
     rxnzero     Matrix containing all no flux var rxns (to skip, set=0)
 
 Limitations:
     -Works properly with only integer value reaction coeff. (except for .5
     or -.5)
     Other non-integer value coeff. have to be edited manually
     -Exchange reactions have to be clumped together in model
     -If using rxnzero, make sure that EX reactions contain no compounds
     that are not used in the uncommented reactions
 
 Aarash Bordbar, 07/06/07
 Updated Aarash Bordbar 02/22/10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 % convert Matlab Model to XPA format
0003 % Inputs:
0004 %     model       Model Structure
0005 %     filename    Filename of Output File (make sure to include '.txt' or
0006 %     '.xpa')
0007 %     rxnzero     Matrix containing all no flux var rxns (to skip, set=0)
0008 %
0009 % Limitations:
0010 %     -Works properly with only integer value reaction coeff. (except for .5
0011 %     or -.5)
0012 %     Other non-integer value coeff. have to be edited manually
0013 %     -Exchange reactions have to be clumped together in model
0014 %     -If using rxnzero, make sure that EX reactions contain no compounds
0015 %     that are not used in the uncommented reactions
0016 %
0017 % Aarash Bordbar, 07/06/07
0018 % Updated Aarash Bordbar 02/22/10
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 function convertModelToEX(model,filename,rxnzero)
0022 
0023 fid = fopen(filename,'w');
0024 fprintf(fid,'(Internal Fluxes)\n');
0025 
0026 EXrxns = [strmatch('EX_',model.rxns);strmatch('DM_',model.rxns)];
0027 EXrxns = model.rxns(EXrxns);
0028 checkEX = ismember(model.rxns,EXrxns);
0029 
0030 % Reactions prior to exchange reactions
0031 for i = 1:length(model.rxns)
0032     if checkEX(i) == 0
0033         
0034         for t = 1:size(rxnzero,1)
0035             if i == rxnzero(t)
0036                 fprintf(fid,'// ');
0037             end
0038         end
0039         fprintf(fid,'%s\t',model.rxns{i});
0040         if model.rev(i) == 0
0041             fprintf(fid,'I\t');
0042         else
0043             fprintf(fid,'R\t');
0044         end
0045         reactionPlace = find(model.S(:,i));
0046         if abs(model.S(reactionPlace,i)) > 1 - 1e-2
0047             for j = 1:size(reactionPlace,1)
0048                 fprintf(fid,'%i\t%s\t',model.S(reactionPlace(j),i),model.mets{reactionPlace(j)});
0049             end
0050         else
0051             for j = 1:size(reactionPlace,1)
0052                 newS(j,i) = 2*model.S(reactionPlace(j),i);
0053                 fprintf(fid,'%i\t%s\t',newS(j,i),model.mets{reactionPlace(j)});
0054             end
0055         end
0056         fprintf(fid,'\n');
0057     end
0058 end
0059 
0060 % Exchange Reactions
0061 fprintf(fid,'(Exchange Fluxes)\n');
0062 for i = 1:length(model.rxns)
0063     if checkEX(i) == 1
0064         metabolitePlace = find(model.S(:,i));
0065         fprintf(fid,'%s\t',model.mets{metabolitePlace});
0066         if model.lb(i) >= 0 && model.ub(i) >= 0
0067             fprintf(fid,'Output\n');
0068         else if model.lb(i) <= 0 && model.ub(i) <= 0
0069                 fprintf(fid,'Input\n');
0070             else
0071                 fprintf(fid,'Free\n');
0072             end
0073         end
0074     end
0075 end
0076 
0077 fclose(fid);

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003