Skip to content

Commit

Permalink
Merge pull request #488 from SysBioChalmers/develop
Browse files Browse the repository at this point in the history
RAVEN 2.8.1
  • Loading branch information
edkerk authored May 17, 2023
2 parents 5b48c22 + 8793679 commit 2aa27fa
Show file tree
Hide file tree
Showing 16 changed files with 1,487 additions and 1,409 deletions.
30 changes: 24 additions & 6 deletions INIT/prepINITModel.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function prepData = prepINITModel(origRefModel, taskStruct, spontRxnNames, convertGenes, customRxnsToIgnore, extComp)
function prepData = prepINITModel(origRefModel, taskStruct, spontRxnNames, convertGenes, customRxnsToIgnore, extComp, skipScaling)
% prepINITModel
%
% The purpose of this function is to run time-consuming calculation steps that are not
Expand All @@ -16,7 +16,19 @@
% extComp Name of the external compartment, typically 's' or 'e'. This
% is used for identifying exch and import rxns (opt, default = 'e')
% prepData The resulting prepData structure which is used as input to ftINIT
%
% skipScaling If true the scaling step is not run on the minimal model. The
% scaling is there to remove large differences between the
% stoichiometric coefficients within a reaction, since such
% differences creates numerical issues in the ftINIT algorithm
% due to limitations in solver resolution. However,
% the current scaling step is also risky and may lead to that
% some reactions cannot carry flux, since it changes the stoichiometry
% of the reactions with large differences. If you experience problems
% where the solution is infeasible, it may be worth trying to turn off
% the scaling. Note that it is only the minModel that is scaled,
% the scaling will not be present in the final model.
% Default: (opt, default = false)
%
% Usage: prepData = prepINITModel(origRefModel, taskStruct, spontRxnNames, convertGenes, customRxnsToIgnore, extComp)


Expand All @@ -36,6 +48,9 @@
extComp = 'e';
end

if nargin < 7
skipScaling = false;
end
disp('Step 1: Gene rules')
[origRefModel.grRules, origRefModel.rxnGeneMat] = standardizeGrRules(origRefModel, true);

Expand Down Expand Up @@ -286,10 +301,13 @@
% metabolites as well (ROS => kROS, albumin => millialbumin, etc., but
% scaled freely with a mathematical method). It could potentially open up
% for using less strict margins in the MILP, and make it run faster.
scaledMinModel = rescaleModelForINIT(minModel3);
scaledMinModel.ub(scaledMinModel.ub > 0) = 1000;
scaledMinModel.lb(scaledMinModel.lb < 0) = -1000;

if (skipScaling)
scaledMinModel = minModel3;
else
scaledMinModel = rescaleModelForINIT(minModel3);
scaledMinModel.ub(scaledMinModel.ub > 0) = 1000;
scaledMinModel.lb(scaledMinModel.lb < 0) = -1000;
end
% create data structure with pre-processing results
prepData.taskReport = taskReport;
prepData.essentialRxns = newEssentialRxns; %essential rxns in the minModel
Expand Down
13 changes: 11 additions & 2 deletions core/getModelFromHomology.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@
end
end

%Check that genes do not begin with ( or end with ), as this makes problematic grRules
for i=1:numel(blastStructure)
problemGenes = startsWith(blastStructure(i).fromGenes,'(') | endsWith(blastStructure(i).fromGenes,')');
if any(problemGenes)
error(['One or multiple gene identifiers from ' blastStructure(i).fromId ...
' starts with ''('' and/or ends with '')'', which is not allowed'])
end
end

%Assume for now that all information is there and that it's correct. This
%is important to fix since no further checks are being made!

Expand Down Expand Up @@ -509,8 +518,8 @@
%complexes
draftModel=mergeModels(models,'metNames');

% %Remove unnecessary OLD_ genes, that were added with OR relationships
regexStr=['OLD_(', strjoin(modelNames(:),'|'),')_\S+'];
%Remove unnecessary OLD_ genes, that were added with OR relationships
regexStr=['OLD_(', strjoin(modelNames(:),'|'),')_(\S^\))+'];
draftModel.grRules=regexprep(draftModel.grRules,[' or ' regexStr],'');
draftModel.grRules=regexprep(draftModel.grRules,[regexStr ' or '],'');

Expand Down
2 changes: 1 addition & 1 deletion doc/INIT/mergeLinear.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="prepINITModel.html" class="code" title="function prepData = prepINITModel(origRefModel, taskStruct, spontRxnNames, convertGenes, customRxnsToIgnore, extComp)">prepINITModel</a> prepINITModel</li></ul>
<li><a href="prepINITModel.html" class="code" title="function prepData = prepINITModel(origRefModel, taskStruct, spontRxnNames, convertGenes, customRxnsToIgnore, extComp, skipScaling)">prepINITModel</a> prepINITModel</li></ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
Expand Down
Loading

0 comments on commit 2aa27fa

Please sign in to comment.