Skip to content

Commit

Permalink
Human 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
haowang-bioinfo committed Sep 30, 2023
2 parents da072ba + be554ff commit 8643327
Show file tree
Hide file tree
Showing 17 changed files with 1,075 additions and 3,511 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/check-metabolictasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ jobs:
matrix:
task-type: [essential, verification]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Checkout
uses: actions/checkout@v3

- name: Check ${{ matrix.task-type }} metabolic tasks
run: |
/usr/local/bin/matlab -nodisplay -nosplash -nodesktop -r "addpath(genpath('.')); testMetabolicTasks('${{ matrix.task-type }}'); exit;"
- name: Check ${{ matrix.task-type }} metabolic tasks
run: |
/usr/local/bin/matlab -nodisplay -nosplash -nodesktop -r "addpath(genpath('.')); testMetabolicTasks('${{ matrix.task-type }}');"
11 changes: 5 additions & 6 deletions .github/workflows/yaml-conversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ jobs:
timeout-minutes: 60

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Checkout
uses: actions/checkout@v3

- name: Run conversion script
run: |
/usr/local/bin/matlab -nodisplay -nosplash -nodesktop -r "addpath(genpath('.')); run('code/test/testYamlConversion.m'); exit;"
- name: Run conversion script
run: |
/usr/local/bin/matlab -nodisplay -nosplash -nodesktop -r "addpath(genpath('.')); testYamlConversion"
5 changes: 4 additions & 1 deletion .github/workflows/yaml-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ jobs:
## Return non-zero exit code on warnings as well as errors
# strict: # optional, default is false

- name: Basic MEMOTE tests
run: python code/test/memoteTest.py

- name: Test import with cobrapy and consistency with annotation files
run: python code/test/sanityCheck.py
run: python code/test/sanityCheck.py
8 changes: 5 additions & 3 deletions code/GPRs/simplifyGrRules.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
eqn = str2sym(eqn_str);

% separate equation into terms/pieces ("children")
eqn_pieces = arrayfun(@char,children(eqn),'UniformOutput',false);
eqn_pieces = cellfun(@char,children(eqn),'UniformOutput',false);

% find pieces that are further separable, and recursively separate until
% all pieces are single genes
Expand All @@ -202,12 +202,14 @@
%% Functions to test whether an equation is a collection of ORs or ANDs
function res = is_or(eqn)
% check if outermost operations contain ORs
res = length(regexp(char(eqn),'\|')) > length(regexp(char(children(eqn)),'\|'));
res = length(regexp(char(eqn),'\|')) > ...
sum(cell2mat(cellfun(@(x) length(regexp(char(x), '\|')), children(eqn), 'UniformOutput', false)));
end

function res = is_and(eqn)
% check if outermost operations contain ANDs
res = length(regexp(char(eqn),'&')) > length(regexp(char(children(eqn)),'&'));
res = length(regexp(char(eqn),'&')) > ...
sum(cell2mat(cellfun(@(x) length(regexp(char(x), '\&')), children(eqn), 'UniformOutput', false)));
end


Expand Down
5 changes: 4 additions & 1 deletion code/addMetabolicNetwork.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@
newGenes = setdiff(newGenes, newModel.genes);
end

% append new genes to list of model genes
% append new genes and their names to model
newModel.genes = [newModel.genes; newGenes];
emptyGeneNames = newGenes;
emptyGeneNames(:) = {''};
newModel.geneShortNames = [newModel.geneShortNames; emptyGeneNames];

% add new columns to rxnGeneMat will be updated after the new reactions are added below.
newModel.rxnGeneMat(:, end+1:end+numel(newGenes)) = 0;
Expand Down
18 changes: 18 additions & 0 deletions code/test/memoteTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import cobra
import memote.support.basic

if __name__ == "__main__":
try:
model = cobra.io.load_yaml_model("model/Human-GEM.yml")

# Use the MEMOTE way of testing
# https://github.com/opencobra/memote/blob/c8bd3fe75e2d955deaec824d1e93ebe60e754710/tests/test_for_support/test_for_basic.py#L908-L909
rxns, num = memote.support.basic.find_duplicate_reactions(model)
assert num == 0, "Duplicate reactions found: {}".format(rxns)

