0001
0002
0003 function tests = modelSortingTests
0004 tests = functiontests(localfunctions);
0005 end
0006
0007 function sortIdentifirs_and_permuteModelTest(testCase)
0008
0009
0010 sourceDir = fileparts(which(mfilename));
0011 load([sourceDir,'/test_data/ecoli_textbook.mat'], 'model');
0012 expModel = model;
0013
0014
0015 actModel = expModel;
0016
0017
0018 rndIdx = randperm(numel(actModel.rxns));
0019 fieldsToChange = {'rxns','lb','ub','rev','c','rxnNames','grRules','eccodes'};
0020 for i=1:numel(fieldsToChange)
0021 actModel.(fieldsToChange{i}) = actModel.(fieldsToChange{i})(rndIdx);
0022 end
0023 actModel.S = actModel.S(:,rndIdx);
0024 actModel.rxnGeneMat = actModel.rxnGeneMat(rndIdx,:);
0025
0026 rndIdx = randperm(numel(actModel.mets));
0027 fieldsToChange = {'mets','metNames','metComps','metFormulas','metMiriams'};
0028 for i=1:numel(fieldsToChange)
0029 actModel.(fieldsToChange{i}) = actModel.(fieldsToChange{i})(rndIdx);
0030 end
0031 actModel.S = actModel.S(rndIdx,:);
0032
0033 rndIdx = randperm(numel(actModel.genes));
0034 fieldsToChange = {'genes','geneShortNames'};
0035 for i=1:numel(fieldsToChange)
0036 actModel.(fieldsToChange{i}) = actModel.(fieldsToChange{i})(rndIdx);
0037 end
0038 actModel.rxnGeneMat = actModel.rxnGeneMat(:,rndIdx);
0039
0040 rndIdx = randperm(numel(actModel.comps));
0041 fieldsToChange = {'comps','compNames'};
0042 for i=1:numel(fieldsToChange)
0043 actModel.(fieldsToChange{i}) = actModel.(fieldsToChange{i})(rndIdx);
0044 end
0045 [~,J]=sort(rndIdx);
0046 [toreplace, bywhat] = ismember(actModel.metComps,1:length(J));
0047 actModel.metComps(toreplace) = J(bywhat(toreplace));
0048
0049
0050 actModel = sortIdentifiers(actModel);
0051
0052
0053 verifyEqual(testCase,actModel,expModel)
0054 end
0055
0056 function expandModel_and_contractModelTest(testCase)
0057
0058 sourceDir = fileparts(which(mfilename));
0059 load([sourceDir,'/test_data/ecoli_textbook.mat'], 'model');
0060
0061
0062
0063 evalc('modelNew = expandModel(model);');
0064 modelNew = contractModel(modelNew);
0065
0066 verifyEqual(testCase,model,modelNew)
0067 end
0068