0001
0002
0003 function tests = fillGapsSmallTests
0004 tests = functiontests(localfunctions);
0005 testGurobi = exist('gurobi','file')==3;
0006 if testGurobi
0007 try
0008 gurobi_read('solverTests.m');
0009 catch ME
0010 if ~startsWith(ME.message,'Gurobi error 10012')
0011 testGurobi = false;
0012 end
0013 end
0014 end
0015 if ~testGurobi
0016 disp('Gurobi not installed or not functional, some fillGapsSmallTests skipped.')
0017 skipTests = contains({tests.Name},'gurobi','IgnoreCase',true);
0018 tests(skipTests) = [];
0019 end
0020 if exist('scip','file')~=3
0021 disp('SCIP MEX binary not installed or not functional, some fillGapsSmallTests skipped.')
0022 skipTests = contains({tests.Name},'scip','IgnoreCase',true);
0023 tests(skipTests) = [];
0024 end
0025 end
0026
0027 function testSmallSCIP(testCase)
0028
0029 sourceDir = fileparts(which(mfilename));
0030 load([sourceDir,'/test_data/ecoli_textbook.mat'], 'model');
0031 modelDB=model;
0032 try
0033 oldSolver=getpref('RAVEN','solver');
0034 catch
0035 end
0036 setRavenSolver('scip');
0037
0038
0039 model=removeReactions(modelDB,(1:10));
0040 modelDB.id='DB';
0041 try
0042 evalc('[newConnected,cannotConnect,addedRxns,model,exitFlag]=fillGaps(model,modelDB)');
0043 catch
0044 try
0045 setRavenSolver(oldSolver);
0046 catch
0047 rmpref('RAVEN','solver');
0048 end
0049 error('Solver not working')
0050 end
0051 sol=solveLP(model);
0052 try
0053 setRavenSolver(oldSolver);
0054 catch
0055 rmpref('RAVEN','solver');
0056 end
0057
0058 verifyTrue(testCase,sol.f>0);
0059 end
0060
0061 function testSmallGurobi(testCase)
0062
0063 sourceDir = fileparts(which(mfilename));
0064 load([sourceDir,'/test_data/ecoli_textbook.mat'], 'model');
0065 modelDB=model;
0066 try
0067 oldSolver=getpref('RAVEN','solver');
0068 catch
0069 end
0070 setRavenSolver('gurobi');
0071
0072
0073 model=removeReactions(modelDB,(1:10));
0074
0075 modelDB.id='DB';
0076 try
0077 evalc('[newConnected,cannotConnect,addedRxns,model,exitFlag]=fillGaps(model,modelDB)');
0078 catch
0079 try
0080 setRavenSolver(oldSolver);
0081 catch
0082 rmpref('RAVEN','solver');
0083 end
0084 error('Solver not working')
0085 end
0086 sol=solveLP(model);
0087 try
0088 setRavenSolver(oldSolver);
0089 catch
0090 rmpref('RAVEN','solver');
0091 end
0092
0093 verifyTrue(testCase,sol.f>0);
0094 end