# Make sure all reactions have at least one metabolite
for r in model.reactions:
assert len(r.metabolites) > 0, "Reaction with no metabolite found: {}".format(r.id)
except AssertionError as e:
print(e)
exit(1)
24 changes: 17 additions & 7 deletions code/test/sanityCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ def checkRxnAnnotation(rxns):
rxnList = get_column_from_tsv("model/reactions.tsv", "rxns")
spontaneous = get_column_from_tsv("model/reactions.tsv", "spontaneous", False)
rxnDeprecated = get_column_from_tsv("data/deprecatedIdentifiers/deprecatedReactions.tsv", "rxns")
assert set(rxnList).isdisjoint(set(rxnDeprecated)), "Deprecated reaction reused!"
assert rxnList == rxns, "Reaction annotation mismatch!"
rxnMisused = set(rxns).intersection(set(rxnDeprecated))
assert len(rxnMisused) == 0, "Deprecated reaction(s) used: {}".format(rxnMisused)
rxnMisused = set(rxns).difference(set(rxnList))
assert len(rxnMisused) == 0, "Reaction(s) not annotated in reactions.tsv: {}".format(rxnMisused)
rxnMisused = set(rxnList).difference(set(rxns))
assert len(rxnMisused) == 0, "Annotated reactions are missing from the model: {}".format(rxnMisused)
assert pd.api.types.is_numeric_dtype(spontaneous), "Spontaneous column should be in numeric!"


