-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathcheckModelStruct.html
More file actions
517 lines (506 loc) · 39.4 KB
/
Copy pathcheckModelStruct.html
File metadata and controls
517 lines (506 loc) · 39.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Description of checkModelStruct</title>
<meta name="keywords" content="checkModelStruct">
<meta name="description" content="checkModelStruct">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="m2html v1.5 © 2003-2005 Guillaume Flandin">
<meta name="robots" content="index, follow">
<link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> > <a href="index.html">core</a> > checkModelStruct.m</div>
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
<td align="right"><a href="index.html">Index for core <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
<h1>checkModelStruct
</h1>
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>checkModelStruct</strong></div>
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function checkModelStruct(model,throwErrors,trimWarnings) </strong></div>
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> checkModelStruct
Performs a number of checks to ensure that a model structure is ok
model a model structure
throwErrors true if the function should throw errors if
inconsistencies are found. The alternative is to
print warnings for all types of issues (optional, default true)
trimWarnings true if only a maximal of 10 items should be displayed in
a given error/warning (optional, default true)
NOTE: This is performed after importing a model from Excel or before
attempting to export a model to SBML format.
Usage: checkModelStruct(model,throwErrors,trimWarnings)</pre></div>
<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a> dispEM</li><li><a href="getGenesFromGrRules.html" class="code" title="function [genes,rxnGeneMat] = getGenesFromGrRules(grRules, originalGenes)">getGenesFromGrRules</a> getGenesFromGrRules Extract gene list and rxnGeneMat from grRules array.</li><li><a href="parseFormulas.html" class="code" title="function [elements, useMat, exitFlag, MW]=parseFormulas(formulas, noPolymers,isInchi,ignoreRX)">parseFormulas</a> parseFormulas</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->
<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="#_sub1" class="code">function I=duplicates(strings)</a></li></ul>
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function checkModelStruct(model,throwErrors,trimWarnings)</a>
0002 <span class="comment">% checkModelStruct</span>
0003 <span class="comment">% Performs a number of checks to ensure that a model structure is ok</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% model a model structure</span>
0006 <span class="comment">% throwErrors true if the function should throw errors if</span>
0007 <span class="comment">% inconsistencies are found. The alternative is to</span>
0008 <span class="comment">% print warnings for all types of issues (optional, default true)</span>
0009 <span class="comment">% trimWarnings true if only a maximal of 10 items should be displayed in</span>
0010 <span class="comment">% a given error/warning (optional, default true)</span>
0011 <span class="comment">%</span>
0012 <span class="comment">% NOTE: This is performed after importing a model from Excel or before</span>
0013 <span class="comment">% attempting to export a model to SBML format.</span>
0014 <span class="comment">%</span>
0015 <span class="comment">% Usage: checkModelStruct(model,throwErrors,trimWarnings)</span>
0016
0017 <span class="keyword">if</span> nargin<2
0018 throwErrors=true;
0019 <span class="keyword">end</span>
0020 <span class="keyword">if</span> nargin<3
0021 trimWarnings=true;
0022 <span class="keyword">end</span>
0023
0024 <span class="comment">%Missing elements</span>
0025 fields={<span class="string">'id'</span>;<span class="string">'name'</span>;<span class="string">'rxns'</span>;<span class="string">'mets'</span>;<span class="string">'S'</span>;<span class="string">'lb'</span>;<span class="string">'ub'</span>;<span class="string">'rev'</span>;<span class="string">'c'</span>;<span class="string">'b'</span>;<span class="string">'comps'</span>;<span class="string">'metComps'</span>};
0026 <span class="keyword">for</span> i=1:numel(fields)
0027 <span class="keyword">if</span> ~isfield(model,fields{i})
0028 EM=[<span class="string">'The model is missing the "'</span> fields{i} <span class="string">'" field'</span>];
0029 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0030 <span class="keyword">end</span>
0031 <span class="keyword">end</span>
0032
0033 <span class="comment">%Type check</span>
0034 <span class="keyword">if</span> ~ischar(model.id)
0035 EM=<span class="string">'The "id" field must be a string'</span>;
0036 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0037 <span class="keyword">end</span>
0038 <span class="keyword">if</span> ~ischar(model.name)
0039 EM=<span class="string">'The "name" field must be a string'</span>;
0040 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0041 <span class="keyword">end</span>
0042 <span class="keyword">if</span> ~iscellstr(model.rxns)
0043 EM=<span class="string">'The "rxns" field must be a cell array of strings'</span>;
0044 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0045 <span class="keyword">end</span>
0046 <span class="keyword">if</span> ~iscellstr(model.mets)
0047 EM=<span class="string">'The "mets" field must be a cell array of strings'</span>;
0048 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0049 <span class="keyword">end</span>
0050 <span class="keyword">if</span> ~isnumeric(model.S)
0051 EM=<span class="string">'The "S" field must be of type "double"'</span>;
0052 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0053 <span class="keyword">end</span>
0054 <span class="keyword">if</span> ~isnumeric(model.lb)
0055 EM=<span class="string">'The "lb" field must be of type "double"'</span>;
0056 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0057 <span class="keyword">end</span>
0058 <span class="keyword">if</span> ~isnumeric(model.ub)
0059 EM=<span class="string">'The "ub" field must be of type "double"'</span>;
0060 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0061 <span class="keyword">end</span>
0062 <span class="keyword">if</span> ~isnumeric(model.rev)
0063 EM=<span class="string">'The "rev" field must be of type "double"'</span>;
0064 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0065 <span class="keyword">end</span>
0066 <span class="keyword">if</span> ~isnumeric(model.c)
0067 EM=<span class="string">'The "c" field must be of type "double"'</span>;
0068 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0069 <span class="keyword">end</span>
0070 <span class="keyword">if</span> ~isnumeric(model.b)
0071 EM=<span class="string">'The "b" field must be of type "double"'</span>;
0072 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0073 <span class="keyword">end</span>
0074 <span class="keyword">if</span> ~iscellstr(model.comps)
0075 EM=<span class="string">'The "comps" field must be a cell array of strings'</span>;
0076 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0077 <span class="keyword">end</span>
0078 <span class="keyword">if</span> ~isnumeric(model.metComps)
0079 EM=<span class="string">'The "metComps" field must be of type "double"'</span>;
0080 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0081 <span class="keyword">end</span>
0082 <span class="keyword">if</span> isfield(model,<span class="string">'compNames'</span>)
0083 <span class="keyword">if</span> ~iscellstr(model.compNames)
0084 EM=<span class="string">'The "compNames" field must be a cell array of strings'</span>;
0085 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0086 <span class="keyword">end</span>
0087 <span class="keyword">end</span>
0088 <span class="keyword">if</span> isfield(model,<span class="string">'compOutside'</span>)
0089 <span class="keyword">if</span> ~iscellstr(model.compOutside)
0090 EM=<span class="string">'The "compOutside" field must be a cell array of strings'</span>;
0091 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0092 <span class="keyword">end</span>
0093 <span class="keyword">end</span>
0094 <span class="keyword">if</span> isfield(model,<span class="string">'rxnNames'</span>)
0095 <span class="keyword">if</span> ~iscellstr(model.rxnNames)
0096 EM=<span class="string">'The "rxnNames" field must be a cell array of strings'</span>;
0097 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0098 <span class="keyword">end</span>
0099 <span class="keyword">end</span>
0100 <span class="keyword">if</span> isfield(model,<span class="string">'metNames'</span>)
0101 <span class="keyword">if</span> ~iscellstr(model.metNames)
0102 EM=<span class="string">'The "metNames" field must be a cell array of strings'</span>;
0103 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0104 <span class="keyword">end</span>
0105 <span class="keyword">end</span>
0106 <span class="keyword">if</span> isfield(model,<span class="string">'genes'</span>)
0107 <span class="keyword">if</span> ~iscellstr(model.genes)
0108 EM=<span class="string">'The "genes" field must be a cell array of strings'</span>;
0109 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0110 <span class="keyword">end</span>
0111 <span class="keyword">end</span>
0112 <span class="keyword">if</span> isfield(model,<span class="string">'rxnGeneMat'</span>)
0113 <span class="keyword">if</span> ~isnumeric(model.rxnGeneMat)
0114 EM=<span class="string">'The "rxnGeneMat" field must be of type "double"'</span>;
0115 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0116 <span class="keyword">end</span>
0117 <span class="keyword">end</span>
0118 <span class="keyword">if</span> isfield(model,<span class="string">'grRules'</span>)
0119 <span class="keyword">if</span> ~iscellstr(model.grRules)
0120 EM=<span class="string">'The "grRules" field must be a cell array of strings'</span>;
0121 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0122 <span class="keyword">end</span>
0123 <span class="keyword">if</span> ~isfield(model,<span class="string">'genes'</span>)
0124 EM=<span class="string">'If "grRules" field exists, the model should also contain a "genes" field'</span>;
0125 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0126 <span class="keyword">else</span>
0127 <span class="comment">%Erroneous grRules that start/end with OR/AND</span>
0128 EM=<span class="string">'The following reaction(s) have grRules that start or end with ''OR'' or ''AND'':'</span>;
0129 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,model.rxns(startsWith(model.grRules,{<span class="string">'or '</span>,<span class="string">'and '</span>}) | endsWith(model.grRules,{<span class="string">' or'</span>,<span class="string">' and'</span>})),trimWarnings);
0130 <span class="comment">%grRules that are not in genes field</span>
0131 geneList = <a href="getGenesFromGrRules.html" class="code" title="function [genes,rxnGeneMat] = getGenesFromGrRules(grRules, originalGenes)">getGenesFromGrRules</a>(model.grRules);
0132 geneList = setdiff(unique(geneList),model.genes);
0133 <span class="keyword">if</span> ~isempty(geneList)
0134 problemGrRules = model.rxns(contains(model.grRules,geneList));
0135 problemGrRules = strjoin(problemGrRules(:),<span class="string">'; '</span>);
0136 EM=[<span class="string">'The reaction(s) "'</span> problemGrRules <span class="string">'" contain the following genes in its "grRules" field, but these are not in the "genes" field:'</span>];
0137 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,geneList);
0138 <span class="keyword">end</span>
0139 <span class="keyword">end</span>
0140 <span class="keyword">end</span>
0141 <span class="keyword">if</span> isfield(model,<span class="string">'rxnComps'</span>)
0142 <span class="keyword">if</span> ~isnumeric(model.rxnComps)
0143 EM=<span class="string">'The "rxnComps" field must be of type "double"'</span>;
0144 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0145 <span class="keyword">end</span>
0146 <span class="keyword">end</span>
0147 <span class="keyword">if</span> isfield(model,<span class="string">'inchis'</span>)
0148 <span class="keyword">if</span> ~iscellstr(model.inchis)
0149 EM=<span class="string">'The "inchis" field must be a cell array of strings'</span>;
0150 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0151 <span class="keyword">end</span>
0152 <span class="keyword">end</span>
0153 <span class="keyword">if</span> isfield(model,<span class="string">'metSmiles'</span>)
0154 <span class="keyword">if</span> ~iscellstr(model.metSmiles)
0155 EM=<span class="string">'The "metSmiles" field must be a cell array of strings'</span>;
0156 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0157 <span class="keyword">end</span>
0158 <span class="keyword">end</span>
0159 <span class="keyword">if</span> isfield(model,<span class="string">'metFormulas'</span>)
0160 <span class="keyword">if</span> ~iscellstr(model.metFormulas)
0161 EM=<span class="string">'The "metFormulas" field must be a cell array of strings'</span>;
0162 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0163 <span class="keyword">end</span>
0164 <span class="keyword">end</span>
0165 <span class="keyword">if</span> isfield(model,<span class="string">'metCharges'</span>)
0166 <span class="keyword">if</span> ~isnumeric(model.metCharges)
0167 EM=<span class="string">'The "metCharges" field must be a double'</span>;
0168 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0169 <span class="keyword">end</span>
0170 <span class="keyword">end</span>
0171 <span class="keyword">if</span> isfield(model,<span class="string">'metDeltaG'</span>)
0172 <span class="keyword">if</span> ~isnumeric(model.metDeltaG)
0173 EM=<span class="string">'The "metDeltaG" field must be a double'</span>;
0174 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0175 <span class="keyword">end</span>
0176 <span class="keyword">end</span>
0177 <span class="keyword">if</span> isfield(model,<span class="string">'subSystems'</span>)
0178 <span class="keyword">for</span> i=1:numel(model.subSystems)
0179 <span class="keyword">if</span> ~iscell(model.subSystems{i,1})
0180 EM=<span class="string">'The "subSystems" field must be a cell array'</span>;
0181 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0182 <span class="keyword">end</span>
0183 <span class="keyword">end</span>
0184 <span class="keyword">end</span>
0185 <span class="keyword">if</span> isfield(model,<span class="string">'eccodes'</span>)
0186 <span class="keyword">if</span> ~iscellstr(model.eccodes)
0187 EM=<span class="string">'The "eccodes" field must be a cell array of strings'</span>;
0188 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0189 <span class="keyword">end</span>
0190 <span class="keyword">end</span>
0191 <span class="keyword">if</span> isfield(model,<span class="string">'unconstrained'</span>)
0192 <span class="keyword">if</span> ~isnumeric(model.unconstrained)
0193 EM=<span class="string">'The "unconstrained" field must be of type "double"'</span>;
0194 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0195 <span class="keyword">end</span>
0196 <span class="keyword">end</span>
0197 <span class="keyword">if</span> isfield(model,<span class="string">'rxnNotes'</span>)
0198 <span class="keyword">if</span> ~iscellstr(model.rxnNotes)
0199 EM=<span class="string">'The "rxnNotes" field must be a cell array of strings'</span>;
0200 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0201 <span class="keyword">end</span>
0202 <span class="keyword">end</span>
0203 <span class="keyword">if</span> isfield(model,<span class="string">'rxnReferences'</span>)
0204 <span class="keyword">if</span> ~iscellstr(model.rxnReferences)
0205 EM=<span class="string">'The "rxnReferences" field must be a cell array of strings'</span>;
0206 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0207 <span class="keyword">end</span>
0208 <span class="keyword">end</span>
0209 <span class="keyword">if</span> isfield(model,<span class="string">'rxnConfidenceScores'</span>)
0210 <span class="keyword">if</span> ~isnumeric(model.rxnConfidenceScores)
0211 EM=<span class="string">'The "rxnConfidenceScores" field must be a double'</span>;
0212 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0213 <span class="keyword">end</span>
0214 <span class="keyword">end</span>
0215 <span class="keyword">if</span> isfield(model,<span class="string">'rxnDeltaG'</span>)
0216 <span class="keyword">if</span> ~isnumeric(model.rxnDeltaG)
0217 EM=<span class="string">'The "rxnDeltaG" field must be a double'</span>;
0218 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0219 <span class="keyword">end</span>
0220 <span class="keyword">end</span>
0221
0222 <span class="comment">%Empty strings</span>
0223 <span class="keyword">if</span> isempty(model.id)
0224 EM=<span class="string">'The "id" field cannot be empty'</span>;
0225 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0226 <span class="keyword">end</span>
0227 <span class="keyword">if</span> any(cellfun(@isempty,model.rxns))
0228 EM=<span class="string">'The model contains empty reaction IDs'</span>;
0229 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0230 <span class="keyword">end</span>
0231 <span class="keyword">if</span> any(cellfun(@isempty,model.mets))
0232 EM=<span class="string">'The model contains empty metabolite IDs'</span>;
0233 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0234 <span class="keyword">end</span>
0235 <span class="keyword">if</span> any(cellfun(@isempty,model.comps))
0236 EM=<span class="string">'The model contains empty compartment IDs'</span>;
0237 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0238 <span class="keyword">end</span>
0239 EM=<span class="string">'The following metabolites have empty names:'</span>;
0240 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,model.mets(cellfun(@isempty,model.metNames)),trimWarnings);
0241
0242 <span class="keyword">if</span> isfield(model,<span class="string">'genes'</span>)
0243 <span class="keyword">if</span> any(cellfun(@isempty,model.genes))
0244 EM=<span class="string">'The model contains empty gene IDs'</span>;
0245 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors);
0246 <span class="keyword">end</span>
0247 <span class="keyword">end</span>
0248
0249 <span class="comment">%Validate format of ids</span>
0250 fields = {<span class="string">'rxns'</span>;<span class="string">'mets'</span>;<span class="string">'comps'</span>;<span class="string">'genes'</span>};
0251 fieldNames = {<span class="string">'reaction'</span>;<span class="string">'metabolite'</span>;<span class="string">'compartment'</span>;<span class="string">'gene'</span>};
0252 fieldPrefix = {<span class="string">'R_'</span>;<span class="string">'M_'</span>;<span class="string">'C_'</span>;<span class="string">'G_'</span>};
0253 <span class="keyword">for</span> i=1:numel(fields)
0254 <span class="keyword">try</span>
0255 numIDs = ~startsWith(model.(fields{i}),regexpPattern(<span class="string">'^[a-zA-Z_]'</span>));
0256 <span class="keyword">catch</span>
0257 numIDs = [];
0258 <span class="keyword">end</span>
0259 <span class="keyword">if</span> any(numIDs)
0260 EM = [<span class="string">'The following '</span> fieldNames{i} <span class="string">' identifiers do not start '</span><span class="keyword">...</span>
0261 <span class="string">'with a letter or _ (conflicting with SBML specifications). '</span><span class="keyword">...</span>
0262 <span class="string">'This does not impact RAVEN functionality, but be aware that '</span><span class="keyword">...</span>
0263 <span class="string">'exportModel will automatically add '</span> fieldPrefix{i} <span class="keyword">...</span>
0264 <span class="string">' prefixes to all '</span> fieldNames{i} <span class="string">' identifiers:'</span>];
0265 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,{model.(fields{i}){numIDs}},trimWarnings);
0266 <span class="keyword">end</span>
0267 <span class="keyword">end</span>
0268
0269 <span class="comment">%Duplicates</span>
0270 EM=<span class="string">'The following reaction IDs are duplicates:'</span>;
0271 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,model.rxns(<a href="#_sub1" class="code" title="subfunction I=duplicates(strings)">duplicates</a>(model.rxns)),trimWarnings);
0272 EM=<span class="string">'The following metabolite IDs are duplicates:'</span>;
0273 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,model.mets(<a href="#_sub1" class="code" title="subfunction I=duplicates(strings)">duplicates</a>(model.mets)),trimWarnings);
0274 EM=<span class="string">'The following compartment IDs are duplicates:'</span>;
0275 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,model.comps(<a href="#_sub1" class="code" title="subfunction I=duplicates(strings)">duplicates</a>(model.comps)),trimWarnings);
0276 <span class="keyword">if</span> isfield(model,<span class="string">'genes'</span>)
0277 EM=<span class="string">'The following genes are duplicates:'</span>;
0278 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,model.genes(<a href="#_sub1" class="code" title="subfunction I=duplicates(strings)">duplicates</a>(model.genes)),trimWarnings);
0279 <span class="keyword">end</span>
0280 metInComp=strcat(model.metNames,<span class="string">'['</span>,model.comps(model.metComps),<span class="string">']'</span>);
0281 EM=<span class="string">'The following metabolites already exist in the same compartment:'</span>;
0282 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,metInComp(<a href="#_sub1" class="code" title="subfunction I=duplicates(strings)">duplicates</a>(metInComp)),trimWarnings);
0283
0284 <span class="comment">%Elements never used (print only as warnings</span>
0285 EM=<span class="string">'The following reactions are empty (no involved metabolites):'</span>;
0286 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,model.rxns(~any(model.S,1)),trimWarnings);
0287 EM=<span class="string">'The following metabolites are never used in a reaction:'</span>;
0288 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,model.mets(~any(model.S,2)),trimWarnings);
0289 <span class="keyword">if</span> isfield(model,<span class="string">'genes'</span>)
0290 EM=<span class="string">'The following genes are not associated to a reaction:'</span>;
0291 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,model.genes(~any(model.rxnGeneMat,1)),trimWarnings);
0292 <span class="keyword">end</span>
0293 I=true(numel(model.comps),1);
0294 I(model.metComps)=false;
0295 EM=<span class="string">'The following compartments contain no metabolites:'</span>;
0296 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,model.comps(I),trimWarnings);
0297
0298 <span class="comment">%Contradicting bounds</span>
0299 EM=<span class="string">'The following reactions have contradicting bounds (lower bound is higher than upper bound):'</span>;
0300 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,model.rxns(model.lb>model.ub),trimWarnings);
0301 EM=<span class="string">'The following reactions have lower and upper bounds that indicate reversibility, but are indicated as irreversible in model.rev:'</span>;
0302 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,model.rxns(model.lb < 0 & model.ub > 0 & model.rev==0),trimWarnings);
0303
0304 <span class="comment">%Multiple or no objective functions not allowed in SBML L3V1 FBCv2</span>
0305 <span class="keyword">if</span> numel(find(model.c))>1
0306 EM=<span class="string">'Multiple objective functions found. This might be intended, but results in FBCv2 non-compliant SBML file when exported'</span>;
0307 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,model.rxns(find(model.c)),trimWarnings);
0308 <span class="keyword">elseif</span> ~any(model.c)
0309 EM=<span class="string">'No objective function found. This might be intended, but results in FBCv2 non-compliant SBML file when exported'</span>;
0310 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false);
0311 <span class="keyword">end</span>
0312
0313 <span class="comment">%Mapping of compartments</span>
0314 <span class="keyword">if</span> isfield(model,<span class="string">'compOutside'</span>)
0315 EM=<span class="string">'The following compartments are in "compOutside" but not in "comps":'</span>;
0316 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,throwErrors,setdiff(model.compOutside,[{<span class="string">''</span>};model.comps]),trimWarnings);
0317 <span class="keyword">end</span>
0318
0319 <span class="comment">%Met names which start with number</span>
0320 I=false(numel(model.metNames),1);
0321 <span class="keyword">for</span> i=1:numel(model.metNames)
0322 index=strfind(model.metNames{i},<span class="string">' '</span>);
0323 <span class="keyword">if</span> any(index)
0324 <span class="keyword">if</span> any(str2double(model.metNames{i}(1:index(1)-1)))
0325 I(i)=true;
0326 <span class="keyword">end</span>
0327 <span class="keyword">end</span>
0328 <span class="keyword">end</span>
0329 EM=<span class="string">'The following metabolite names begin with a number directly followed by space, which could potentially cause problems:'</span>;
0330 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,model.metNames(I),trimWarnings);
0331
0332 <span class="comment">%Non-parseable composition</span>
0333 <span class="keyword">if</span> isfield(model,<span class="string">'metFormulas'</span>)
0334 [~, ~, exitFlag]=<a href="parseFormulas.html" class="code" title="function [elements, useMat, exitFlag, MW]=parseFormulas(formulas, noPolymers,isInchi,ignoreRX)">parseFormulas</a>(model.metFormulas,true,false);
0335 EM=<span class="string">'The composition for the following metabolites could not be parsed:'</span>;
0336 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,model.mets(exitFlag==-1),trimWarnings);
0337 <span class="keyword">end</span>
0338
0339 <span class="comment">%Check if there are metabolites with different names but the same MIRIAM</span>
0340 <span class="comment">%codes</span>
0341 <span class="keyword">if</span> isfield(model,<span class="string">'metMiriams'</span>)
0342 miriams=containers.Map();
0343 <span class="keyword">for</span> i=1:numel(model.mets)
0344 <span class="keyword">if</span> ~isempty(model.metMiriams{i})
0345 <span class="comment">%Loop through and add for each miriam</span>
0346 <span class="keyword">for</span> j=1:numel(model.metMiriams{i}.name)
0347 <span class="comment">%Get existing metabolite indexes</span>
0348 current=strcat(model.metMiriams{i}.name{j},<span class="string">'/'</span>,model.metMiriams{i}.value{j});
0349 <span class="keyword">if</span> isKey(miriams,current)
0350 existing=miriams(current);
0351 <span class="keyword">else</span>
0352 existing=[];
0353 <span class="keyword">end</span>
0354 miriams(current)=[existing;i];
0355 <span class="keyword">end</span>
0356 <span class="keyword">end</span>
0357 <span class="keyword">end</span>
0358
0359 <span class="comment">%Get all keys</span>
0360 allMiriams=keys(miriams);
0361
0362 hasMultiple=false(numel(allMiriams),1);
0363 <span class="keyword">for</span> i=1:numel(allMiriams)
0364 <span class="keyword">if</span> numel(miriams(allMiriams{i}))>1
0365 <span class="comment">%Check if they all have the same name</span>
0366 <span class="keyword">if</span> numel(unique(model.metNames(miriams(allMiriams{i}))))>1
0367 <span class="keyword">if</span> ~regexp(allMiriams{i},<span class="string">'^sbo\/SBO:'</span>) <span class="comment">% SBO terms are expected to be multiple</span>
0368 hasMultiple(i)=true;
0369 <span class="keyword">end</span>
0370 <span class="keyword">end</span>
0371 <span class="keyword">end</span>
0372 <span class="keyword">end</span>
0373
0374 <span class="comment">%Print output</span>
0375 EM=<span class="string">'The following MIRIAM strings are associated to more than one unique metabolite name:'</span>;
0376 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,allMiriams(hasMultiple),trimWarnings);
0377 <span class="keyword">end</span>
0378
0379 <span class="comment">%Check if there are metabolites with different names but the same InChI</span>
0380 <span class="comment">%codes</span>
0381 <span class="keyword">if</span> isfield(model,<span class="string">'inchis'</span>)
0382 inchis=containers.Map();
0383 <span class="keyword">for</span> i=1:numel(model.mets)
0384 <span class="keyword">if</span> ~isempty(model.inchis{i})
0385 <span class="comment">%Get existing metabolite indexes</span>
0386 <span class="keyword">if</span> isKey(inchis,model.inchis{i})
0387 existing=inchis(model.inchis{i});
0388 <span class="keyword">else</span>
0389 existing=[];
0390 <span class="keyword">end</span>
0391 inchis(model.inchis{i})=[existing;i];
0392 <span class="keyword">end</span>
0393 <span class="keyword">end</span>
0394
0395 <span class="comment">%Get all keys</span>
0396 allInchis=keys(inchis);
0397
0398 hasMultiple=false(numel(allInchis),1);
0399 <span class="keyword">for</span> i=1:numel(allInchis)
0400 <span class="keyword">if</span> numel(inchis(allInchis{i}))>1
0401 <span class="comment">%Check if they all have the same name</span>
0402 <span class="keyword">if</span> numel(unique(model.metNames(inchis(allInchis{i}))))>1
0403 hasMultiple(i)=true;
0404 <span class="keyword">end</span>
0405 <span class="keyword">end</span>
0406 <span class="keyword">end</span>
0407
0408 <span class="comment">%Print output</span>
0409 EM=<span class="string">'The following InChI strings are associated to more than one unique metabolite name:'</span>;
0410 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,allInchis(hasMultiple),trimWarnings);
0411 <span class="keyword">end</span>
0412
0413 <span class="comment">% %Check if there are metabolites with different names but the same SMILES</span>
0414 <span class="comment">% if isfield(model,'metSmiles')</span>
0415 <span class="comment">% metSmiles=containers.Map();</span>
0416 <span class="comment">% for i=1:numel(model.mets)</span>
0417 <span class="comment">% if ~isempty(model.metSmiles{i})</span>
0418 <span class="comment">% %Get existing metabolite indexes</span>
0419 <span class="comment">% if isKey(metSmiles,model.metSmiles{i})</span>
0420 <span class="comment">% existing=metSmiles(model.metSmiles{i});</span>
0421 <span class="comment">% else</span>
0422 <span class="comment">% existing=[];</span>
0423 <span class="comment">% end</span>
0424 <span class="comment">% metSmiles(model.metSmiles{i})=[existing;i];</span>
0425 <span class="comment">% end</span>
0426 <span class="comment">% end</span>
0427 <span class="comment">%</span>
0428 <span class="comment">% %Get all keys</span>
0429 <span class="comment">% allmetSmiles=keys(metSmiles);</span>
0430 <span class="comment">%</span>
0431 <span class="comment">% hasMultiple=false(numel(metSmiles),1);</span>
0432 <span class="comment">% for i=1:numel(metSmiles)</span>
0433 <span class="comment">% if numel(metSmiles(metSmiles{i}))>1</span>
0434 <span class="comment">% %Check if they all have the same name</span>
0435 <span class="comment">% if numel(unique(model.metNames(metSmiles(allmetSmiles{i}))))>1</span>
0436 <span class="comment">% hasMultiple(i)=true;</span>
0437 <span class="comment">% end</span>
0438 <span class="comment">% end</span>
0439 <span class="comment">% end</span>
0440 <span class="comment">%</span>
0441 <span class="comment">% %Print output</span>
0442 <span class="comment">% EM='The following metSmiles strings are associated to more than one unique metabolite name:';</span>
0443 <span class="comment">% dispEM(EM,false,allmetSmiles(hasMultiple),trimWarnings);</span>
0444 <span class="comment">% end</span>
0445 <span class="keyword">end</span>
0446
0447 <a name="_sub1" href="#_subfunctions" class="code">function I=duplicates(strings)</a>
0448 I=false(numel(strings),1);
0449 [J, K]=unique(strings);
0450 <span class="keyword">if</span> numel(J)~=numel(strings)
0451 L=1:numel(strings);
0452 L(K)=[];
0453 I(L)=true;
0454 <span class="keyword">end</span>
0455 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> © 2005</address>
</body>
</html>