Skip to content

Commit

Permalink
fix: change model field proteinNames to proteins (SysBioChalmers#564)
Browse files Browse the repository at this point in the history
* fix: change model field proteinNames to proteins

* fix: enforce column form for model.proteins

* doc: importModel more informative warning

* chore: update documentation

---------

Co-authored-by: Eduard Kerkhoven <[email protected]>
  • Loading branch information
IVANDOMENZAIN and edkerk authored Oct 12, 2024
1 parent 38f8415 commit e6f2837
Show file tree
Hide file tree
Showing 32 changed files with 393 additions and 367 deletions.
4 changes: 2 additions & 2 deletions INIT/getINITModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@
if isfield(model,'geneShortNames')
model.geneShortNames(I)=[];
end
if isfield(model,'proteinNames')
model.proteinNames(I)=[];
if isfield(model,'proteins')
model.proteins(I)=[];
end
if isfield(model,'geneMiriams')
model.geneMiriams(I)=[];
Expand Down
4 changes: 2 additions & 2 deletions INIT/mergeLinear.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
if isfield(reducedModel,'geneShortNames')
reducedModel.geneShortNames={};
end
if isfield(reducedModel,'proteinNames')
reducedModel.proteinNames={};
if isfield(reducedModel,'proteins')
reducedModel.proteins={};
end
if isfield(reducedModel,'geneMiriams')
reducedModel.geneMiriams={};
Expand Down
4 changes: 2 additions & 2 deletions INIT/removeLowScoreGenes.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@
if isfield(newModel,'geneShortNames')
newModel.geneShortNames(remInd) = [];
end
if isfield(newModel,'proteinNames')
newModel.proteinNames(remInd) = [];
if isfield(newModel,'proteins')
newModel.proteins(remInd) = [];
end
if isfield(newModel,'geneMiriams')
newModel.geneMiriams(remInd) = [];
Expand Down
24 changes: 12 additions & 12 deletions core/addGenesRaven.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
% default '')
% geneMiriams cell array with MIRIAM structures (optional,
% default [])
% proteinNames cell array of protein names associated to
% proteins cell array of protein names associated to
% each gene (optional, default '')
%
% newModel an updated model structure
Expand Down Expand Up @@ -58,8 +58,8 @@
if isfield(genesToAdd,'geneShortNames')
genesToAdd.geneShortNames(I)=[];
end
if isfield(genesToAdd,'proteinNames')
genesToAdd.proteinNames(I)=[];
if isfield(genesToAdd,'proteins')
genesToAdd.proteins(I)=[];
end
if isfield(genesToAdd,'geneMiriams')
genesToAdd.geneMiriams(I)=[];
Expand All @@ -86,21 +86,21 @@
newModel.geneShortNames=[newModel.geneShortNames;filler];
end
end
if isfield(genesToAdd,'proteinNames')
genesToAdd.proteinNames=convertCharArray(genesToAdd.proteinNames);
if numel(genesToAdd.proteinNames)~=nGenes
EM='genesToAdd.proteinNames must have the same number of elements as genesToAdd.genes';
if isfield(genesToAdd,'proteins')
genesToAdd.proteins=convertCharArray(genesToAdd.proteins);
if numel(genesToAdd.proteins)~=nGenes
EM='genesToAdd.proteins must have the same number of elements as genesToAdd.genes';
dispEM(EM);
end
%Add empty field if it doesn't exist
if ~isfield(newModel,'proteinNames')
newModel.proteinNames=largeFiller;
if ~isfield(newModel,'proteins')
newModel.proteins=largeFiller;
end
newModel.proteinNames=[newModel.proteinNames;genesToAdd.proteinNames(:)];
newModel.proteins=[newModel.proteins;genesToAdd.proteins(:)];
else
%Add empty strings if structure is in model
if isfield(newModel,'proteinNames')
newModel.proteinNames=[newModel.proteinNames;filler];
if isfield(newModel,'proteins')
newModel.proteins=[newModel.proteins;filler];
end
end

Expand Down
4 changes: 2 additions & 2 deletions core/deleteUnusedGenes.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
reducedModel.geneShortNames=reducedModel.geneShortNames(toKeep);
end