Expand All @@ -49,16 +53,22 @@ def checkMetAnnotation(mets):
"""
metList = get_column_from_tsv("model/metabolites.tsv", "mets")
metDeprecated = get_column_from_tsv("data/deprecatedIdentifiers/deprecatedMetabolites.tsv", "mets")
assert set(metList).isdisjoint(set(metDeprecated)), "Deprecated metabolite reused!"
assert metList == mets, "Metabolite annotation mismatch!"

metMisused = set(mets).intersection(set(metDeprecated))
assert len(metMisused) == 0, "Deprecated metabolite(s) used: {}".format(metMisused)
metMisused = set(mets).difference(set(metList))
assert len(metMisused) == 0, "Metabolite(s) not annotated in metabolites.tsv: {}".format(metMisused)
metMisused = set(metList).difference(set(mets))
assert len(metMisused) == 0, "Annotated metabolite(s) are missing from the model: {}".format(metMisused)

def checkGeneAnnotation(genes):
"""
check consistency of gene lists between model and annotation file
"""
geneList = get_column_from_tsv("model/genes.tsv", "genes")
assert geneList == genes, "Gene annotation mismatch!"
geneMisused = set(genes).difference(set(geneList))
assert len(geneMisused) == 0, "Gene(s) not annotated in genes.tsv: {}".format(geneMisused)
geneMisused = set(geneList).difference(set(genes))
assert len(geneMisused) == 0, "Annotated gene(s) are missing from the model: {}".format(geneMisused)


def find_unused_entities(model, entity_type):
Expand Down Expand Up @@ -93,7 +103,7 @@ def checkUnusedEntities(model, entity_type):

# collect unused entites
unused_entities = find_unused_entities(model, entity_type)
assert len(unused_entities) == 0, f"Found unused {{entity_type}}!"
assert len(unused_entities) == 0, f"Found unused {entity_type}: {unused_entities}"


if __name__ == "__main__":
Expand Down
10 changes: 6 additions & 4 deletions code/test/testMetabolicTasks.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
%

if nargin < 1
error('Task type is missing!');
disp('::error::Task type is missing!');
exit(1)
end

% Get model path
Expand All @@ -28,7 +29,8 @@
elseif taskType == "verification"
taskFile=fullfile(modelPath,'data','metabolicTasks','metabolicTasks_VerifyModel.txt');
else
error('Unknown task type is provided.');
warning('::error::Unknown task type is provided.');
exit(1)
end
verificationTasks = parseTaskList(taskFile);

Expand All @@ -38,6 +40,6 @@
fprintf('Suceeded with %s tasks.\n', taskType)
status = 1;
else
error('Failed in %s tasks.', taskType);
warning('::error::Failed in %s tasks.', taskType);
exit(1)
end

48 changes: 23 additions & 25 deletions code/test/testYamlConversion.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,40 @@
% test the functions for yaml import/export see if the conversion process
% changes the model content
%
% Usage: status = testYamlConversion
%


% Get model path
[ST, I]=dbstack('-completenames');
modelPath=fileparts(fileparts(fileparts(ST(I).file)));

% Import yaml model
ymlFile=fullfile(modelPath,'model','Human-GEM.yml');
model = importYaml(ymlFile, true);
% export to yml and then import back
try

% make sure there is no intermediate Yaml file under the current folder
warning('off', 'MATLAB:DELETE:FileNotFound')
if exist('testYamlConversion.yml','file')
delete testYamlConversion.yml;
end
% Import yaml model
ymlFile=fullfile(modelPath,'model','Human-GEM.yml');
model = importYaml(ymlFile, true);

% make sure there is no intermediate Yaml file under the current folder
warning('off', 'MATLAB:DELETE:FileNotFound')
if exist('testYamlConversion.yml','file')
delete testYamlConversion.yml;
end

% export to yml and then import back
try
exportYaml(model,'testYamlConversion.yml');
importedHumanGEM = importYaml('testYamlConversion.yml', true);
catch
error('There are problems during the conversion import and export');
end

% remove intermediate Yaml file
delete testYamlConversion.yml;
% remove intermediate Yaml file
delete testYamlConversion.yml;

% compare the imported model from yaml with the original one
if isequal(model, importedHumanGEM)
% model conversion between Matlab and Yaml files is successful
disp('The conversion was successful.')
status = 1;
else
error('There are problems during the conversion between Matlab and Yaml files');
% compare the imported model from yaml with the original one
if ~isequal(model, importedHumanGEM)
warning('::error::Re-imported model is diffrent from export');
exit(1);
end
catch
warning('::error::There are problems during the conversion import and export');
exit(1)
end

% model conversion between Matlab and Yaml files is successful
disp('The conversion was successful.')
exit(0)
9 changes: 6 additions & 3 deletions code/updateAnimalGEM.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [animalGEM, speciesSpecNetwork, gapfillNetwork]=updateAnimalGEM(orthologPairs,rxnsToAdd,metsToAdd,modelId)
function [animalGEM, speciesSpecNetwork, gapfillNetwork]=updateAnimalGEM(orthologPairs,rxnsToAdd,metsToAdd,modelId,resetBiomass)
% updateAnimalGEM
% Generate a model by using the Human-GEM as a template and taking into
% account species-specific pathways/reactions
Expand All @@ -11,7 +11,9 @@
% rxnsToAdd the structure of species-specific reactions
% metsToAdd the structure of species-specific metabolites
% modelId model id
%
% resetBiomass reset biomass objective function to "biomass_components"
% which is constituted by generic componenets that
% suppose to occur in a eukaryotic cell (opt, default TRUE)
%
% Output:
% animalGEM an updated animal GEM
Expand Down Expand Up @@ -81,7 +83,8 @@


%% Gap-filling
[animalGEM, gapfillNetwork]=gapfill4EssentialTasks(animalGEM,ihuman);
[animalGEM, gapfillNetwork]=gapfill4EssentialTasks(animalGEM,ihuman,resetBiomass);
animalGEM.b = animalGEM.b(:,1); % ensure b field in single column


%% post-gapfilling procedures
Expand Down
45 changes: 44 additions & 1 deletion data/deprecatedIdentifiers/deprecatedMetabolites.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -2203,4 +2203,47 @@ mets metsNoComp metBiGGID metKEGGID metHMDBID metChEBIID metPubChemID metLipidMa
"MAM03573m" "MAM03573" "etfox" "" "" "" "" "" "" "" "etfox" "MNXM11479" "" "etfox_m"
"MAM03574m" "MAM03574" "etfrd" "" "" "" "" "" "" "" "etfrd" "MNXM11480" "" "etfrd_m"
"MAM03494c" "MAM03494" "c3dc" "" "" "" "22833583" "" "" "" "c3dc" "" "" "c3dc_c"
"MAM03494e" "MAM03494" "c3dc" "" "" "" "22833583" "" "" "" "c3dc" "" "" "c3dc_s"
"MAM03494e" "MAM03494" "c3dc" "" "" "" "22833583" "" "" "" "c3dc" "" "" "c3dc_s"
"MAM03318e" "MAM03318" "C02528" "C02528" "HMDB0000518" "CHEBI:16755" "10133" "" "" "" "C02528" "MNXM1183" "" "C02528_s"
"MAM03318c" "MAM03318" "C02528" "C02528" "HMDB0000518" "CHEBI:16755" "10133" "" "" "" "C02528" "MNXM1183" "" "C02528_c"
"MAM03318r" "MAM03318" "C02528" "C02528" "HMDB0000518" "CHEBI:16755" "10133" "" "" "" "C02528" "MNXM1183" "" "C02528_r"
"MAM03318m" "MAM03318" "C02528" "C02528" "HMDB0000518" "CHEBI:16755" "10133" "" "" "" "C02528" "MNXM1183" "" "C02528_m"
"MAM03325c" "MAM03325" "C08276" "C08276" "HMDB0001527" "CHEBI:1438" "563" "" "" "" "C08276" "MNXM2782" "" "C08276_c"
"MAM00591c" "MAM00591" "" "C14748" "" "CHEBI:34306" "" "" "" "HC02179" "" "MNXM6760" "m00591c" "m00591c"
"MAM00591e" "MAM00591" "" "C14748" "" "CHEBI:34306" "" "" "" "HC02179" "" "MNXM6760" "m00591s" "m00591s"
"MAM03162c" "MAM03162" "" "C05578" "" "CHEBI:27404" "" "" "" "" "M03162" "MNXM2336" "m03162c" "m03162c"
"MAM03231c" "MAM03231" "" "" "" "CHEBI:57277" "" "" "" "" "3hppa" "" "" "3hppa_c"
"MAM03540c" "MAM03540" "ddeccrn" "" "" "" "168381" "" "" "" "ddeccrn" "" "" "ddeccrn_c"
"MAM03540e" "MAM03540" "ddeccrn" "" "" "" "168381" "" "" "" "ddeccrn" "" "" "ddeccrn_s"
"MAM03226m" "MAM03226" "3hibutcoa" "C04047" "" "CHEBI:15481" "" "" "" "" "3hibutcoa" "MNXM446" "" "3hibutcoa_m"
"MAM03884c" "MAM03884" "phyt" "C01607" "HMDB0000801" "CHEBI:16285" "26840" "" "" "" "phyt" "MNXM91275" "" "phyt_c"
"MAM03884e" "MAM03884" "phyt" "C01607" "HMDB0000801" "CHEBI:16285" "26840" "" "" "" "phyt" "MNXM91275" "" "phyt_s"
"MAM03554c" "MAM03554" "dmnoncoa" "" "" "" "" "" "" "" "dmnoncoa" "MNXM6100" "" "dmnoncoa_c"
"MAM03884x" "MAM03884" "phyt" "C01607" "HMDB0000801" "CHEBI:16285" "26840" "" "" "" "phyt" "MNXM91275" "" "phyt_p"
"MAM03354c" "MAM03354" "CE4837" "C16171" "HMDB0006516" "CHEBI:63548" "53477846" "" "CE4837" "" "CE4837" "MNXM165171" "" "CE4837_c"
"MAM03332c" "MAM03332" "CE2516" "C03242" "HMDB0002925" "CHEBI:53486" "5280581" "" "CE2516" "" "CE2516" "MNXM5607" "" "CE2516_c"
"MAM03332e" "MAM03332" "" "C03242" "HMDB0002925" "CHEBI:53486" "5280581" "" "CE2516" "" "CE2516" "" "" "CE2516_s"
"MAM03354r" "MAM03354" "CE4837" "C16171" "HMDB0006516" "CHEBI:63548" "53477846" "" "CE4837" "" "CE4837" "MNXM165171" "" "CE4837_r"
"MAM00029c" "MAM00029" "" "" "" "CHEBI:81563" "16061126" "LMFA03070025" "CE7090" "" "CE7090" "MNXM33782" "m00029c" "m00029c"
"MAM03368m" "MAM03368" "" "C05467" "HMDB0006891" "CHEBI:27379" "440690" "" "CE5169" "" "CE5169" "" "" "CE5169_m"
"MAM03368x" "MAM03368" "" "C05467" "HMDB0006891" "CHEBI:27379" "440690" "" "CE5169" "" "CE5169" "" "" "CE5169_p"
"MAM00902c" "MAM00902" "" "" "" "" "" "" "CE4820" "" "CE4820" "MNXM164259" "m00902c" "m00902c"
"MAM00616m" "MAM00616" "cholcoar" "C15613" "" "CHEBI:37642" "15942889" "LMST01010218" "CE5165" "HC01348" "cholcoar" "MNXM549;MNXM90922;MNXM91096" "m00616p" "m00616p"
"MAM00749m" "MAM00749" "cholcoads" "C05460" "HMDB0006889" "CHEBI:27505" "5280797" "LMST01010217" "" "HC01466" "cholcoads" "MNXM162945;MNXM2747" "m00749m" "m00749m"
"MAM00036m" "MAM00036" "" "C05450" "" "CHEBI:52050" "46224537" "" "CE5168" "" "HC01459" "MNXM732;MNXM827" "m00036m" "m00036m"
"MAM00748m" "MAM00748" "cholcoaone" "C05467" "HMDB0006891" "CHEBI:27379" "440690" "LMST01010216" "CE5169" "HC01473" "cholcoaone" "MNXM162946;MNXM873" "m00748m" "m00748m"
"MAM03367m" "MAM03367" "" "" "" "" "" "" "CE5168" "" "CE5168" "" "" "CE5168_m"
"MAM00618m" "MAM00618" "cholcoas" "C17343" "" "CHEBI:37643" "15942888" "" "CE5166" "" "CE5166;cholcoas" "MNXM1201;MNXM8131" "m00618m" "m00618m"
"MAM01445m" "MAM01445" "cholate" "C00695" "HMDB0000619" "CHEBI:16359" "221493" "LMST04010001" "" "HC00502" "cholate" "MNXM450" "m01445m" "m01445m"
"MAM01514m" "MAM01514" "cholcoa" "C01794" "HMDB0001374" "CHEBI:15519" "439573" "" "" "HC00844" "cholcoa" "MNXM162468;MNXM431" "m01514m" "m01514m"
"MAM00759c" "MAM00759" "" "C13712" "" "" "" "LMST02030130" "" "" "M00759" "MNXM3494" "m00759c" "m00759c"
"MAM01268c" "MAM01268" "" "" "" "" "" "PROTEIN" "" "" "M01268" "" "m01268c" "m01268c"
"MAM01268m" "MAM01268" "" "" "" "" "" "PROTEIN" "" "" "M01268" "" "m01268m" "m01268m"
"MAM01268n" "MAM01268" "" "" "" "" "" "PROTEIN" "" "" "M01268" "" "m01268n" "m01268n"
"MAM01268x" "MAM01268" "" "" "" "" "" "PROTEIN" "" "" "M01268" "" "m01268p" "m01268p"
"MAM01268r" "MAM01268" "" "" "" "" "" "PROTEIN" "" "" "M01268" "" "m01268r" "m01268r"
"MAM01268e" "MAM01268" "" "" "" "" "" "PROTEIN" "" "" "M01268" "" "m01268s" "m01268s"
"MAM02757c" "MAM02757" "" "" "" "" "" "" "" "" "M02757" "" "m02757c" "m02757c"
"MAM02757l" "MAM02757" "" "" "" "" "" "" "" "" "M02757" "" "m02757l" "m02757l"
"MAM02757n" "MAM02757" "" "" "" "" "" "" "" "" "M02757" "" "m02757n" "m02757n"
"MAM01816n" "MAM01816" "" "" "" "" "" "PROTEIN" "" "" "M01816" "" "m01816n" "m01816n"
Loading

0 comments on commit 8643327

Please sign in to comment.