1function y = testReadFromFile8(silent) 2 3filename = fullfile(pwd,'test-data', 'l2v3-newelements.xml'); 4 5m = TranslateSBML(filename); 6 7test = 37; 8Totalfail = 0; 9 10Totalfail = Totalfail + fail_unless(m.SBML_level == 2); 11Totalfail = Totalfail + fail_unless(m.SBML_version == 3); 12 13Totalfail = Totalfail + fail_unless(m.sboTerm == 4); 14 15% <listOfCompartmentTypes> 16% <compartmentType id="mitochondria"/> 17% </listOfCompartmentTypes> 18 19 Totalfail = Totalfail + fail_unless( length(m.compartmentType) == 1); 20 21 Totalfail = Totalfail + fail_unless( strcmp(m.compartmentType.id, 'mitochondria')); 22 Totalfail = Totalfail + fail_unless( m.compartmentType.sboTerm == 236); 23 24% <listOfSpeciesTypes> 25% <speciesType id="Glucose"/> 26% </listOfSpeciesTypes> 27 28 Totalfail = Totalfail + fail_unless( length(m.speciesType) == 1); 29 30 Totalfail = Totalfail + fail_unless( strcmp(m.speciesType.id, 'Glucose')); 31 32 33% // 34% // <listOfCompartments> 35% <compartment id="cell" size="0.013" compartmentType="mitochondria" outside="m"/> 36% <compartment id="m" size="0.013" compartmentType="mitochondria"/> 37% // </listOfCompartments> 38% // 39 40 Totalfail = Totalfail + fail_unless( length(m.compartment) == 2); 41 42 Totalfail = Totalfail + fail_unless( strcmp(m.compartment(1).id, 'cell')); 43 Totalfail = Totalfail + fail_unless( m.compartment(1).size == 0.013); 44 Totalfail = Totalfail + fail_unless( strcmp(m.compartment(1).compartmentType, 'mitochondria')); 45 Totalfail = Totalfail + fail_unless( strcmp(m.compartment(1).outside, 'm')); 46 47 Totalfail = Totalfail + fail_unless( strcmp(m.compartment(2).id, 'm')); 48 Totalfail = Totalfail + fail_unless( m.compartment(2).size == 0.013); 49 Totalfail = Totalfail + fail_unless( strcmp(m.compartment(2).compartmentType, 'mitochondria')); 50 51% // 52% // <listOfSpecies> 53% <species id="X0" compartment="cell" speciesType="Glucose"/> 54% // </listOfSpecies> 55% // 56 57 Totalfail = Totalfail + fail_unless( length(m.species) == 2); 58 59 Totalfail = Totalfail + fail_unless( strcmp( m.species(1).id, 'X0' )); 60 Totalfail = Totalfail + fail_unless( strcmp( m.species(1).compartment, 'cell' )); 61 Totalfail = Totalfail + fail_unless( strcmp( m.species(1).speciesType, 'Glucose' )); 62 63% <listOfInitialAssignments> 64% <initialAssignment symbol="X0"> 65% <math xmlns="http://www.w3.org/1998/Math/MathML"> 66% <apply> 67% <times/> 68% <ci> y </ci> 69% <cn> 2 </cn> 70% </apply> 71% </math> 72% </initialAssignment> 73% </listOfInitialAssignments> 74 75 Totalfail = Totalfail + fail_unless( length(m.initialAssignment) == 1); 76 77 Totalfail = Totalfail + fail_unless( strcmp( m.initialAssignment(1).symbol, 'X0' )); 78 Totalfail = Totalfail + fail_unless( strcmp( m.initialAssignment(1).math, 'y*2' )); 79 Totalfail = Totalfail + fail_unless( m.initialAssignment(1).sboTerm == 64); 80 81% <listOfConstraints> 82% <constraint> 83% <math xmlns="http://www.w3.org/1998/Math/MathML"> 84% <apply> 85% <lt/> 86% <cn> 1 </cn> 87% <ci> cell </ci> 88% </apply> 89% </math> 90% <message> 91% <p xmlns="http://www.w3.org/1999/xhtml"> 92% Species S1 is out of range 93% </p> 94% </message> 95% </constraint> 96% </listOfConstraints> 97 98 Totalfail = Totalfail + fail_unless( length(m.constraint) == 1); 99 100 Totalfail = Totalfail + fail_unless( strcmp( m.constraint(1).math, 'lt(1,cell)' )); 101 message = sprintf('%s\n%s\n%s\n%s\n%s', ... 102'<message>', ... 103' <p xmlns="http://www.w3.org/1999/xhtml">', ... 104' Species S1 is out of range ', ... 105' </p>', ... 106'</message>'); 107 Totalfail = Totalfail + fail_unless( strcmp( m.constraint(1).message, message )); 108 109% // 110% // <listOfReactions> ... </listOfReactions> 111% // 112 113 Totalfail = Totalfail + fail_unless( length(m.reaction) == 1); 114 115% <listOfReactions> 116% <reaction id="in" sboTerm="0000005"> 117% <listOfReactants> 118% <speciesReference species="X0" id="me" name="sarah"/> 119% </listOfReactants> 120% </reaction> 121% </listOfReactions> 122 123 Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).id, 'in')); 124 Totalfail = Totalfail + fail_unless( m.reaction(1).sboTerm == 231); 125 Totalfail = Totalfail + fail_unless( m.reaction(1).reversible == 1); 126 127 Totalfail = Totalfail + fail_unless( length(m.reaction(1).reactant) == 1); 128 Totalfail = Totalfail + fail_unless( length(m.reaction(1).product) == 0); 129 130 Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).reactant.species, 'X0')); 131 Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).reactant.id, 'me')); 132 Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).reactant.name, 'sarah')); 133 134if (silent == 0) 135disp('Testing readFromFile8:'); 136disp(sprintf('Number tests: %d', test)); 137disp(sprintf('Number fails: %d', Totalfail)); 138disp(sprintf('Pass rate: %d%%\n', ((test-Totalfail)/test)*100)); 139end; 140 141if (Totalfail == 0) 142 y = 0; 143else 144 y = 1; 145end; 146 147function y = fail_unless(arg) 148 149if (~arg) 150 y = 1; 151else 152 y = 0; 153end; 154 155