From e59624433e90bdb5a5d3c6e1d4919acf938cc1f0 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Mon, 3 Dec 2018 06:08:15 +0100 Subject: [PATCH 1/2] :bug: nRxns -> nRxns1 --- src/analysis/MOMA/MOMA.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analysis/MOMA/MOMA.m b/src/analysis/MOMA/MOMA.m index 801c986fb2..5955ee3dc8 100644 --- a/src/analysis/MOMA/MOMA.m +++ b/src/analysis/MOMA/MOMA.m @@ -156,7 +156,7 @@ if minNormFlag QPproblem = buildLPproblemFromModel(modelDel); - QPproblem.c(1:nRxns) = -2*solutionWT.x; + QPproblem.c(1:nRxns1) = -2*solutionWT.x; QPproblem.F = sparse(size(QPproblem.A,2)); QPproblem.F(1:nRxns2,1:nRxns2) = 2*speye(nRxns2); From c2cde51cb25c111a5e9950a4b84fffb2512a73a0 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Mon, 3 Dec 2018 06:18:56 +0100 Subject: [PATCH 2/2] Adding test for minNormFlag and updating solver Selection --- .../analysis/testMOMA/testMOMA.m | 68 ++++++++++--------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/test/verifiedTests/analysis/testMOMA/testMOMA.m b/test/verifiedTests/analysis/testMOMA/testMOMA.m index 2a70321925..70944a64e3 100644 --- a/test/verifiedTests/analysis/testMOMA/testMOMA.m +++ b/test/verifiedTests/analysis/testMOMA/testMOMA.m @@ -30,44 +30,50 @@ model = getDistributedModel('ecoli_core_model.mat'); % test solver packages -solverPkgs = {'mosek', 'ibm_cplex', 'tomlab_cplex', 'gurobi'}; +solverPkgs = prepareTest('needsLP', true, 'needsQP', true, 'excludeSolvers', 'pdco'); % define solver tolerances QPtol = 0.02; LPtol = 0.0001; -for k = 1:length(solverPkgs) - fprintf(' -- Running testMOMA using the solver interface: %s ... ', solverPkgs{k}); - - solverQPOK = changeCobraSolver(solverPkgs{k}, 'QP', 0); - solverLPOK = changeCobraSolver(solverPkgs{k}, 'LP', 0); - - if solverLPOK && solverQPOK - % test deleteModelGenes - [modelOut, hasEffect, constrRxnNames, deletedGenes] = deleteModelGenes(model, 'b3956'); % gene for reaction PPC - - % run MOMA - sol = MOMA(model, modelOut); - - if sol.stat == 1 - assert(abs(0.8463 - sol.f) < QPtol) - end - - % run linearMOMA - sol = linearMOMA(model, modelOut); - - assert(abs(0.8608 - sol.f) < LPtol) - - %run linear moma with minimal fluxes - solMin = linearMOMA(model, modelOut,'max',1); - assert(abs(0.8608 - solMin.f) < LPtol) - - %We know that at least in this case, the flux sum is actually - %smaller. - assert(sum(abs(sol.x)) > sum(abs(solMin.x))) +for k = 1:length(solverPkgs.QP) + % select the same solver for QP and LP (if available) + if ~any(ismember(solverPkgs.QP{k},solverPkgs.LP)) + lpSolver = solverPkgs.LP{1}; else - fprintf('\nMOMA requires a QP solver to be installed. QPNG does not work.\n'); + lpSolver = solverPkgs.QP{k}; end + fprintf(' -- Running testMOMA using the solver %s for QP and %s for LP ... ', solverPkgs.QP{k}, lpSolver); + + solverQPOK = changeCobraSolver(solverPkgs.QP{k}, 'QP', 0); + solverLPOK = changeCobraSolver(lpSolver, 'LP', 0); + + % test deleteModelGenes + [modelOut, hasEffect, constrRxnNames, deletedGenes] = deleteModelGenes(model, 'b3956'); % gene for reaction PPC + + % run MOMA + sol = MOMA(model, modelOut); + + assert(abs(0.8463 - sol.f) < QPtol) + + % run MOMA with minNormFlag + sol = MOMA(model, modelOut, 'max', 0, true); + + assert(abs(sol.f - 0.8392) < QPtol) + + % run linearMOMA + sol = linearMOMA(model, modelOut); + + assert(abs(0.8608 - sol.f) < LPtol) + + + %run linear moma with minimal fluxes + solMin = linearMOMA(model, modelOut,'max',1); + assert(abs(0.8608 - solMin.f) < LPtol) + + %We know that at least in this case, the flux sum is actually + %smaller. + assert(sum(abs(sol.x)) > sum(abs(solMin.x))) % output a success message fprintf('Done.\n');