Skip to content

Commit c27145a

Browse files
committed
RAVEN 2.11.0
2 parents cded846 + d6550a6 commit c27145a

182 files changed

Lines changed: 6998 additions & 6094 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ mafft binary
1010
.gitattributes export-ignore
1111
.gitignore export-ignore
1212
.github export-ignore
13+
*.mat filter=lfs diff=lfs merge=lfs -text

INIT/runINIT.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [outModel, deletedRxns, metProduction, fValue]=runINIT(model,rxnScores,presentMets,essentialRxns,prodWeight,allowExcretion,noRevLoops)
1+
function [outModel, deletedRxns, metProduction, fValue]=runINIT(model,rxnScores,presentMets,essentialRxns,prodWeight,allowExcretion,noRevLoops,params)
22
% runINIT
33
% Generates a model using the INIT algorithm, based on proteomics and/or
44
% transcriptomics and/or metabolomics and/or metabolic tasks. This is the
@@ -38,6 +38,7 @@
3838
% problem significantly more computationally intensive to
3939
% solve (two more integer constraints per reversible reaction)
4040
% (optional, default false)
41+
% params parameter structure for use by optimizeProb
4142
%
4243
% outModel the resulting model structure
4344
% deletedRxns reactions which were deleted by the algorithm

core/FSEOF.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@
119119
A2=char(model.rxns(num)); %enzyme ID
120120
A3=char(model.rxnNames(num)); %enzyme Name
121121
if isfield(model,'subSystems') && ~isempty(model.subSystems{num});
122-
A4=char(strjoin(model.subSystems{num,1},';')); %Subsystems
122+
if ~any(cellfun(@(x) iscell(x), model.subSystems));
123+
subSys = cellfun(@(x) {x}, model.subSystems, 'uni', 0);
124+
else
125+
subSys = model.subSystems;
126+
end
127+
A4=char(strjoin(subSys{num},';')); %Subsystems
123128
else
124129
A4='';
125130
end

core/addExchangeRxns.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
end
6464
if isfield(model,'subSystems')
6565
fillerSub = filler;
66-
if iscell(model.subSystems(1,1))
67-
fillerSub = repmat({fillerSub},numel(J),1);
66+
if any(cellfun(@(x) iscell(x), model.subSystems))
67+
fillerSub(:)={{''}};
6868
end
6969
model.subSystems=[model.subSystems;fillerSub];
7070
end

core/addRxns.m

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,12 @@
227227
nOldRxns=numel(model.rxns);
228228
filler=cell(nRxns,1);
229229
filler(:)={''};
230-
cellfiller=cellfun(@(x) cell(0,0),filler,'UniformOutput',false);
230+
cellfiller=cell(nRxns,1);
231+
cellfiller(:)={{''}};
231232
largeFiller=cell(nOldRxns,1);
232233
largeFiller(:)={''};
233-
celllargefiller=cellfun(@(x) cell(0,0),largeFiller,'UniformOutput',false);
234+
largeCellFiller=cell(nOldRxns,1);
235+
largeCellFiller(:)={{''}};
234236

235237
%***Add everything to the model except for the equations.
236238
if numel(rxnsToAdd.equations)~=nRxns
@@ -350,24 +352,45 @@
350352
end
351353

