Skip to content

Commit

Permalink
Merge pull request #430 from SysBioChalmers/feat/KEGG102
Browse files Browse the repository at this point in the history
chore: update KEGG to version 102
  • Loading branch information
edkerk authored Jun 26, 2022
2 parents 1200bd5 + 6f7b3c6 commit ea7a378
Show file tree
Hide file tree
Showing 25 changed files with 2,448 additions and 2,410 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Mark as binary to prevent EOL changes. Also no need to track
mafft.bat binary
mafft/ binary
mafft binary
# Files/folders that should not be included when downloading repo as ZIP
.gitattributes export-ignore
.gitignore export-ignore
Expand Down
37 changes: 18 additions & 19 deletions core/addRxns.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
% interpreted
% 1 - The metabolites are matched to model.mets. New
% metabolites (if allowed) are added to
% "compartment"
% "compartment" (default)
% 2 - The metabolites are matched to model.metNames and
% all metabolites are assigned to "compartment". Any
% new metabolites that are added will be assigned
Expand Down Expand Up @@ -101,6 +101,16 @@
% Usage: newModel=addRxns(model,rxnsToAdd,eqnType,compartment,...
% allowNewMets,allowNewGenes)

if nargin<3
eqnType=1;
elseif ~isnumeric(eqnType)
EM='eqnType must be numeric';
dispEM(EM);
elseif ~ismember(eqnType,[1 2 3])
EM='eqnType must be 1, 2, or 3';
dispEM(EM);
end

if nargin<4
compartment=[];
else
Expand Down Expand Up @@ -139,17 +149,6 @@
return;
end

%Check the input
if isfield(rxnsToAdd,'stoichCoeffs')
eqnType=1;
elseif ~isnumeric(eqnType)
EM='eqnType must be numeric';
dispEM(EM);
elseif ~ismember(eqnType,[1 2 3])
EM='eqnType must be 1, 2, or 3';
dispEM(EM);
end

if eqnType==2 || (eqnType==1 && allowNewMets==true)
compartment=char(compartment);
if ~ismember(compartment,model.comps)
Expand Down Expand Up @@ -518,18 +517,18 @@
if eqnType==1
[I, J]=ismember(mets,model.mets);
if ~all(I)
if allowNewMets==true | isstr(allowNewMets)
if allowNewMets==true || ischar(allowNewMets)
%Add the new mets
metsToAdd.mets=mets(~I);
metsToAdd.metNames=metsToAdd.mets;
metsToAdd.compartments=compartment;
if isstr(allowNewMets)
if ischar(allowNewMets)
newModel=addMets(newModel,metsToAdd,true,allowNewMets);
else
newModel=addMets(newModel,metsToAdd,true);
end
else
EM='One or more equations contain metabolites that are not in model.mets. Set allowNewMets to true to allow this function to add metabolites or use addMets to add them before calling this function';
EM='One or more equations contain metabolites that are not in model.mets. Set allowNewMets to true to allow this function to add metabolites or use addMets to add them before calling this function. Are you sure that eqnType=1?';
dispEM(EM);
end
end
Expand All @@ -553,11 +552,11 @@
[I, J]=ismember(t1,t2);

if ~all(I)
if allowNewMets==true | isstr(allowNewMets)
if allowNewMets==true || ischar(allowNewMets)
%Add the new mets
metsToAdd.metNames=mets(~I);
metsToAdd.compartments=compartment;
if isstr(allowNewMets)
if ischar(allowNewMets)
newModel=addMets(newModel,metsToAdd,true,allowNewMets);
else
newModel=addMets(newModel,metsToAdd,true);
Expand Down Expand Up @@ -603,11 +602,11 @@
[I, J]=ismember(t1,t2);

if ~all(I)
if allowNewMets==true | isstr(allowNewMets)
if allowNewMets==true || ischar(allowNewMets)
%Add the new mets
metsToAdd.metNames=metNames(~I);
metsToAdd.compartments=compartments(~I);
if isstr(allowNewMets)
if ischar(allowNewMets)
newModel=addMets(newModel,metsToAdd,true,allowNewMets);
else
newModel=addMets(newModel,metsToAdd,true);
Expand Down
4 changes: 2 additions & 2 deletions core/changeRxns.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
% interpreted
% 1 - The metabolites are matched to model.mets. New
% metabolites (if allowed) are added to
% "compartment"
% "compartment" (default)
% 2 - The metabolites are matched to model.metNames and
% all metabolites are assigned to "compartment". Any
% new metabolites that are added will be assigned
Expand Down Expand Up @@ -53,7 +53,7 @@
%
% Usage: model=changeRxns(model,rxns,equations,eqnType,compartment,allowNewMets)

if nargin<4 & isfield(equations,'stoichCoeffs')
if nargin<4
eqnType=1;
end

Expand Down
22 changes: 17 additions & 5 deletions core/getGenesFromGrRules.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function [genes,rxnGeneMat] = getGenesFromGrRules(grRules)
function [genes,rxnGeneMat] = getGenesFromGrRules(grRules, originalGenes)
%getGenesFromGrRules Extract gene list and rxnGeneMat from grRules array.
%
% USAGE:
%
% [genes,rxnGeneMat] = getGenesFromGrRules(grRules);
% [genes,rxnGeneMat] = getGenesFromGrRules(grRules, originalGenes);
%
% INPUTS:
%
Expand All @@ -12,6 +12,7 @@
% NOTE: Boolean operators can be text ("and", "or") or
% symbolic ("&", "|"), but there must be a space
% between operators and gene names/IDs.
% originalGenes The original gene list from the model as reference
%
% OUTPUTS:
%
Expand All @@ -24,6 +25,11 @@
%


% handle input arguments
if nargin < 2
originalGenes = [];
end

% check if the grRules use written or symbolic boolean operators
if any(contains(grRules,{'&','|'}))
% fix some potential missing spaces between parentheses and &/|
Expand All @@ -50,10 +56,16 @@
nonEmpty = ~cellfun(@isempty,rxnGenes);
genes = unique([rxnGenes{nonEmpty}]');

if ~isempty(originalGenes)
if ~isequal(sort(originalGenes), sort(genes))
error('The grRules and original gene list are inconsistent!');
else
genes = originalGenes;
end
end

% construct new rxnGeneMat (if requested)
if nargout > 1
rxnGeneCell = cellfun(@(rg) ismember(genes,rg),rxnGenes,'UniformOutput',false);
rxnGeneMat = sparse(double(horzcat(rxnGeneCell{:})'));
end


end
Loading

0 comments on commit ea7a378

Please sign in to comment.