From 6d26d17cfca9f16cbab06df200ebb646c798a0ae Mon Sep 17 00:00:00 2001 From: haowang-bioinfo Date: Tue, 22 Mar 2022 21:26:18 +0800 Subject: [PATCH 1/5] fix: change to txt format metabolic task file --- code/gapfill4EssentialTasks.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/gapfill4EssentialTasks.m b/code/gapfill4EssentialTasks.m index 827f938d..110bfb0b 100644 --- a/code/gapfill4EssentialTasks.m +++ b/code/gapfill4EssentialTasks.m @@ -57,7 +57,7 @@ % load metabolic task for growth under Ham's media [ST, I] = dbstack('-completenames'); path = fileparts(ST(I).file); -essentialTasks = fullfile(path,'../data/metabolicTasks','metabolicTasks_Essential.xlsx'); +essentialTasks = fullfile(path,'../data/metabolicTasks','metabolicTasks_Essential.txt'); taskStruct = parseTaskList(essentialTasks); %taskStruct = taskStruct(end); From 51f86ca60b50918d9b05811fd8ba9f61d183a59c Mon Sep 17 00:00:00 2001 From: haowang-bioinfo Date: Mon, 28 Mar 2022 20:17:32 +0800 Subject: [PATCH 2/5] fix: Inactivate human biomass reaction (MAR13082) by default - This is to fix the issue reported in Mouse-GEM issue #11 --- code/gapfill4EssentialTasks.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/gapfill4EssentialTasks.m b/code/gapfill4EssentialTasks.m index 110bfb0b..83aed0f3 100644 --- a/code/gapfill4EssentialTasks.m +++ b/code/gapfill4EssentialTasks.m @@ -120,10 +120,10 @@ outputModel = inputModel; -% block all biomass equations -%ind = find(startsWith(outputModel.rxns,'biomass')); -%outputModel.ub(ind) = 0; -%outputModel.lb(ind) = 0; +% block human biomass equations +ind = find(strcmp(outputModel.rxns,'MAR13082')); +outputModel.ub(ind) = 0; +outputModel.lb(ind) = 0; outputModel.c(:) = 0; % reset object function to "biomass_components" From 7f5bc440ad8e53ffbb22a30a93e7f7eaba991c51 Mon Sep 17 00:00:00 2001 From: haowang-bioinfo Date: Mon, 28 Mar 2022 21:51:37 +0800 Subject: [PATCH 3/5] fix: add proper LB and UB to generated draft model - This is to fix the issue reported in Mouse-GEM issue #12 --- code/getModelFromOrthology.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/getModelFromOrthology.m b/code/getModelFromOrthology.m index e7170820..2497b1cf 100644 --- a/code/getModelFromOrthology.m +++ b/code/getModelFromOrthology.m @@ -43,7 +43,8 @@ templateModel.description = ''; templateModel.version = ''; templateModel.annotation = structfun(@(x) '',templateModel.annotation,'UniformOutput',0); - +templateModel.annotation.defaultLB = -1000; +templateModel.annotation.defaultUB = 1000; % find the index of non-empty grRules before replacing genes preNonEmptyRuleInd = find(~cellfun(@isempty, templateModel.grRules)); From c56b4ebab2f41f032076b4eee4baec8703b80eb0 Mon Sep 17 00:00:00 2001 From: haowang-bioinfo Date: Wed, 30 Mar 2022 14:15:12 +0800 Subject: [PATCH 4/5] feat: turn into a more generic function by adding `annPath` argument --- code/annotateGEM.m | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/code/annotateGEM.m b/code/annotateGEM.m index 8c823d2e..50e1c64f 100644 --- a/code/annotateGEM.m +++ b/code/annotateGEM.m @@ -1,10 +1,13 @@ -function annModel = annotateGEM(model,annType,addMiriams,addFields,overwrite) +function annModel = annotateGEM(model,annPath,annType,addMiriams,addFields,overwrite) % Add reaction, metabolite, and/or gene annotation to a model. % % Input: % % model Model structure. % +% annPath Path to the annotation files, which suppose to be named as +% 'reactions.tsv', 'metabolites.tsv', and 'genes.tsv'。 +% % annType String or cell array of strings specifying the type(s) of % annotation data to add: 'rxn', 'met', and/or 'gene'. To % add all annotation types, use 'all'. @@ -35,27 +38,32 @@ % % Usage: % -% annModel = annotateGEM(model,annType,addMiriams,addFields,overwrite); +% annModel = annotateGEM(model,annPath,annType,addMiriams,addFields,overwrite); % %% Inputs and setup -if nargin < 2 || isempty(annType) || strcmpi(annType,'all') +if nargin < 2 + [ST, I] = dbstack('-completenames'); + annPath = strcat(fileparts(ST(I).file),'/../model'); +end + +if nargin < 3 || isempty(annType) || strcmpi(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"'); end -if nargin < 3 || isempty(addMiriams) +if nargin < 4 || isempty(addMiriams) addMiriams = true; end -if nargin < 4 || isempty(addFields) +if nargin < 5 || isempty(addFields) addFields = true; end -if nargin < 5 +if nargin < 6 overwrite = true; end @@ -96,9 +104,7 @@ % load reaction annotation data if any(ismember({'rxn','reaction'},lower(annType))) - [ST, I] = dbstack('-completenames'); - path = fileparts(ST(I).file); - tmpfile = fullfile(path,'../model','reactions.tsv'); + tmpfile = fullfile(annPath,'reactions.tsv'); rxnAssoc = importTsvFile(tmpfile); % strip "RHEA:" prefix from Rhea IDs since it should not be included in @@ -119,9 +125,7 @@ % load metabolite annotation data if any(ismember({'met','metabolite'},lower(annType))) - [ST, I] = dbstack('-completenames'); - path = fileparts(ST(I).file); - tmpfile = fullfile(path,'../model','metabolites.tsv'); + tmpfile = fullfile(annPath,'metabolites.tsv'); metAssoc = importTsvFile(tmpfile); % ChEBI IDs should be of the form "CHEBI:#####" @@ -140,9 +144,7 @@ % load and organize gene annotation data if ismember('gene',lower(annType)) - [ST, I] = dbstack('-completenames'); - path = fileparts(ST(I).file); - tmpfile = fullfile(path,'../model','genes.tsv'); + tmpfile = fullfile(annPath,'genes.tsv'); geneAssoc = importTsvFile(tmpfile); % add geneEnsemblID field if missing From 2708eeafe6e1614ad3f0ac58de365ba58c678022 Mon Sep 17 00:00:00 2001 From: haowang-bioinfo Date: Wed, 30 Mar 2022 16:42:24 +0800 Subject: [PATCH 5/5] 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)