From 7db0db31239aff54f0f8992c0b6dbeb46144f019 Mon Sep 17 00:00:00 2001 From: edkerk Date: Tue, 27 Jun 2023 01:33:21 +0200 Subject: [PATCH 1/2] fix: readYAMLmodel allows non-used genes Allow for not all model.genes entries being in model.grRules. --- doc/io/readYAMLmodel.html | 169 +++++++++++++++++++------------------- io/readYAMLmodel.m | 17 ++-- 2 files changed, 94 insertions(+), 92 deletions(-) diff --git a/doc/io/readYAMLmodel.html b/doc/io/readYAMLmodel.html index a7d7c9c4..2914b6d9 100644 --- a/doc/io/readYAMLmodel.html +++ b/doc/io/readYAMLmodel.html @@ -635,93 +635,94 @@

SOURCE CODE ^% end 0579 % end 0580 -0581 % Make rxnGeneMat fields -0582 [genes, rxnGeneMat] = getGenesFromGrRules(model.grRules, model.genes); -0583 if isequal(sort(genes), sort(model.genes)) -0584 model.rxnGeneMat = rxnGeneMat; -0585 model.genes = genes; -0586 else -0587 error('The gene list and grRules are inconsistent.'); +0581 % Make rxnGeneMat fields and map to the existing model.genes field +0582 [genes, rxnGeneMat] = getGenesFromGrRules(model.grRules); +0583 model.rxnGeneMat = sparse(numel(model.rxns),numel(model.genes)); +0584 [~,geneOrder] = ismember(genes,model.genes); +0585 if any(geneOrder == 0) +0586 error(['The grRules includes the following gene(s), that are not in '... +0587 'the list of model genes: ', genes{~geneOrder}]) 0588 end -0589 -0590 % Finalize GECKO model -0591 if isGECKO -0592 % Fill in empty fields and empty entries -0593 for i={'kcat','source','notes','eccodes'} % Even keep empty -0594 model.ec = emptyOrFill(model.ec,i{1},{''},'rxns',true); -0595 end -0596 for i={'enzymes','mw','sequence'} -0597 model.ec = emptyOrFill(model.ec,i{1},{''},'genes',true); -0598 end -0599 model.ec = emptyOrFill(model.ec,'concs',{'NaN'},'genes',true); -0600 model.ec = emptyOrFill(model.ec,'kcat',{'0'},'genes',true); -0601 % Change string to double -0602 for i={'kcat','mw','concs'} -0603 if isfield(model.ec,i{1}) -0604 model.ec.(i{1}) = str2double(model.ec.(i{1})); -0605 end -0606 end -0607 % Fill rxnEnzMat -0608 rxnIdx = cellfun(@isempty, enzStoich(:,1)); -0609 enzStoich(rxnIdx,:) = ''; -0610 rxnIdx = cell2mat(enzStoich(:,1)); -0611 [~,enzIdx] = ismember(enzStoich(:,2),model.ec.enzymes); -0612 coeffs = cell2mat(enzStoich(:,3)); -0613 model.ec.rxnEnzMat = zeros(max(rxnIdx), max(enzIdx)); -0614 linearIndices = sub2ind([max(rxnIdx), max(enzIdx)], rxnIdx, enzIdx); -0615 model.ec.rxnEnzMat(linearIndices) = coeffs; -0616 %Parse ec-codes -0617 if ~isempty(ecGecko) -0618 locs = cell2mat(ecGecko(:,1)); -0619 for i=unique(locs)' -0620 ecGeckoCat=strjoin(ecGecko(locs==i,2),';'); -0621 model.ec.eccodes{i,1}=ecGeckoCat; -0622 end -0623 emptyEc=cellfun(@isempty,model.ec.eccodes); -0624 model.ec.eccodes(emptyEc)={''}; -0625 end -0626 end -0627 -0628 if verbose -0629 fprintf(' Done!\n'); -0630 end +0589 model.rxnGeneMat(:,geneOrder) = rxnGeneMat; +0590 +0591 % Finalize GECKO model +0592 if isGECKO +0593 % Fill in empty fields and empty entries +0594 for i={'kcat','source','notes','eccodes'} % Even keep empty +0595 model.ec = emptyOrFill(model.ec,i{1},{''},'rxns',true); +0596 end +0597 for i={'enzymes','mw','sequence'} +0598 model.ec = emptyOrFill(model.ec,i{1},{''},'genes',true); +0599 end +0600 model.ec = emptyOrFill(model.ec,'concs',{'NaN'},'genes',true); +0601 model.ec = emptyOrFill(model.ec,'kcat',{'0'},'genes',true); +0602 % Change string to double +0603 for i={'kcat','mw','concs'} +0604 if isfield(model.ec,i{1}) +0605 model.ec.(i{1}) = str2double(model.ec.(i{1})); +0606 end +0607 end +0608 % Fill rxnEnzMat +0609 rxnIdx = cellfun(@isempty, enzStoich(:,1)); +0610 enzStoich(rxnIdx,:) = ''; +0611 rxnIdx = cell2mat(enzStoich(:,1)); +0612 [~,enzIdx] = ismember(enzStoich(:,2),model.ec.enzymes); +0613 coeffs = cell2mat(enzStoich(:,3)); +0614 model.ec.rxnEnzMat = zeros(max(rxnIdx), max(enzIdx)); +0615 linearIndices = sub2ind([max(rxnIdx), max(enzIdx)], rxnIdx, enzIdx); +0616 model.ec.rxnEnzMat(linearIndices) = coeffs; +0617 %Parse ec-codes +0618 if ~isempty(ecGecko) +0619 locs = cell2mat(ecGecko(:,1)); +0620 for i=unique(locs)' +0621 ecGeckoCat=strjoin(ecGecko(locs==i,2),';'); +0622 model.ec.eccodes{i,1}=ecGeckoCat; +0623 end +0624 emptyEc=cellfun(@isempty,model.ec.eccodes); +0625 model.ec.eccodes(emptyEc)={''}; +0626 end +0627 end +0628 +0629 if verbose +0630 fprintf(' Done!\n'); 0631 end -0632 -0633 function model = emptyOrFill(model,field,emptyEntry,type,keepEmpty) -0634 if nargin<5 -0635 keepEmpty=false; -0636 end -0637 if isnumeric(emptyEntry) -0638 emptyCells=isempty(model.(field)); -0639 else -0640 emptyCells=cellfun(@isempty,model.(field)); -0641 end -0642 if all(emptyCells) && ~keepEmpty -0643 model = rmfield(model, field); -0644 elseif numel(model.(field))<numel(model.(type)) -0645 model.(field)(end+1:numel(model.(type)),1)=emptyEntry; -0646 end +0632 end +0633 +0634 function model = emptyOrFill(model,field,emptyEntry,type,keepEmpty) +0635 if nargin<5 +0636 keepEmpty=false; +0637 end +0638 if isnumeric(emptyEntry) +0639 emptyCells=isempty(model.(field)); +0640 else +0641 emptyCells=cellfun(@isempty,model.(field)); +0642 end +0643 if all(emptyCells) && ~keepEmpty +0644 model = rmfield(model, field); +0645 elseif numel(model.(field))<numel(model.(type)) +0646 model.(field)(end+1:numel(model.(type)),1)=emptyEntry; 0647 end -0648 -0649 function model = readFieldValue(model, fieldName, value, pos) -0650 if numel(model.(fieldName))<pos-1 -0651 model.(fieldName)(end+1:pos,1) = {''}; -0652 end -0653 model.(fieldName)(pos,1) = {value}; -0654 end -0655 -0656 function [miriams, miriamKey,entryNumber] = gatherAnnotation(pos,miriams,key,value,miriamKey,entryNumber) -0657 if isempty(key) -0658 key=miriamKey; -0659 else -0660 miriamKey=key; -0661 end -0662 if ~isempty(value) -0663 miriams(entryNumber,1:3) = {pos, key, strip(value)}; -0664 else -0665 entryNumber = entryNumber - 1; -0666 end -0667 end +0648 end +0649 +0650 function model = readFieldValue(model, fieldName, value, pos) +0651 if numel(model.(fieldName))<pos-1 +0652 model.(fieldName)(end+1:pos,1) = {''}; +0653 end +0654 model.(fieldName)(pos,1) = {value}; +0655 end +0656 +0657 function [miriams, miriamKey,entryNumber] = gatherAnnotation(pos,miriams,key,value,miriamKey,entryNumber) +0658 if isempty(key) +0659 key=miriamKey; +0660 else +0661 miriamKey=key; +0662 end +0663 if ~isempty(value) +0664 miriams(entryNumber,1:3) = {pos, key, strip(value)}; +0665 else +0666 entryNumber = entryNumber - 1; +0667 end +0668 end
Generated by m2html © 2005
\ No newline at end of file diff --git a/io/readYAMLmodel.m b/io/readYAMLmodel.m index a56420e3..a32df0ff 100644 --- a/io/readYAMLmodel.m +++ b/io/readYAMLmodel.m @@ -578,14 +578,15 @@ % end % end -% Make rxnGeneMat fields -[genes, rxnGeneMat] = getGenesFromGrRules(model.grRules, model.genes); -if isequal(sort(genes), sort(model.genes)) - model.rxnGeneMat = rxnGeneMat; - model.genes = genes; -else - error('The gene list and grRules are inconsistent.'); -end +% Make rxnGeneMat fields and map to the existing model.genes field +[genes, rxnGeneMat] = getGenesFromGrRules(model.grRules); +model.rxnGeneMat = sparse(numel(model.rxns),numel(model.genes)); +[~,geneOrder] = ismember(genes,model.genes); +if any(geneOrder == 0) + error(['The grRules includes the following gene(s), that are not in '... + 'the list of model genes: ', genes{~geneOrder}]) +end +model.rxnGeneMat(:,geneOrder) = rxnGeneMat; % Finalize GECKO model if isGECKO From a1584869a2e0594fd6e8aa55c5f73a973657a78c Mon Sep 17 00:00:00 2001 From: edkerk Date: Wed, 28 Jun 2023 01:27:41 +0200 Subject: [PATCH 2/2] fix: writeYAMLmodel avoid escape character parsing --- doc/io/writeYAMLmodel.html | 131 ++++++++++++++++++------------------- io/writeYAMLmodel.m | 53 +++++++-------- 2 files changed, 89 insertions(+), 95 deletions(-) diff --git a/doc/io/writeYAMLmodel.html b/doc/io/writeYAMLmodel.html index 531ed4c3..39b01959 100644 --- a/doc/io/writeYAMLmodel.html +++ b/doc/io/writeYAMLmodel.html @@ -223,7 +223,7 @@

