diff --git a/geckomat/change_model/addEnzymesToRxn.m b/geckomat/change_model/addEnzymesToRxn.m index 3c65a85df..a21f22aa3 100644 --- a/geckomat/change_model/addEnzymesToRxn.m +++ b/geckomat/change_model/addEnzymesToRxn.m @@ -43,7 +43,7 @@ rxnToAdd.mets = [metS,newMets,metP]; rxnToAdd.stoichCoeffs = [coeffsS,-kvalues.^-1,coeffsP]; if ismember(newRxnName{1},model.rxns) - model = changeRxns(model,newRxnName(1),rxnToAdd,1,comp); + model = changeRxns(model,newRxnName(1),rxnToAdd,1,comp,true); else rxnToAdd.rxns = newRxnName(1); rxnToAdd.rxnNames = newRxnName(2); diff --git a/geckomat/change_model/manualModifications.m b/geckomat/change_model/manualModifications.m index 3eb37b4e2..8c7b4f9fb 100644 --- a/geckomat/change_model/manualModifications.m +++ b/geckomat/change_model/manualModifications.m @@ -62,20 +62,19 @@ for k = 1:length(prot_set) model.S(int_pos(k),i) = 0; end - %If some proteins where not present previously, add them: - newMets = uniprots{j}; + %Add new protein stoich. coeffs to rxn: + kvalues = kcats(j)./stoich{j}; + rxnID = model.rxns{i}; + newMets = strcat('prot_',uniprots{j}); + rxnName = model.rxnNames{i}; grRule = protGenes{j}; + model = addEnzymesToRxn(model,kvalues,rxnID,newMets,{rxnID,rxnName},grRule); + %If some proteins where not present previously, add them: for k = 1:length(uniprots{j}) if sum(strcmp(model.enzymes,uniprots{j}{k})) == 0 model = addProtein(model,uniprots{j}{k},kegg,swissprot); end - newMets{k} = ['prot_' newMets{k}]; end - %Add new protein stoich. coeffs to rxn: - kvalues = kcats(j)./stoich{j}; - rxnID = model.rxns{i}; - rxnName = model.rxnNames{i}; - model = addEnzymesToRxn(model,kvalues,rxnID,newMets,{rxnID,rxnName},grRule); end end %Update int_pos: diff --git a/geckomat/limit_proteins/scaleBioMass.m b/geckomat/limit_proteins/scaleBioMass.m index 95632f04d..e91aefa7a 100644 --- a/geckomat/limit_proteins/scaleBioMass.m +++ b/geckomat/limit_proteins/scaleBioMass.m @@ -60,11 +60,13 @@ rxnName = [metName ' pseudoreaction']; rxnPos = strcmp(model.rxnNames,rxnName); -for i = 1:length(model.mets) - S_ir = model.S(i,rxnPos); - isProd = strcmp(model.metNames{i},metName); - if S_ir ~= 0 && ~isProd - model.S(i,rxnPos) = f*S_ir; +if sum(rxnPos) == 1 + for i = 1:length(model.mets) + S_ir = model.S(i,rxnPos); + isProd = strcmp(model.metNames{i},metName); + if S_ir ~= 0 && ~isProd + model.S(i,rxnPos) = f*S_ir; + end end end diff --git a/models/saveECmodel.m b/models/saveECmodel.m index 945144333..2bfde34ea 100644 --- a/models/saveECmodel.m +++ b/models/saveECmodel.m @@ -39,16 +39,16 @@ %Transform model back to COBRA for saving purposes: model_cobra = ravenCobraWrapper(model); %Remove fields from COBRA model (temporal): - model_cobra = rmfield(model_cobra,'metCharges'); - model_cobra = rmfield(model_cobra,'metChEBIID'); - model_cobra = rmfield(model_cobra,'metKEGGID'); - model_cobra = rmfield(model_cobra,'metSBOTerms'); - model_cobra = rmfield(model_cobra,'rxnConfidenceScores'); - model_cobra = rmfield(model_cobra,'rxnECNumbers'); - model_cobra = rmfield(model_cobra,'rxnKEGGID'); - model_cobra = rmfield(model_cobra,'rxnReferences'); - model_cobra = rmfield(model_cobra,'subSystems'); - model_cobra = rmfield(model_cobra,'rxnSBOTerms'); + model_cobra = takeOutField(model_cobra,'metCharges'); + model_cobra = takeOutField(model_cobra,'metChEBIID'); + model_cobra = takeOutField(model_cobra,'metKEGGID'); + model_cobra = takeOutField(model_cobra,'metSBOTerms'); + model_cobra = takeOutField(model_cobra,'rxnConfidenceScores'); + model_cobra = takeOutField(model_cobra,'rxnECNumbers'); + model_cobra = takeOutField(model_cobra,'rxnKEGGID'); + model_cobra = takeOutField(model_cobra,'rxnReferences'); + model_cobra = takeOutField(model_cobra,'subSystems'); + model_cobra = takeOutField(model_cobra,'rxnSBOTerms'); %Save model as sbml and text: writeCbModel(model_cobra,'sbml',[file_name '.xml']); writeCbModel(model_cobra,'text',[file_name '.txt']); @@ -81,3 +81,13 @@ end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function model = takeOutField(model,field) + +if isfield(model,field) + model = rmfield(model,field); +end + +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%