Home > RAVEN > convertToIrrev.m

convertToIrrev

PURPOSE ^

convertToIrrev

SYNOPSIS ^

function irrevModel=convertToIrrev(model)

DESCRIPTION ^

 convertToIrrev
   Converts a model to irreversible form

   model         a model structure

   irrevModel    a model structure where all reversible reactions have
                 been split into one forward and one reverse reaction

   The reverse reactions are saved as 'REV_rxnID'.

   Usage: irrevModel=convertToIrrev(model)

   Rasmus Agren, 2010-12-16

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function irrevModel=convertToIrrev(model)
0002 % convertToIrrev
0003 %   Converts a model to irreversible form
0004 %
0005 %   model         a model structure
0006 %
0007 %   irrevModel    a model structure where all reversible reactions have
0008 %                 been split into one forward and one reverse reaction
0009 %
0010 %   The reverse reactions are saved as 'REV_rxnID'.
0011 %
0012 %   Usage: irrevModel=convertToIrrev(model)
0013 %
0014 %   Rasmus Agren, 2010-12-16
0015 %
0016 
0017 irrevModel=model;
0018 
0019 revIndexes=model.rev~=0;
0020 
0021 if any(revIndexes)
0022     irrevModel.S=[model.S,model.S(:,revIndexes)*-1];
0023     irrevModel.rev=zeros(size(irrevModel.S,2),1);
0024     
0025     %Get the limits for all normal and reversible rxns
0026     ubNormal=irrevModel.ub;
0027     ubNormal(ubNormal<0)=0;
0028     lbNormal=irrevModel.lb;
0029     lbNormal(lbNormal<0)=0;
0030     ubRev=irrevModel.lb(revIndexes)*-1;
0031     ubRev(ubRev<0)=0;
0032     lbRev=irrevModel.ub(revIndexes)*-1;
0033     lbRev(lbRev<0)=0;
0034     irrevModel.ub=[ubNormal;ubRev];
0035     irrevModel.lb=[lbNormal;lbRev];
0036 
0037     %The objective coefficents should be zero for the backwards reversible
0038     %reactions unless they were negative in the original. In that case they
0039     %should be positive for the backwards reversible and deleted from the
0040     %original
0041     irrevC=zeros(numel(find(revIndexes)),1);
0042     
0043     if any(irrevModel.c(revIndexes)<0)
0044         originalC=irrevModel.c(revIndexes);
0045         irrevC(irrevModel.c(revIndexes)<0)=originalC(originalC<0)*-1;
0046         irrevModel.c(irrevModel.c<0 & revIndexes)=0;
0047     end
0048     irrevModel.c=[irrevModel.c;irrevC];
0049 
0050     irrevModel.rxns=[irrevModel.rxns;strcat(irrevModel.rxns(revIndexes),'_REV')];
0051     irrevModel.rxnNames=[irrevModel.rxnNames;strcat(irrevModel.rxnNames(revIndexes),' (reversible)')];
0052 
0053     if isfield(irrevModel,'grRules')
0054         irrevModel.grRules=[irrevModel.grRules;irrevModel.grRules(revIndexes,:)];
0055     end
0056     if isfield(irrevModel,'rxnMiriams')
0057         irrevModel.rxnMiriams=[irrevModel.rxnMiriams;irrevModel.rxnMiriams(revIndexes,:)];
0058     end
0059     if isfield(irrevModel,'rxnGeneMat')
0060         irrevModel.rxnGeneMat=[irrevModel.rxnGeneMat;irrevModel.rxnGeneMat(revIndexes,:)];
0061     end
0062     if isfield(irrevModel,'subSystems')
0063         irrevModel.subSystems=[irrevModel.subSystems;irrevModel.subSystems(revIndexes)];
0064     end
0065     if isfield(irrevModel,'eccodes')
0066         irrevModel.eccodes=[irrevModel.eccodes;irrevModel.eccodes(revIndexes)];
0067     end
0068     if isfield(irrevModel,'rxnFrom')
0069         irrevModel.rxnFrom=[irrevModel.rxnFrom;irrevModel.rxnFrom(revIndexes)];
0070     end
0071 end
0072 end

Generated on Tue 16-Jul-2013 21:50:02 by m2html © 2005