1function y = testReadFromFileFbc2(silent)
2
3filename = fullfile(pwd,'test-data', 'fbcV2.xml');
4
5m = TranslateSBML(filename);
6
7test = 58;
8Totalfail = 0;
9
10Totalfail = Totalfail + fail_unless(m.SBML_level == 3);
11Totalfail = Totalfail + fail_unless(m.SBML_version == 1);
12Totalfail = Totalfail + fail_unless(m.fbc_version == 2);
13Totalfail = Totalfail + fail_unless(m.fbc_strict == 1);
14
15
16%     <listOfSpecies>
17%      <species id="S" compartment="c" hasOnlySubstanceUnits="false"
18%                        boundaryCondition="false" constant="false"
19%                        fbc:charge="2" fbc:chemicalFormula="s20"/>
20%       <species id="S1" compartment="c" hasOnlySubstanceUnits="false"
21%                        boundaryCondition="false" constant="false"
22%                        fbc:charge="2" fbc:chemicalFormula="s20"/>
23%       <species id="S2" compartment="c" hasOnlySubstanceUnits="false"
24%                        boundaryCondition="false" constant="false"/>
25%       <species id="S3" compartment="c" hasOnlySubstanceUnits="false"
26%                        boundaryCondition="false" constant="false"
27%                        fbc:charge="2" fbc:chemicalFormula="s20"/>
28%       <species id="S4" compartment="c" hasOnlySubstanceUnits="false"
29%                        boundaryCondition="false" constant="false"
30%                        fbc:charge="2" fbc:chemicalFormula="s20"/>
31%     </listOfSpecies>
32
33  Totalfail = Totalfail + fail_unless( length(m.species) == 5);
34
35  Totalfail = Totalfail + fail_unless( strcmp( m.species(1).id, 'S'             ));
36  Totalfail = Totalfail + fail_unless( strcmp( m.species(1).compartment, 'comp1' ));
37  Totalfail = Totalfail + fail_unless( m.species(1).isSetInitialAmount == 1);
38  Totalfail = Totalfail + fail_unless( m.species(1).isSetInitialConcentration == 0);
39  Totalfail = Totalfail + fail_unless( m.species(1).fbc_charge == 2);
40  Totalfail = Totalfail + fail_unless( m.species(1).isSetfbc_charge == 1);
41  Totalfail = Totalfail + fail_unless( strcmp( m.species(1).fbc_chemicalFormula, 'S20'             ));
42
43  Totalfail = Totalfail + fail_unless( strcmp( m.species(2).id, 'S1'             ));
44  Totalfail = Totalfail + fail_unless( strcmp( m.species(2).compartment, 'comp1' ));
45  Totalfail = Totalfail + fail_unless( m.species(2).isSetInitialAmount == 1);
46  Totalfail = Totalfail + fail_unless( m.species(2).isSetInitialConcentration == 0);
47  Totalfail = Totalfail + fail_unless( m.species(2).fbc_charge == 2);
48  Totalfail = Totalfail + fail_unless( m.species(2).isSetfbc_charge == 1);
49  Totalfail = Totalfail + fail_unless( strcmp( m.species(2).fbc_chemicalFormula, 'S20'             ));
50
51  Totalfail = Totalfail + fail_unless( strcmp( m.species(3).id, 'S2'             ));
52  Totalfail = Totalfail + fail_unless( strcmp( m.species(3).compartment, 'comp1' ));
53  Totalfail = Totalfail + fail_unless( m.species(3).isSetInitialAmount == 1);
54  Totalfail = Totalfail + fail_unless( m.species(3).isSetInitialConcentration == 0);
55  Totalfail = Totalfail + fail_unless( m.species(3).isSetfbc_charge == 0);
56  Totalfail = Totalfail + fail_unless( ~isempty( m.species(2).fbc_chemicalFormula));
57
58  Totalfail = Totalfail + fail_unless( m.species(3).level == 3);
59  Totalfail = Totalfail + fail_unless( m.species(3).version == 1);
60  Totalfail = Totalfail + fail_unless( m.species(3).fbc_version == 2);
61
62
63%     <fbc:listOfObjectives activeObjective="obj1">
64%       <fbc:objective id="c" type="maximize">
65%         <fbc:listOfFluxes>
66%           <fbc:fluxObjective reaction="J8" coefficient="1"/>
67%           <fbc:fluxObjective fbc:reaction="J8"/>
68%         </fbc:listOfFluxes>
69%       </fbc:objective>
70%     </fbc:listOfObjectives>
71
72  Totalfail = Totalfail + fail_unless( length(m.fbc_objective) == 1);
73
74  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_objective(1).typecode, 'SBML_FBC_OBJECTIVE'));
75  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_objective(1).fbc_id, 'c'));
76  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_objective(1).fbc_type, 'maximize'));
77
78  Totalfail = Totalfail + fail_unless( length(m.fbc_objective(1).fbc_fluxObjective) == 1);
79
80  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_objective(1).fbc_fluxObjective(1).typecode, 'SBML_FBC_FLUXOBJECTIVE'));
81  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_objective(1).fbc_fluxObjective(1).fbc_reaction, 'R1'));
82  Totalfail = Totalfail + fail_unless( m.fbc_objective(1).fbc_fluxObjective(1).fbc_coefficient == 1);
83  Totalfail = Totalfail + fail_unless( m.fbc_objective(1).fbc_fluxObjective(1).isSetfbc_coefficient == 1);
84
85  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_activeObjective, 'c'));
86
87  %    <fbc:listOfGeneProducts>
88  %     <fbc:geneProduct fbc:id="g_1" fbc:label="b1"/>
89  %   </fbc:listOfGeneProducts>
90
91  Totalfail = Totalfail + fail_unless( length(m.fbc_geneProduct) == 2);
92
93  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_geneProduct(1).typecode, 'SBML_FBC_GENE_PRODUCT'));
94  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_geneProduct(1).fbc_id, 'g_1'));
95  Totalfail = Totalfail + fail_unless( strcmp(m.fbc_geneProduct(1).fbc_label, 'g_1'));
96
97%         <fbc:geneProductAssociation fbc:id="gg1">
98%             <fbc:geneProductRef fbc:geneProduct="g_1"/>
99%          </fbc:geneProductAssociation>
100
101  gpa = m.reaction(1).fbc_geneProductAssociation;
102
103  Totalfail = Totalfail + fail_unless( strcmp(gpa.typecode, 'SBML_FBC_GENE_PRODUCT_ASSOCIATION'));
104  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_id, 'gg1'));
105
106  Totalfail = Totalfail + fail_unless( length(gpa.fbc_association) == 1);
107
108  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_association.typecode, 'SBML_FBC_GENE_PRODUCT_REF'));
109  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_association.fbc_association, 'g_1'));
110
111%        <fbc:geneProductAssociation fbc:id="gg1">
112%           <fbc:or metaid="ss">
113%             <fbc:geneProductRef fbc:geneProduct="g_1"/>
114%             <fbc:geneProductRef fbc:geneProduct="g_2"/>
115%           </fbc:or>
116%         </fbc:geneProductAssociation>
117
118  gpa = m.reaction(2).fbc_geneProductAssociation;
119
120  Totalfail = Totalfail + fail_unless( strcmp(gpa.typecode, 'SBML_FBC_GENE_PRODUCT_ASSOCIATION'));
121  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_id, 'gg2'));
122
123  Totalfail = Totalfail + fail_unless( length(gpa.fbc_association) == 1);
124
125  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_association.typecode, 'SBML_FBC_OR'));
126  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_association.fbc_association, '(g_1 or g_2)'));
127
128%         <fbc:geneProductAssociation fbc:id="gg3">
129%           <fbc:or metaid="ss">
130%             <fbc:geneProductRef fbc:geneProduct="g_1"/>
131%             <fbc:geneProductRef fbc:geneProduct="g_2"/>
132%             <fbc:and>
133%               <fbc:geneProductRef fbc:geneProduct="g_1"/>
134%               <fbc:geneProductRef fbc:geneProduct="g_2"/>
135%             </fbc:and>
136%           </fbc:or>
137%         </fbc:geneProductAssociation>
138
139  gpa = m.reaction(3).fbc_geneProductAssociation;
140
141  Totalfail = Totalfail + fail_unless( strcmp(gpa.typecode, 'SBML_FBC_GENE_PRODUCT_ASSOCIATION'));
142  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_id, 'gg3'));
143
144  Totalfail = Totalfail + fail_unless( length(gpa.fbc_association) == 1);
145
146  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_association.typecode, 'SBML_FBC_OR'));
147  Totalfail = Totalfail + fail_unless( strcmp(gpa.fbc_association.fbc_association, '(g_1 or g_2 or (g_1 and g_2))'));
148
149
150
151if (silent == 0)
152disp('Testing readFromFileFbc2:');
153disp(sprintf('Number tests: %d', test));
154disp(sprintf('Number fails: %d', Totalfail));
155disp(sprintf('Pass rate: %d%%\n', ((test-Totalfail)/test)*100));
156end;
157
158if (Totalfail == 0)
159    y = 0;
160else
161    y = 1;
162end;
163
164function y = fail_unless(arg)
165
166if (~arg)
167    y = 1;
168else
169    y = 0;
170end;
171
172