Skip to content

Commit

Permalink
fix: checkModelStruct skip metSmiles (SysBioChalmers#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
edkerk authored Jul 15, 2023
1 parent cd8ee29 commit 0e3d007
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 77 deletions.
33 changes: 0 additions & 33 deletions core/checkModelStruct.m
Original file line number Diff line number Diff line change
Expand Up @@ -363,39 +363,6 @@ function checkModelStruct(model,throwErrors,trimWarnings)
EM='The following InChI strings are associated to more than one unique metabolite name:';
dispEM(EM,false,allInchis(hasMultiple),trimWarnings);
end

%Check if there are metabolites with different names but the same SMILES
if isfield(model,'metSmiles')
metSmiles=containers.Map();
for i=1:numel(model.mets)
if ~isempty(model.metSmiles{i})
%Get existing metabolite indexes
if isKey(metSmiles,model.metSmiles{i})
existing=metSmiles(model.metSmiles{i});
else
existing=[];
end
metSmiles(model.metSmiles{i})=[existing;i];
end
end

%Get all keys
allmetSmiles=keys(metSmiles);

hasMultiple=false(numel(metSmiles),1);
for i=1:numel(metSmiles)
if numel(metSmiles(metSmiles{i}))>1
%Check if they all have the same name
if numel(unique(model.metNames(metSmiles(allmetSmiles{i}))))>1
hasMultiple(i)=true;
end
end
end

%Print output
EM='The following metSmiles strings are associated to more than one unique metabolite name:';
dispEM(EM,false,allmetSmiles(hasMultiple),trimWarnings);
end
end

function I=duplicates(strings)
Expand Down
55 changes: 11 additions & 44 deletions doc/core/checkModelStruct.html
Original file line number Diff line number Diff line change
Expand Up @@ -422,50 +422,17 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0363 EM=<span class="string">'The following InChI strings are associated to more than one unique metabolite name:'</span>;
0364 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,allInchis(hasMultiple),trimWarnings);
0365 <span class="keyword">end</span>
0366
0367 <span class="comment">%Check if there are metabolites with different names but the same SMILES</span>
0368 <span class="keyword">if</span> isfield(model,<span class="string">'metSmiles'</span>)
0369 metSmiles=containers.Map();
0370 <span class="keyword">for</span> i=1:numel(model.mets)
0371 <span class="keyword">if</span> ~isempty(model.metSmiles{i})
0372 <span class="comment">%Get existing metabolite indexes</span>
0373 <span class="keyword">if</span> isKey(metSmiles,model.metSmiles{i})
0374 existing=metSmiles(model.metSmiles{i});
0375 <span class="keyword">else</span>
0376 existing=[];
0377 <span class="keyword">end</span>
0378 metSmiles(model.metSmiles{i})=[existing;i];
0379 <span class="keyword">end</span>
0380 <span class="keyword">end</span>
0381
0382 <span class="comment">%Get all keys</span>
0383 allmetSmiles=keys(metSmiles);
0384
0385 hasMultiple=false(numel(metSmiles),1);
0386 <span class="keyword">for</span> i=1:numel(metSmiles)
0387 <span class="keyword">if</span> numel(metSmiles(metSmiles{i}))&gt;1
0388 <span class="comment">%Check if they all have the same name</span>
0389 <span class="keyword">if</span> numel(unique(model.metNames(metSmiles(allmetSmiles{i}))))&gt;1
0390 hasMultiple(i)=true;
0391 <span class="keyword">end</span>
0392 <span class="keyword">end</span>
0393 <span class="keyword">end</span>
0394
0395 <span class="comment">%Print output</span>
0396 EM=<span class="string">'The following metSmiles strings are associated to more than one unique metabolite name:'</span>;
0397 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM,false,allmetSmiles(hasMultiple),trimWarnings);
0398 <span class="keyword">end</span>
0399 <span class="keyword">end</span>
0400
0401 <a name="_sub1" href="#_subfunctions" class="code">function I=duplicates(strings)</a>
0402 I=false(numel(strings),1);
0403 [J, K]=unique(strings);
0404 <span class="keyword">if</span> numel(J)~=numel(strings)
0405 L=1:numel(strings);
0406 L(K)=[];
0407 I(L)=true;
0408 <span class="keyword">end</span>
0409 <span class="keyword">end</span></pre></div>
0366 <span class="keyword">end</span>
0367
0368 <a name="_sub1" href="#_subfunctions" class="code">function I=duplicates(strings)</a>
0369 I=false(numel(strings),1);
0370 [J, K]=unique(strings);
0371 <span class="keyword">if</span> numel(J)~=numel(strings)
0372 L=1:numel(strings);
0373 L(K)=[];
0374 I(L)=true;
0375 <span class="keyword">end</span>
0376 <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> &copy; 2005</address>
</body>
</html>

0 comments on commit 0e3d007

Please sign in to comment.