Home > testing > unit_tests > fillGapsLargeTests.m

fillGapsLargeTests

PURPOSE ^

run this test case with the command

SYNOPSIS ^

function tests = fillGapsLargeTests

DESCRIPTION ^

run this test case with the command
results = runtests('fillGapsLargeTests.m')

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %run this test case with the command
0002 %results = runtests('fillGapsLargeTests.m')
0003 function tests = fillGapsLargeTests
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','Gurobi error 10003'}) % Expected error codes, others may indicate problems with license
0011            testGurobi = false;
0012         end
0013     end
0014 end
0015 if ~testGurobi
0016     disp('Gurobi not installed or not functional, some fillGapsLargeTests 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 fillGapsLargeTests skipped.')
0022     skipTests = contains({tests.Name},'scip','IgnoreCase',true);
0023     tests(skipTests) = [];
0024 end
0025 end
0026 
0027 function testLargeGurobi(testCase)
0028 sourceDir = fileparts(fileparts(fileparts(which(mfilename))));
0029 evalc('model=importModel(fullfile(sourceDir,''tutorial'',''iAL1006 v1.00.xml''))');
0030 model.c(1484)=1;
0031 modelDB=model; % Keep as database with reactions
0032 try
0033     oldSolver=getpref('RAVEN','solver');
0034 catch
0035 end
0036 setRavenSolver('gurobi');
0037 
0038 %Remove first 10 reactions
0039 model=removeReactions(modelDB,(1:10));
0040 modelDB.id='DB';
0041 try
0042     evalc('[newConnected,cannotConnect,addedRxns,model,exitFlag]=fillGaps(model,modelDB,false,false)');
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 %Expect at least 5% of the original growth
0058 verifyTrue(testCase,sol.f>0);
0059 end
0060 
0061 function testLargeSCIP(testCase)
0062 sourceDir = fileparts(fileparts(fileparts(which(mfilename))));
0063 evalc('model=importModel(fullfile(sourceDir,''tutorial'',''iAL1006 v1.00.xml''))');
0064 model.c(1484)=1;
0065 modelDB=model; % Keep as database with reactions
0066 % Force growth in gapped model
0067 sol=solveLP(model);
0068 model.lb(1484)=sol.f*0.1;
0069 try
0070     oldSolver=getpref('RAVEN','solver');
0071 catch
0072 end
0073 setRavenSolver('scip');
0074 
0075 %Remove first 10 reactions
0076 model=removeReactions(model,(1:10));
0077 modelDB.id='DB';
0078 try
0079     evalc('[newConnected,cannotConnect,addedRxns,model,exitFlag]=fillGaps(model,modelDB,false,true)');
0080 catch
0081     try
0082         setRavenSolver(oldSolver);
0083     catch
0084         rmpref('RAVEN','solver');
0085     end
0086     error('Solver not working')
0087 end
0088 sol=solveLP(model);
0089 try
0090     setRavenSolver(oldSolver);
0091 catch
0092     rmpref('RAVEN','solver');
0093 end
0094 %Expect at least 5% of the original growth
0095 verifyTrue(testCase,sol.f>0);
0096 end

Generated by m2html © 2005