From 0fd7b53d903d9f5f7df208f73380051af7b98522 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Mon, 5 Nov 2018 08:03:48 +0100 Subject: [PATCH 01/29] Adapt QP solver list --- test/verifiedTests/base/testSolvers/testSolveCobraQP.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/verifiedTests/base/testSolvers/testSolveCobraQP.m b/test/verifiedTests/base/testSolvers/testSolveCobraQP.m index f643b60f14..e413efd804 100644 --- a/test/verifiedTests/base/testSolvers/testSolveCobraQP.m +++ b/test/verifiedTests/base/testSolvers/testSolveCobraQP.m @@ -23,7 +23,9 @@ % test solver packages useIfAvailable = {'tomlab_cplex','ibm_cplex', 'gurobi','qpng','ibm_cplex','mosek'}; -solverPkgs = prepareTest('needsQP',true,'useSolversIfAvailable', useIfAvailable); +% pdco is a normalizing solver not a general purpose QP solver, so it will +% fail the test +solverPkgs = prepareTest('needsQP',true,'useSolversIfAvailable', useIfAvailable,'excludeSolvers',{'pdco'}); %QP Solver test: http://tomopt.com/docs/quickguide/quickguide005.php From 6f72a68e99bc81e8d399727d59ad0e5efd0a78fc Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Mon, 5 Nov 2018 11:05:00 +0100 Subject: [PATCH 02/29] Adjust tolerance --- .../analysis/testFBA/testMinimizeModelFlux.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/verifiedTests/analysis/testFBA/testMinimizeModelFlux.m b/test/verifiedTests/analysis/testFBA/testMinimizeModelFlux.m index c8cb2f7c0e..e798e6d12d 100644 --- a/test/verifiedTests/analysis/testFBA/testMinimizeModelFlux.m +++ b/test/verifiedTests/analysis/testFBA/testMinimizeModelFlux.m @@ -29,21 +29,21 @@ % qpng does not support this model size, so we don't use quadratic % minimzation. sol = minimizeModelFlux(currentmodel,'min','one'); - assert(sol.x(end) == 0); + assert(abs(sol.x(end)) < tol); sol = minimizeModelFlux(currentmodel); - assert(sol.x(end) == 12000); %Since its reversible, exchangers cycle and all rev reactions cycle. + assert(abs(sol.x(end) - 12000) <= tol); %Since its reversible, exchangers cycle and all rev reactions cycle. sol = minimizeModelFlux(currentmodel,'max','one'); %same as before. - assert(sol.x(end) == 12000); %Since its reversible, exchangers cycle and all rev reactions cycle. + assert(abs(sol.x(end) - 12000 ) <= tol); %Since its reversible, exchangers cycle and all rev reactions cycle. currentmodel.osenseStr = 'min'; modelChanged = changeRxnBounds(currentmodel,'R3',5,'l'); sol = minimizeModelFlux(modelChanged); - assert(sol.x(end) == 20); %Can only come from the cycle + assert(abs(sol.x(end) - 20) <= tol); %Can only come from the cycle sol = minimizeModelFlux(modelChanged,'max'); - assert(sol.x(end) == 11000); %MAx flux through C-> E and Exchangers, + 3 reactions from the cycle. + assert(abs(sol.x(end) - 11000) <= tol); %MAx flux through C-> E and Exchangers, + 3 reactions from the cycle. modelChanged = changeRxnBounds(currentmodel,'EX_E',5,'l'); %Force production of E sol = minimizeModelFlux(modelChanged); modelChanged = rmfield(modelChanged,'osenseStr'); - assert(sol.x(end) == 25); %Flux -> A -> B -> C -> E -> + assert(abs(sol.x(end) - 25) <= tol); %Flux -> A -> B -> C -> E -> end % change the directory From 12f691ddd39be5689a67a09442cbb5474b9ae994 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Mon, 5 Nov 2018 11:48:21 +0100 Subject: [PATCH 03/29] Further adjustments for Tests --- src/base/install/prepareTest.m | 19 ++++++++++++++++++- test/verifiedTests/analysis/testFVA/testFVA.m | 7 +++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/base/install/prepareTest.m b/src/base/install/prepareTest.m index 521f5f05b0..feb89b2112 100644 --- a/src/base/install/prepareTest.m +++ b/src/base/install/prepareTest.m @@ -9,7 +9,8 @@ % OPTIONAL INPUTS: % varagin: `ParameterName` value pairs with the following options: % -% - `toolboxes` or `requiredToolboxes`: Names of required toolboxes (the license feature name) (default: {}) +% - `toolboxes` or `requiredToolboxes`: Names of required toolboxes (the license feature name).(default: {}) +% - `minimalMatlabSolverVersion`: Minimal version of the optimization toolbox required to use the matlab solver.(default: 0) % - `requiredSolvers`: Names of all solvers that MUST be available. If not empty, the resulting solvers struct will contain cell arrays (default: {}) % - `useSolversIfAvailable`: Names of solvers that should be used if available. If not empty, the resulting solvers struct will contain cell arrays (will not throw an error if not). (default: {}) % - `requireOneSolverOf`: Names of solvers, at least one of which has to be available @@ -86,6 +87,8 @@ parser = inputParser(); parser.addParamValue('toolboxes', {}, @iscell); parser.addParamValue('requiredToolboxes', {}, @iscell); +parser.addParamValue('minimalMatlabSolverVersion',0,@isnumeric); + parser.addParamValue('requiredSolvers', {}, @iscell); parser.addParamValue('useSolversIfAvailable', {}, @iscell); parser.addParamValue('requireOneSolverOf', {}, @iscell); @@ -103,6 +106,7 @@ parser.addParamValue('needsWebAddress', '', @ischar); parser.addParamValue('needsWebRead', false, @(x) islogical(x) || x == 1 || x == 0); + parser.parse(varargin{:}); useQP = parser.Results.needsQP; @@ -130,6 +134,8 @@ useMinimalNumberOfSolvers = parser.Results.useMinimalNumberOfSolvers; runtype = getenv('CI_RUNTYPE'); +minimalMatlabSolverVersion = parser.Results.minimalMatlabSolverVersion; + errorMessage = {}; infoMessage = {}; @@ -191,6 +197,17 @@ % restrict the solvers available for this test solversForTest = availableSolvers; +if any(ismember(solversForTest.LP,'matlab')) + boxes = ver(); + optBox = find(ismember({boxes.Name},'Optimization Toolbox')); + if ~isempty(optBox) + optVer = boxes(optBox).Version; + if str2double(optVer) < minimalMatlabSolverVersion + excludedSolvers = [columnVector(excludedSolvers);'matlab']; + end + end +end + if ~isempty(excludedSolvers) solverTypes = fieldnames(availableSolvers); for i = 1:numel(solverTypes) diff --git a/test/verifiedTests/analysis/testFVA/testFVA.m b/test/verifiedTests/analysis/testFVA/testFVA.m index 6732136626..165b5c107f 100644 --- a/test/verifiedTests/analysis/testFVA/testFVA.m +++ b/test/verifiedTests/analysis/testFVA/testFVA.m @@ -22,7 +22,10 @@ % define the solver packages to be used to run this test, can't use % dqq/Minos for the parallel part. -solverPkgs = prepareTest('needsLP',true,'needsMILP',true,'needsQP',true,'useSolversIfAvailable',{'ibm_cplex'},'excludeSolvers',{'dqqMinos','quadMinos'}); +solverPkgs = prepareTest('needsLP',true,'needsMILP',true,'needsQP',true,... + 'useSolversIfAvailable',{'ibm_cplex'},... + 'excludeSolvers',{'dqqMinos','quadMinos'},... + 'minimalMatlabSolverVersion',8.0); @@ -143,7 +146,7 @@ %there pttoolboxPath = which('parpool'); % here, we can use dqq and quadMinos again, because this is not parallel. -solverPkgs = prepareTest('needsLP',true,'needsMILP',true,'needsQP',true,'useSolversIfAvailable',{'ibm_cplex'}); +solverPkgs = prepareTest('needsLP',true,'needsMILP',true,'needsQP',true,'useSolversIfAvailable',{'ibm_cplex'},'minimalMatlabSolverVersion',8.0); if ~isempty(pttoolboxPath) %We also have to shut down the parallel pool, as otherwise problems %occur with the pool. From 4c8bbf4c331211fdd4268e62a7cd7da9b4de695e Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Tue, 6 Nov 2018 09:42:50 +0100 Subject: [PATCH 04/29] Allow empty Objective - no objective in the SBML --- src/base/io/utilities/writeSBML.m | 80 ++++++++++++++++--------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/src/base/io/utilities/writeSBML.m b/src/base/io/utilities/writeSBML.m index 241fda05dd..ee5023818f 100644 --- a/src/base/io/utilities/writeSBML.m +++ b/src/base/io/utilities/writeSBML.m @@ -552,54 +552,58 @@ %% Set the objective sense of the FBC objective according to the osenseStr in %the model. -objectiveSense = 'maximize'; - -if isfield(model,'osenseStr') && strcmpi(model.osenseStr,'min') - objectiveSense = 'minimize'; -end - -tmp_fbc_objective=getSBMLDefaultStruct('SBML_FBC_OBJECTIVE',sbmlLevel, sbmlVersion,sbmlPackages, sbmlPackageVersions); -tmp_fbc_objective.fbc_id = 'obj'; -tmp_fbc_objective.fbc_type = objectiveSense; -sbmlModel.fbc_activeObjective = 'obj'; - -tmp_fbc_objective.fbc_fluxObjective=getSBMLDefaultStruct('SBML_FBC_FLUXOBJECTIVE',sbmlLevel, sbmlVersion,sbmlPackages, sbmlPackageVersions); - %%%%% multiple objectives if ~isnumeric(model.c) model.c=double(cell2mat(model.c)); % convert the variable type to double end -% check=~isempty(model.c(model.c~=0)) the following block is necessry for -% libSBML library 5.11 -% % % % % % % if isempty(model.c(model.c~=0)) % if no objective function is defined, the first reaction is set as the objective function. -% % % % % % % model.c(1)=1; -% % % % % % % end -%if ~isempty(model.c(model.c~=0)) -% Construct a default structure of objective reactions and set intial values. -% fbc_objective.fbc_fluxObjective=fbc_fluxObjective; -ind=find(model.c); % Find the index numbers for the objective reactions -% The fields of a COBRA model are converted into respective fields of a FBCv2 structure. -if isempty(ind) - tmp_fbc_objective.fbc_fluxObjective.fbc_coefficient=0; % no objective function is set - sbmlModel.fbc_objective=tmp_fbc_objective; -else - for i=1:length(ind) - % model.c(ind(i)); - values=model.c(model.c~=0); - tmp_fbc_objective.fbc_fluxObjective.fbc_reaction=sbmlModel.reaction(ind(i)).id; % the reaction.id contains the % model.rxns{ind(i)}; - tmp_fbc_objective.fbc_fluxObjective.fbc_coefficient=values(i); - tmp_fbc_objective.fbc_fluxObjective.isSetfbc_coefficient=1; - if i==1 - sbmlModel.fbc_objective=tmp_fbc_objective; - else - sbmlModel.fbc_objective.fbc_fluxObjective=[sbmlModel.fbc_objective.fbc_fluxObjective,tmp_fbc_objective.fbc_fluxObjective]; +if ~all(model.c == 0) + + + objectiveSense = 'maximize'; + + if isfield(model,'osenseStr') && strcmpi(model.osenseStr,'min') + objectiveSense = 'minimize'; + end + + tmp_fbc_objective=getSBMLDefaultStruct('SBML_FBC_OBJECTIVE',sbmlLevel, sbmlVersion,sbmlPackages, sbmlPackageVersions); + tmp_fbc_objective.fbc_id = 'obj'; + tmp_fbc_objective.fbc_type = objectiveSense; + sbmlModel.fbc_activeObjective = 'obj'; + + tmp_fbc_objective.fbc_fluxObjective=getSBMLDefaultStruct('SBML_FBC_FLUXOBJECTIVE',sbmlLevel, sbmlVersion,sbmlPackages, sbmlPackageVersions); + + + % check=~isempty(model.c(model.c~=0)) the following block is necessry for + % libSBML library 5.11 + % % % % % % % if isempty(model.c(model.c~=0)) % if no objective function is defined, the first reaction is set as the objective function. + % % % % % % % model.c(1)=1; + % % % % % % % end + %if ~isempty(model.c(model.c~=0)) + % Construct a default structure of objective reactions and set intial values. + % fbc_objective.fbc_fluxObjective=fbc_fluxObjective; + ind=find(model.c); % Find the index numbers for the objective reactions + % The fields of a COBRA model are converted into respective fields of a FBCv2 structure. + if isempty(ind) + tmp_fbc_objective.fbc_fluxObjective.fbc_coefficient=0; % no objective function is set + sbmlModel.fbc_objective=tmp_fbc_objective; + else + for i=1:length(ind) + % model.c(ind(i)); + values=model.c(model.c~=0); + tmp_fbc_objective.fbc_fluxObjective.fbc_reaction=sbmlModel.reaction(ind(i)).id; % the reaction.id contains the % model.rxns{ind(i)}; + tmp_fbc_objective.fbc_fluxObjective.fbc_coefficient=values(i); + tmp_fbc_objective.fbc_fluxObjective.isSetfbc_coefficient=1; + if i==1 + sbmlModel.fbc_objective=tmp_fbc_objective; + else + sbmlModel.fbc_objective.fbc_fluxObjective=[sbmlModel.fbc_objective.fbc_fluxObjective,tmp_fbc_objective.fbc_fluxObjective]; + end end end end - %end sbmlModel.namespaces=struct('prefix',{'','fbc','groups'},... From 8f2d0524193423ff89f725b9906ac648aa77758c Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Tue, 6 Nov 2018 14:59:28 +0100 Subject: [PATCH 05/29] Adjust function Name --- .../transcriptomics/eFlux/verifyEFluxExpressionStruct.m | 2 +- .../refinement/{removeGenes.m => removeGenesFromModel.m} | 4 ++-- test/verifiedTests/dataIntegration/testEFlux/testEFlux.m | 2 +- .../testModelManipulation/testModelManipulation.m | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename src/reconstruction/refinement/{removeGenes.m => removeGenesFromModel.m} (95%) diff --git a/src/dataIntegration/transcriptomics/eFlux/verifyEFluxExpressionStruct.m b/src/dataIntegration/transcriptomics/eFlux/verifyEFluxExpressionStruct.m index c3b824f5e4..d22df3ff73 100644 --- a/src/dataIntegration/transcriptomics/eFlux/verifyEFluxExpressionStruct.m +++ b/src/dataIntegration/transcriptomics/eFlux/verifyEFluxExpressionStruct.m @@ -17,7 +17,7 @@ % checkoptional field preprocessed % This leads to -1 for unassociated genes if ~isempty(setdiff(model.genes,expression.target)) - error('The following genes are lacking assignments:\n%s\nAll genes need to be assigned in order to use eFlux. You can remove genes by using the removeGenes function',strjoin(setdiff(model.genes,expression.target),'\n')); + error('The following genes are lacking assignments:\n%s\nAll genes need to be assigned in order to use eFlux. You can remove genes by using the removeGenesFromModel function',strjoin(setdiff(model.genes,expression.target),'\n')); end end % check sizes of the value/target fields. They must be of equal size. diff --git a/src/reconstruction/refinement/removeGenes.m b/src/reconstruction/refinement/removeGenesFromModel.m similarity index 95% rename from src/reconstruction/refinement/removeGenes.m rename to src/reconstruction/refinement/removeGenesFromModel.m index 3fc2bcc78a..98b87d7cd5 100644 --- a/src/reconstruction/refinement/removeGenes.m +++ b/src/reconstruction/refinement/removeGenesFromModel.m @@ -1,4 +1,4 @@ -function [model, affectedRxns, originalGPRs, deletedReaction] = removeGenes(model, geneList, varargin) +function [model, affectedRxns, originalGPRs, deletedReaction] = removeGenesFromModel(model, geneList, varargin) % Removes the given genes from the model. GPR rules will be adjusted to reflect the removal. % By default, the rules are converted to DNF and all clauses containing any of the given % genes are removed. Note, that this function is not supposed to be used to model @@ -6,7 +6,7 @@ % % USAGE: % -% [model, affectedRxns, originalGPRs, deletedReactions] = deleteModelGenes(model, geneList) +% [model, affectedRxns, originalGPRs, deletedReactions] = removeGenesFromModel(model, geneList) % % INPUT: % model: COBRA model with the appropriate constrains for a diff --git a/test/verifiedTests/dataIntegration/testEFlux/testEFlux.m b/test/verifiedTests/dataIntegration/testEFlux/testEFlux.m index edad6321ac..c443e72845 100644 --- a/test/verifiedTests/dataIntegration/testEFlux/testEFlux.m +++ b/test/verifiedTests/dataIntegration/testEFlux/testEFlux.m @@ -16,7 +16,7 @@ solverPkgs = prepareTest('needsLP',true,'toolboxes',{'bioinformatics_toolbox'},'needsWebAddress','https://www.ncbi.nlm.nih.gov/geo/query/','excludeSolvers',{'matlab'}); model = getDistributedModel('ecoli_core_model.mat'); -model = removeGenes(model,'s0001','keepReactions',true); +model = removeGenesFromModel(model,'s0001','keepReactions',true); geoaddress = 'https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?form=text&acc=%s&view=full'; anaerobic = geosoftread(urlread(sprintf(geoaddress,'GSM1010240'))); aerobic = geosoftread(urlread(sprintf(geoaddress,'GSM1126445'))); diff --git a/test/verifiedTests/reconstruction/testModelManipulation/testModelManipulation.m b/test/verifiedTests/reconstruction/testModelManipulation/testModelManipulation.m index a08b9c0faf..d1b8c143d4 100644 --- a/test/verifiedTests/reconstruction/testModelManipulation/testModelManipulation.m +++ b/test/verifiedTests/reconstruction/testModelManipulation/testModelManipulation.m @@ -455,14 +455,14 @@ fprintf('>> Done \n\n >> Testing Gene removal...\n'); %Test removal of a gene -modelMod1 = removeGenes(modelMod,'G1'); +modelMod1 = removeGenesFromModel(modelMod,'G1'); % now, rules{1} and rules{3} should be equal; fp = FormulaParser(); rule = fp.parseFormula(modelMod1.rules{1}); rule2 = fp.parseFormula(modelMod1.rules{3}); assert(rule2.isequal(rule)); % and now without keeping the clauses -modelMod2 = removeGenes(modelMod,'G1','keepClauses',false); +modelMod2 = removeGenesFromModel(modelMod,'G1','keepClauses',false); fp = FormulaParser(); rule = fp.parseFormula(modelMod2.rules{1}); rule2 = fp.parseFormula(modelMod2.rules{2}); From a64e07e562474d735a83d49c7a519a5782f64b51 Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Mon, 5 Nov 2018 11:27:55 +0100 Subject: [PATCH 06/29] testing calculateLODs function --- .../testMetaboTools/testCalculateLODs.m | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m diff --git a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m new file mode 100644 index 0000000000..be2d3261df --- /dev/null +++ b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m @@ -0,0 +1,35 @@ +% The COBRA Toolbox: testcalculateLODs +% +% Purpose: +% - tests the calculateLODs function +% +% Authors: +% Loic Marx, November 2018 +% +% + + +% save the current path +currentDir = pwd; + +% initialize the test +fileDir = fileparts(which('testcalculateLODs')); +cd(fileDir); + +% calculate reference value +theo_mass = (10: - 1:1); +lod_gL = 1; + +v_ref = lod_gL ./theo_mass*1000; + +%calculate inputs +theo_mass = (10: - 1:1); +lod_ngmL = 1; + +calculateLOD = calculateLODs(theo_mass,lod_ngmL) +% Comparison to ref value + assert(isequal(calculateLOD, v_ref)) + + +% change the directory +cd(currentDir) From cbf051049e6ed93ccf766c493c3dfedb13402d38 Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Mon, 5 Nov 2018 16:59:06 +0100 Subject: [PATCH 07/29] testing calculateLODs function --- .../metabotools/calculateLODs.m | 14 ++++++++++++- .../testMetaboTools/testCalculateLODs.m | 21 ++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/dataIntegration/metabotools/calculateLODs.m b/src/dataIntegration/metabotools/calculateLODs.m index 1882e3053c..7c19a61fe6 100644 --- a/src/dataIntegration/metabotools/calculateLODs.m +++ b/src/dataIntegration/metabotools/calculateLODs.m @@ -14,10 +14,22 @@ % lod_mM: Detection limits in mM % % .. Author: - Maike K. Aurich 27/05/15 +% Modified by Loic Marx + +% input checking +if length(lod_ngmL) == 1 + lod_ngmL = repmat(lod_ngmL, length(theo_mass)) + % throw a warning +warning(The inputs have different size but we fixed it) +end + +if length(lod_ngmL) ~= 1 + error ('both inputs do not have the same size') +end lod_gL = lod_ngmL* 0.000001; -lodmM =[]; +lod_mM =[]; for i=1:length(lod_gL) diff --git a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m index be2d3261df..d56b61a51e 100644 --- a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m +++ b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m @@ -17,19 +17,24 @@ cd(fileDir); % calculate reference value -theo_mass = (10: - 1:1); -lod_gL = 1; +theo_mass = [1, 2]; +v_ref = [1000, 500]; -v_ref = lod_gL ./theo_mass*1000; - -%calculate inputs -theo_mass = (10: - 1:1); +%calculate inputs lod_ngmL = 1; calculateLOD = calculateLODs(theo_mass,lod_ngmL) % Comparison to ref value - assert(isequal(calculateLOD, v_ref)) - +assert(isequal(calculateLOD, v_ref)) +% throwing an error if the dimension are not equal +lod_ngmL_unequal = [1, 2, 3] +assert(verifyCobraFunctionError('calculateLODs', 'theo_mass,lod_ngmL_unequal ', {theo_mass,lod_ngmL_unequal'}, 'testMessage', 'both inputs do not have the same size')); +% Testing the case where lod_ngmL is a vector of the same size as theo_mass +lod_ngmL_vector = [1, 2] +v_ref_vector = [1000, 1000] +% Comparison to the ref value +calculateLOD_vector = calculateLODs(theo_mass,lod_ngmL) +assert(isequal(calculateLOD_vector, v_ref_vector)) % change the directory cd(currentDir) From 1041d2d8a306e680aa65b25dd94517585c43986a Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Tue, 6 Nov 2018 14:21:59 +0100 Subject: [PATCH 08/29] final testing function --- .../testMetaboTools/testCalculateLODs.m | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m index d56b61a51e..a9ba9a39c6 100644 --- a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m +++ b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m @@ -18,23 +18,25 @@ % calculate reference value theo_mass = [1, 2]; -v_ref = [1000, 500]; +v_ref = 1e-3 * [1; 0.5]; %calculate inputs lod_ngmL = 1; -calculateLOD = calculateLODs(theo_mass,lod_ngmL) +calculateLOD = calculateLODs(theo_mass,lod_ngmL); % Comparison to ref value assert(isequal(calculateLOD, v_ref)) -% throwing an error if the dimension are not equal -lod_ngmL_unequal = [1, 2, 3] -assert(verifyCobraFunctionError('calculateLODs', 'theo_mass,lod_ngmL_unequal ', {theo_mass,lod_ngmL_unequal'}, 'testMessage', 'both inputs do not have the same size')); +% throwing an error if the dimensions are not equal +lod_ngmL_unequal = [1, 2, 3]; + +assert(verifyCobraFunctionError('calculateLODs', 'inputs', {theo_mass,lod_ngmL_unequal'}, 'testMessage', 'both inputs do not have the same size')); % Testing the case where lod_ngmL is a vector of the same size as theo_mass -lod_ngmL_vector = [1, 2] -v_ref_vector = [1000, 1000] + +lod_ngmL_vector = [1, 2]; +v_ref_vector = 1e-3 * [1; 1]; % Comparison to the ref value -calculateLOD_vector = calculateLODs(theo_mass,lod_ngmL) -assert(isequal(calculateLOD_vector, v_ref_vector)) +calculateLOD_vector = calculateLODs(theo_mass,lod_ngmL_vector); +assert(isequal(calculateLOD_vector, v_ref_vector)); % change the directory cd(currentDir) From f78f1ba3a2a4fc36375c58fe2247d063b23450bb Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Tue, 6 Nov 2018 14:23:29 +0100 Subject: [PATCH 09/29] Modification of the function calculateLOD --- src/dataIntegration/metabotools/calculateLODs.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dataIntegration/metabotools/calculateLODs.m b/src/dataIntegration/metabotools/calculateLODs.m index 7c19a61fe6..be39fe4188 100644 --- a/src/dataIntegration/metabotools/calculateLODs.m +++ b/src/dataIntegration/metabotools/calculateLODs.m @@ -18,22 +18,22 @@ % input checking if length(lod_ngmL) == 1 - lod_ngmL = repmat(lod_ngmL, length(theo_mass)) + lod_ngmL = repmat(lod_ngmL, 1, length(theo_mass)); % throw a warning -warning(The inputs have different size but we fixed it) + warning('The inputs have different size'); end -if length(lod_ngmL) ~= 1 - error ('both inputs do not have the same size') +if length(lod_ngmL) ~= length(theo_mass) + error('both inputs do not have the same size'); end lod_gL = lod_ngmL* 0.000001; -lod_mM =[]; +lod_mM = zeros(length(lod_gL), 1); for i=1:length(lod_gL) - lod_mM(i,1)= lod_gL(i,1)/theo_mass(i,1)*1000; + lod_mM(i)= lod_gL(i)/theo_mass(i)*1000; end From 23bb009aea0373772b42778a702c925ec0827596 Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Tue, 6 Nov 2018 15:06:31 +0100 Subject: [PATCH 10/29] rewriting the code --- .../metabotools/calculateLODs.m | 16 ++++++---- .../testMetaboTools/testCalculateLODs.m | 31 +++++++++++++------ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/dataIntegration/metabotools/calculateLODs.m b/src/dataIntegration/metabotools/calculateLODs.m index be39fe4188..e24fbfd949 100644 --- a/src/dataIntegration/metabotools/calculateLODs.m +++ b/src/dataIntegration/metabotools/calculateLODs.m @@ -14,26 +14,30 @@ % lod_mM: Detection limits in mM % % .. Author: - Maike K. Aurich 27/05/15 -% Modified by Loic Marx +% Modified by Loic Marx, November 2018 % input checking if length(lod_ngmL) == 1 + lod_ngmL = repmat(lod_ngmL, 1, length(theo_mass)); + % throw a warning - warning('The inputs have different size'); + warning('The inputs have different size but we managed to fix this problem'); + end if length(lod_ngmL) ~= length(theo_mass) - error('both inputs do not have the same size'); + + error('The length of the inputs are not the same'); end -lod_gL = lod_ngmL* 0.000001; +lod_gL = lod_ngmL * 0.000001; lod_mM = zeros(length(lod_gL), 1); -for i=1:length(lod_gL) +for i=1 : length(lod_gL) - lod_mM(i)= lod_gL(i)/theo_mass(i)*1000; + lod_mM(i) = lod_gL(i)/theo_mass(i)*1000; end diff --git a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m index a9ba9a39c6..27cac42b2c 100644 --- a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m +++ b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m @@ -9,34 +9,45 @@ % -% save the current path +% Save the current path currentDir = pwd; -% initialize the test +% Initialize the test fileDir = fileparts(which('testcalculateLODs')); + cd(fileDir); -% calculate reference value +% Defining the inputs +lod_ngmL = 1; + theo_mass = [1, 2]; + +% Calculate the reference value + v_ref = 1e-3 * [1; 0.5]; -%calculate inputs -lod_ngmL = 1; +% Calculate the actual value by using the function calculateLOD = calculateLODs(theo_mass,lod_ngmL); -% Comparison to ref value + +% Comparison between calculate value and ref value assert(isequal(calculateLOD, v_ref)) -% throwing an error if the dimensions are not equal + +% Throwing an error if the dimensions of both inputs are not equal lod_ngmL_unequal = [1, 2, 3]; assert(verifyCobraFunctionError('calculateLODs', 'inputs', {theo_mass,lod_ngmL_unequal'}, 'testMessage', 'both inputs do not have the same size')); -% Testing the case where lod_ngmL is a vector of the same size as theo_mass +% If both inputs are two vectors of the same size lod_ngmL_vector = [1, 2]; + v_ref_vector = 1e-3 * [1; 1]; -% Comparison to the ref value + +% Comparison between the values calculated when the inputs have the same size and the reference value calculateLOD_vector = calculateLODs(theo_mass,lod_ngmL_vector); + assert(isequal(calculateLOD_vector, v_ref_vector)); -% change the directory + +% Change the directory cd(currentDir) From baf5dce92e3d76b3e4d0e9178ce766b11713d47c Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Thu, 8 Nov 2018 11:17:44 +0100 Subject: [PATCH 11/29] Final modification on the function --- src/dataIntegration/metabotools/calculateLODs.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/dataIntegration/metabotools/calculateLODs.m b/src/dataIntegration/metabotools/calculateLODs.m index e24fbfd949..f80c657bd6 100644 --- a/src/dataIntegration/metabotools/calculateLODs.m +++ b/src/dataIntegration/metabotools/calculateLODs.m @@ -21,17 +21,14 @@ lod_ngmL = repmat(lod_ngmL, 1, length(theo_mass)); - % throw a warning - warning('The inputs have different size but we managed to fix this problem'); - end -if length(lod_ngmL) ~= length(theo_mass) +if numel(lod_ngmL) ~= numel(theo_mass) - error('The length of the inputs are not the same'); + error('The number of elements in the input vectors do not match. They have to be either the same size, or lod_ngmL has to be a single value which is used for all elements'); end -lod_gL = lod_ngmL * 0.000001; +lod_gL = lod_ngmL * 1e-6; lod_mM = zeros(length(lod_gL), 1); From e11c9a0db524329f4225c64819645577a738c349 Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Thu, 8 Nov 2018 11:19:39 +0100 Subject: [PATCH 12/29] Changing error message on the code --- .../dataIntegration/testMetaboTools/testCalculateLODs.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m index 27cac42b2c..f9ba90bda0 100644 --- a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m +++ b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m @@ -37,7 +37,7 @@ % Throwing an error if the dimensions of both inputs are not equal lod_ngmL_unequal = [1, 2, 3]; -assert(verifyCobraFunctionError('calculateLODs', 'inputs', {theo_mass,lod_ngmL_unequal'}, 'testMessage', 'both inputs do not have the same size')); +assert(verifyCobraFunctionError('calculateLODs', 'inputs', {theo_mass,lod_ngmL_unequal'}, 'testMessage', 'The number of elements in the input vectors do not match. They have to be either the same size, or lod_ngmL has to be a single value which is used for all elements')); % If both inputs are two vectors of the same size lod_ngmL_vector = [1, 2]; From e8217c3a91cba5f61066516d388aae848c486aac Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Thu, 8 Nov 2018 13:53:14 +0100 Subject: [PATCH 13/29] Updating the code --- src/dataIntegration/metabotools/calculateLODs.m | 2 +- .../testMetaboTools/testCalculateLODs.m | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/dataIntegration/metabotools/calculateLODs.m b/src/dataIntegration/metabotools/calculateLODs.m index f80c657bd6..ab62dd3f21 100644 --- a/src/dataIntegration/metabotools/calculateLODs.m +++ b/src/dataIntegration/metabotools/calculateLODs.m @@ -14,7 +14,7 @@ % lod_mM: Detection limits in mM % % .. Author: - Maike K. Aurich 27/05/15 -% Modified by Loic Marx, November 2018 +% Modified by Loic Marx, November 2018 % input checking if length(lod_ngmL) == 1 diff --git a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m index f9ba90bda0..d562f9c213 100644 --- a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m +++ b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m @@ -5,8 +5,7 @@ % % Authors: % Loic Marx, November 2018 -% -% +% % Save the current path @@ -17,7 +16,7 @@ cd(fileDir); -% Defining the inputs +% Define the inputs lod_ngmL = 1; theo_mass = [1, 2]; @@ -30,21 +29,21 @@ calculateLOD = calculateLODs(theo_mass,lod_ngmL); -% Comparison between calculate value and ref value +% Compare between the calculated value and the reference value assert(isequal(calculateLOD, v_ref)) -% Throwing an error if the dimensions of both inputs are not equal +% Throw an error if the dimensions of both inputs are not equal lod_ngmL_unequal = [1, 2, 3]; assert(verifyCobraFunctionError('calculateLODs', 'inputs', {theo_mass,lod_ngmL_unequal'}, 'testMessage', 'The number of elements in the input vectors do not match. They have to be either the same size, or lod_ngmL has to be a single value which is used for all elements')); -% If both inputs are two vectors of the same size +% lod_ngmL and theo_mass are two vectors of the same size lod_ngmL_vector = [1, 2]; v_ref_vector = 1e-3 * [1; 1]; -% Comparison between the values calculated when the inputs have the same size and the reference value +% Compare the values calculated when the inputs have the same size and the reference value calculateLOD_vector = calculateLODs(theo_mass,lod_ngmL_vector); assert(isequal(calculateLOD_vector, v_ref_vector)); From 2dd1a2bb8a76241fb08e7e8e71ee278485ecf854 Mon Sep 17 00:00:00 2001 From: Loic Marx Date: Thu, 8 Nov 2018 15:52:52 +0100 Subject: [PATCH 14/29] Reformating the style --- .../metabotools/calculateLODs.m | 16 +++------- .../testMetaboTools/testCalculateLODs.m | 32 +++++++------------ 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/dataIntegration/metabotools/calculateLODs.m b/src/dataIntegration/metabotools/calculateLODs.m index ab62dd3f21..a3e183c3f9 100644 --- a/src/dataIntegration/metabotools/calculateLODs.m +++ b/src/dataIntegration/metabotools/calculateLODs.m @@ -14,28 +14,22 @@ % lod_mM: Detection limits in mM % % .. Author: - Maike K. Aurich 27/05/15 -% Modified by Loic Marx, November 2018 +% - Modified by Loic Marx, November 2018 % input checking -if length(lod_ngmL) == 1 - +if size(lod_ngmL) == 1 lod_ngmL = repmat(lod_ngmL, 1, length(theo_mass)); - -end + end -if numel(lod_ngmL) ~= numel(theo_mass) - +if size(lod_ngmL) ~= size(theo_mass) error('The number of elements in the input vectors do not match. They have to be either the same size, or lod_ngmL has to be a single value which is used for all elements'); end lod_gL = lod_ngmL * 1e-6; - lod_mM = zeros(length(lod_gL), 1); -for i=1 : length(lod_gL) - +for i = 1 : length(lod_gL) lod_mM(i) = lod_gL(i)/theo_mass(i)*1000; - end end diff --git a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m index d562f9c213..b9c379fff2 100644 --- a/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m +++ b/test/verifiedTests/dataIntegration/testMetaboTools/testCalculateLODs.m @@ -3,50 +3,40 @@ % Purpose: % - tests the calculateLODs function % -% Authors: -% Loic Marx, November 2018 +% Author: - Loic Marx, November 2018 % - - -% Save the current path + +% save the current path currentDir = pwd; -% Initialize the test +% initialize the test fileDir = fileparts(which('testcalculateLODs')); - cd(fileDir); -% Define the inputs +% define the inputs lod_ngmL = 1; - theo_mass = [1, 2]; -% Calculate the reference value - +% calculate the reference value v_ref = 1e-3 * [1; 0.5]; -% Calculate the actual value by using the function - +% calculate the actual value by using the function calculateLOD = calculateLODs(theo_mass,lod_ngmL); -% Compare between the calculated value and the reference value - +% compare the calculated value and the reference value assert(isequal(calculateLOD, v_ref)) -% Throw an error if the dimensions of both inputs are not equal +% throw an error if the dimensions of both inputs are not equal lod_ngmL_unequal = [1, 2, 3]; - assert(verifyCobraFunctionError('calculateLODs', 'inputs', {theo_mass,lod_ngmL_unequal'}, 'testMessage', 'The number of elements in the input vectors do not match. They have to be either the same size, or lod_ngmL has to be a single value which is used for all elements')); % lod_ngmL and theo_mass are two vectors of the same size lod_ngmL_vector = [1, 2]; - v_ref_vector = 1e-3 * [1; 1]; -% Compare the values calculated when the inputs have the same size and the reference value +% compare the values calculated when the inputs have the same size and the reference value calculateLOD_vector = calculateLODs(theo_mass,lod_ngmL_vector); - assert(isequal(calculateLOD_vector, v_ref_vector)); -% Change the directory +% change the directory cd(currentDir) From 6c850895d8fa21f25cd1b5b5b16f6a3d2ad4dfca Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Thu, 8 Nov 2018 08:42:28 +0100 Subject: [PATCH 15/29] Removing Matlab test from 2016b and earlier --- test/verifiedTests/analysis/testGeometricFBA/testGeometricFBA.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/verifiedTests/analysis/testGeometricFBA/testGeometricFBA.m b/test/verifiedTests/analysis/testGeometricFBA/testGeometricFBA.m index 19dee473b7..4361b2795c 100644 --- a/test/verifiedTests/analysis/testGeometricFBA/testGeometricFBA.m +++ b/test/verifiedTests/analysis/testGeometricFBA/testGeometricFBA.m @@ -26,7 +26,7 @@ %When detectDeadEnds is changed according to Ronans suggestion, we need to test %multiple solvers. -solverPkgs = prepareTest('needsLP', true); +solverPkgs = prepareTest('needsLP', true, 'minimalMatlabSolverVersion',8.0); tol = 1e-4; for k = 1:length(solverPkgs.LP) % set the solver From 25f3b88ad2c3b4278a93af187a302c00256175f8 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 08:25:46 +0100 Subject: [PATCH 16/29] Increase test verbosity to deterine error --- test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index fc6ecdccc7..ef11a97b54 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -340,7 +340,8 @@ for j3 = 1:numel(vRef) if abs(vRef(j3)) < 1e-5 assert(abs(vRef(j3) - v(j3)) < 1e-5) - else + else + fprintf('%2.8f <-> %2.8f', vRef(j3), v(j3)); assert(abs(vRef(j3) - v(j3)) / abs(vRef(j3)) < tolPercent) end end From cf4d2b006498f60a5f287466cfe3708b8bb90675 Mon Sep 17 00:00:00 2001 From: laurentheirendt Date: Fri, 9 Nov 2018 08:33:36 +0100 Subject: [PATCH 17/29] [documentation] update to tutorials submodule --- tutorials | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials b/tutorials index 100b2fe0d4..21dbe32953 160000 --- a/tutorials +++ b/tutorials @@ -1 +1 @@ -Subproject commit 100b2fe0d4faefff88625bbb29c1d48042716bdc +Subproject commit 21dbe32953a018ad2bb9b7ed96f5337383de73c5 From 9a00db5623e50b481cc1400925b7f93cf6ff0358 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 09:58:26 +0100 Subject: [PATCH 18/29] Cleanup before the test --- src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m | 11 ++++------- .../SteadyCom/subroutines/SteadyComFVAgr.m | 9 +++------ .../analysis/testSteadyCom/testSteadyCom.m | 7 ++++++- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m b/src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m index 3c5fcf43b3..9c327968eb 100644 --- a/src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m +++ b/src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m @@ -286,14 +286,11 @@ kDisp = 0; end end - directory = strsplit(saveFVA,filesep); - if numel(directory) > 1 + [folder,filename] = fileparts(saveFVA); + if ~isempty(folder) && ~isfolder(folder) % not saving in the current directory. Create the directory. - directory = strjoin([{pwd}, directory(1:end-1)],filesep); - if ~exist(directory, 'dir') - mkdir(directory); - end - end + mkdir(folder); + end if ibm_cplex LPmodel = LP.Model; % the Cplex dynamic object is not good for saving LPstart = LP.Start; diff --git a/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m b/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m index e10ed64e66..756ead86fb 100644 --- a/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m +++ b/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m @@ -279,13 +279,10 @@ end % check save directory if ~isempty(saveFVA) - directory = strsplit(saveFVA,filesep); - if numel(directory) > 1 + [directory,filename] = fileparts(saveFVA); + if ~isempty(directory) && ~isdir(directory) % not saving in the current directory. Check existence - directory = strjoin([{pwd}, directory(1:end-1)],filesep); - if ~exist(directory, 'dir') - mkdir(directory); - end + mkdir(directory); end end if verbFlag diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index ef11a97b54..26bdf40587 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -21,6 +21,11 @@ % initialize the test fileDir = fileparts(which('testSteadyCom')); cd(fileDir); +% Make sure, that no old data exists! +if exist([fileDir filesep 'testSteadyComFVAsave']) + rmdir([fileDir filesep 'testSteadyComFVAsave'],'s'); +end + %Test for parallel toolbox try poolobj = gcp('nocreate');% create a toy model @@ -341,7 +346,7 @@ if abs(vRef(j3)) < 1e-5 assert(abs(vRef(j3) - v(j3)) < 1e-5) else - fprintf('%2.8f <-> %2.8f', vRef(j3), v(j3)); + fprintf('%2.8f <-> %2.8f\n', vRef(j3), v(j3)); assert(abs(vRef(j3) - v(j3)) / abs(vRef(j3)) < tolPercent) end end From cd1afed8c3e98ea3a8c5323065c711cb5a183ed2 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 10:30:29 +0100 Subject: [PATCH 19/29] Further printout adjustments --- .../multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m | 2 ++ test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m b/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m index 756ead86fb..95a5c1e621 100644 --- a/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m +++ b/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m @@ -308,6 +308,7 @@ % continue from previous saved file if ~isempty(saveFVA) if exist([saveFVA '.mat'], 'file') + fprintf('In non parallel mode found save file at %s\n', which([saveFVA '.mat'])); load([saveFVA '.mat'], 'i0', 'minFlux', 'maxFlux', 'minFD', 'maxFD'); if i0 == nRxnFVA fprintf('FVA was already finished previously and saved in %s.mat.\n', saveFVA); @@ -373,6 +374,7 @@ if ~isempty(saveFVA) %check if previous results from single-thread computation exist if exist([saveFVA '.mat'], 'file') + fprintf('In parallel mode found save file at %s\n', which([saveFVA '.mat'])); load([saveFVA '.mat'], 'i0'); i0P = i0; clear i0 diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index 26bdf40587..33d7e46b48 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -489,8 +489,8 @@ end % remove all created files - rmdir([pwd filesep 'testSteadyComFVAsave'], 's') - rmdir([pwd filesep 'testSteadyComFVAsavePar'], 's') + rmdir([fileDir filesep 'testSteadyComFVAsave'], 's') + rmdir([fileDir filesep 'testSteadyComFVAsavePar'], 's') else disp('Skipping Parallel Test, No Parallel toolbox installed'); end From dfde74f3251c69d26784e70a18c9efd701df03b5 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 10:30:51 +0100 Subject: [PATCH 20/29] Temporary Restrict tests --- test/runTestSuite.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runTestSuite.m b/test/runTestSuite.m index 9777003c39..c11308fd5f 100644 --- a/test/runTestSuite.m +++ b/test/runTestSuite.m @@ -36,7 +36,7 @@ currentDir = cd(testDir); % get all names of test files -testFiles = rdir(['verifiedTests' filesep '**' filesep 'test*.m']); +testFiles = rdir(['verifiedTests' filesep '**' filesep 'testSteadyCom*.m']); testFileNames = {testFiles.name}; testFileNames = testFileNames(~cellfun(@(x) isempty(regexp(x,testNames,'ONCE')),testFileNames)); From 52ba56680851baf5b66270415a9c45b373a1f4a9 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 10:40:55 +0100 Subject: [PATCH 21/29] Verbose cleanup --- test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index 33d7e46b48..12cef169be 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -22,7 +22,8 @@ fileDir = fileparts(which('testSteadyCom')); cd(fileDir); % Make sure, that no old data exists! -if exist([fileDir filesep 'testSteadyComFVAsave']) +if isfolder([fileDir filesep 'testSteadyComFVAsave']) + fprintf('The save folder exists and will be deleted at %s\n', [fileDir filesep 'testSteadyComFVAsave'] ); rmdir([fileDir filesep 'testSteadyComFVAsave'],'s'); end From 9288e9be78c0d883f84ae3518e602fd4ef474775 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 10:44:49 +0100 Subject: [PATCH 22/29] Even more verbosity --- test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index 12cef169be..7929dd3da1 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -21,6 +21,8 @@ % initialize the test fileDir = fileparts(which('testSteadyCom')); cd(fileDir); + +fprintf('The test is running in the following folder:\n%s\n',fileDir); % Make sure, that no old data exists! if isfolder([fileDir filesep 'testSteadyComFVAsave']) fprintf('The save folder exists and will be deleted at %s\n', [fileDir filesep 'testSteadyComFVAsave'] ); From 48057679cd3ccc3a241e55129c01c378027daac8 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 10:57:40 +0100 Subject: [PATCH 23/29] Resetting the path on the CI --- test/testAll.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/testAll.m b/test/testAll.m index 3b3d20f62e..9891653b76 100644 --- a/test/testAll.m +++ b/test/testAll.m @@ -25,7 +25,10 @@ else launchTestSuite = false; end -else +else + % on the CI, always reset the path to make absolutely sure, that we test + % the current version + restoredefaultpath() launchTestSuite = true; end @@ -166,7 +169,7 @@ if launchTestSuite % save the userpath originalUserPath = path; - + % run the tests in the subfolder verifiedTests/ recursively [result, resultTable] = runTestSuite(); From 8c0de3e71e487b82f90cc70265cb78e51201f1dd Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 11:02:43 +0100 Subject: [PATCH 24/29] Revert "Even more verbosity" This reverts commit 9288e9be78c0d883f84ae3518e602fd4ef474775. --- test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index 7929dd3da1..12cef169be 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -21,8 +21,6 @@ % initialize the test fileDir = fileparts(which('testSteadyCom')); cd(fileDir); - -fprintf('The test is running in the following folder:\n%s\n',fileDir); % Make sure, that no old data exists! if isfolder([fileDir filesep 'testSteadyComFVAsave']) fprintf('The save folder exists and will be deleted at %s\n', [fileDir filesep 'testSteadyComFVAsave'] ); From 09c10a96e7f6837d179270af2b6d2e4fc8f553ab Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 11:02:57 +0100 Subject: [PATCH 25/29] Revert "Verbose cleanup" This reverts commit 52ba56680851baf5b66270415a9c45b373a1f4a9. --- test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index 12cef169be..33d7e46b48 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -22,8 +22,7 @@ fileDir = fileparts(which('testSteadyCom')); cd(fileDir); % Make sure, that no old data exists! -if isfolder([fileDir filesep 'testSteadyComFVAsave']) - fprintf('The save folder exists and will be deleted at %s\n', [fileDir filesep 'testSteadyComFVAsave'] ); +if exist([fileDir filesep 'testSteadyComFVAsave']) rmdir([fileDir filesep 'testSteadyComFVAsave'],'s'); end From 458a0be607f661cb73bc9e563bc8c902b0476d85 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 11:03:09 +0100 Subject: [PATCH 26/29] Revert "Temporary Restrict tests" This reverts commit dfde74f3251c69d26784e70a18c9efd701df03b5. --- test/runTestSuite.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runTestSuite.m b/test/runTestSuite.m index c11308fd5f..9777003c39 100644 --- a/test/runTestSuite.m +++ b/test/runTestSuite.m @@ -36,7 +36,7 @@ currentDir = cd(testDir); % get all names of test files -testFiles = rdir(['verifiedTests' filesep '**' filesep 'testSteadyCom*.m']); +testFiles = rdir(['verifiedTests' filesep '**' filesep 'test*.m']); testFileNames = {testFiles.name}; testFileNames = testFileNames(~cellfun(@(x) isempty(regexp(x,testNames,'ONCE')),testFileNames)); From 85d2647201eb87a454aeabc921d0a31739042845 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 11:03:19 +0100 Subject: [PATCH 27/29] Revert "Further printout adjustments" This reverts commit cd1afed8c3e98ea3a8c5323065c711cb5a183ed2. --- .../multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m | 2 -- test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m b/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m index 95a5c1e621..756ead86fb 100644 --- a/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m +++ b/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m @@ -308,7 +308,6 @@ % continue from previous saved file if ~isempty(saveFVA) if exist([saveFVA '.mat'], 'file') - fprintf('In non parallel mode found save file at %s\n', which([saveFVA '.mat'])); load([saveFVA '.mat'], 'i0', 'minFlux', 'maxFlux', 'minFD', 'maxFD'); if i0 == nRxnFVA fprintf('FVA was already finished previously and saved in %s.mat.\n', saveFVA); @@ -374,7 +373,6 @@ if ~isempty(saveFVA) %check if previous results from single-thread computation exist if exist([saveFVA '.mat'], 'file') - fprintf('In parallel mode found save file at %s\n', which([saveFVA '.mat'])); load([saveFVA '.mat'], 'i0'); i0P = i0; clear i0 diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index 33d7e46b48..26bdf40587 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -489,8 +489,8 @@ end % remove all created files - rmdir([fileDir filesep 'testSteadyComFVAsave'], 's') - rmdir([fileDir filesep 'testSteadyComFVAsavePar'], 's') + rmdir([pwd filesep 'testSteadyComFVAsave'], 's') + rmdir([pwd filesep 'testSteadyComFVAsavePar'], 's') else disp('Skipping Parallel Test, No Parallel toolbox installed'); end From 012dd59681f8dba093ee04a4418acdd208d95476 Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 11:03:28 +0100 Subject: [PATCH 28/29] Revert "Cleanup before the test" This reverts commit 9a00db5623e50b481cc1400925b7f93cf6ff0358. --- src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m | 11 +++++++---- .../SteadyCom/subroutines/SteadyComFVAgr.m | 9 ++++++--- .../analysis/testSteadyCom/testSteadyCom.m | 7 +------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m b/src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m index 9c327968eb..3c5fcf43b3 100644 --- a/src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m +++ b/src/analysis/multiSpecies/SteadyCom/SteadyComFVA.m @@ -286,11 +286,14 @@ kDisp = 0; end end - [folder,filename] = fileparts(saveFVA); - if ~isempty(folder) && ~isfolder(folder) + directory = strsplit(saveFVA,filesep); + if numel(directory) > 1 % not saving in the current directory. Create the directory. - mkdir(folder); - end + directory = strjoin([{pwd}, directory(1:end-1)],filesep); + if ~exist(directory, 'dir') + mkdir(directory); + end + end if ibm_cplex LPmodel = LP.Model; % the Cplex dynamic object is not good for saving LPstart = LP.Start; diff --git a/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m b/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m index 756ead86fb..e10ed64e66 100644 --- a/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m +++ b/src/analysis/multiSpecies/SteadyCom/subroutines/SteadyComFVAgr.m @@ -279,10 +279,13 @@ end % check save directory if ~isempty(saveFVA) - [directory,filename] = fileparts(saveFVA); - if ~isempty(directory) && ~isdir(directory) + directory = strsplit(saveFVA,filesep); + if numel(directory) > 1 % not saving in the current directory. Check existence - mkdir(directory); + directory = strjoin([{pwd}, directory(1:end-1)],filesep); + if ~exist(directory, 'dir') + mkdir(directory); + end end end if verbFlag diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index 26bdf40587..ef11a97b54 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -21,11 +21,6 @@ % initialize the test fileDir = fileparts(which('testSteadyCom')); cd(fileDir); -% Make sure, that no old data exists! -if exist([fileDir filesep 'testSteadyComFVAsave']) - rmdir([fileDir filesep 'testSteadyComFVAsave'],'s'); -end - %Test for parallel toolbox try poolobj = gcp('nocreate');% create a toy model @@ -346,7 +341,7 @@ if abs(vRef(j3)) < 1e-5 assert(abs(vRef(j3) - v(j3)) < 1e-5) else - fprintf('%2.8f <-> %2.8f\n', vRef(j3), v(j3)); + fprintf('%2.8f <-> %2.8f', vRef(j3), v(j3)); assert(abs(vRef(j3) - v(j3)) / abs(vRef(j3)) < tolPercent) end end From 08b1fd2fd07cceaad53d94617c9fcc50ea2e012a Mon Sep 17 00:00:00 2001 From: Thomas Pfau Date: Fri, 9 Nov 2018 11:03:35 +0100 Subject: [PATCH 29/29] Revert "Increase test verbosity to deterine error" This reverts commit 25f3b88ad2c3b4278a93af187a302c00256175f8. --- test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m index ef11a97b54..fc6ecdccc7 100644 --- a/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m +++ b/test/verifiedTests/analysis/testSteadyCom/testSteadyCom.m @@ -340,8 +340,7 @@ for j3 = 1:numel(vRef) if abs(vRef(j3)) < 1e-5 assert(abs(vRef(j3) - v(j3)) < 1e-5) - else - fprintf('%2.8f <-> %2.8f', vRef(j3), v(j3)); + else assert(abs(vRef(j3) - v(j3)) / abs(vRef(j3)) < tolPercent) end end