Home > RAVEN > convertToIrrev.m

convertToIrrev

PURPOSE ^

convertToIrrev

SYNOPSIS ^

function irrevModel=convertToIrrev(model,rxns)

DESCRIPTION ^

 convertToIrrev
   Converts a model to irreversible form

   model         a model structure
   rxns          cell array with the reactions so split (if reversible)
                 (opt, default model.rxns)

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

   The reverse reactions are saved as 'REV_rxnID'.

   Usage: irrevModel=convertToIrrev(model,rxns)

   Rasmus Agren, 2013-08-01

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Mon 06-Jan-2014 14:58:12 by m2html © 2005