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: 4 additions & 2 deletions manipulation/addRxns.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@
%Parse the equations. This is done at this early stage since I need the
%reversibility info
[S, mets, badRxns, reversible]=constructS(rxnsToAdd.equations);
EM='The following equations have one or more metabolites both as substrate and product. Only the net equations will be added:';
warning('RAVEN:warning', '%s', ravenList(EM, rxnsToAdd.rxns(badRxns)));
if any(badRxns)
EM='The following equations have one or more metabolites both as substrate and product. Only the net equations will be added:';
warning('RAVEN:warning', '%s', ravenList(EM, rxnsToAdd.rxns(badRxns)));
end

newModel.rev=[newModel.rev;reversible];
newModel.rxns=[newModel.rxns;rxnsToAdd.rxns(:)];
Expand Down
9 changes: 9 additions & 0 deletions queries/constructS.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
equations=strtrim(equations);
equations=fixEquations(equations);

%A supplied list is authoritative, so an entry in it can be matched in full
%before the leading number of "2 oxoglutarate" is read as a coefficient. A
%list derived from the equations cannot disambiguate that.
metsSupplied=~isempty(mets);
if isempty(mets)
mets=parseRxnEqu(equations);
end
Expand Down Expand Up @@ -125,6 +129,11 @@
%No coefficient
coeff=1;
name=metabolites{j};
elseif metsSupplied && any(strcmp(strtrim(metabolites{j}),mets))
%The whole entry is a known metabolite, so its leading number is
%part of its name ("2 oxoglutarate") rather than a coefficient
coeff=1;
name=strtrim(metabolites{j});
else
coeff=str2double(metabolites{j}(1:space(1)));

Expand Down
10 changes: 10 additions & 0 deletions testing/function_tests/tManipulation.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ function addTransportAddsRxn(testCase)
testCase.verifyGreaterThan(numel(m2.rxns), numel(testCase.model.rxns));
end

function addRxnsCleanEquationDoesNotWarn(testCase)
% The "metabolite on both sides" warning must only fire for the
% equations it names, not on every call.
rxnsToAdd.rxns = {'newRxn'};
rxnsToAdd.equations = {[testCase.model.mets{1} ' => ' testCase.model.mets{2}]};
lastwarn('');
evalc('addRxns(testCase.model, rxnsToAdd, 1);');
testCase.verifyEmpty(strfind(lastwarn, 'both as substrate and product')); %#ok<STRIFY>
end

function changeGrRulesUpdatesRule(testCase)
m2 = changeGrRules(testCase.model, 'ACKr', 'b2296 and b1849', true);
idx = strcmp(m2.rxns, 'ACKr');
Expand Down
18 changes: 18 additions & 0 deletions testing/function_tests/tQueries.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ function constructSSimple(testCase)
testCase.verifyEqual(full(S), [-1;-1;1]);
end

function constructSLeadingNumberIsPartOfName(testCase)
% A metabolite whose name starts with a number must not have that
% number read as a stoichiometric coefficient when the metabolite
% list says the whole entry is a metabolite.
mets = {'2 oxoglutarate';'succinate'};
[S, outMets] = constructS({'2 oxoglutarate => succinate'}, 'mets', mets);
testCase.verifyEqual(outMets, mets);
testCase.verifyEqual(full(S), [-1;1]);
end

function constructSLeadingNumberStillReadsCoefficient(testCase)
% With no such metabolite, the leading number is a coefficient.
mets = {'oxoglutarate';'succinate'};
[S, outMets] = constructS({'2 oxoglutarate => succinate'}, 'mets', mets);
testCase.verifyEqual(outMets, mets);
testCase.verifyEqual(full(S), [-2;1]);
end

function getAllRxnsFromGenesType(testCase)
% Use a reaction that has a gene association.
withGpr = testCase.model.rxns(find(~cellfun(@isempty, ...
Expand Down