diff --git a/GECKOInstaller.m b/GECKOInstaller.m index 210b8ee2..ccb469d4 100644 --- a/GECKOInstaller.m +++ b/GECKOInstaller.m @@ -72,15 +72,11 @@ function checkRAVENversion(minmVer) minmVerNum = str2double(strsplit(minmVer,'.')); if currVerNum(1) < minmVerNum(1) wrongVersion = true; - elseif currVerNum(1) > minmVerNum(1) - wrongVersion = false; elseif currVerNum(2) < minmVerNum(2) wrongVersion = true; - elseif currVerNum(2) > minmVerNum(2) - wrongVersion = false; elseif currVerNum(3) < minmVerNum(3) wrongVersion = true; - elseif currVerNum(3) >= minmVerNum(3) + else wrongVersion = false; end end diff --git a/doc/src/geckomat/gather_kcats/getStandardKcat.html b/doc/src/geckomat/gather_kcats/getStandardKcat.html index b5b6ea32..ae9276e8 100644 --- a/doc/src/geckomat/gather_kcats/getStandardKcat.html +++ b/doc/src/geckomat/gather_kcats/getStandardKcat.html @@ -279,134 +279,141 @@

SOURCE CODE ^% Add a new metabolite named prot_standard 0178 proteinStdMets.mets = 'prot_standard'; 0179 proteinStdMets.metNames = proteinStdMets.mets; -0180 proteinStdMets.compartments = 'c'; -0181 if isfield(model,'metNotes') -0182 proteinStdMets.metNotes = 'Standard enzyme-usage pseudometabolite'; -0183 end -0184 model = addMets(model, proteinStdMets); -0185 -0186 % Add a protein usage reaction if not a light version -0187 proteinStdUsageRxn.rxns = {'usage_prot_standard'}; -0188 proteinStdUsageRxn.rxnNames = proteinStdUsageRxn.rxns; -0189 proteinStdUsageRxn.mets = {proteinStdMets.mets, 'prot_pool'}; -0190 proteinStdUsageRxn.stoichCoeffs = [-1, 1]; -0191 proteinStdUsageRxn.lb = -1000; -0192 proteinStdUsageRxn.ub = 0; -0193 proteinStdUsageRxn.grRules = proteinStdGenes.genes; -0194 -0195 model = addRxns(model, proteinStdUsageRxn); -0196 end -0197 % Update .ec structure in model -0198 model.ec.genes(end+1) = {'standard'}; -0199 model.ec.enzymes(end+1) = {'standard'}; -0200 model.ec.mw(end+1) = standardMW; -0201 model.ec.sequence(end+1) = {''}; -0202 % Additional info -0203 if isfield(model.ec,'concs') -0204 model.ec.concs(end+1) = nan(); -0205 end -0206 -0207 % Expand the enzyme rxns matrix -0208 model.ec.rxnEnzMat = [model.ec.rxnEnzMat, zeros(length(model.ec.rxns), 1)]; % 1 new enzyme -0209 model.ec.rxnEnzMat = [model.ec.rxnEnzMat; zeros(length(rxnsMissingGPR), length(model.ec.enzymes))]; % new rxns -0210 end -0211 stdMetIdx = find(strcmpi(model.ec.enzymes, 'standard')); -0212 -0213 % Remove previous standard kcat assignment -0214 oldStandardEnz = find(strcmp(model.ec.source,'standard')); -0215 if ~isempty(oldStandardEnz) -0216 oldStandardProt = logical(model.ec.rxnEnzMat(oldStandardEnz,stdMetIdx)); -0217 % If annotated with real enzyme => set kcat to zero -0218 model.ec.kcat(oldStandardEnz(~oldStandardProt)) = 0; -0219 model.ec.source(oldStandardEnz(~oldStandardProt)) = {''}; -0220 % If annotated with standard protein => remove entry -0221 model.ec.rxns(oldStandardEnz(oldStandardProt)) = []; -0222 model.ec.kcat(oldStandardEnz(oldStandardProt)) = []; -0223 model.ec.source(oldStandardEnz(oldStandardProt)) = []; -0224 model.ec.notes(oldStandardEnz(oldStandardProt)) = []; -0225 model.ec.eccodes(oldStandardEnz(oldStandardProt)) = []; -0226 model.ec.rxnEnzMat(oldStandardEnz(oldStandardProt),:) = []; -0227 end -0228 -0229 numRxns = length(model.ec.rxns); -0230 for i = 1:numel(rxnsMissingGPR) -0231 rxnIdx = rxnsMissingGPR(i); -0232 -0233 % Update .ec structure in model -0234 if ~model.ec.geckoLight -0235 model.ec.rxns(end+1) = model.rxns(rxnIdx); -0236 % Add prefix in case is light version -0237 else -0238 model.ec.rxns{end+1} = ['001_' model.rxns{rxnIdx}]; -0239 end -0240 -0241 if ~standard -0242 kcatSubSystemIdx = strcmpi(enzSubSystem_names, model.subSystems{rxnIdx}(1)); -0243 if all(kcatSubSystemIdx) -0244 model.ec.kcat(end+1) = kcatSubSystem(kcatSubSystemIdx); -0245 else -0246 model.ec.kcat(end+1) = standardKcat; -0247 end -0248 else -0249 model.ec.kcat(end+1) = standardKcat; -0250 end -0251 -0252 model.ec.source(end+1) = {'standard'}; -0253 model.ec.notes(end+1) = {''}; -0254 model.ec.eccodes(end+1) = {''}; -0255 -0256 % Update the enzyme rxns matrix -0257 model.ec.rxnEnzMat(numRxns+i, stdMetIdx) = 1; -0258 end -0259 % Get the rxns identifiers of the updated rxns -0260 rxnsMissingGPR = model.rxns(rxnsMissingGPR); -0261 -0262 if fillZeroKcat -0263 zeroKcat = model.ec.kcat == 0 | isnan(model.ec.kcat); -0264 model.ec.kcat(zeroKcat) = standardKcat; -0265 model.ec.source(zeroKcat) = {'standard'}; -0266 rxnsNoKcat = model.ec.rxns(zeroKcat); -0267 else -0268 rxnsNoKcat = []; -0269 end -0270 end -0271 -0272 function Cflat = flattenCell(C,strFlag) -0273 %FLATTENCELL Flatten a nested column cell array into a matrix cell array. -0274 % -0275 % CFLAT = FLATTENCELL(C) takes a column cell array in which one or more -0276 % entries is a nested cell array, and flattens it into a 2D matrix cell -0277 % array, where the nested entries are spread across new columns. -0278 % -0279 % CFLAT = FLATTENCELL(C,STRFLAG) if STRFLAG is TRUE, empty entries in the -0280 % resulting CFLAT will be replaced with empty strings {''}. Default = FALSE -0281 if nargin < 2 -0282 strFlag = false; -0283 end -0284 -0285 % determine which entries are cells -0286 cells = cellfun(@iscell,C); -0287 -0288 % determine number of elements in each nested cell -0289 cellsizes = cellfun(@numel,C); -0290 cellsizes(~cells) = 1; % ignore non-cell entries +0180 % Validate compartment +0181 proteinStdMets.compartments = strcmp(model.compNames,params.enzyme_comp); +0182 if ~any(proteinStdMets.compartments) +0183 error(['Compartment ' params.enzyme_comp ' (specified in params.enzyme_comp) '... +0184 'cannot be found in model.compNames']) +0185 end +0186 proteinStdMets.compartments = model.comps(compartmentID); +0187 +0188 if isfield(model,'metNotes') +0189 proteinStdMets.metNotes = 'Standard enzyme-usage pseudometabolite'; +0190 end +0191 model = addMets(model, proteinStdMets); +0192 +0193 % Add a protein usage reaction if not a light version +0194 proteinStdUsageRxn.rxns = {'usage_prot_standard'}; +0195 proteinStdUsageRxn.rxnNames = proteinStdUsageRxn.rxns; +0196 proteinStdUsageRxn.mets = {proteinStdMets.mets, 'prot_pool'}; +0197 proteinStdUsageRxn.stoichCoeffs = [-1, 1]; +0198 proteinStdUsageRxn.lb = -1000; +0199 proteinStdUsageRxn.ub = 0; +0200 proteinStdUsageRxn.grRules = proteinStdGenes.genes; +0201 +0202 model = addRxns(model, proteinStdUsageRxn); +0203 end +0204 % Update .ec structure in model +0205 model.ec.genes(end+1) = {'standard'}; +0206 model.ec.enzymes(end+1) = {'standard'}; +0207 model.ec.mw(end+1) = standardMW; +0208 model.ec.sequence(end+1) = {''}; +0209 % Additional info +0210 if isfield(model.ec,'concs') +0211 model.ec.concs(end+1) = nan(); +0212 end +0213 +0214 % Expand the enzyme rxns matrix +0215 model.ec.rxnEnzMat = [model.ec.rxnEnzMat, zeros(length(model.ec.rxns), 1)]; % 1 new enzyme +0216 model.ec.rxnEnzMat = [model.ec.rxnEnzMat; zeros(length(rxnsMissingGPR), length(model.ec.enzymes))]; % new rxns +0217 end +0218 stdMetIdx = find(strcmpi(model.ec.enzymes, 'standard')); +0219 +0220 % Remove previous standard kcat assignment +0221 oldStandardEnz = find(strcmp(model.ec.source,'standard')); +0222 if ~isempty(oldStandardEnz) +0223 oldStandardProt = logical(model.ec.rxnEnzMat(oldStandardEnz,stdMetIdx)); +0224 % If annotated with real enzyme => set kcat to zero +0225 model.ec.kcat(oldStandardEnz(~oldStandardProt)) = 0; +0226 model.ec.source(oldStandardEnz(~oldStandardProt)) = {''}; +0227 % If annotated with standard protein => remove entry +0228 model.ec.rxns(oldStandardEnz(oldStandardProt)) = []; +0229 model.ec.kcat(oldStandardEnz(oldStandardProt)) = []; +0230 model.ec.source(oldStandardEnz(oldStandardProt)) = []; +0231 model.ec.notes(oldStandardEnz(oldStandardProt)) = []; +0232 model.ec.eccodes(oldStandardEnz(oldStandardProt)) = []; +0233 model.ec.rxnEnzMat(oldStandardEnz(oldStandardProt),:) = []; +0234 end +0235 +0236 numRxns = length(model.ec.rxns); +0237 for i = 1:numel(rxnsMissingGPR) +0238 rxnIdx = rxnsMissingGPR(i); +0239 +0240 % Update .ec structure in model +0241 if ~model.ec.geckoLight +0242 model.ec.rxns(end+1) = model.rxns(rxnIdx); +0243 % Add prefix in case is light version +0244 else +0245 model.ec.rxns{end+1} = ['001_' model.rxns{rxnIdx}]; +0246 end +0247 +0248 if ~standard +0249 kcatSubSystemIdx = strcmpi(enzSubSystem_names, model.subSystems{rxnIdx}(1)); +0250 if all(kcatSubSystemIdx) +0251 model.ec.kcat(end+1) = kcatSubSystem(kcatSubSystemIdx); +0252 else +0253 model.ec.kcat(end+1) = standardKcat; +0254 end +0255 else +0256 model.ec.kcat(end+1) = standardKcat; +0257 end +0258 +0259 model.ec.source(end+1) = {'standard'}; +0260 model.ec.notes(end+1) = {''}; +0261 model.ec.eccodes(end+1) = {''}; +0262 +0263 % Update the enzyme rxns matrix +0264 model.ec.rxnEnzMat(numRxns+i, stdMetIdx) = 1; +0265 end +0266 % Get the rxns identifiers of the updated rxns +0267 rxnsMissingGPR = model.rxns(rxnsMissingGPR); +0268 +0269 if fillZeroKcat +0270 zeroKcat = model.ec.kcat == 0 | isnan(model.ec.kcat); +0271 model.ec.kcat(zeroKcat) = standardKcat; +0272 model.ec.source(zeroKcat) = {'standard'}; +0273 rxnsNoKcat = model.ec.rxns(zeroKcat); +0274 else +0275 rxnsNoKcat = []; +0276 end +0277 end +0278 +0279 function Cflat = flattenCell(C,strFlag) +0280 %FLATTENCELL Flatten a nested column cell array into a matrix cell array. +0281 % +0282 % CFLAT = FLATTENCELL(C) takes a column cell array in which one or more +0283 % entries is a nested cell array, and flattens it into a 2D matrix cell +0284 % array, where the nested entries are spread across new columns. +0285 % +0286 % CFLAT = FLATTENCELL(C,STRFLAG) if STRFLAG is TRUE, empty entries in the +0287 % resulting CFLAT will be replaced with empty strings {''}. Default = FALSE +0288 if nargin < 2 +0289 strFlag = false; +0290 end 0291 -0292 % flatten single-entry cells -0293 Cflat = C; -0294 Cflat(cells & (cellsizes == 1)) = cellfun(@(x) x{1},Cflat(cells & (cellsizes == 1)),'UniformOutput',false); -0295 -0296 % iterate through multi-entry cells -0297 multiCells = find(cellsizes > 1); -0298 for i = 1:length(multiCells) -0299 cellContents = Cflat{multiCells(i)}; -0300 Cflat(multiCells(i),1:length(cellContents)) = cellContents; -0301 end +0292 % determine which entries are cells +0293 cells = cellfun(@iscell,C); +0294 +0295 % determine number of elements in each nested cell +0296 cellsizes = cellfun(@numel,C); +0297 cellsizes(~cells) = 1; % ignore non-cell entries +0298 +0299 % flatten single-entry cells +0300 Cflat = C; +0301 Cflat(cells & (cellsizes == 1)) = cellfun(@(x) x{1},Cflat(cells & (cellsizes == 1)),'UniformOutput',false); 0302 -0303 % change empty elements to strings, if specified -0304 if ( strFlag ) -0305 Cflat(cellfun(@isempty,Cflat)) = {''}; -0306 end -0307 end +0303 % iterate through multi-entry cells +0304 multiCells = find(cellsizes > 1); +0305 for i = 1:length(multiCells) +0306 cellContents = Cflat{multiCells(i)}; +0307 Cflat(multiCells(i),1:length(cellContents)) = cellContents; +0308 end +0309 +0310 % change empty elements to strings, if specified +0311 if ( strFlag ) +0312 Cflat(cellfun(@isempty,Cflat)) = {''}; +0313 end +0314 end
Generated by m2html © 2005
\ No newline at end of file diff --git a/doc/src/geckomat/limit_proteins/flexibilizeEnzConcs.html b/doc/src/geckomat/limit_proteins/flexibilizeEnzConcs.html index 539fa531..f63a0379 100644 --- a/doc/src/geckomat/limit_proteins/flexibilizeEnzConcs.html +++ b/doc/src/geckomat/limit_proteins/flexibilizeEnzConcs.html @@ -277,58 +277,59 @@