if isfield(reducedModel,'proteinNames')
reducedModel.proteinNames=reducedModel.proteinNames(toKeep);
if isfield(reducedModel,'proteins')
reducedModel.proteins=reducedModel.proteins(toKeep);
end

if isfield(reducedModel,'geneMiriams')
Expand Down
4 changes: 2 additions & 2 deletions core/getModelFromHomology.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
if isfield(models{i},'geneMiriams')
models{i}=rmfield(models{i},'geneMiriams');
end
if isfield(models{i},'proteinNames')
models{i}=rmfield(models{i},'proteinNames');
if isfield(models{i},'proteins')
models{i}=rmfield(models{i},'proteins');
end
%The geneFrom field also loses meaning if the genes are replaced by
%orthologs
Expand Down
16 changes: 8 additions & 8 deletions core/mergeModels.m
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@
model.geneShortNames=models{i}.geneShortNames;
end

if isfield(models{i},'proteinNames')
model.proteinNames=models{i}.proteinNames;
if isfield(models{i},'proteins')
model.proteins=models{i}.proteins;
end

if isfield(models{i},'geneMiriams')
Expand Down Expand Up @@ -535,19 +535,19 @@
end
end

if isfield(models{i},'proteinNames')
if isfield(model,'proteinNames')
model.proteinNames=[model.proteinNames;models{i}.proteinNames(genesToAdd)];
if isfield(models{i},'proteins')
if isfield(model,'proteins')
model.proteins=[model.proteins;models{i}.proteins(genesToAdd)];
else
emptyGeneSN=cell(numel(model.genes)-numel(genesToAdd),1);
emptyGeneSN(:)={''};
model.proteinNames=[emptyGeneSN;models{i}.proteinNames(genesToAdd)];
model.proteins=[emptyGeneSN;models{i}.proteins(genesToAdd)];
end
else
if isfield(model,'proteinNames')
if isfield(model,'proteins')
emptyGeneSN=cell(numel(genesToAdd),1);
emptyGeneSN(:)={''};
model.proteinNames=[model.proteinNames;emptyGeneSN];
model.proteins=[model.proteins;emptyGeneSN];
end
end

Expand Down
4 changes: 2 additions & 2 deletions core/permuteModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
if isfield(newModel,'geneShortNames')
newModel.geneShortNames=newModel.geneShortNames(indexes);
end
if isfield(newModel,'proteinNames')
newModel.proteinNames=newModel.proteinNames(indexes);
if isfield(newModel,'proteins')
newModel.proteins=newModel.proteins(indexes);
end
if isfield(newModel,'rxnGeneMat')
newModel.rxnGeneMat=newModel.rxnGeneMat(:,indexes);
Expand Down
12 changes: 6 additions & 6 deletions core/predictLocalization.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@
if isfield(model,'geneMiriams')
model.geneMiriams=[model.geneMiriams;{[]}];
end
if isfield(model,'proteinNames')
model.proteinNames=[model.proteinNames;{[]}];
if isfield(model,'proteins')
model.proteins=[model.proteins;{[]}];
end
if isfield(model,'geneFrom')
model.geneFrom=[model.geneFrom;{{'FAKE'}}];
Expand Down Expand Up @@ -261,8 +261,8 @@
if isfield(model,'geneShortNames')
model.geneShortNames=[model.geneShortNames;{''}];
end
if isfield(model,'proteinNames')
model.proteinNames=[model.proteinNames;{''}];
if isfield(model,'proteins')
model.proteins=[model.proteins;{''}];
end
if isfield(model,'geneFrom')
model.geneFrom=[model.geneFrom;{'COMPLEX'}];
Expand Down Expand Up @@ -765,8 +765,8 @@
if isfield(outModel,'geneShortNames')
outModel.geneShortNames(I)=[];
end
if isfield(outModel,'proteinNames')
outModel.proteinNames(I)=[];
if isfield(outModel,'proteins')
outModel.proteins(I)=[];
end
outModel.rxnGeneMat(:,I)=[];

