1function y = testReadWriteGeneProducts(silent, outdir) 2 3if (~isdir(outdir)) 4 mkdir (outdir); 5end; 6Totalfail = 0; 7test = 0; 8 9filename = fullfile(pwd,'test-data', 'fbcV2Labels.xml'); 10fileout1 = 'outGP10.xml'; 11fileout2 = 'outGP11.xml'; 12fileout3 = 'outGP01.xml'; 13fileout4 = 'outGP00.xml'; 14 15m = TranslateSBML(filename, 0, 0, [1,0]); 16 17[Totalfail, test] = runTest(Totalfail, test, fail_unless( length(m.fbc_geneProduct) == 2)); 18[Totalfail, test] = runTest(Totalfail, test, fail_unless( strcmp(m.reaction(1).fbc_geneProductAssociation.fbc_association.fbc_association, 'g_1'))); 19[Totalfail, test] = runTest(Totalfail, test, fail_unless( strcmp(m.reaction(2).fbc_geneProductAssociation.fbc_association.fbc_association, '(g_1 or g_2)'))); 20 21% adjust the association 22m.reaction(1).fbc_geneProductAssociation.fbc_association.fbc_association = 'g_3'; 23OutputSBML(m, [outdir, filesep, fileout1], 0, 0, [1,0]); 24 25test = test + 1; 26if (compareFiles(['test-data', filesep, fileout1], [outdir, filesep, fileout1])) 27 disp(sprintf('Output of %s failed', fileout1)); 28 Totalfail = Totalfail + 1; 29end; 30 31m = TranslateSBML(filename, 0, 0, [1,1]); 32% adjust the association 33m.reaction(1).fbc_geneProductAssociation.fbc_association.fbc_association = 'g_3'; 34OutputSBML(m, [outdir, filesep, fileout2], 0, 0, [1,1]); 35 36test = test + 1; 37if (compareFiles(['test-data', filesep, fileout2], [outdir, filesep, fileout2])) 38 disp(sprintf('Output of %s failed', fileout2)); 39 Totalfail = Totalfail + 1; 40end; 41 42m = TranslateSBML(filename, 0, 0, [0,1]); 43% adjust the association 44m.reaction(1).fbc_geneProductAssociation.fbc_association.fbc_association = 'g_3'; 45OutputSBML(m, [outdir, filesep, fileout3], 0, 0, [0,1]); 46 47test = test + 1; 48if (compareFiles(['test-data', filesep, fileout3], [outdir, filesep, fileout3])) 49 disp(sprintf('Output of %s failed', fileout3)); 50 Totalfail = Totalfail + 1; 51end; 52 53m = TranslateSBML(filename, 0, 0, [0,0]); 54% adjust the association 55m.reaction(1).fbc_geneProductAssociation.fbc_association.fbc_association = 'g_3'; 56OutputSBML(m, [outdir, filesep, fileout4], 0, 0, [0,0]); 57 58test = test + 1; 59if (compareFiles(['test-data', filesep, fileout4], [outdir, filesep, fileout4])) 60 disp(sprintf('Output of %s failed', fileout4)); 61 Totalfail = Totalfail + 1; 62end; 63 64 65 66if (silent == 0) 67disp('Testing testReadWriteGeneProduct :'); 68disp(sprintf('Number tests: %d', test)); 69disp(sprintf('Number fails: %d', Totalfail)); 70disp(sprintf('Pass rate: %d%%\n', ((test-Totalfail)/test)*100)); 71end; 72 73if (Totalfail == 0) 74 y = 0; 75else 76 y = 1; 77end; 78 79 80function [f, t] = runTest(f1, t1, y) 81 f = f1 + y; 82 t = t1 + 1; 83 84 85function y = fail_unless(arg) 86 87if (~arg) 88 y = 1; 89else 90 y = 0; 91end; 92