function y = testReadFromFile1 filename = fullfile(pwd,'test-data', 'l1v1-branch.xml'); notes1 = sprintf('%s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n%s', ... '', ... '', ... '

Simple branch system.

', ... '

The reaction looks like this:

', ... '

reaction-1: X0 -> S1; k1*X0;

', ... '

reaction-2: S1 -> X1; k2*S1;

', ... '

reaction-3: S1 -> X2; k3*S1;

', ... '', ... '
'); m = TranslateSBML(filename); test = 70; Totalfail = 0; Totalfail = Totalfail + fail_unless(m.SBML_level == 1); Totalfail = Totalfail + fail_unless(m.SBML_version == 1); Totalfail = Totalfail + fail_unless(strcmp(m.name,'Branch')); Totalfail = Totalfail + fail_unless(strcmp(m.notes, notes1)); % /** % * % * % * % */ Totalfail = Totalfail + fail_unless( length(m.compartment) == 1); Totalfail = Totalfail + fail_unless( strcmp(m.compartment.name, 'compartmentOne')); Totalfail = Totalfail + fail_unless( m.compartment.volume == 1); % /** % * % * % * % * % * % * % */ Totalfail = Totalfail + fail_unless( length(m.species) == 4); Totalfail = Totalfail + fail_unless( strcmp( m.species(1).name, 'S1' )); Totalfail = Totalfail + fail_unless( strcmp( m.species(1).compartment, 'compartmentOne' )); Totalfail = Totalfail + fail_unless( m.species(1).initialAmount == 0); Totalfail = Totalfail + fail_unless( m.species(1).boundaryCondition == 0); Totalfail = Totalfail + fail_unless( strcmp( m.species(2).name, 'X0' )); Totalfail = Totalfail + fail_unless( strcmp( m.species(2).compartment, 'compartmentOne' )); Totalfail = Totalfail + fail_unless( m.species(2).initialAmount == 0); Totalfail = Totalfail + fail_unless( m.species(2).boundaryCondition == 1); Totalfail = Totalfail + fail_unless( strcmp( m.species(3).name, 'X1' )); Totalfail = Totalfail + fail_unless( strcmp( m.species(3).compartment, 'compartmentOne' )); Totalfail = Totalfail + fail_unless( m.species(3).initialAmount == 0); Totalfail = Totalfail + fail_unless( m.species(3).boundaryCondition == 1); Totalfail = Totalfail + fail_unless( strcmp( m.species(4).name, 'X2' )); Totalfail = Totalfail + fail_unless( strcmp( m.species(4).compartment, 'compartmentOne' )); Totalfail = Totalfail + fail_unless( m.species(4).initialAmount == 0); Totalfail = Totalfail + fail_unless( m.species(4).boundaryCondition == 1); % % /** % * % * ... % * ... % * ... % * % */ Totalfail = Totalfail + fail_unless( length(m.reaction) == 3); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).name, 'reaction_1')); Totalfail = Totalfail + fail_unless( m.reaction(1).reversible == 0); Totalfail = Totalfail + fail_unless( m.reaction(1).fast == 0); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(2).name, 'reaction_2')); Totalfail = Totalfail + fail_unless( m.reaction(2).reversible == 0); Totalfail = Totalfail + fail_unless( m.reaction(2).fast == 0); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(3).name, 'reaction_3')); Totalfail = Totalfail + fail_unless( m.reaction(3).reversible == 0); Totalfail = Totalfail + fail_unless( m.reaction(3).fast == 0); % % /** % * % * % * % * % * % * % * % * % * % * % * % * % * % */ % Totalfail = Totalfail + fail_unless( length(m.reaction(1).reactant) == 1); Totalfail = Totalfail + fail_unless( length(m.reaction(1).product) == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).reactant.species, 'X0')); Totalfail = Totalfail + fail_unless( m.reaction(1).reactant.stoichiometry == 1); Totalfail = Totalfail + fail_unless( m.reaction(1).reactant.denominator == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).product.species, 'S1')); Totalfail = Totalfail + fail_unless( m.reaction(1).product.stoichiometry == 1); Totalfail = Totalfail + fail_unless( m.reaction(1).product.denominator == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).kineticLaw.formula, 'k1*X0')); Totalfail = Totalfail + fail_unless(length(m.reaction(1).kineticLaw.parameter) == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(1).kineticLaw.parameter.name, 'k1')); Totalfail = Totalfail + fail_unless( m.reaction(1).kineticLaw.parameter.value == 0); % % % /** % * % * % * % * % * % * % * % * % * % * % * % * % * % */ Totalfail = Totalfail + fail_unless( length(m.reaction(2).reactant) == 1); Totalfail = Totalfail + fail_unless( length(m.reaction(2).product) == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(2).reactant.species, 'S1')); Totalfail = Totalfail + fail_unless( m.reaction(2).reactant.stoichiometry == 1); Totalfail = Totalfail + fail_unless( m.reaction(2).reactant.denominator == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(2).product.species, 'X1')); Totalfail = Totalfail + fail_unless( m.reaction(2).product.stoichiometry == 1); Totalfail = Totalfail + fail_unless( m.reaction(2).product.denominator == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(2).kineticLaw.formula, 'k2*S1')); Totalfail = Totalfail + fail_unless(length(m.reaction(2).kineticLaw.parameter) == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(2).kineticLaw.parameter.name, 'k2')); Totalfail = Totalfail + fail_unless( m.reaction(2).kineticLaw.parameter.value == 0); % % /** % * % * % * % * % * % * % * % * % * % * % * % * % * % */ Totalfail = Totalfail + fail_unless( length(m.reaction(3).reactant) == 1); Totalfail = Totalfail + fail_unless( length(m.reaction(3).product) == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(3).reactant.species, 'S1')); Totalfail = Totalfail + fail_unless( m.reaction(3).reactant.stoichiometry == 1); Totalfail = Totalfail + fail_unless( m.reaction(3).reactant.denominator == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(3).product.species, 'X2')); Totalfail = Totalfail + fail_unless( m.reaction(3).product.stoichiometry == 1); Totalfail = Totalfail + fail_unless( m.reaction(3).product.denominator == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(3).kineticLaw.formula, 'k3*S1')); Totalfail = Totalfail + fail_unless(length(m.reaction(3).kineticLaw.parameter) == 1); Totalfail = Totalfail + fail_unless( strcmp(m.reaction(3).kineticLaw.parameter.name, 'k3')); Totalfail = Totalfail + fail_unless( m.reaction(3).kineticLaw.parameter.value == 0); disp('Testing readFromFile1:'); disp(sprintf('Number tests: %d', test)); disp(sprintf('Number fails: %d', Totalfail)); disp(sprintf('Pass rate: %d%%\n', ((test-Totalfail)/test)*100)); if (Totalfail == 0) y = 0; else y = 1; end; function y = fail_unless(arg) if (~arg) y = 1; else y = 0; end;