SOURCE CODE ^'Protein concentrations have not been defined. Please run readProteomics and constrainEnzConcs') 0183 end 0184 -0185 protFlex = proteins(frequence>0); -0186 protUsageIdx = find(ismember(model.rxns, strcat('usage_prot_', protFlex))); -0187 ecProtId = find(ismember(model.ec.enzymes,protFlex)); -0188 oldConcs = model.ec.concs(ecProtId); -0189 -0190 if flexBreak == false && ~isempty(protFlex) -0191 % Not all flexibilized proteins require flexibilization in the end -0192 % Test flux distribution with minimum prot_pool usage -0193 modelTemp = setParam(model,'var',params.bioRxn,expGrowth,0.5); -0194 modelTemp = setParam(modelTemp,'obj','prot_pool_exchange',1); -0195 sol = solveLP(modelTemp,1); -0196 % Check which concentrations can remain unchanged -0197 newConcs = abs(sol.x(protUsageIdx)); -0198 keepOld = newConcs<oldConcs; -0199 % Set UBs -0200 model.lb(protUsageIdx(keepOld)) = -oldConcs(keepOld); -0201 model.lb(protUsageIdx(~keepOld)) = -newConcs(~keepOld); -0202 % Output structure -0203 protFlex(keepOld) = []; -0204 oldConcs(keepOld) = []; -0205 newConcs(keepOld) = []; -0206 frequence=frequence(frequence>0); -0207 frequence(keepOld) = []; -0208 -0209 flexEnz.uniprotIDs = protFlex; -0210 flexEnz.oldConcs = oldConcs; -0211 flexEnz.flexConcs = newConcs; -0212 flexEnz.frequence = frequence(frequence>0); -0213 else -0214 protFlex = proteins(frequence>0); -0215 protUsageIdx = find(ismember(model.rxns, strcat('usage_prot_', protFlex))); -0216 -0217 flexEnz.uniprotIDs = protFlex; -0218 flexEnz.oldConcs = model.ec.concs(ecProtId); -0219 flexEnz.flexConcs = abs(model.lb(protUsageIdx)); -0220 flexEnz.frequence = frequence(frequence>0); -0221 end -0222 if changedProtPool -0223 flexEnz.uniprotIDs(end+1) = {'prot_pool'}; -0224 flexEnz.oldConcs(end+1) = oldProtPool; -0225 flexEnz.flexConcs(end+1) = newProtPool; -0226 flexEnz.frequence(end+1) = 1; -0227 end -0228 % Sort by biggest ratio increase -0229 flexEnz.ratioIncr = flexEnz.flexConcs./flexEnz.oldConcs; -0230 [~,b] = sort(flexEnz.ratioIncr,'descend'); -0231 flexEnz.ratioIncr = flexEnz.ratioIncr(b); -0232 flexEnz.uniprotIDs = flexEnz.uniprotIDs(b); -0233 flexEnz.oldConcs = flexEnz.oldConcs(b); -0234 flexEnz.flexConcs = flexEnz.flexConcs(b); -0235 flexEnz.frequence = flexEnz.frequence(b); -0236 end +0185 protFlex = proteins(frequence>0); +0186 [~,protUsageIdx] = ismember(strcat('usage_prot_', protFlex), model.rxns); +0187 [~,ecProtId] = ismember(protFlex, model.ec.enzymes); +0188 oldConcs = model.ec.concs(ecProtId); +0189 %frequence = frequence(ecProtId); +0190 +0191 if flexBreak == false && ~isempty(protFlex) +0192 % Not all flexibilized proteins require flexibilization in the end +0193 % Test flux distribution with minimum prot_pool usage +0194 modelTemp = setParam(model,'var',params.bioRxn,expGrowth,0.5); +0195 modelTemp = setParam(modelTemp,'obj','prot_pool_exchange',1); +0196 sol = solveLP(modelTemp,1); +0197 % Check which concentrations can remain unchanged +0198 newConcs = abs(sol.x(protUsageIdx)); +0199 keepOld = newConcs<oldConcs; +0200 % Set UBs +0201 model.lb(protUsageIdx(keepOld)) = -oldConcs(keepOld); +0202 model.lb(protUsageIdx(~keepOld)) = -newConcs(~keepOld); +0203 % Output structure +0204 protFlex(keepOld) = []; +0205 oldConcs(keepOld) = []; +0206 newConcs(keepOld) = []; +0207 frequence=frequence(frequence>0); +0208 frequence(keepOld) = []; +0209 +0210 flexEnz.uniprotIDs = protFlex; +0211 flexEnz.oldConcs = oldConcs; +0212 flexEnz.flexConcs = newConcs; +0213 flexEnz.frequence = frequence(frequence>0); +0214 else +0215 protFlex = proteins(frequence>0); +0216 [~, protUsageIdx] = ismember(strcat('usage_prot_', protFlex), model.rxns); +0217 +0218 flexEnz.uniprotIDs = protFlex; +0219 flexEnz.oldConcs = model.ec.concs(ecProtId); +0220 flexEnz.flexConcs = abs(model.lb(protUsageIdx)); +0221 flexEnz.frequence = frequence(frequence>0); +0222 end +0223 if changedProtPool +0224 flexEnz.uniprotIDs(end+1) = {'prot_pool'}; +0225 flexEnz.oldConcs(end+1) = oldProtPool; +0226 flexEnz.flexConcs(end+1) = newProtPool; +0227 flexEnz.frequence(end+1) = 1; +0228 end +0229 % Sort by biggest ratio increase +0230 flexEnz.ratioIncr = flexEnz.flexConcs./flexEnz.oldConcs; +0231 [~,b] = sort(flexEnz.ratioIncr,'descend'); +0232 flexEnz.ratioIncr = flexEnz.ratioIncr(b); +0233 flexEnz.uniprotIDs = flexEnz.uniprotIDs(b); +0234 flexEnz.oldConcs = flexEnz.oldConcs(b); +0235 flexEnz.flexConcs = flexEnz.flexConcs(b); +0236 flexEnz.frequence = flexEnz.frequence(b); +0237 end
Generated by m2html © 2005
\ No newline at end of file diff --git a/src/geckomat/gather_kcats/getStandardKcat.m b/src/geckomat/gather_kcats/getStandardKcat.m index 0a5203b8..a70f685a 100644 --- a/src/geckomat/gather_kcats/getStandardKcat.m +++ b/src/geckomat/gather_kcats/getStandardKcat.m @@ -177,7 +177,14 @@ % Add a new metabolite named prot_standard proteinStdMets.mets = 'prot_standard'; proteinStdMets.metNames = proteinStdMets.mets; - proteinStdMets.compartments = 'c'; + % Validate compartment + proteinStdMets.compartments = strcmp(model.compNames,params.enzyme_comp); + if ~any(proteinStdMets.compartments) + error(['Compartment ' params.enzyme_comp ' (specified in params.enzyme_comp) '... + 'cannot be found in model.compNames']) + end + proteinStdMets.compartments = model.comps(compartmentID); + if isfield(model,'metNotes') proteinStdMets.metNotes = 'Standard enzyme-usage pseudometabolite'; end diff --git a/src/geckomat/limit_proteins/flexibilizeEnzConcs.m b/src/geckomat/limit_proteins/flexibilizeEnzConcs.m index fd69e156..98fcac37 100644 --- a/src/geckomat/limit_proteins/flexibilizeEnzConcs.m +++ b/src/geckomat/limit_proteins/flexibilizeEnzConcs.m @@ -182,10 +182,11 @@ error('Protein concentrations have not been defined. Please run readProteomics and constrainEnzConcs') end -protFlex = proteins(frequence>0); -protUsageIdx = find(ismember(model.rxns, strcat('usage_prot_', protFlex))); -ecProtId = find(ismember(model.ec.enzymes,protFlex)); -oldConcs = model.ec.concs(ecProtId); +protFlex = proteins(frequence>0); +[~,protUsageIdx] = ismember(strcat('usage_prot_', protFlex), model.rxns); +[~,ecProtId] = ismember(protFlex, model.ec.enzymes); +oldConcs = model.ec.concs(ecProtId); +%frequence = frequence(ecProtId); if flexBreak == false && ~isempty(protFlex) % Not all flexibilized proteins require flexibilization in the end @@ -211,8 +212,8 @@ flexEnz.flexConcs = newConcs; flexEnz.frequence = frequence(frequence>0); else - protFlex = proteins(frequence>0); - protUsageIdx = find(ismember(model.rxns, strcat('usage_prot_', protFlex))); + protFlex = proteins(frequence>0); + [~, protUsageIdx] = ismember(strcat('usage_prot_', protFlex), model.rxns); flexEnz.uniprotIDs = protFlex; flexEnz.oldConcs = model.ec.concs(ecProtId);