SOURCE CODE ^if strcmp(fieldName,'metMiriams') 0166 if ~isempty(model.metMiriams{pos}) -0167 fprintf(fid,[' ' name ': !!omap\n']); +0167 fprintf(fid,' %s: !!omap\n',name); 0168 for i=1:size(model.newMetMiriams,2) 0169 %'i' represents the different miriam names, e.g. 0170 %kegg.compound or chebi @@ -238,7 +238,7 @@

SOURCE CODE ^elseif strcmp(fieldName,'rxnMiriams') 0181 if ~isempty(model.rxnMiriams{pos}) -0182 fprintf(fid,[' ' name ': !!omap\n']); +0182 fprintf(fid,' %s: !!omap\n',name); 0183 for i=1:size(model.newRxnMiriams,2) 0184 if ~isempty(model.newRxnMiriams{pos,i}) 0185 writeField(model, fid, 'newRxnMiriams', 'txt', pos, [' - ' model.newRxnMiriamNames{i} '_' sprintf('%d',i)], preserveQuotes) @@ -248,7 +248,7 @@

SOURCE CODE ^elseif strcmp(fieldName,'geneMiriams') 0191 if ~isempty(model.geneMiriams{pos}) -0192 fprintf(fid,[' ' name ': !!omap\n']); +0192 fprintf(fid,' %s: !!omap\n',name); 0193 for i=1:size(model.newGeneMiriams,2) 0194 if ~isempty(model.newGeneMiriams{pos,i}) 0195 writeField(model, fid, 'newGeneMiriams', 'txt', pos, [' - ' model.newGeneMiriamNames{i} '_' sprintf('%d',i)], preserveQuotes) @@ -258,7 +258,7 @@

