diff --git a/core/addRxns.m b/core/addRxns.m
index f23222e1..8efcd5e2 100755
--- a/core/addRxns.m
+++ b/core/addRxns.m
@@ -350,15 +350,19 @@
end
if isfield(rxnsToAdd,'subSystems')
+ if ischar(rxnsToAdd.subSystems)
+ rxnsToAdd.subSystems = {{rxnsToAdd.subSystems}};
+ else
+ for i=1:numel(rxnsToAdd.subSystems)
+ if ischar(rxnsToAdd.subSystems{i})
+ rxnsToAdd.subSystems{i}=rxnsToAdd.subSystems(i);
+ end
+ end
+ end
if numel(rxnsToAdd.subSystems)~=nRxns
EM='rxnsToAdd.subSystems must have the same number of elements as rxnsToAdd.rxns';
dispEM(EM);
end
- for i=1:numel(rxnsToAdd.subSystems)
- if ischar(rxnsToAdd.subSystems{i})
- rxnsToAdd.subSystems{i}=rxnsToAdd.subSystems(i);
- end
- end
%Fill with standard if it doesn't exist
if ~isfield(newModel,'subSystems')
newModel.subSystems=celllargefiller;
diff --git a/core/copyToComps.m b/core/copyToComps.m
index a285e650..042b4c0b 100755
--- a/core/copyToComps.m
+++ b/core/copyToComps.m
@@ -25,24 +25,26 @@
%
% Usage: model=copyToComps(model,toComps,rxns,deleteOriginal,compNames,compOutside)
-if nargin<3
- rxns=model.rxns;
-elseif ~islogical(rxns) && ~isnumeric(rxns)
- rxns=convertCharArray(rxns);
+arguments
+ model (1,1) struct
+ toComps {emptyOrTextOrCellOfText}
+ rxns = model.rxns
+ deleteOriginal {emptyOrLogicalScalar} = false
+ compNames {emptyOrTextOrCellOfText} = toComps
+ compOutside {emptyOrTextOrCellOfText} = '';
end
-if nargin<4
- deleteOriginal=false;
+
+if nargin >= 3 && ~islogical(rxns) && ~isnumeric(rxns)
+ rxns = convertCharArray(rxns);
end
-if nargin<5
- compNames=toComps;
-else
+if nargin >= 5
compNames=convertCharArray(compNames);
end
-if nargin<6
- compOutside=cell(numel(toComps),1);
- compOutside(:)={''};
-else
+if nargin >= 6
compOutside=convertCharArray(compOutside);
+ if length(compOutside) ~= length(compNames)
+ error('compOutside and compNames should be of equal size.');
+ end
end
originalID=model.id;
@@ -79,15 +81,20 @@
modelToAdd.compMiriams=modelToAdd.compMiriams(J);
end
modelToAdd.metComps=ones(numel(modelToAdd.mets),1);
-
+ if isfield(modelToAdd,'metFrom')
+ modelToAdd = rmfield(modelToAdd,'metFrom');
+ end
+ if isfield(modelToAdd,'rxnFrom')
+ modelToAdd = rmfield(modelToAdd,'rxnFrom');
+ end
+ if isfield(modelToAdd,'geneFrom')
+ modelToAdd = rmfield(modelToAdd,'geneFrom');
+ end
+
%Merge the models
- model=mergeModels({model;modelToAdd},'metNames');
+ model=mergeModels({model;modelToAdd},'metNames',[],true);
end
-model=rmfield(model,'rxnFrom');
-model=rmfield(model,'metFrom');
-model=rmfield(model,'geneFrom');
-
if deleteOriginal==true
model=removeReactions(model,rxns,true,true,true); %Also delete unused compartments
end
diff --git a/core/fitTasks.m b/core/fitTasks.m
index 9963f9e7..992c3762 100755
--- a/core/fitTasks.m
+++ b/core/fitTasks.m
@@ -266,7 +266,7 @@
%Only do gap-filling if it cannot be solved
failed=false;
try
- [~, ~, newRxns, newModel, exitFlag]=fillGaps(tModel,refModel,false,true,supressWarnings,rxnScores,params);
+ [~, ~, newRxns, newModel, exitFlag]=fillGaps(tModel,refModel,false,true,supressWarnings,rxnScores);
if exitFlag==-2
EM=['"[' taskStructure(i).id '] ' taskStructure(i).description '" was aborted before reaching optimality. Consider increasing params.maxTime\n'];
dispEM(EM,false);
diff --git a/core/mergeModels.m b/core/mergeModels.m
index 29faff96..cf45dd7a 100755
--- a/core/mergeModels.m
+++ b/core/mergeModels.m
@@ -1,37 +1,76 @@
-function model=mergeModels(models,metParam,supressWarnings)
+function model=mergeModels(models,metParam,supressWarnings,copyToComps)
% mergeModels
% Merges models into one model structure. Reactions are added without any
% checks, so duplicate reactions might appear. Metabolites are matched by
% their name and compartment (metaboliteName[comp]), while genes are
% matched by their name.
%
+% Input:
% models a cell array with model structures
-% metParam string specifying whether to refer to metabolite name
-% (metNames) or ID (mets) for matching (default, metNames)
-% supressWarnings true if warnings should be supressed (optional, default
-% false)
+% metParam string metabolite name ('metNames') or ID ('mets') are
+% used for matching (optional, default 'metNames')
+% supressWarnings logical whether warnings should be supressed (optional,
+% default false)
+% copyToComps logical whether mergeModels is run via copyToComps
+% (optional, default false)
%
-% model a model structure with the merged model. Follows the structure
-% of normal models but also has 'rxnFrom/metFrom/geneFrom' fields
-% to indicate from which model each reaction/metabolite/gene was
-% taken
+% Output:
+% model a model structure with the merged model. Follows the
+% structure of normal models but also has 'rxnFrom/
+% metFrom/geneFrom' fields to indicate from which model
+% each reaction/metabolite/gene was taken. If the model
+% already has 'rxnFrom/metFrom/geneFrom' fields, then
+% these fields are not modified.
%
% Usage: model=mergeModels(models)
+arguments
+ models;
+ metParam {emptyOrTextScalar} = "metNames"
+ supressWarnings {emptyOrLogicalScalar} = false
+ copyToComps {emptyOrLogicalScalar} = false
+end
+
+metParam = char(metParam);
+
%Just return the model
if numel(models)<=1
model=models{1};
return;
end
-if nargin<2
- metParam='metNames';
-else
- metParam=char(metParam);
-end
+hasMetFrom = cellfun(@(s) isfield(s,'metFrom'), models);
+hasGeneFrom = cellfun(@(s) isfield(s,'geneFrom'), models);
+hasRxnFrom = cellfun(@(s) isfield(s,'rxnFrom'), models);
-if nargin<3
- supressWarnings=false;
+for i = 1:numel(models)
+ if copyToComps
+ if hasMetFrom(1)
+ models{2}.metFrom = repmat({''},numel(models{i}.mets),1);
+ end
+ elseif ~any(hasMetFrom)
+ models{i}.metFrom = repmat({models{i}.id},numel(models{i}.mets),1);
+ elseif ~hasMetFrom(i)
+ models{i}.metFrom = repmat({''},numel(models{i}.mets),1);
+ end
+ if copyToComps
+ if hasRxnFrom(1)
+ models{2}.rxnFrom = repmat({''},numel(models{i}.rxns),1);
+ end
+ elseif ~any(hasRxnFrom)
+ models{i}.rxnFrom = repmat({models{i}.id},numel(models{i}.rxns),1);
+ elseif ~hasRxnFrom(i)
+ models{i}.rxnFrom = repmat({''},numel(models{i}.rxns),1);
+ end
+ if copyToComps
+ if hasGeneFrom(1)
+ models{2}.geneFrom = repmat({''},numel(models{i}.genes),1);
+ end
+ elseif ~any(hasGeneFrom) && any(cellfun(@(s) isfield(s,'genes'), models))
+ models{i}.geneFrom = repmat({models{i}.id},numel(models{i}.genes),1);
+ elseif ~hasGeneFrom(i)
+ models{i}.geneFrom = repmat({''},numel(models{i}.genes),1);
+ end
end
%Add new functionality in the order specified in models
@@ -39,15 +78,6 @@
model.id='MERGED';
model.name='';
-model.rxnFrom=cell(numel(models{1}.rxns),1);
-model.rxnFrom(:)={models{1}.id};
-model.metFrom=cell(numel(models{1}.mets),1);
-model.metFrom(:)={models{1}.id};
-if isfield(models{1},'genes')
- model.geneFrom=cell(numel(models{1}.genes),1);
- model.geneFrom(:)={models{1}.id};
-end
-
if isfield(model,'equations')
model=rmfield(model,'equations');
end
@@ -78,15 +108,15 @@
end
%Add all static stuff
- rxnFrom=cell(numel(models{i}.rxns),1);
- rxnFrom(:)={models{i}.id};
- model.rxnFrom=[model.rxnFrom;rxnFrom];
- model.rxns=[model.rxns;models{i}.rxns];
- model.rxnNames=[model.rxnNames;models{i}.rxnNames];
- model.lb=[model.lb;models{i}.lb];
- model.ub=[model.ub;models{i}.ub];
- model.c=[model.c;models{i}.c];
- model.rev=[model.rev;models{i}.rev];
+ if any(hasRxnFrom) || (~copyToComps && ~any(hasRxnFrom))
+ model.rxnFrom = [model.rxnFrom; models{i}.rxnFrom];
+ end
+ model.rxns = [model.rxns; models{i}.rxns];
+ model.rxnNames = [model.rxnNames; models{i}.rxnNames];
+ model.lb = [model.lb; models{i}.lb];
+ model.ub = [model.ub; models{i}.ub];
+ model.c = [model.c; models{i}.c];
+ model.rev = [model.rev; models{i}.rev];
if isfield(models{i},'subSystems')
if isfield(model,'subSystems')
@@ -287,12 +317,12 @@
end
%Add static info on the metabolites
- metFrom=cell(numel(metsToAdd),1);
- metFrom(:)={models{i}.id};
- model.metFrom=[model.metFrom;metFrom];
- model.mets=[model.mets;models{i}.mets(metsToAdd)];
- model.metNames=[model.metNames;models{i}.metNames(metsToAdd)];
- model.b=[model.b;zeros(numel(metsToAdd),size(model.b,2))];
+ if any(hasMetFrom)
+ model.metFrom = [model.metFrom; models{i}.metFrom(metsToAdd)];
+ end
+ model.mets = [model.mets; models{i}.mets(metsToAdd)];
+ model.metNames = [model.metNames; models{i}.metNames(metsToAdd)];
+ model.b = [model.b; zeros(numel(metsToAdd),size(model.b,2))];
if isfield(model,'unconstrained')
if isfield(models{i},'unconstrained')
@@ -481,13 +511,13 @@
if isfield(models{i},'genes')
if ~isfield(model,'genes')
%If there was no gene info before
- model.genes=models{i}.genes;
- model.rxnGeneMat=[sparse(numel(model.rxns),numel(models{i}.genes));models{i}.rxnGeneMat];
- emptyGene=cell(numel(model.rxns),1);
- emptyGene(:)={''};
- model.grRules=[emptyGene;models{i}.grRules];
- model.geneFrom=cell(numel(models{i}.genes),1);
- model.geneFrom(:)={models{i}.id};
+ model.genes = models{i}.genes;
+ model.rxnGeneMat = [sparse(numel(model.rxns),numel(models{i}.genes));models{i}.rxnGeneMat];
+ emptyGene = repmat({''},numel(model.rxns),1);
+ model.grRules = [emptyGene;models{i}.grRules];
+ if any(hasGeneFrom)
+ model.geneFrom = models{i}.geneFrom;
+ end
if isfield(models{i},'geneShortNames')
model.geneShortNames=models{i}.geneShortNames;
@@ -513,11 +543,9 @@
%Only add extra gene info on new genes. This might not be
%correct and should be changed later...
if ~isempty(genesToAdd)
- model.genes=[model.genes;models{i}.genes(genesToAdd)];
- emptyGene=cell(numel(genesToAdd),1);
- emptyGene(:)={models{i}.id};
- model.geneFrom=[model.geneFrom;emptyGene];
- model.rxnGeneMat=[model.rxnGeneMat sparse(size(model.rxnGeneMat,1),numel(genesToAdd))];
+ model.genes = [model.genes; models{i}.genes(genesToAdd)];
+ model.geneFrom = [model.geneFrom; models{i}.geneFrom(genesToAdd)];
+ model.rxnGeneMat = [model.rxnGeneMat sparse(size(model.rxnGeneMat,1),numel(genesToAdd))];
if isfield(models{i},'geneShortNames')
if isfield(model,'geneShortNames')
@@ -587,7 +615,7 @@
%Remap the genes from the new model. The same thing as with
%mets; this is a wasteful way to do it but I don't care right
%now
- [a, b]=ismember(models{i}.genes,model.genes);
+ a = ismember(models{i}.genes,model.genes);
%Just a check
if ~all(a)
diff --git a/core/parseTaskList.m b/core/parseTaskList.m
index 614710c5..e6cafca0 100755
--- a/core/parseTaskList.m
+++ b/core/parseTaskList.m
@@ -2,10 +2,11 @@
% parseTaskList
% Parses a task list file.
%
-% inputFile a task list in Excel format. The file must contain a
-% sheet named TASKS, which in turn may contain the
-% following column headers (note, all rows starting with
-% a non-empty cell are removed. The first row after that
+% inputFile a task list in either Excel (*.xlsx, with a sheet named
+% TASKS with all relevant content) or tab-delimited
+% (*.txt) format. The file may contain the following
+% column headers (note, all rows starting with a
+% non-empty cell are removed. The first row after that
% is considered the headers):
% ID
% the only required header. Each task must have a
diff --git a/core/predictLocalization.m b/core/predictLocalization.m
index 2bfff833..a2b5a550 100755
--- a/core/predictLocalization.m
+++ b/core/predictLocalization.m
@@ -621,7 +621,7 @@
outModel.compNames(2)=GSS.compartments(1);
end
end
-outModel.compNames=[outModel.compNames;GSS.compartments(2:end)'];
+outModel.compNames=[outModel.compNames;GSS.compartments(2:end)];
%Ugly little loop
for i=1:numel(GSS.compartments)-1
diff --git a/core/setParam.m b/core/setParam.m
index 734853b7..70705f3f 100755
--- a/core/setParam.m
+++ b/core/setParam.m
@@ -68,7 +68,7 @@
params(~Lia)=[];
indexes(~Lia)=[];
paramType(~Lia)=[];
- dispEM('Reactions not present in model, will be ignored:',false,rxnLise(~Lia));
+ dispEM('Reactions not present in model, will be ignored:',false,rxnList(~Lia));
end
%Change the parameters
diff --git a/doc/core/addRxns.html b/doc/core/addRxns.html
index ffdcf6e6..e4ebe1c7 100644
--- a/doc/core/addRxns.html
+++ b/doc/core/addRxns.html
@@ -494,330 +494,334 @@
SOURCE CODE
end
0351
0352 if isfield(rxnsToAdd,'subSystems')
-0353 if numel(rxnsToAdd.subSystems)~=nRxns
-0354 EM='rxnsToAdd.subSystems must have the same number of elements as rxnsToAdd.rxns';
-0355 dispEM(EM);
-0356 end
-0357 for i=1:numel(rxnsToAdd.subSystems)
-0358 if ischar(rxnsToAdd.subSystems{i})
-0359 rxnsToAdd.subSystems{i}=rxnsToAdd.subSystems(i);
+0353 if ischar(rxnsToAdd.subSystems)
+0354 rxnsToAdd.subSystems = {{rxnsToAdd.subSystems}};
+0355 else
+0356 for i=1:numel(rxnsToAdd.subSystems)
+0357 if ischar(rxnsToAdd.subSystems{i})
+0358 rxnsToAdd.subSystems{i}=rxnsToAdd.subSystems(i);
+0359 end
0360 end
0361 end
-0362
-0363 if ~isfield(newModel,'subSystems')
-0364 newModel.subSystems=celllargefiller;
+0362 if numel(rxnsToAdd.subSystems)~=nRxns
+0363 EM='rxnsToAdd.subSystems must have the same number of elements as rxnsToAdd.rxns';
+0364 dispEM(EM);
0365 end
-0366 newModel.subSystems=[newModel.subSystems;rxnsToAdd.subSystems(:)];
-0367 else
-0368
-0369 if isfield(newModel,'subSystems')
-0370 newModel.subSystems=[newModel.subSystems;cellfiller];
-0371 end
-0372 end
-0373 if isfield(rxnsToAdd,'rxnMiriams')
-0374 if numel(rxnsToAdd.rxnMiriams)~=nRxns
-0375 EM='rxnsToAdd.rxnMiriams must have the same number of elements as rxnsToAdd.rxns';
-0376 dispEM(EM);
-0377 end
-0378
-0379 if ~isfield(newModel,'rxnMiriams')
-0380 newModel.rxnMiriams=cell(nOldRxns,1);
+0366
+0367 if ~isfield(newModel,'subSystems')
+0368 newModel.subSystems=celllargefiller;
+0369 end
+0370 newModel.subSystems=[newModel.subSystems;rxnsToAdd.subSystems(:)];
+0371 else
+0372
+0373 if isfield(newModel,'subSystems')
+0374 newModel.subSystems=[newModel.subSystems;cellfiller];
+0375 end
+0376 end
+0377 if isfield(rxnsToAdd,'rxnMiriams')
+0378 if numel(rxnsToAdd.rxnMiriams)~=nRxns
+0379 EM='rxnsToAdd.rxnMiriams must have the same number of elements as rxnsToAdd.rxns';
+0380 dispEM(EM);
0381 end
-0382 newModel.rxnMiriams=[newModel.rxnMiriams;rxnsToAdd.rxnMiriams(:)];
-0383 else
-0384
-0385 if isfield(newModel,'rxnMiriams')
-0386 newModel.rxnMiriams=[newModel.rxnMiriams;cell(nRxns,1)];
-0387 end
-0388 end
-0389 if isfield(rxnsToAdd,'rxnComps')
-0390 if numel(rxnsToAdd.rxnComps)~=nRxns
-0391 EM='rxnsToAdd.rxnComps must have the same number of elements as rxnsToAdd.rxns';
-0392 dispEM(EM);
-0393 end
-0394
-0395 if ~isfield(newModel,'rxnComps')
-0396 newModel.rxnComps=ones(nOldRxns,1);
-0397 EM='Adding reactions with compartment information to a model without such information. All existing reactions will be assigned to the first compartment';
-0398 dispEM(EM,false);
-0399 end
-0400 newModel.rxnComps=[newModel.rxnComps;rxnsToAdd.rxnComps(:)];
-0401 else
-0402
-0403 if isfield(newModel,'rxnComps')
-0404 newModel.rxnComps=[newModel.rxnComps;ones(nRxns,1)];
-0405
-0406
-0407 end
-0408 end
-0409 if isfield(rxnsToAdd,'grRules')
-0410 rxnsToAdd.grRules=convertCharArray(rxnsToAdd.grRules);
-0411 if numel(rxnsToAdd.grRules)~=nRxns
-0412 EM='rxnsToAdd.grRules must have the same number of elements as rxnsToAdd.rxns';
-0413 dispEM(EM);
-0414 end
-0415
-0416 if ~isfield(newModel,'grRules')
-0417 newModel.grRules=largeFiller;
+0382
+0383 if ~isfield(newModel,'rxnMiriams')
+0384 newModel.rxnMiriams=cell(nOldRxns,1);
+0385 end
+0386 newModel.rxnMiriams=[newModel.rxnMiriams;rxnsToAdd.rxnMiriams(:)];
+0387 else
+0388
+0389 if isfield(newModel,'rxnMiriams')
+0390 newModel.rxnMiriams=[newModel.rxnMiriams;cell(nRxns,1)];
+0391 end
+0392 end
+0393 if isfield(rxnsToAdd,'rxnComps')
+0394 if numel(rxnsToAdd.rxnComps)~=nRxns
+0395 EM='rxnsToAdd.rxnComps must have the same number of elements as rxnsToAdd.rxns';
+0396 dispEM(EM);
+0397 end
+0398
+0399 if ~isfield(newModel,'rxnComps')
+0400 newModel.rxnComps=ones(nOldRxns,1);
+0401 EM='Adding reactions with compartment information to a model without such information. All existing reactions will be assigned to the first compartment';
+0402 dispEM(EM,false);
+0403 end
+0404 newModel.rxnComps=[newModel.rxnComps;rxnsToAdd.rxnComps(:)];
+0405 else
+0406
+0407 if isfield(newModel,'rxnComps')
+0408 newModel.rxnComps=[newModel.rxnComps;ones(nRxns,1)];
+0409
+0410
+0411 end
+0412 end
+0413 if isfield(rxnsToAdd,'grRules')
+0414 rxnsToAdd.grRules=convertCharArray(rxnsToAdd.grRules);
+0415 if numel(rxnsToAdd.grRules)~=nRxns
+0416 EM='rxnsToAdd.grRules must have the same number of elements as rxnsToAdd.rxns';
+0417 dispEM(EM);
0418 end
-0419 newModel.grRules=[newModel.grRules;rxnsToAdd.grRules(:)];
-0420 else
-0421
-0422 if isfield(newModel,'grRules')
-0423 newModel.grRules=[newModel.grRules;filler];
-0424 end
-0425 end
-0426
-0427 if isfield(rxnsToAdd,'rxnFrom')
-0428 rxnsToAdd.rxnFrom=convertCharArray(rxnsToAdd.rxnFrom);
-0429 if numel(rxnsToAdd.rxnFrom)~=nRxns
-0430 EM='rxnsToAdd.rxnFrom must have the same number of elements as rxnsToAdd.rxns';
-0431 dispEM(EM);
-0432 end
-0433
-0434 if ~isfield(newModel,'rxnFrom')
-0435 newModel.rxnFrom=largeFiller;
+0419
+0420 if ~isfield(newModel,'grRules')
+0421 newModel.grRules=largeFiller;
+0422 end
+0423 newModel.grRules=[newModel.grRules;rxnsToAdd.grRules(:)];
+0424 else
+0425
+0426 if isfield(newModel,'grRules')
+0427 newModel.grRules=[newModel.grRules;filler];
+0428 end
+0429 end
+0430
+0431 if isfield(rxnsToAdd,'rxnFrom')
+0432 rxnsToAdd.rxnFrom=convertCharArray(rxnsToAdd.rxnFrom);
+0433 if numel(rxnsToAdd.rxnFrom)~=nRxns
+0434 EM='rxnsToAdd.rxnFrom must have the same number of elements as rxnsToAdd.rxns';
+0435 dispEM(EM);
0436 end
-0437 newModel.rxnFrom=[newModel.rxnFrom;rxnsToAdd.rxnFrom(:)];
-0438 else
-0439
-0440 if isfield(newModel,'rxnFrom')
-0441 newModel.rxnFrom=[newModel.rxnFrom;filler];
-0442 end
-0443 end
-0444
-0445 if isfield(rxnsToAdd,'rxnNotes')
-0446 rxnsToAdd.rxnNotes=convertCharArray(rxnsToAdd.rxnNotes);
-0447 if numel(rxnsToAdd.rxnNotes)~=nRxns
-0448 EM='rxnsToAdd.rxnNotes must have the same number of elements as rxnsToAdd.rxns';
-0449 dispEM(EM);
-0450 end
-0451
-0452 if ~isfield(newModel,'rxnNotes')
-0453 newModel.rxnNotes=largeFiller;
+0437
+0438 if ~isfield(newModel,'rxnFrom')
+0439 newModel.rxnFrom=largeFiller;
+0440 end
+0441 newModel.rxnFrom=[newModel.rxnFrom;rxnsToAdd.rxnFrom(:)];
+0442 else
+0443
+0444 if isfield(newModel,'rxnFrom')
+0445 newModel.rxnFrom=[newModel.rxnFrom;filler];
+0446 end
+0447 end
+0448
+0449 if isfield(rxnsToAdd,'rxnNotes')
+0450 rxnsToAdd.rxnNotes=convertCharArray(rxnsToAdd.rxnNotes);
+0451 if numel(rxnsToAdd.rxnNotes)~=nRxns
+0452 EM='rxnsToAdd.rxnNotes must have the same number of elements as rxnsToAdd.rxns';
+0453 dispEM(EM);
0454 end
-0455 newModel.rxnNotes=[newModel.rxnNotes;rxnsToAdd.rxnNotes(:)];
-0456 else
-0457
-0458 if isfield(newModel,'rxnNotes')
-0459 newModel.rxnNotes=[newModel.rxnNotes;filler];
-0460 end
-0461 end
-0462
-0463 if isfield(rxnsToAdd,'rxnReferences')
-0464 rxnsToAdd.rxnReferences=convertCharArray(rxnsToAdd.rxnReferences);
-0465 if numel(rxnsToAdd.rxnReferences)~=nRxns
-0466 EM='rxnsToAdd.rxnReferences must have the same number of elements as rxnsToAdd.rxns';
-0467 dispEM(EM);
-0468 end
-0469
-0470 if ~isfield(newModel,'rxnReferences')
-0471 newModel.rxnReferences=largeFiller;
+0455
+0456 if ~isfield(newModel,'rxnNotes')
+0457 newModel.rxnNotes=largeFiller;
+0458 end
+0459 newModel.rxnNotes=[newModel.rxnNotes;rxnsToAdd.rxnNotes(:)];
+0460 else
+0461
+0462 if isfield(newModel,'rxnNotes')
+0463 newModel.rxnNotes=[newModel.rxnNotes;filler];
+0464 end
+0465 end
+0466
+0467 if isfield(rxnsToAdd,'rxnReferences')
+0468 rxnsToAdd.rxnReferences=convertCharArray(rxnsToAdd.rxnReferences);
+0469 if numel(rxnsToAdd.rxnReferences)~=nRxns
+0470 EM='rxnsToAdd.rxnReferences must have the same number of elements as rxnsToAdd.rxns';
+0471 dispEM(EM);
0472 end
-0473 newModel.rxnReferences=[newModel.rxnReferences;rxnsToAdd.rxnReferences(:)];
-0474 else
-0475
-0476 if isfield(newModel,'rxnReferences')
-0477 newModel.rxnReferences=[newModel.rxnReferences;filler];
-0478 end
-0479 end
-0480
-0481 if isfield(rxnsToAdd,'pwys')
-0482 rxnsToAdd.pwys=convertCharArray(rxnsToAdd.pwys);
-0483 if numel(rxnsToAdd.pwys)~=nRxns
-0484 EM='rxnsToAdd.pwys must have the same number of elements as rxnsToAdd.rxns';
-0485 dispEM(EM);
-0486 end
-0487
-0488 if ~isfield(newModel,'pwys')
-0489 newModel.pwys=largeFiller;
+0473
+0474 if ~isfield(newModel,'rxnReferences')
+0475 newModel.rxnReferences=largeFiller;
+0476 end
+0477 newModel.rxnReferences=[newModel.rxnReferences;rxnsToAdd.rxnReferences(:)];
+0478 else
+0479
+0480 if isfield(newModel,'rxnReferences')
+0481 newModel.rxnReferences=[newModel.rxnReferences;filler];
+0482 end
+0483 end
+0484
+0485 if isfield(rxnsToAdd,'pwys')
+0486 rxnsToAdd.pwys=convertCharArray(rxnsToAdd.pwys);
+0487 if numel(rxnsToAdd.pwys)~=nRxns
+0488 EM='rxnsToAdd.pwys must have the same number of elements as rxnsToAdd.rxns';
+0489 dispEM(EM);
0490 end
-0491 newModel.pwys=[newModel.pwys;rxnsToAdd.pwys(:)];
-0492 else
-0493
-0494 if isfield(newModel,'pwys')
-0495 newModel.pwys=[newModel.pwys;filler];
-0496 end
-0497 end
-0498
-0499 if isfield(rxnsToAdd,'rxnConfidenceScores')
-0500 if numel(rxnsToAdd.rxnConfidenceScores)~=nRxns
-0501 EM='rxnsToAdd.rxnConfidenceScores must have the same number of elements as rxnsToAdd.rxns';
-0502 dispEM(EM);
-0503 end
-0504
-0505 if ~isfield(newModel,'rxnConfidenceScores')
-0506 newModel.rxnConfidenceScores=NaN(nOldRxns,1);
+0491
+0492 if ~isfield(newModel,'pwys')
+0493 newModel.pwys=largeFiller;
+0494 end
+0495 newModel.pwys=[newModel.pwys;rxnsToAdd.pwys(:)];
+0496 else
+0497
+0498 if isfield(newModel,'pwys')
+0499 newModel.pwys=[newModel.pwys;filler];
+0500 end
+0501 end
+0502
+0503 if isfield(rxnsToAdd,'rxnConfidenceScores')
+0504 if numel(rxnsToAdd.rxnConfidenceScores)~=nRxns
+0505 EM='rxnsToAdd.rxnConfidenceScores must have the same number of elements as rxnsToAdd.rxns';
+0506 dispEM(EM);
0507 end
-0508 newModel.rxnConfidenceScores=[newModel.rxnConfidenceScores;rxnsToAdd.rxnConfidenceScores(:)];
-0509 else
-0510
-0511 if isfield(newModel,'rxnConfidenceScores')
-0512 newModel.rxnConfidenceScores=[newModel.rxnConfidenceScores;NaN(nRxns,1)];
-0513 end
-0514 end
-0515
-0516 if isfield(rxnsToAdd,'rxnDeltaG')
-0517 if numel(rxnsToAdd.rxnDeltaG)~=nRxns
-0518 EM='rxnsToAdd.rxnDeltaG must have the same number of elements as rxnsToAdd.rxns';
-0519 dispEM(EM);
-0520 end
-0521
-0522 if ~isfield(newModel,'rxnDeltaG')
-0523 newModel.rxnDeltaG=NaN(nOldRxns,1);
+0508
+0509 if ~isfield(newModel,'rxnConfidenceScores')
+0510 newModel.rxnConfidenceScores=NaN(nOldRxns,1);
+0511 end
+0512 newModel.rxnConfidenceScores=[newModel.rxnConfidenceScores;rxnsToAdd.rxnConfidenceScores(:)];
+0513 else
+0514
+0515 if isfield(newModel,'rxnConfidenceScores')
+0516 newModel.rxnConfidenceScores=[newModel.rxnConfidenceScores;NaN(nRxns,1)];
+0517 end
+0518 end
+0519
+0520 if isfield(rxnsToAdd,'rxnDeltaG')
+0521 if numel(rxnsToAdd.rxnDeltaG)~=nRxns
+0522 EM='rxnsToAdd.rxnDeltaG must have the same number of elements as rxnsToAdd.rxns';
+0523 dispEM(EM);
0524 end
-0525 newModel.rxnDeltaG=[newModel.rxnDeltaG;rxnsToAdd.rxnDeltaG(:)];
-0526 else
-0527
-0528 if isfield(newModel,'rxnDeltaG')
-0529 newModel.rxnDeltaG=[newModel.rxnDeltaG;NaN(nRxns,1)];
-0530 end
-0531 end
-0532
-0533
-0534
-0535
-0536 if eqnType==1
-0537 [I, J]=ismember(mets,model.mets);
-0538 if ~all(I)
-0539 if allowNewMets==true || ischar(allowNewMets)
-0540
-0541 metsToAdd.mets=mets(~I);
-0542 metsToAdd.metNames=metsToAdd.mets;
-0543 metsToAdd.compartments=compartment;
-0544 if ischar(allowNewMets)
-0545 newModel=addMets(newModel,metsToAdd,true,allowNewMets);
-0546 else
-0547 newModel=addMets(newModel,metsToAdd,true);
-0548 end
-0549 else
-0550 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?';
-0551 dispEM(EM);
-0552 end
-0553 end
-0554
-0555 metIndexes=J;
-0556 metIndexes(~I)=numel(newModel.mets)-sum(~I)+1:numel(newModel.mets);
-0557 end
-0558
-0559
-0560 if eqnType==2 || eqnType==3
-0561
-0562 t2=strcat(model.metNames,'***',model.comps(model.metComps));
-0563 end
-0564
-0565
-0566 if eqnType==2
-0567
-0568
-0569
-0570 t1=strcat(mets,'***',compartment);
-0571 [I, J]=ismember(t1,t2);
-0572
-0573 if ~all(I)
-0574 if allowNewMets==true || ischar(allowNewMets)
-0575
-0576 metsToAdd.metNames=mets(~I);
-0577 metsToAdd.compartments=compartment;
-0578 if ischar(allowNewMets)
-0579 newModel=addMets(newModel,metsToAdd,true,allowNewMets);
-0580 else
-0581 newModel=addMets(newModel,metsToAdd,true);
-0582 end
-0583 else
-0584 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';
-0585 dispEM(EM);
-0586 end
-0587 end
-0588
-0589
-0590 metIndexes=J;
-0591 metIndexes(~I)=numel(newModel.mets)-sum(~I)+1:numel(newModel.mets);
-0592 end
-0593
-0594
-0595 if eqnType==3
-0596
-0597 metNames=cell(numel(mets),1);
-0598 compartments=metNames;
-0599 for i=1:numel(mets)
-0600 starts=max(strfind(mets{i},'['));
-0601 ends=max(strfind(mets{i},']'));
-0602
-0603
-0604 if isempty(starts) || isempty(ends) || ends<numel(mets{i})
-0605 EM=['The metabolite ' mets{i} ' is not correctly formatted for eqnType=3'];
-0606 dispEM(EM);
-0607 end
-0608
-0609
-0610 compartments{i}=mets{i}(starts+1:ends-1);
-0611 I=ismember(compartments(i),newModel.comps);
-0612 if ~I
-0613 EM=['The metabolite ' mets{i} ' has a compartment that is not in model.comps'];
-0614 dispEM(EM);
-0615 end
-0616 metNames{i}=mets{i}(1:starts-1);
-0617 end
-0618
-0619
-0620 t1=strcat(metNames,'***',compartments);
-0621 [I, J]=ismember(t1,t2);
+0525
+0526 if ~isfield(newModel,'rxnDeltaG')
+0527 newModel.rxnDeltaG=NaN(nOldRxns,1);
+0528 end
+0529 newModel.rxnDeltaG=[newModel.rxnDeltaG;rxnsToAdd.rxnDeltaG(:)];
+0530 else
+0531
+0532 if isfield(newModel,'rxnDeltaG')
+0533 newModel.rxnDeltaG=[newModel.rxnDeltaG;NaN(nRxns,1)];
+0534 end
+0535 end
+0536
+0537
+0538
+0539
+0540 if eqnType==1
+0541 [I, J]=ismember(mets,model.mets);
+0542 if ~all(I)
+0543 if allowNewMets==true || ischar(allowNewMets)
+0544
+0545 metsToAdd.mets=mets(~I);
+0546 metsToAdd.metNames=metsToAdd.mets;
+0547 metsToAdd.compartments=compartment;
+0548 if ischar(allowNewMets)
+0549 newModel=addMets(newModel,metsToAdd,true,allowNewMets);
+0550 else
+0551 newModel=addMets(newModel,metsToAdd,true);
+0552 end
+0553 else
+0554 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?';
+0555 dispEM(EM);
+0556 end
+0557 end
+0558
+0559 metIndexes=J;
+0560 metIndexes(~I)=numel(newModel.mets)-sum(~I)+1:numel(newModel.mets);
+0561 end
+0562
+0563
+0564 if eqnType==2 || eqnType==3
+0565
+0566 t2=strcat(model.metNames,'***',model.comps(model.metComps));
+0567 end
+0568
+0569
+0570 if eqnType==2
+0571
+0572
+0573
+0574 t1=strcat(mets,'***',compartment);
+0575 [I, J]=ismember(t1,t2);
+0576
+0577 if ~all(I)
+0578 if allowNewMets==true || ischar(allowNewMets)
+0579
+0580 metsToAdd.metNames=mets(~I);
+0581 metsToAdd.compartments=compartment;
+0582 if ischar(allowNewMets)
+0583 newModel=addMets(newModel,metsToAdd,true,allowNewMets);
+0584 else
+0585 newModel=addMets(newModel,metsToAdd,true);
+0586 end
+0587 else
+0588 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';
+0589 dispEM(EM);
+0590 end
+0591 end
+0592
+0593
+0594 metIndexes=J;
+0595 metIndexes(~I)=numel(newModel.mets)-sum(~I)+1:numel(newModel.mets);
+0596 end
+0597
+0598
+0599 if eqnType==3
+0600
+0601 metNames=cell(numel(mets),1);
+0602 compartments=metNames;
+0603 for i=1:numel(mets)
+0604 starts=max(strfind(mets{i},'['));
+0605 ends=max(strfind(mets{i},']'));
+0606
+0607
+0608 if isempty(starts) || isempty(ends) || ends<numel(mets{i})
+0609 EM=['The metabolite ' mets{i} ' is not correctly formatted for eqnType=3'];
+0610 dispEM(EM);
+0611 end
+0612
+0613
+0614 compartments{i}=mets{i}(starts+1:ends-1);
+0615 I=ismember(compartments(i),newModel.comps);
+0616 if ~I
+0617 EM=['The metabolite ' mets{i} ' has a compartment that is not in model.comps'];
+0618 dispEM(EM);
+0619 end
+0620 metNames{i}=mets{i}(1:starts-1);
+0621 end
0622
-0623 if ~all(I)
-0624 if allowNewMets==true | ischar(allowNewMets)
-0625
-0626 metsToAdd.metNames=metNames(~I);
-0627 metsToAdd.compartments=compartments(~I);
-0628 if ischar(allowNewMets)
-0629 newModel=addMets(newModel,metsToAdd,true,allowNewMets);
-0630 else
-0631 newModel=addMets(newModel,metsToAdd,true);
-0632 end
-0633 else
-0634 EM='One or more equations contain metabolites that are not in model.metNames. Set allowNewMets to true to allow this function to add metabolites or use addMets to add them before calling this function';
-0635 dispEM(EM);
-0636 end
-0637 end
-0638
-0639
-0640 metIndexes=J;
-0641 metIndexes(~I)=numel(newModel.mets)-sum(~I)+1:numel(newModel.mets);
-0642 end
-0643
-0644
-0645 newModel.S=[newModel.S sparse(size(newModel.S,1),nRxns)];
-0646
-0647 for i=1:nRxns
-0648 newModel.S(metIndexes,nOldRxns+i)=S(:,i);
-0649
-0650
-0651 if isfield(newModel,'grRules')
-0652 rule=newModel.grRules{nOldRxns+i};
-0653 rule=strrep(rule,'(','');
-0654 rule=strrep(rule,')','');
-0655 rule=strrep(rule,' or ',' ');
-0656 rule=strrep(rule,' and ',' ');
-0657 genes=regexp(rule,' ','split');
-0658 [I, J]=ismember(genes,newModel.genes);
-0659 if ~all(I) && any(rule)
-0660 EM=['Not all genes for reaction ' rxnsToAdd.rxns{i} ' were found in model.genes. If needed, add genes with addGenesRaven before calling this function, or set the ''allowNewGenes'' flag to true'];
-0661 dispEM(EM);
-0662 end
-0663 end
-0664 end
-0665
-0666
-0667
-0668 newRxnsModel.genes=newModel.genes;
-0669 newRxnsModel.grRules=newModel.grRules(length(model.rxns)+1:end);
-0670 newRxnsModel.rxns=newModel.rxns(length(model.rxns)+1:end);
-0671
-0672
-0673 [grRules,rxnGeneMat] = standardizeGrRules(newRxnsModel,true);
-0674 newModel.rxnGeneMat = [newModel.rxnGeneMat; rxnGeneMat];
-0675 newModel.grRules = [newModel.grRules(1:nOldRxns); grRules];
-0676 end
+0623
+0624 t1=strcat(metNames,'***',compartments);
+0625 [I, J]=ismember(t1,t2);
+0626
+0627 if ~all(I)
+0628 if allowNewMets==true | ischar(allowNewMets)
+0629
+0630 metsToAdd.metNames=metNames(~I);
+0631 metsToAdd.compartments=compartments(~I);
+0632 if ischar(allowNewMets)
+0633 newModel=addMets(newModel,metsToAdd,true,allowNewMets);
+0634 else
+0635 newModel=addMets(newModel,metsToAdd,true);
+0636 end
+0637 else
+0638 EM='One or more equations contain metabolites that are not in model.metNames. Set allowNewMets to true to allow this function to add metabolites or use addMets to add them before calling this function';
+0639 dispEM(EM);
+0640 end
+0641 end
+0642
+0643
+0644 metIndexes=J;
+0645 metIndexes(~I)=numel(newModel.mets)-sum(~I)+1:numel(newModel.mets);
+0646 end
+0647
+0648
+0649 newModel.S=[newModel.S sparse(size(newModel.S,1),nRxns)];
+0650
+0651 for i=1:nRxns
+0652 newModel.S(metIndexes,nOldRxns+i)=S(:,i);
+0653
+0654
+0655 if isfield(newModel,'grRules')
+0656 rule=newModel.grRules{nOldRxns+i};
+0657 rule=strrep(rule,'(','');
+0658 rule=strrep(rule,')','');
+0659 rule=strrep(rule,' or ',' ');
+0660 rule=strrep(rule,' and ',' ');
+0661 genes=regexp(rule,' ','split');
+0662 [I, J]=ismember(genes,newModel.genes);
+0663 if ~all(I) && any(rule)
+0664 EM=['Not all genes for reaction ' rxnsToAdd.rxns{i} ' were found in model.genes. If needed, add genes with addGenesRaven before calling this function, or set the ''allowNewGenes'' flag to true'];
+0665 dispEM(EM);
+0666 end
+0667 end
+0668 end
+0669
+0670
+0671
+0672 newRxnsModel.genes=newModel.genes;
+0673 newRxnsModel.grRules=newModel.grRules(length(model.rxns)+1:end);
+0674 newRxnsModel.rxns=newModel.rxns(length(model.rxns)+1:end);
+0675
+0676
+0677 [grRules,rxnGeneMat] = standardizeGrRules(newRxnsModel,true);
+0678 newModel.rxnGeneMat = [newModel.rxnGeneMat; rxnGeneMat];
+0679 newModel.grRules = [newModel.grRules(1:nOldRxns); grRules];
+0680 end
Generated by m2html © 2005