-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1644 from opencobra/develop
Merger of PSCM toolbox described in PMID 32463598
- Loading branch information
Showing
108 changed files
with
24,237 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule papers
updated
2 files
+0 −123 | 2018_microbiomeModelingToolbox/mgPipe.m | |
+66 −30 | 2018_microbiomeModelingToolbox/startMgPipe.m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 50 additions & 44 deletions
94
src/analysis/multiSpecies/microbiomeModelingToolbox/mgPipe/addMicrobeCommunityBiomass.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,50 @@ | ||
function model = addMicrobeCommunityBiomass(model, microbeNames, abundances) | ||
% Adds a community biomass reaction to a model structure with multiple | ||
% microbes based on their relative abundances. If no abundance values are | ||
% provided, all n microbes get equal weights (1/n). Assumes a lumen | ||
% compartment [u] and a fecal secretion comparment [fe]. Creates a community | ||
% biomass metabolite 'microbeBiomass' that is secreted from [u] to [fe] and | ||
% exchanged from fecal compartment. | ||
% | ||
% USAGE: | ||
% | ||
% model = addMicrobeCommunityBiomass(model, microbeNames, abundances) | ||
% | ||
% INPUTS: | ||
% model: COBRA model structure with n joined microbes with biomass | ||
% metabolites 'Microbe_biomass[c]'. | ||
% microbeNames: nx1 cell array of n unique strings that represent | ||
% each microbe in the model. | ||
% | ||
% OPTIONAL INPUT: | ||
% abundances: nx1 vector with the relative abundance of each microbe. | ||
% | ||
% OUTPUT: | ||
% model: COBRA model structure | ||
% | ||
% .. Author: Stefania Magnusdottir June 2016 | ||
|
||
dummy = createModel(); %makeDummyModel(length(microbeNames) + 2, 3); | ||
|
||
mets = [strcat(microbeNames, '_biomass[c]'); 'microbeBiomass[u]'; 'microbeBiomass[fe]']; | ||
rxns = {'communityBiomass'; 'UFEt_microbeBiomass'; 'EX_microbeBiomass[fe]'}; | ||
if ~exist('abundances','var') || isempty(abundances) | ||
S = [-ones(size(microbeNames)) / length(microbeNames); 1; 0]; | ||
else | ||
S = [-abundances; 1; 0]; | ||
end | ||
S(end-1:end,2) = [-1; 1]; | ||
S(end,3) = -1; | ||
% three reactions are added | ||
lb = [0;0;-1000]; | ||
ub = ones(3,1) * 1000; | ||
dummy = addMultipleMetabolites(dummy,mets); | ||
dummy = addMultipleReactions(dummy,rxns,mets,S,'lb',lb,'ub',ub); | ||
% join models | ||
model = mergeTwoModels(dummy, model, 2, 0); | ||
function model = addMicrobeCommunityBiomass(model, microbeNames, abundances) | ||
% Adds a community biomass reaction to a model structure with multiple | ||
% microbes based on their relative abundances. If no abundance values are | ||
% provided, all n microbes get equal weights (1/n). Assumes a lumen | ||
% compartment [u] and a fecal secretion comparment [fe]. Creates a community | ||
% biomass metabolite 'microbeBiomass' that is secreted from [u] to [fe] and | ||
% exchanged from fecal compartment. | ||
% | ||
% USAGE: | ||
% | ||
% model = addMicrobeCommunityBiomass(model, microbeNames, abundances) | ||
% | ||
% INPUTS: | ||
% model: COBRA model structure with n joined microbes with biomass | ||
% metabolites 'Microbe_biomass[c]'. | ||
% microbeNames: nx1 cell array of n unique strings that represent | ||
% each microbe in the model. | ||
% | ||
% OPTIONAL INPUT: | ||
% abundances: nx1 vector with the relative abundance of each microbe. | ||
% | ||
% OUTPUT: | ||
% model: COBRA model structure | ||
% | ||
% .. Author: Stefania Magnusdottir June 2016 | ||
|
||
dummy = createModel(); %makeDummyModel(length(microbeNames) + 2, 3); | ||
|
||
mets = [strcat(microbeNames, '_biomass[c]'); 'microbeBiomass[u]'; 'microbeBiomass[fe]']; | ||
rxns = {'communityBiomass'; 'UFEt_microbeBiomass'; 'EX_microbeBiomass[fe]'}; | ||
if ~exist('abundances','var') || isempty(abundances) | ||
S = [-ones(size(microbeNames)) / length(microbeNames); 1; 0]; | ||
else | ||
S = [-abundances; 1; 0]; | ||
end | ||
S(end-1:end,2) = [-1; 1]; | ||
S(end,3) = -1; | ||
% three reactions are added | ||
lb = [0;0;-1000]; | ||
ub = ones(3,1) * 1000; | ||
dummy = addMultipleMetabolites(dummy,mets); | ||
dummy = addMultipleReactions(dummy,rxns,mets,S,'lb',lb,'ub',ub); | ||
% join models | ||
%model = mergeTwoModels(dummy, model, 2, 0); | ||
% modification made by IT, May 2020 | ||
% alternative and faster way to add the 3 reactions | ||
a = printRxnFormula(dummy); | ||
for i = 1 : length(a) | ||
model = addReaction(model, dummy.rxns{i},a{i}); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/analysis/topology/conservedMoieties/generateMoietyMoleculeNetwork.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
function MMN = generateMoietyMoleculeNetwork(model,L,moietyFormulae,mbool) | ||
%Generate a structure to represent a network that associates moieties to molecules | ||
|
||
[nMet,~]=size(model.S); | ||
[nMoieties, nMappedMet] = size(L); | ||
|
||
if ~exist('mbool','var') | ||
if nMet==nMappedMet | ||
mbool=true(nMet,1); | ||
else | ||
if nMet==nMoieties | ||
L=L'; | ||
[nMoieties, nMappedMet] = size(L); | ||
else | ||
error('mbool must be provided if the number of columns of L is different from the number of rows of model.S') | ||
end | ||
end | ||
else | ||
if nMappedMet~=nnz(mbool) | ||
if nMoieties==nnz(mbool) | ||
L=L'; | ||
[nMoieties, nMappedMet] = size(L); | ||
else | ||
error('mbool must have the same number of nonzeros as the number of columns of L') | ||
end | ||
end | ||
end | ||
|
||
MMN=struct(); | ||
|
||
MMN.L = L; | ||
|
||
%order of the numbers matches the order of the rows of L | ||
moietyID = zeros(nMoieties,1); | ||
for i=1:nMoieties | ||
moietyID(i) = i; | ||
end | ||
|
||
moietyFormulae = hillformula(moietyFormulae); | ||
|
||
isotopeAbundance = 0; %use polyisotopic inexact mass i.e. uses all isotopes of each element weighted by natural abundance | ||
generalFormula = 1; %NaN for unknown elements | ||
[moietyMasses, knownMasses, unknownElements, Ematrix, elements] = getMolecularMass(moietyFormulae,isotopeAbundance,generalFormula); | ||
|
||
NumMolecules = sum(L,2); | ||
|
||
%table of moiety properties | ||
MMN.moi = table(moietyID,moietyFormulae,moietyMasses,NumMolecules,'VariableNames',{'Name','Formula','Mass','NumMolecules'}); | ||
|
||
if 0 | ||
% Error using parse_formula>parse_formula_ (line 197) | ||
% Could not parse formula: | ||
% C30H56NO12FULLRCO | ||
% ^^^ | ||
molFormulae = hillformula(model.metFormulas(mbool)); | ||
else | ||
molFormulae = model.metFormulas(mbool); | ||
end | ||
|
||
%order of the numbers matches the order of the columns of L | ||
molID = zeros(nMappedMet,1); | ||
for i=1:nMappedMet | ||
molID(i) = i; | ||
end | ||
|
||
[molecularMasses, knownMasses, unknownElements, Ematrix, elements] = getMolecularMass(model.metFormulas(mbool),isotopeAbundance,generalFormula); | ||
|
||
NumMoieties = sum(L,1)'; | ||
|
||
%table of molecule properties | ||
MMN.mol = table(molID,model.mets(mbool),molFormulae,molecularMasses,NumMoieties,'VariableNames',{'Name','Mets','Formula','Mass','NumMoieties'}); | ||
|
||
end | ||
|
Oops, something went wrong.