352354
if isfield(rxnsToAdd,'subSystems')
353-
if numel(rxnsToAdd.subSystems)~=nRxns
354-
EM='rxnsToAdd.subSystems must have the same number of elements as rxnsToAdd.rxns';
355-
dispEM(EM);
355+
% Has to be cell array
356+
if ischar(rxnsToAdd.subSystems)
357+
rxnsToAdd.subSystems = {rxnsToAdd.subSystems};
358+
end
359+
% If all nested cells are 1x1, then unnest
360+
if all(cellfun(@(x) iscell(x) && isscalar(x), rxnsToAdd.subSystems))
361+
rxnsToAdd.subSystems = transpose([rxnsToAdd.subSystems{:}]);
356362
end
357-
for i=1:numel(rxnsToAdd.subSystems)
358-
if ischar(rxnsToAdd.subSystems{i})
359-
rxnsToAdd.subSystems{i}=rxnsToAdd.subSystems(i);
363+
% Cell array should now be as simple as possible. Check if it is nested
364+
subSysRxnsNested = any(cellfun(@(x) iscell(x), rxnsToAdd.subSystems));
365+
if isfield(newModel,'subSystems')
366+
subSysModelNested = any(cellfun(@(x) iscell(x), newModel.subSystems));
367+
else
368+
subSysModelNested = subSysRxnsNested;
369+
if subSysRxnsNested
370+
newModel.subSystems=largeCellFiller;
371+
else
372+
newModel.subSystems=largeFiller;
360373
end
361374
end
362-
%Fill with standard if it doesn't exist
363-
if ~isfield(newModel,'subSystems')
364-
newModel.subSystems=celllargefiller;
375+
if subSysRxnsNested && ~subSysModelNested
376+
% Make all existing subSystems nested
377+
newModel.subSystems = cellfun(@(x) {x}, newModel.subSystems, 'uni', 0);
378+
elseif ~subSysRxnsNested && subSysModelNested
379+
rxnsToAdd.subSystems = cellfun(@(x) {x}, rxnsToAdd.subSystems, 'uni', 0);
380+
end
381+
if numel(rxnsToAdd.subSystems)~=nRxns
382+
EM='rxnsToAdd.subSystems must have the same number of elements as rxnsToAdd.rxns';
383+
dispEM(EM);
365384
end
366385
newModel.subSystems=[newModel.subSystems;rxnsToAdd.subSystems(:)];
367386
else
368-
%Fill with standard if it doesn't exist
387+
%Fill with standard if it does not exist
369388
if isfield(newModel,'subSystems')
370-
newModel.subSystems=[newModel.subSystems;cellfiller];
389+
if any(cellfun(@(x) iscell(x), newModel.subSystems))
390+
newModel.subSystems=[newModel.subSystems;cellfiller];
391+
else
392+
newModel.subSystems=[newModel.subSystems;filler];
393+
end
371394
end
372395
end
373396
if isfield(rxnsToAdd,'rxnMiriams')

core/addTransport.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@
134134
model.eccodes=[model.eccodes;filler];
135135
end
136136
if isfield(model,'subSystems')
137-
ssFiller=filler;
137+
isNested = any(cellfun(@(x) iscell(x), model.subSystems));
138+
ssFiller = filler;
138139
if isRev==1
139-
ssFiller(:)={{['Transport between ' fromComp ' and ' toComps{i}]}};
140+
ssFiller(:) = {['Transport between ' fromComp ' and ' toComps{i}]};
140141
else
141-
ssFiller(:)={{['Transport from ' fromComp ' to ' toComps{i}]}};
142+
ssFiller(:) = {['Transport from ' fromComp ' to ' toComps{i}]};
143+
end
144+
if isNested
145+
ssFiller = cellfun(@(x) {x}, ssFiller, 'uni', 0);
142146
end
143147
model.subSystems=[model.subSystems;ssFiller];
144148
end

core/checkModelStruct.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ function checkModelStruct(model,throwErrors,trimWarnings)
175175
end
176176
end
177177
if isfield(model,'subSystems')
178-
for i=1:numel(model.subSystems)
179-
if ~iscell(model.subSystems{i,1})
180-
EM='The "subSystems" field must be a cell array';
178+
isNested = any(cellfun(@(x) iscell(x), model.subSystems));
179+
isCellStr = any(cellfun(@(x) ischar(x), model.subSystems));
180+
if ~xor(isNested,isCellStr)
181+
EM='The "subSystems" field must be a cell array of chars, *or* a cell array of cell arrays of chars';
181182
dispEM(EM,throwErrors);
182-
end
183183
end
184184
end
185185
if isfield(model,'eccodes')

core/compareMultipleModels.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@
9292
fprintf('*** Done \n\n')
9393

9494

95-
%% Flatten models' subSystems field
96-
% Convert from cell array of cells to cell array of strings
97-
% NOTE: this function currently only recognizes one subSystem per reaction;
98-
% additional subSystems will be ignored!
99-
for i = 1:numel(models)
100-
cells = cellfun(@iscell,models{i}.subSystems);
101-
models{i}.subSystems(cells) = cellfun(@(s) s{1}, models{i}.subSystems(cells), 'UniformOutput', false);
102-
end
103-
104-
10595
%% Compare models structure & function based on high-dimensional methods
10696
% Compare number of reactions in each subsystem in each model using a heatmap
10797
field = 'subSystems';
@@ -110,6 +100,16 @@
110100
fprintf('\nWARNING: At least one model does not contain the field "subSystems". \n')
111101
fprintf(' Skipping subsystem comparison. \n\n')
112102
else
103+
%% Flatten model subSystems field
104+
% Convert from cell array of cells to cell array of strings
105+
% NOTE: this function currently only recognizes one subSystem per reaction;
106+
% additional subSystems will be ignored!
107+
for i = 1:numel(models)
108+
if any(cellfun(@(x) iscell(x), models{i}.subSystems));
109+
cells = cellfun(@iscell,models{i}.subSystems);
110+
models{i}.subSystems(cells) = cellfun(@(s) s{1}, models{i}.subSystems(cells), 'UniformOutput', false);
111+
end
112+
end
113113
[id,compMat] = compareModelField(models,field);
114114
compStruct.subsystems.ID = id;
115115
compStruct.subsystems.matrix = compMat;

