-
Notifications
You must be signed in to change notification settings - Fork 44
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 #179 from SysBioChalmers/removeBoundaryComp
feat: remove the boundary compartment
- Loading branch information
Showing
5 changed files
with
95,624 additions
and
130,789 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
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,52 @@ | ||
% | ||
% FILE NAME: removeBoundaryCompartment.m | ||
% | ||
% PURPOSE: This script removes the boundary compartment [x] and all | ||
% metabolites within this compartment from the model, as discussed | ||
% in #172 | ||
|
||
% load model | ||
ihuman = importHumanYaml('../../modelFiles/yml/HumanGEM.yml'); | ||
|
||
% delete unconstrained (boundary) metabolites | ||
model_del = simplifyModel(ihuman); | ||
del_mets = setdiff(ihuman.mets, model_del.mets); | ||
fprintf('\nRemoved %u boundary metabolites from the model.\n\n', numel(del_mets)); | ||
|
||
% remove the boundary compartment itself and update the metComps field | ||
metCompSymbols = model_del.comps(model_del.metComps); | ||
[~,comp_ind] = ismember('boundary', lower(model_del.compNames)); | ||
model_del.comps(comp_ind) = []; | ||
model_del.compNames(comp_ind) = []; | ||
[~,model_del.metComps] = ismember(metCompSymbols, model_del.comps); | ||
|
||
|
||
% write new model to yml | ||
writeHumanYaml(model_del, '../../modelFiles/yml/HumanGEM.yml'); | ||
|
||
|
||
% import metabolite annotations | ||
metAssoc = jsondecode(fileread('../../data/annotation/humanGEMMetAssoc.JSON')); | ||
|
||
% remove boundary metabolites | ||
del_ind = ismember(metAssoc.mets, del_mets); | ||
f = fieldnames(metAssoc); | ||
for i = 1:numel(f) | ||
metAssoc.(f{i})(del_ind) = []; | ||
end | ||
|
||
% verify that annotation structure is aligned with model | ||
if ~isequal(model_del.mets, metAssoc.mets) | ||
error('Model and metabolite annotation structures not synced!'); | ||
end | ||
|
||
% export metabolite annotations | ||
jsonStr = jsonencode(metAssoc); | ||
fid = fopen('../../data/annotation/humanGEMMetAssoc.JSON', 'w'); | ||
fwrite(fid, prettyJson(jsonStr)); | ||
fclose(fid); | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.