Home > RAVEN > checkRxn.m

checkRxn

PURPOSE ^

checkRxn

SYNOPSIS ^

function report=checkRxn(model,rxn,cutoff,revDir,printReport)

DESCRIPTION ^

 checkRxn
   Checks which reactants in a reaction that can be synthesized and which
   products that can be consumed. This is primarily for debugging
   reactions which cannot have flux

   model       a model structure
   rxn         the id of the reaction to check
   cutoff      minimal flux for successful production/consumption (opt,
               default 10^-7) 
   revDir      true if the reaction should be reversed (opt, default
               false)
   printReport print a report (opt, default true)

   report
       reactants   array with reactant indexes
       canMake     boolean array, true if the corresponding reactant can be
                   synthesized
       products    array with product indexes
       canConsume  boolean array, true if the corresponding reactant can
                   be consumed

   Usage: report=checkRxn(model,rxn,cutoff,revDir,printReport)

   Rasmus Agren, 2013-09-17

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function report=checkRxn(model,rxn,cutoff,revDir,printReport)
0002 % checkRxn
0003 %   Checks which reactants in a reaction that can be synthesized and which
0004 %   products that can be consumed. This is primarily for debugging
0005 %   reactions which cannot have flux
0006 %
0007 %   model       a model structure
0008 %   rxn         the id of the reaction to check
0009 %   cutoff      minimal flux for successful production/consumption (opt,
0010 %               default 10^-7)
0011 %   revDir      true if the reaction should be reversed (opt, default
0012 %               false)
0013 %   printReport print a report (opt, default true)
0014 %
0015 %   report
0016 %       reactants   array with reactant indexes
0017 %       canMake     boolean array, true if the corresponding reactant can be
0018 %                   synthesized
0019 %       products    array with product indexes
0020 %       canConsume  boolean array, true if the corresponding reactant can
0021 %                   be consumed
0022 %
0023 %   Usage: report=checkRxn(model,rxn,cutoff,revDir,printReport)
0024 %
0025 %   Rasmus Agren, 2013-09-17
0026 %
0027 
0028 %Convert to cell string
0029 if isstr(rxn)
0030     rxn={rxn};
0031 end
0032 if nargin<3
0033     cutoff=10^-7;
0034 end
0035 if nargin<4
0036     revDir=false;
0037 end
0038 if isempty(cutoff)
0039     cutoff=10^-7;
0040 end
0041 if nargin<5
0042     printReport=true;
0043 end
0044 
0045 [I rxnID]=ismember(rxn,model.rxns);
0046 
0047 if ~I
0048     dispEM('Reaction ID not found');
0049 end
0050 
0051 if revDir==false
0052     report.reactants=find(model.S(:,rxnID)<0);
0053     report.products=find(model.S(:,rxnID)>0);
0054 else
0055     report.reactants=find(model.S(:,rxnID)>0);
0056     report.products=find(model.S(:,rxnID)<0);
0057 end
0058 report.canMake=false(numel(report.reactants),1);
0059 report.canConsume=false(numel(report.products),1);
0060 
0061 %Remove this field as it would give an annoying note otherwise
0062 if isfield(model,'rxnComps')
0063     model=rmfield(model,'rxnComps');
0064 end
0065 
0066 %There are several ways to do this. Here I choose to add the reactions one
0067 %by one and checking their bounds. This might not be optimal
0068 for i=1:numel(report.reactants)
0069     [tempModel testRxn]=addExchangeRxns(model,'out',report.reactants(i));
0070     tempModel=setParam(tempModel,'obj',testRxn,1);
0071     sol=solveLP(tempModel);
0072     if sol.f*-1>cutoff
0073        report.canMake(i)=true; 
0074     else
0075         if printReport==true
0076            fprintf(['Failed to make ' model.metNames{report.reactants(i)} '[' model.comps{model.metComps(report.reactants(i))} ']\n']);
0077         end
0078     end
0079 end
0080 
0081 for i=1:numel(report.products)
0082     [tempModel testRxn]=addExchangeRxns(model,'in',report.products(i));
0083     tempModel=setParam(tempModel,'obj',testRxn,1);
0084     sol=solveLP(tempModel);
0085     if sol.f*-1>cutoff
0086        report.canConsume(i)=true; 
0087     else
0088         if printReport==true
0089             fprintf(['Failed to consume ' model.metNames{report.products(i)} '[' model.comps{model.metComps(report.products(i))} ']\n']);
0090         end
0091     end
0092 end
0093 end

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