-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: importModel allows empty params * fix: constructS correct error message missing mets * fix: importExcelModel if faulty MIRIAM are defined * fix: checkModelStruct check reaction reversibility To determine if reaction is reversible, consider all combinations of LB and UB, not just whether LB < 0 or not * doc: getKEGGModelForOrganism dataDir example * chore: updateDocumentation * fix: getExchangeRxns reactionType options * feat: checkModelStruct grRules and genes match
- Loading branch information
Showing
12 changed files
with
1,534 additions
and
1,411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,82 @@ | ||
function [exchangeRxns, exchangeRxnsIndexes]=getExchangeRxns(model,reactionType) | ||
% getExchangeRxns | ||
% Retrieves the exchange reactions from a model | ||
% Retrieves the exchange reactions from a model. Exchange reactions are | ||
% identified by having either no substrates or products. | ||
% | ||
% Input: | ||
% model a model structure | ||
% reactionType retrieve all reactions ('both'), only production | ||
% ('out'), or only consumption ('in') (optional, default | ||
% 'both') | ||
% reactionType which exchange reactions should be returned | ||
% 'all' all reactions, irrespective of reaction | ||
% bounds | ||
% 'uptake' reactions with bounds that imply that | ||
% only uptake are allowed. Reaction | ||
% direction, upper and lower bounds are | ||
% all considered | ||
% 'excrete' reactions with bounds that imply that | ||
% only excretion are allowed. Reaction | ||
% direction, upper and lower bounds are | ||
% all considered | ||
% 'reverse' reactions with non-zero upper and lower | ||
% bounds that imply that both uptake and | ||
% excretion are allowed | ||
% 'blocked' reactions that have zero upper and lower | ||
% bounds, not allowing any flux | ||
% 'in' reactions where the boundary metabolite | ||
% is the substrate of the reaction, a | ||
% positive flux value would imply uptake, | ||
% but reaction bounds are not considered | ||
% 'out' reactions where the boundary metabolite | ||
% is the substrate of the reaction, a | ||
% positive flux value would imply uptake, | ||
% but reaction bounds are not considered. | ||
% | ||
% Output: | ||
% exchangeRxns cell array with the IDs of the exchange reactions | ||
% exchangeRxnsIndexes vector with the indexes of the exchange reactions | ||
% | ||
% Exchange reactions are defined as reactions which involve only products | ||
% or only reactants. If the unconstrained field is present, then that is | ||
% used instead. | ||
% Note: | ||
% The union of 'in' and 'out' equals 'all'. Also, the union of 'uptake', | ||
% 'excrete', 'reverse' and 'blocked' equals all. | ||
% | ||
% Usage: [exchangeRxns,exchangeRxnsIndexes]=getExchangeRxns(model,reactionType) | ||
|
||
if nargin<2 | ||
reactionType='both'; | ||
reactionType='all'; | ||
else | ||
reactionType=char(reactionType); | ||
end | ||
|
||
hasNoProducts=sparse(numel(model.rxns),1); | ||
hasNoReactants=sparse(numel(model.rxns),1); | ||
|
||
if isfield(model,'unconstrained') | ||
if strcmpi(reactionType,'both') || strcmpi(reactionType,'out') | ||
[~, I]=find(model.S(model.unconstrained~=0,:)>0); | ||
hasNoProducts(I)=true; | ||
end | ||
if strcmpi(reactionType,'both') || strcmpi(reactionType,'in') | ||
[~, I]=find(model.S(model.unconstrained~=0,:)<0); | ||
hasNoReactants(I)=true; | ||
end | ||
% Find exchange reactions | ||
if isfield(model, 'unconstrained') | ||
[~, I]=find(model.S(model.unconstrained~=0,:)>0); | ||
hasNoProd(I)=true; | ||
[~, I]=find(model.S(model.unconstrained~=0,:)<0); | ||
hasNoSubs(I)=true; | ||
else | ||
if strcmpi(reactionType,'both') || strcmpi(reactionType,'out') | ||
hasNoProducts=sum((model.S>0))==0; | ||
end | ||
if strcmpi(reactionType,'both') || strcmpi(reactionType,'in') | ||
hasNoReactants=sum((model.S<0))==0; | ||
end | ||
hasNoProd = transpose(find(sum(model.S>0)==0)); | ||
hasNoSubs = transpose(find(sum(model.S<0)==0)); | ||
end | ||
allExch = [hasNoProd; hasNoSubs]; | ||
|
||
switch reactionType | ||
case {'both','all'} % For legacy reasons, 'both' is also allowed | ||
exchangeRxnsIndexes = allExch; | ||
case 'in' | ||
exchangeRxnsIndexes = hasNoSubs; | ||
case 'out' | ||
exchangeRxnsIndexes = hasNoProd; | ||
case 'blocked' | ||
exchangeRxnsIndexes = allExch(model.lb(allExch) == 0 & model.ub(allExch) == 0); | ||
case 'reverse' | ||
exchangeRxnsIndexes = allExch(model.lb(allExch) < 0 & model.ub(allExch) > 0); | ||
case 'uptake' | ||
exchangeRxnsIndexes = allExch([(model.lb(hasNoSubs) >= 0 & model.ub(hasNoSubs) > 0); ... | ||
(model.lb(hasNoProd) < 0 & model.ub(hasNoProd) <= 0)]); | ||
case 'excrete' | ||
exchangeRxnsIndexes = allExch([(model.lb(hasNoSubs) < 0 & model.ub(hasNoSubs) <= 0); ... | ||
(model.lb(hasNoProd) >= 0 & model.ub(hasNoProd) > 0)]); | ||
otherwise | ||
error('Invalid reactionType specified') | ||
end | ||
exchangeRxnsIndexes=find(hasNoProducts(:) | hasNoReactants(:)); | ||
exchangeRxns=model.rxns(exchangeRxnsIndexes); | ||
exchangeRxns = model.rxns(exchangeRxnsIndexes); | ||
end |
Oops, something went wrong.