core/copyToComps.m

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,26 @@
2525
%
2626
% Usage: model=copyToComps(model,toComps,rxns,deleteOriginal,compNames,compOutside)
2727

28-
if nargin<3
29-
rxns=model.rxns;
30-
elseif ~islogical(rxns) && ~isnumeric(rxns)
31-
rxns=convertCharArray(rxns);
28+
arguments
29+
model (1,1) struct
30+
toComps {emptyOrTextOrCellOfText}
31+
rxns = model.rxns
32+
deleteOriginal {emptyOrLogicalScalar} = false
33+
compNames {emptyOrTextOrCellOfText} = toComps
34+
compOutside {emptyOrTextOrCellOfText} = '';
3235
end
33-
if nargin<4
34-
deleteOriginal=false;
36+
37+
if nargin >= 3 && ~islogical(rxns) && ~isnumeric(rxns)
38+
rxns = convertCharArray(rxns);
3539
end
36-
if nargin<5
37-
compNames=toComps;
38-
else
40+
if nargin >= 5
3941
compNames=convertCharArray(compNames);
4042
end
41-
if nargin<6
42-
compOutside=cell(numel(toComps),1);
43-
compOutside(:)={''};
44-
else
43+
if nargin >= 6
4544
compOutside=convertCharArray(compOutside);
45+
if length(compOutside) ~= length(compNames)
46+
error('compOutside and compNames should be of equal size.');
47+
end
4648
end
4749

4850
originalID=model.id;
@@ -79,15 +81,20 @@
7981
modelToAdd.compMiriams=modelToAdd.compMiriams(J);
8082
end
8183
modelToAdd.metComps=ones(numel(modelToAdd.mets),1);
82-
84+
if isfield(modelToAdd,'metFrom')
85+
modelToAdd = rmfield(modelToAdd,'metFrom');
86+
end
87+
if isfield(modelToAdd,'rxnFrom')
88+
modelToAdd = rmfield(modelToAdd,'rxnFrom');
89+
end
90+
if isfield(modelToAdd,'geneFrom')
91+
modelToAdd = rmfield(modelToAdd,'geneFrom');
92+
end
93+
8394
%Merge the models
84-
model=mergeModels({model;modelToAdd},'metNames');
95+
model=mergeModels({model;modelToAdd},'metNames',[],true);
8596
end
8697

87-
model=rmfield(model,'rxnFrom');
88-
model=rmfield(model,'metFrom');
89-
model=rmfield(model,'geneFrom');
90-
9198
if deleteOriginal==true
9299
model=removeReactions(model,rxns,true,true,true); %Also delete unused compartments
93100
end

core/findRAVENroot.m

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
function [ravenPath, prevDir] = findRAVENroot()
22
% findRAVENroot
3-
% Finds the root of the RAVEN directory, by searching for the path to
3+
% Finds the root of the RAVEN directory, first by by searching for the path to
44
% RAVEN2.png. Can also record the current directory, in case a function will
55
% use the ravenPath to navigate to a precise folder, and it should return to
66
% the previous directory afterwards. See e.g. optimizeProb calling glpk.
77

88
ST=dbstack('-completenames');
99
prevDir = pwd();
10-
ravenPath = ST(strcmp({ST.name},'findRAVENroot')).file;
11-
rootFound = 0;
12-
while rootFound == 0
13-
isRoot = isfile(fullfile(ravenPath,'RAVEN2.png'));
14-
if isRoot
15-
rootFound = 1;
16-
else
17-
ravenPathOld = ravenPath;
18-
ravenPath = fileparts(ravenPath);
19-
if strcmp(ravenPathOld,ravenPath)
20-
error('Cannot find the RAVEN root directory. Make sure you have not removed the RAVEN2.png file from your RAVEN installation.')
10+
if ispref('RAVEN','ravenPath')
11+
ravenPath = getpref('RAVEN','ravenPath');
12+
else
13+
ravenPath = ST(strcmp({ST.name},'findRAVENroot')).file;
14+
rootFound = 0;
15+
while rootFound == 0
16+
isRoot = isfile(fullfile(ravenPath,'RAVEN2.png'));
17+
if isRoot
18+
rootFound = 1;
19+
else
20+
ravenPathOld = ravenPath;
21+
ravenPath = fileparts(ravenPath);
22+
if strcmp(ravenPathOld,ravenPath)
23+
error('Cannot find the RAVEN root directory. Make sure you have not removed the RAVEN2.png file from your RAVEN installation.')
24+
end
2125
end
2226
end
2327
end

0 commit comments

Comments
 (0)