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