Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: GH workflow test #635

Merged
merged 16 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion code/io/importYaml.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@

otherwise
if readSubsystems
subSystems = {regexprep(tline_value, '^ *- (.+)$','$1')};
subSystems(end+1,1) = {regexprep(tline_value, '^ *- (.+)$','$1')};

% resolve the equation
elseif readEquation
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)
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);
mihai-sysbio marked this conversation as resolved.
Show resolved Hide resolved
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)
4 changes: 2 additions & 2 deletions model/Human-GEM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307292,8 +307292,8 @@
- !!omap
- id: "MAR20111"
- name: "MAR20111"
- metabolties: !!omap
- MAM1261m: -1
- metabolites: !!omap
- MAM01261m: -1
- MAM01597m: 1
- MAM02007m: -1
- MAM02040m: -1
Expand Down