Skip to content

Commit

Permalink
Merge pull request #433 from SysBioChalmers/devel
Browse files Browse the repository at this point in the history
RAVEN 2.7.4
  • Loading branch information
edkerk authored Jun 26, 2022
2 parents 6a87dd3 + ea7a378 commit e95ae5d
Show file tree
Hide file tree
Showing 29 changed files with 2,645 additions and 2,605 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
2 changes: 1 addition & 1 deletion INIT/runINIT.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
prob.b=zeros(size(prob.a,1), 1);
prob.ub=[prob.bux; prob.buc];
prob.osense=1;
prob.csense=char(1,zeros(size(prob.a,1)));
prob.csense=char(zeros(1,size(prob.a,1)));
prob.csense(:)='E';

%We still don't know which of the presentMets that can be produced. Go
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
7 changes: 3 additions & 4 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 All @@ -65,7 +65,6 @@
end

rxns=convertCharArray(rxns);
equations=convertCharArray(equations);
compartment=char(compartment);

%Find the indexes of the reactions and throw an error if they aren't all
Expand All @@ -86,7 +85,7 @@
rxnsToChange.mets=equations.mets;
rxnsToChange.stoichCoeffs=equations.stoichCoeffs;
else
rxnsToChange.equations=equations;
rxnsToChange.equations=convertCharArray(equations);
end
if isfield(model,'rxnNames')
rxnsToChange.rxnNames=model.rxnNames(J);
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
2 changes: 1 addition & 1 deletion doc/INIT/runINIT.html
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0283 prob.b=zeros(size(prob.a,1), 1);
0284 prob.ub=[prob.bux; prob.buc];
0285 prob.osense=1;
0286 prob.csense=char(1,zeros(size(prob.a,1)));
0286 prob.csense=char(zeros(1,size(prob.a,1)));
0287 prob.csense(:)=<span class="string">'E'</span>;
0288
0289 <span class="comment">%We still don't know which of the presentMets that can be produced. Go</span>
Expand Down
Loading

0 comments on commit e95ae5d

Please sign in to comment.