SOURCE CODE ^elseif strcmp(fieldName,'compMiriams') 0201 if ~isempty(model.compMiriams{pos}) -0202 fprintf(fid,[' ' name ': !!omap\n']); +0202 fprintf(fid,' %s: !!omap\n',name); 0203 for i=1:size(model.newCompMiriams,2) 0204 if ~isempty(model.newCompMiriams{pos,i}) 0205 writeField(model, fid, 'newCompMiriams', 'txt', pos, [' - ' model.newCompMiriamNames{i} '_' sprintf('%d',i)], preserveQuotes) @@ -268,7 +268,7 @@

SOURCE CODE ^elseif strcmp(fieldName,'S') 0211 %S: create header & write each metabolite in a new line -0212 fprintf(fid,[' ' name ': !!omap\n']); +0212 fprintf(fid,' %s: !!omap\n',name); 0213 if sum(field(:,pos) ~= 0) > 0 0214 model.mets = model.mets(field(:,pos) ~= 0); 0215 model.coeffs = field(field(:,pos) ~= 0,pos); @@ -282,7 +282,7 @@

SOURCE CODE ^elseif strcmp(fieldName,'rxnEnzMat') 0225 %S: create header & write each enzyme in a new line -0226 fprintf(fid,[' ' name ': !!omap\n']); +0226 fprintf(fid,' %s: !!omap\n',name); 0227 if sum(field(pos,:) ~= 0) > 0 0228 model.enzymes = model.enzymes(field(pos,:) ~= 0); 0229 model.coeffs = field(pos,field(pos,:) ~= 0); @@ -326,16 +326,16 @@

