From 2708eeafe6e1614ad3f0ac58de365ba58c678022 Mon Sep 17 00:00:00 2001 From: haowang-bioinfo Date: Wed, 30 Mar 2022 16:42:24 +0800 Subject: [PATCH] fix: minor bugs - have conditional check when adding model fields - use `isequal` that returns logical scalar value --- code/annotateGEM.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/code/annotateGEM.m b/code/annotateGEM.m index 50e1c64f..f43e2149 100644 --- a/code/annotateGEM.m +++ b/code/annotateGEM.m @@ -49,7 +49,7 @@ annPath = strcat(fileparts(ST(I).file),'/../model'); end -if nargin < 3 || isempty(annType) || strcmpi(annType,'all') +if nargin < 3 || isempty(annType) || isequal(annType,'all') annType = {'rxn','met','gene'}; elseif ~all(ismember(annType,{'rxn','met','gene','reaction','metabolite'})) error('annType input(s) not recognized. Valid options are "rxn", "met", and/or "gene", or "all"'); @@ -277,9 +277,18 @@ % get fields and their types f = fieldnames(allAssoc); - fieldType = repmat({'rxn'}, numel(f), 1); - fieldType(ismember(f, fieldnames(metAssoc))) = {'met'}; - fieldType(ismember(f, fieldnames(geneAssoc))) = {'gene'}; + + if ~isempty(rxnAssoc) + fieldType = repmat({'rxn'}, numel(f), 1); + end + + if ~isempty(metAssoc) + fieldType(ismember(f, fieldnames(metAssoc))) = {'met'}; + end + + if ~isempty(geneAssoc) + fieldType(ismember(f, fieldnames(geneAssoc))) = {'gene'}; + end % add individual ID fields to the model for i = 1:numel(f)