Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions manipulation/mergeCompartments.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
model.comps={'s'};
model.compOutside={''};
model.metComps=ones(numel(model.mets),1);
%The per-compartment MIRIAM annotations no longer apply once every
%compartment is merged into one, and leaving them would desync compMiriams
%from the rebuilt comps. Drop them.
if isfield(model,'compMiriams')
model=rmfield(model,'compMiriams');
end

%Add exchange mets to another compartment "b" with id "2"
if keepUnconstrained==true
Expand Down
14 changes: 14 additions & 0 deletions testing/function_tests/tManipulation.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ function mergeCompartmentsSingleComp(testCase)
testCase.verifyNumElements(m2.comps, 1);
end

function mergeCompartmentsDropsStaleCompMiriams(testCase)
% Merging collapses every compartment into one, so any
% per-compartment MIRIAM annotation must not be left behind at the
% original length (which would desync compMiriams from comps).
m = testCase.model;
m.compMiriams = cell(numel(m.comps),1);
m.compMiriams{1}.name = {'go'};
m.compMiriams{1}.value = {'GO:0005737'};
evalc('m2 = mergeCompartments(m);');
if isfield(m2,'compMiriams')
testCase.verifyNumElements(m2.compMiriams, numel(m2.comps));
end
end

function mergeModelsReturnsStruct(testCase)
modelB = removeReactions(testCase.model, testCase.model.rxns(1:5), true, true, true);
evalc('merged = mergeModels({testCase.model; modelB});');
Expand Down