Expand Down
4 changes: 2 additions & 2 deletions core/removeReactions.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@
reducedModel.geneShortNames=reducedModel.geneShortNames(toKeep);
end

if isfield(reducedModel,'proteinNames')
reducedModel.proteinNames=reducedModel.proteinNames(toKeep);
if isfield(reducedModel,'proteins')
reducedModel.proteins=reducedModel.proteins(toKeep);
end

if isfield(reducedModel,'geneMiriams')
Expand Down
4 changes: 2 additions & 2 deletions core/simplifyModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@
if isfield(reducedModel,'geneShortNames')
reducedModel.geneShortNames={};
end
if isfield(reducedModel,'proteinNames')
reducedModel.proteinNames={};
if isfield(reducedModel,'proteins')
reducedModel.proteins={};
end
if isfield(reducedModel,'geneMiriams')
reducedModel.geneMiriams={};
Expand Down
4 changes: 2 additions & 2 deletions doc/INIT/getINITModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0391 <span class="keyword">if</span> isfield(model,<span class="string">'geneShortNames'</span>)
0392 model.geneShortNames(I)=[];
0393 <span class="keyword">end</span>
0394 <span class="keyword">if</span> isfield(model,<span class="string">'proteinNames'</span>)
0395 model.proteinNames(I)=[];
0394 <span class="keyword">if</span> isfield(model,<span class="string">'proteins'</span>)
0395 model.proteins(I)=[];
0396 <span class="keyword">end</span>
0397 <span class="keyword">if</span> isfield(model,<span class="string">'geneMiriams'</span>)
0398 model.geneMiriams(I)=[];
Expand Down
4 changes: 2 additions & 2 deletions doc/INIT/mergeLinear.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0029 <span class="keyword">if</span> isfield(reducedModel,<span class="string">'geneShortNames'</span>)
0030 reducedModel.geneShortNames={};
0031 <span class="keyword">end</span>
0032 <span class="keyword">if</span> isfield(reducedModel,<span class="string">'proteinNames'</span>)
0033 reducedModel.proteinNames={};
0032 <span class="keyword">if</span> isfield(reducedModel,<span class="string">'proteins'</span>)
0033 reducedModel.proteins={};
0034 <span class="keyword">end</span>
0035 <span class="keyword">if</span> isfield(reducedModel,<span class="string">'geneMiriams'</span>)
0036 reducedModel.geneMiriams={};
Expand Down
4 changes: 2 additions & 2 deletions doc/INIT/removeLowScoreGenes.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0119 <span class="keyword">if</span> isfield(newModel,<span class="string">'geneShortNames'</span>)
0120 newModel.geneShortNames(remInd) = [];
0121 <span class="keyword">end</span>
0122 <span class="keyword">if</span> isfield(newModel,<span class="string">'proteinNames'</span>)
0123 newModel.proteinNames(remInd) = [];
0122 <span class="keyword">if</span> isfield(newModel,<span class="string">'proteins'</span>)
0123 newModel.proteins(remInd) = [];
0124 <span class="keyword">end</span>
0125 <span class="keyword">if</span> isfield(newModel,<span class="string">'geneMiriams'</span>)
0126 newModel.geneMiriams(remInd) = [];
Expand Down
26 changes: 13 additions & 13 deletions doc/core/addGenesRaven.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="
default '')
geneMiriams cell array with MIRIAM structures (optional,
default [])
proteinNames cell array of protein names associated to
proteins cell array of protein names associated to
each gene (optional, default '')