SOURCE CODE ^if preserveQuotes 0268 list = ['"' list{1} '"']; 0269 end -0270 fprintf(fid,[' ' name ': ' list '\n']); +0270 fprintf(fid,' %s: %s\n',name,list); 0271 elseif length(list) > 1 || strcmp(fieldName,'subSystems') 0272 if preserveQuotes 0273 for j=1:numel(list) 0274 list{j} = ['"' list{j} '"']; 0275 end 0276 end -0277 fprintf(fid,[' ' name ':\n']); +0277 fprintf(fid,' %s:\n',name); 0278 for i = 1:length(list) -0279 fprintf(fid,[regexprep(name,'(^\s*).*','$1') ' - ' list{i} '\n']); +0279 fprintf(fid,'%s - %s\n',regexprep(name,'(^\s*).*','$1'),list{i}); 0280 end 0281 end 0282 @@ -354,68 +354,65 @@

SOURCE CODE ^end 0296 end 0297 if ~isempty(value) -0298 fprintf(fid,[' ' name ': ' value '\n']); +0298 fprintf(fid,' %s: %s\n',name,value); 0299 end 0300 end 0301 end -0302 +0302 end 0303 -0304 end -0305 -0306 function writeMetadata(model,fid) -0307 % Writes model metadata to the yaml file. This information will eventually -0308 % be extracted entirely from the model, but for now, many of the entries -0309 % are hard-coded defaults for HumanGEM. -0310 -0311 fprintf(fid, '- metaData:\n'); -0312 fprintf(fid, [' id: "', model.id, '"\n']); -0313 fprintf(fid, [' name: "', model.name, '"\n']); -0314 if isfield(model,'version') -0315 fprintf(fid, [' version: "', model.version, '"\n']); -0316 end -0317 fprintf(fid, [' date: "', datestr(now,29), '"\n']); % 29=YYYY-MM-DD -0318 if isfield(model,'annotation') -0319 if isfield(model.annotation,'defaultLB') -0320 fprintf(fid, [' defaultLB: "', num2str(model.annotation.defaultLB), '"\n']); -0321 end -0322 if isfield(model.annotation,'defaultUB') -0323 fprintf(fid, [' defaultUB: "', num2str(model.annotation.defaultUB), '"\n']); -0324 end -0325 if isfield(model.annotation,'givenName') -0326 fprintf(fid, [' givenName: "', model.annotation.givenName, '"\n']); -0327 end -0328 if isfield(model.annotation,'familyName') -0329 fprintf(fid, [' familyName: "', model.annotation.familyName, '"\n']); -0330 end -0331 if isfield(model.annotation,'authors') -0332 fprintf(fid, [' authors: "', model.annotation.authors, '"\n']); -0333 end -0334 if isfield(model.annotation,'email') -0335 fprintf(fid, [' email: "', model.annotation.email, '"\n']); -0336 end -0337 if isfield(model.annotation,'organization') -0338 fprintf(fid, [' organization: "', model.annotation.organization, '"\n']); -0339 end -0340 if isfield(model.annotation,'taxonomy') -0341 fprintf(fid, [' taxonomy: "', model.annotation.taxonomy, '"\n']); -0342 end -0343 if isfield(model.annotation,'note') -0344 fprintf(fid, [' note: "', model.annotation.note, '"\n']); -0345 end -0346 if isfield(model.annotation,'sourceUrl') -0347 fprintf(fid, [' sourceUrl: "', model.annotation.sourceUrl, '"\n']); -0348 end -0349 end -0350 if isfield(model,'ec') -0351 if model.ec.geckoLight -0352 geckoLight = 'true'; -0353 else -0354 geckoLight = 'false'; -0355 end -0356 fprintf(fid,[' geckoLight: "' geckoLight '"\n']); -0357 end -0358 end -0359 +0304 function writeMetadata(model,fid) +0305 % Writes model metadata to the yaml file. This information will eventually +0306 % be extracted entirely from the model, but for now, many of the entries +0307 % are hard-coded defaults for HumanGEM. +0308 +0309 fprintf(fid, '- metaData:\n'); +0310 fprintf(fid, ' id: "%s"\n', model.id); +0311 fprintf(fid, ' name: "%s"\n',model.name); +0312 if isfield(model,'version') +0313 fprintf(fid, ' version: "%s"\n',model.version); +0314 end +0315 fprintf(fid, ' date: "%s"\n',datestr(now,29)); % 29=YYYY-MM-DD +0316 if isfield(model,'annotation') +0317 if isfield(model.annotation,'defaultLB') +0318 fprintf(fid, ' defaultLB: "%g"\n', model.annotation.defaultLB); +0319 end +0320 if isfield(model.annotation,'defaultUB') +0321 fprintf(fid, ' defaultUB: "%g"\n', model.annotation.defaultUB); +0322 end +0323 if isfield(model.annotation,'givenName') +0324 fprintf(fid, ' givenName: "%s"\n', model.annotation.givenName); +0325 end +0326 if isfield(model.annotation,'familyName') +0327 fprintf(fid, ' familyName: "%s"\n', model.annotation.familyName); +0328 end +0329 if isfield(model.annotation,'authors') +0330 fprintf(fid, ' authors: "%s"\n', model.annotation.authors); +0331 end +0332 if isfield(model.annotation,'email') +0333 fprintf(fid, ' email: "%s"\n', model.annotation.email); +0334 end +0335 if isfield(model.annotation,'organization') +0336 fprintf(fid, ' organization: "%s"\n',model.annotation.organization); +0337 end +0338 if isfield(model.annotation,'taxonomy') +0339 fprintf(fid, ' taxonomy: "%s"\n', model.annotation.taxonomy); +0340 end +0341 if isfield(model.annotation,'note') +0342 fprintf(fid, ' note: "%s"\n', model.annotation.note); +0343 end +0344 if isfield(model.annotation,'sourceUrl') +0345 fprintf(fid, ' sourceUrl: "%s"\n', model.annotation.sourceUrl); +0346 end +0347 end +0348 if isfield(model,'ec') +0349 if model.ec.geckoLight +0350 geckoLight = 'true'; +0351 else +0352 geckoLight = 'false'; +0353 end +0354 fprintf(fid,' geckoLight: "%s"\n',geckoLight); +0355 end +0356 end
Generated by m2html © 2005
\ No newline at end of file diff --git a/io/writeYAMLmodel.m b/io/writeYAMLmodel.m index b1ac8b34..e50eb4eb 100644 --- a/io/writeYAMLmodel.m +++ b/io/writeYAMLmodel.m @@ -164,7 +164,7 @@ function writeField(model,fid,fieldName,type,pos,name,preserveQuotes) if strcmp(fieldName,'metMiriams') if ~isempty(model.metMiriams{pos}) - fprintf(fid,[' ' name ': !!omap\n']); + fprintf(fid,' %s: !!omap\n',name); for i=1:size(model.newMetMiriams,2) %'i' represents the different miriam names, e.g. %kegg.compound or chebi @@ -179,7 +179,7 @@ function writeField(model,fid,fieldName,type,pos,name,preserveQuotes) elseif strcmp(fieldName,'rxnMiriams') if ~isempty(model.rxnMiriams{pos}) - fprintf(fid,[' ' name ': !!omap\n']); + fprintf(fid,' %s: !!omap\n',name); for i=1:size(model.newRxnMiriams,2) if ~isempty(model.newRxnMiriams{pos,i}) writeField(model, fid, 'newRxnMiriams', 'txt', pos, [' - ' model.newRxnMiriamNames{i} '_' sprintf('%d',i)], preserveQuotes) @@ -189,7 +189,7 @@ function writeField(model,fid,fieldName,type,pos,name,preserveQuotes) elseif strcmp(fieldName,'geneMiriams') if ~isempty(model.geneMiriams{pos}) - fprintf(fid,[' ' name ': !!omap\n']); + fprintf(fid,' %s: !!omap\n',name); for i=1:size(model.newGeneMiriams,2) if ~isempty(model.newGeneMiriams{pos,i}) writeField(model, fid, 'newGeneMiriams', 'txt', pos, [' - ' model.newGeneMiriamNames{i} '_' sprintf('%d',i)], preserveQuotes) @@ -199,7 +199,7 @@ function writeField(model,fid,fieldName,type,pos,name,preserveQuotes) elseif strcmp(fieldName,'compMiriams') if ~isempty(model.compMiriams{pos}) - fprintf(fid,[' ' name ': !!omap\n']); + fprintf(fid,' %s: !!omap\n',name); for i=1:size(model.newCompMiriams,2) if ~isempty(model.newCompMiriams{pos,i}) writeField(model, fid, 'newCompMiriams', 'txt', pos, [' - ' model.newCompMiriamNames{i} '_' sprintf('%d',i)], preserveQuotes) @@ -209,7 +209,7 @@ function writeField(model,fid,fieldName,type,pos,name,preserveQuotes) elseif strcmp(fieldName,'S') %S: create header & write each metabolite in a new line - fprintf(fid,[' ' name ': !!omap\n']); + fprintf(fid,' %s: !!omap\n',name); if sum(field(:,pos) ~= 0) > 0 model.mets = model.mets(field(:,pos) ~= 0); model.coeffs = field(field(:,pos) ~= 0,pos); @@ -223,7 +223,7 @@ function writeField(model,fid,fieldName,type,pos,name,preserveQuotes) elseif strcmp(fieldName,'rxnEnzMat') %S: create header & write each enzyme in a new line - fprintf(fid,[' ' name ': !!omap\n']); + fprintf(fid,' %s: !!omap\n',name); if sum(field(pos,:) ~= 0) > 0 model.enzymes = model.enzymes(field(pos,:) ~= 0); model.coeffs = field(pos,field(pos,:) ~= 0); @@ -267,16 +267,16 @@ function writeField(model,fid,fieldName,type,pos,name,preserveQuotes) if preserveQuotes list = ['"' list{1} '"']; end - fprintf(fid,[' ' name ': ' list '\n']); + fprintf(fid,' %s: %s\n',name,list); elseif length(list) > 1 || strcmp(fieldName,'subSystems') if preserveQuotes for j=1:numel(list) list{j} = ['"' list{j} '"']; end end - fprintf(fid,[' ' name ':\n']); + fprintf(fid,' %s:\n',name); for i = 1:length(list) - fprintf(fid,[regexprep(name,'(^\s*).*','$1') ' - ' list{i} '\n']); + fprintf(fid,'%s - %s\n',regexprep(name,'(^\s*).*','$1'),list{i}); end end @@ -295,12 +295,10 @@ function writeField(model,fid,fieldName,type,pos,name,preserveQuotes) end end if ~isempty(value) - fprintf(fid,[' ' name ': ' value '\n']); + fprintf(fid,' %s: %s\n',name,value); end end end - - end function writeMetadata(model,fid) @@ -309,42 +307,42 @@ function writeMetadata(model,fid) % are hard-coded defaults for HumanGEM. fprintf(fid, '- metaData:\n'); -fprintf(fid, [' id: "', model.id, '"\n']); -fprintf(fid, [' name: "', model.name, '"\n']); +fprintf(fid, ' id: "%s"\n', model.id); +fprintf(fid, ' name: "%s"\n',model.name); if isfield(model,'version') - fprintf(fid, [' version: "', model.version, '"\n']); + fprintf(fid, ' version: "%s"\n',model.version); end -fprintf(fid, [' date: "', datestr(now,29), '"\n']); % 29=YYYY-MM-DD +fprintf(fid, ' date: "%s"\n',datestr(now,29)); % 29=YYYY-MM-DD if isfield(model,'annotation') if isfield(model.annotation,'defaultLB') - fprintf(fid, [' defaultLB: "', num2str(model.annotation.defaultLB), '"\n']); + fprintf(fid, ' defaultLB: "%g"\n', model.annotation.defaultLB); end if isfield(model.annotation,'defaultUB') - fprintf(fid, [' defaultUB: "', num2str(model.annotation.defaultUB), '"\n']); + fprintf(fid, ' defaultUB: "%g"\n', model.annotation.defaultUB); end if isfield(model.annotation,'givenName') - fprintf(fid, [' givenName: "', model.annotation.givenName, '"\n']); + fprintf(fid, ' givenName: "%s"\n', model.annotation.givenName); end if isfield(model.annotation,'familyName') - fprintf(fid, [' familyName: "', model.annotation.familyName, '"\n']); + fprintf(fid, ' familyName: "%s"\n', model.annotation.familyName); end if isfield(model.annotation,'authors') - fprintf(fid, [' authors: "', model.annotation.authors, '"\n']); + fprintf(fid, ' authors: "%s"\n', model.annotation.authors); end if isfield(model.annotation,'email') - fprintf(fid, [' email: "', model.annotation.email, '"\n']); + fprintf(fid, ' email: "%s"\n', model.annotation.email); end if isfield(model.annotation,'organization') - fprintf(fid, [' organization: "', model.annotation.organization, '"\n']); + fprintf(fid, ' organization: "%s"\n',model.annotation.organization); end if isfield(model.annotation,'taxonomy') - fprintf(fid, [' taxonomy: "', model.annotation.taxonomy, '"\n']); + fprintf(fid, ' taxonomy: "%s"\n', model.annotation.taxonomy); end if isfield(model.annotation,'note') - fprintf(fid, [' note: "', model.annotation.note, '"\n']); + fprintf(fid, ' note: "%s"\n', model.annotation.note); end if isfield(model.annotation,'sourceUrl') - fprintf(fid, [' sourceUrl: "', model.annotation.sourceUrl, '"\n']); + fprintf(fid, ' sourceUrl: "%s"\n', model.annotation.sourceUrl); end end if isfield(model,'ec') @@ -353,7 +351,6 @@ function writeMetadata(model,fid) else geckoLight = 'false'; end - fprintf(fid,[' geckoLight: "' geckoLight '"\n']); + fprintf(fid,' geckoLight: "%s"\n',geckoLight); end end -