Skip to content

Commit

Permalink
fix: importModel if SBML contains missing SBO terms (#536)
Browse files Browse the repository at this point in the history
* fix: importModel handle invalid SBOterms

* chore: updateDocumentation

* feat: importModel sboTerm priority over MIRIAM

* fix: importModel only one sboTerm
  • Loading branch information
edkerk authored May 2, 2024
1 parent 1170551 commit 49d0057
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
28 changes: 15 additions & 13 deletions doc/io/importModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0198 compartmentMiriams{i}=[];
0199 <span class="keyword">end</span>
0200
0201 <span class="keyword">if</span> isfield(modelSBML.compartment(i),<span class="string">'sboTerm'</span>)
0201 <span class="keyword">if</span> isfield(modelSBML.compartment(i),<span class="string">'sboTerm'</span>) &amp;&amp; ~(modelSBML.compartment(i).sboTerm==-1)
0202 compartmentMiriams{i} = <a href="#_sub5" class="code" title="subfunction miriam = addSBOtoMiriam(miriam,sboTerm)">addSBOtoMiriam</a>(compartmentMiriams{i},modelSBML.compartment(i).sboTerm);
0203 <span class="keyword">end</span>
0204 <span class="keyword">end</span>
Expand Down Expand Up @@ -386,7 +386,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0267 <span class="keyword">end</span>
0268
0269 <span class="comment">%Get SBO term</span>
0270 <span class="keyword">if</span> isfield(modelSBML.species(i),<span class="string">'sboTerm'</span>)
0270 <span class="keyword">if</span> isfield(modelSBML.species(i),<span class="string">'sboTerm'</span>) &amp;&amp; ~(modelSBML.species(i).sboTerm==-1)
0271 geneSBOs(end+1,1) = modelSBML.species(i).sboTerm;
0272 <span class="keyword">end</span>
0273 <span class="keyword">elseif</span> length(modelSBML.species(i).id)&gt;=2 &amp;&amp; strcmpi(modelSBML.species(i).id(1:3),<span class="string">'Cx_'</span>)
Expand Down Expand Up @@ -472,7 +472,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0353 metaboliteFormula{numel(metaboliteFormula)+1,1}=<span class="string">''</span>;
0354 <span class="keyword">end</span>
0355 <span class="comment">%Get SBO term</span>
0356 <span class="keyword">if</span> isfield(modelSBML.species(i),<span class="string">'sboTerm'</span>)
0356 <span class="keyword">if</span> isfield(modelSBML.species(i),<span class="string">'sboTerm'</span>) &amp;&amp; ~(modelSBML.species(i).sboTerm==-1)
0357 metSBOs(end+1,1) = modelSBML.species(i).sboTerm;
0358 <span class="keyword">end</span>
0359 <span class="keyword">end</span>
Expand Down Expand Up @@ -520,7 +520,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0401 metaboliteMiriams{numel(metaboliteMiriams)+1,1}=metMiriam;
0402
0403 <span class="comment">%Get SBO term</span>
0404 <span class="keyword">if</span> isfield(modelSBML.species(i),<span class="string">'sboTerm'</span>)
0404 <span class="keyword">if</span> isfield(modelSBML.species(i),<span class="string">'sboTerm'</span>) &amp;&amp; ~(modelSBML.species(i).sboTerm==-1)
0405 metSBOs(end+1,1) = modelSBML.species(i).sboTerm;
0406 <span class="keyword">end</span>
0407 <span class="keyword">end</span>
Expand Down Expand Up @@ -778,7 +778,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0659 <span class="keyword">end</span>
0660
0661 <span class="comment">%Get SBO terms</span>
0662 <span class="keyword">if</span> isfield(modelSBML.reaction(i),<span class="string">'sboTerm'</span>)
0662 <span class="keyword">if</span> isfield(modelSBML.reaction(i),<span class="string">'sboTerm'</span>) &amp;&amp; ~(modelSBML.reaction(i).sboTerm==-1)
0663 rxnMiriams{counter} = <a href="#_sub5" class="code" title="subfunction miriam = addSBOtoMiriam(miriam,sboTerm)">addSBOtoMiriam</a>(rxnMiriams{counter}, modelSBML.reaction(i).sboTerm);
0664 <span class="keyword">end</span>
0665
Expand Down Expand Up @@ -1044,7 +1044,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0925 <span class="keyword">end</span>
0926 <span class="keyword">for</span> i = 1:numel(genes)
0927 geneMiriams{i}=<a href="#_sub4" class="code" title="subfunction miriamStruct=parseMiriam(searchString)">parseMiriam</a>(modelSBML.fbc_geneProduct(i).annotation);
0928 <span class="keyword">if</span> isfield(modelSBML.fbc_geneProduct(i),<span class="string">'sboTerm'</span>)
0928 <span class="keyword">if</span> isfield(modelSBML.fbc_geneProduct(i),<span class="string">'sboTerm'</span>) &amp;&amp; ~(modelSBML.fbc_geneProduct(i).sboTerm==-1)
0929 geneMiriams{i} = <a href="#_sub5" class="code" title="subfunction miriam = addSBOtoMiriam(miriam,sboTerm)">addSBOtoMiriam</a>(geneMiriams{i},modelSBML.fbc_geneProduct(i).sboTerm);
0930 <span class="keyword">end</span>
0931 <span class="keyword">end</span>
Expand Down Expand Up @@ -1323,7 +1323,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
1204
1205 counter=0;
1206 <span class="keyword">for</span> i=1:numel(targetString)
1207 <span class="keyword">if</span> isempty(regexp(targetString{1,i},<span class="string">'inchi|ec-code|sbo'</span>, <span class="string">'once'</span>))
1207 <span class="keyword">if</span> isempty(regexp(targetString{1,i},<span class="string">'inchi|ec-code'</span>, <span class="string">'once'</span>))
1208 counter=counter+1;
1209 miriamStruct.name{counter,1} = regexprep(targetString{1,i},<span class="string">'/.+'</span>,<span class="string">''</span>,<span class="string">'once'</span>);
1210 miriamStruct.value{counter,1} = regexprep(targetString{1,i},[miriamStruct.name{counter,1} <span class="string">'/'</span>],<span class="string">''</span>,<span class="string">'once'</span>);
Expand All @@ -1339,12 +1339,14 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
1220 <span class="keyword">if</span> isempty(miriam)
1221 miriam.name = {<span class="string">'sbo'</span>};
1222 miriam.value = sboTerm;
1223 <span class="keyword">else</span>
1224 miriam.name(end+1) = {<span class="string">'sbo'</span>};
1225 miriam.value(end+1) = sboTerm;
1226 <span class="keyword">end</span>
1227
1228 <span class="keyword">end</span></pre></div>
1223 <span class="keyword">elseif</span> any(strcmp(<span class="string">'sbo'</span>,miriam.name))
1224 currSbo = strcmp(<span class="string">'sbo'</span>,miriam.name);
1225 miriam.value(currSbo) = sboTerm;
1226 <span class="keyword">else</span>
1227 miriam.name(end+1) = {<span class="string">'sbo'</span>};
1228 miriam.value(end+1) = sboTerm;
1229 <span class="keyword">end</span>
1230 <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>
18 changes: 10 additions & 8 deletions io/importModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
compartmentMiriams{i}=[];
end

if isfield(modelSBML.compartment(i),'sboTerm')
if isfield(modelSBML.compartment(i),'sboTerm') && ~(modelSBML.compartment(i).sboTerm==-1)
compartmentMiriams{i} = addSBOtoMiriam(compartmentMiriams{i},modelSBML.compartment(i).sboTerm);
end
end
Expand Down Expand Up @@ -267,7 +267,7 @@
end

%Get SBO term
if isfield(modelSBML.species(i),'sboTerm')
if isfield(modelSBML.species(i),'sboTerm') && ~(modelSBML.species(i).sboTerm==-1)
geneSBOs(end+1,1) = modelSBML.species(i).sboTerm;
end
elseif length(modelSBML.species(i).id)>=2 && strcmpi(modelSBML.species(i).id(1:3),'Cx_')
Expand Down Expand Up @@ -353,7 +353,7 @@
metaboliteFormula{numel(metaboliteFormula)+1,1}='';
end
%Get SBO term
if isfield(modelSBML.species(i),'sboTerm')
if isfield(modelSBML.species(i),'sboTerm') && ~(modelSBML.species(i).sboTerm==-1)
metSBOs(end+1,1) = modelSBML.species(i).sboTerm;
end
end
Expand Down Expand Up @@ -401,7 +401,7 @@
metaboliteMiriams{numel(metaboliteMiriams)+1,1}=metMiriam;

%Get SBO term
if isfield(modelSBML.species(i),'sboTerm')
if isfield(modelSBML.species(i),'sboTerm') && ~(modelSBML.species(i).sboTerm==-1)
metSBOs(end+1,1) = modelSBML.species(i).sboTerm;
end
end
Expand Down Expand Up @@ -659,7 +659,7 @@
end

%Get SBO terms
if isfield(modelSBML.reaction(i),'sboTerm')
if isfield(modelSBML.reaction(i),'sboTerm') && ~(modelSBML.reaction(i).sboTerm==-1)
rxnMiriams{counter} = addSBOtoMiriam(rxnMiriams{counter}, modelSBML.reaction(i).sboTerm);
end

Expand Down Expand Up @@ -925,7 +925,7 @@
end
for i = 1:numel(genes)
geneMiriams{i}=parseMiriam(modelSBML.fbc_geneProduct(i).annotation);
if isfield(modelSBML.fbc_geneProduct(i),'sboTerm')
if isfield(modelSBML.fbc_geneProduct(i),'sboTerm') && ~(modelSBML.fbc_geneProduct(i).sboTerm==-1)
geneMiriams{i} = addSBOtoMiriam(geneMiriams{i},modelSBML.fbc_geneProduct(i).sboTerm);
end
end
Expand Down Expand Up @@ -1204,7 +1204,7 @@

counter=0;
for i=1:numel(targetString)
if isempty(regexp(targetString{1,i},'inchi|ec-code|sbo', 'once'))
if isempty(regexp(targetString{1,i},'inchi|ec-code', 'once'))
counter=counter+1;
miriamStruct.name{counter,1} = regexprep(targetString{1,i},'/.+','','once');
miriamStruct.value{counter,1} = regexprep(targetString{1,i},[miriamStruct.name{counter,1} '/'],'','once');
Expand All @@ -1220,9 +1220,11 @@
if isempty(miriam)
miriam.name = {'sbo'};
miriam.value = sboTerm;
elseif any(strcmp('sbo',miriam.name))
currSbo = strcmp('sbo',miriam.name);
miriam.value(currSbo) = sboTerm;
else
miriam.name(end+1) = {'sbo'};
miriam.value(end+1) = sboTerm;
end

end

0 comments on commit 49d0057

Please sign in to comment.