newModel an updated model structure
Expand Down Expand Up @@ -81,7 +81,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0014 <span class="comment">% default '')</span>
0015 <span class="comment">% geneMiriams cell array with MIRIAM structures (optional,</span>
0016 <span class="comment">% default [])</span>
0017 <span class="comment">% proteinNames cell array of protein names associated to</span>
0017 <span class="comment">% proteins cell array of protein names associated to</span>
0018 <span class="comment">% each gene (optional, default '')</span>
0019 <span class="comment">%</span>
0020 <span class="comment">% newModel an updated model structure</span>
Expand Down Expand Up @@ -125,8 +125,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0058 <span class="keyword">if</span> isfield(genesToAdd,<span class="string">'geneShortNames'</span>)
0059 genesToAdd.geneShortNames(I)=[];
0060 <span class="keyword">end</span>
0061 <span class="keyword">if</span> isfield(genesToAdd,<span class="string">'proteinNames'</span>)
0062 genesToAdd.proteinNames(I)=[];
0061 <span class="keyword">if</span> isfield(genesToAdd,<span class="string">'proteins'</span>)
0062 genesToAdd.proteins(I)=[];
0063 <span class="keyword">end</span>
0064 <span class="keyword">if</span> isfield(genesToAdd,<span class="string">'geneMiriams'</span>)
0065 genesToAdd.geneMiriams(I)=[];
Expand All @@ -153,21 +153,21 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0086 newModel.geneShortNames=[newModel.geneShortNames;filler];
0087 <span class="keyword">end</span>
0088 <span class="keyword">end</span>
0089 <span class="keyword">if</span> isfield(genesToAdd,<span class="string">'proteinNames'</span>)
0090 genesToAdd.proteinNames=<a href="convertCharArray.html" class="code" title="function inputConverted = convertCharArray(funcInput)">convertCharArray</a>(genesToAdd.proteinNames);
0091 <span class="keyword">if</span> numel(genesToAdd.proteinNames)~=nGenes
0092 EM=<span class="string">'genesToAdd.proteinNames must have the same number of elements as genesToAdd.genes'</span>;
0089 <span class="keyword">if</span> isfield(genesToAdd,<span class="string">'proteins'</span>)
0090 genesToAdd.proteins=<a href="convertCharArray.html" class="code" title="function inputConverted = convertCharArray(funcInput)">convertCharArray</a>(genesToAdd.proteins);
0091 <span class="keyword">if</span> numel(genesToAdd.proteins)~=nGenes
0092 EM=<span class="string">'genesToAdd.proteins must have the same number of elements as genesToAdd.genes'</span>;
0093 <a href="dispEM.html" class="code" title="function dispEM(string,throwErrors,toList,trimWarnings)">dispEM</a>(EM);
0094 <span class="keyword">end</span>
0095 <span class="comment">%Add empty field if it doesn't exist</span>
0096 <span class="keyword">if</span> ~isfield(newModel,<span class="string">'proteinNames'</span>)
0097 newModel.proteinNames=largeFiller;
0096 <span class="keyword">if</span> ~isfield(newModel,<span class="string">'proteins'</span>)
0097 newModel.proteins=largeFiller;
0098 <span class="keyword">end</span>
0099 newModel.proteinNames=[newModel.proteinNames;genesToAdd.proteinNames(:)];
0099 newModel.proteins=[newModel.proteins;genesToAdd.proteins(:)];
0100 <span class="keyword">else</span>
0101 <span class="comment">%Add empty strings if structure is in model</span>
0102 <span class="keyword">if</span> isfield(newModel,<span class="string">'proteinNames'</span>)
0103 newModel.proteinNames=[newModel.proteinNames;filler];
0102 <span class="keyword">if</span> isfield(newModel,<span class="string">'proteins'</span>)
0103 newModel.proteins=[newModel.proteins;filler];
0104 <span class="keyword">end</span>
0105 <span class="keyword">end</span>
0106
Expand Down
4 changes: 2 additions & 2 deletions doc/core/deleteUnusedGenes.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0037 reducedModel.geneShortNames=reducedModel.geneShortNames(toKeep);
0038 <span class="keyword">end</span>
0039
0040 <span class="keyword">if</span> isfield(reducedModel,<span class="string">'proteinNames'</span>)
0041 reducedModel.proteinNames=reducedModel.proteinNames(toKeep);
0040 <span class="keyword">if</span> isfield(reducedModel,<span class="string">'proteins'</span>)
0041 reducedModel.proteins=reducedModel.proteins(toKeep);
0042 <span class="keyword">end</span>
0043
0044 <span class="keyword">if</span> isfield(reducedModel,<span class="string">'geneMiriams'</span>)
Expand Down
4 changes: 2 additions & 2 deletions doc/core/getModelFromHomology.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0115 <span class="keyword">if</span> isfield(models{i},<span class="string">'geneMiriams'</span>)
0116 models{i}=rmfield(models{i},<span class="string">'geneMiriams'</span>);
0117 <span class="keyword">end</span>
0118 <span class="keyword">if</span> isfield(models{i},<span class="string">'proteinNames'</span>)
0119 models{i}=rmfield(models{i},<span class="string">'proteinNames'</span>);
0118 <span class="keyword">if</span> isfield(models{i},<span class="string">'proteins'</span>)
0119 models{i}=rmfield(models{i},<span class="string">'proteins'</span>);
0120 <span class="keyword">end</span>
0121 <span class="comment">%The geneFrom field also loses meaning if the genes are replaced by</span>
0122 <span class="comment">%orthologs</span>
Expand Down
16 changes: 8 additions & 8 deletions doc/core/mergeModels.html
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0493 model.geneShortNames=models{i}.geneShortNames;
0494 <span class="keyword">end</span>
0495
0496 <span class="keyword">if</span> isfield(models{i},<span class="string">'proteinNames'</span>)
0497 model.proteinNames=models{i}.proteinNames;
0496 <span class="keyword">if</span> isfield(models{i},<span class="string">'proteins'</span>)
0497 model.proteins=models{i}.proteins;
0498 <span class="keyword">end</span>
0499
0500 <span class="keyword">if</span> isfield(models{i},<span class="string">'geneMiriams'</span>)
Expand Down Expand Up @@ -596,19 +596,19 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0535 <span class="keyword">end</span>
0536 <span class="keyword">end</span>
0537
0538 <span class="keyword">if</span> isfield(models{i},<span class="string">'proteinNames'</span>)
0539 <span class="keyword">if</span> isfield(model,<span class="string">'proteinNames'</span>)
0540 model.proteinNames=[model.proteinNames;models{i}.proteinNames(genesToAdd)];
0538 <span class="keyword">if</span> isfield(models{i},<span class="string">'proteins'</span>)
0539 <span class="keyword">if</span> isfield(model,<span class="string">'proteins'</span>)
0540 model.proteins=[model.proteins;models{i}.proteins(genesToAdd)];
0541 <span class="keyword">else</span>
0542 emptyGeneSN=cell(numel(model.genes)-numel(genesToAdd),1);
0543 emptyGeneSN(:)={<span class="string">''</span>};
0544 model.proteinNames=[emptyGeneSN;models{i}.proteinNames(genesToAdd)];
0544 model.proteins=[emptyGeneSN;models{i}.proteins(genesToAdd)];
0545 <span class="keyword">end</span>
0546 <span class="keyword">else</span>
0547 <span class="keyword">if</span> isfield(model,<span class="string">'proteinNames'</span>)
0547 <span class="keyword">if</span> isfield(model,<span class="string">'proteins'</span>)
0548 emptyGeneSN=cell(numel(genesToAdd),1);
0549 emptyGeneSN(:)={<span class="string">''</span>};
0550 model.proteinNames=[model.proteinNames;emptyGeneSN];
0550 model.proteins=[model.proteins;emptyGeneSN];
0551 <span class="keyword">end</span>
0552 <span class="keyword">end</span>
0553
Expand Down
4 changes: 2 additions & 2 deletions doc/core/permuteModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0132 <span class="keyword">if</span> isfield(newModel,<span class="string">'geneShortNames'</span>)
0133 newModel.geneShortNames=newModel.geneShortNames(indexes);
0134 <span class="keyword">end</span>
0135 <span class="keyword">if</span> isfield(newModel,<span class="string">'proteinNames'</span>)
0136 newModel.proteinNames=newModel.proteinNames(indexes);
0135 <span class="keyword">if</span> isfield(newModel,<span class="string">'proteins'</span>)
0136 newModel.proteins=newModel.proteins(indexes);
0137 <span class="keyword">end</span>
0138 <span class="keyword">if</span> isfield(newModel,<span class="string">'rxnGeneMat'</span>)
0139 newModel.rxnGeneMat=newModel.rxnGeneMat(:,indexes);
Expand Down
Loading

0 comments on commit e6f2837

Please sign in to comment.