Skip to content
Open
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
path: ~/Library/Caches/pip
- os: windows-latest
path: ~\AppData\Local\pip\Cache
python-version: ['3.7', '3.10']
python-version: ['3.10', '3.11']
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -86,6 +86,7 @@ jobs:
matrix:
python-version: ['3.10']


steps:
- name: Check out repository
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
7 changes: 3 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ classifiers =
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.6
keywords = YAML, SBML, PEtab, ODE

[options]
Expand All @@ -48,7 +47,7 @@ install_requires =

zip_safe = False
include_package_data = True
python_requires = >=3.6
python_requires = >=3.9

# Where is my code
packages = find:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_CLI.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Tests of Command-line Interface."""
import os
import shutil

Expand Down Expand Up @@ -53,8 +54,7 @@ def test_yaml2petab_cli(script_runner):


def test_yaml2sbml_validate_cli(script_runner):
"""Test the command line command ``yaml2sbml_validate`"""

"""Test the command line command `yaml2sbml_validate`."""
path = os.path.dirname(os.path.abspath(__file__))
yaml_dir = os.path.join(path, 'test_yaml2sbml/ode_input1.yaml')

Expand Down
35 changes: 11 additions & 24 deletions tests/test_YamlModel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Tests of the yaml2sbml model editor."""
import os
import shutil

Expand All @@ -12,6 +13,7 @@ class TestYamlModel(unittest.TestCase):
"""TestCase class for testing YamlModel."""

def setUp(self):
"""Set Up of tests."""
# input directory
this_dir, _ = os.path.split(__file__)
self.test_input_folder = os.path.join(this_dir, 'test_yaml2sbml')
Expand All @@ -20,13 +22,12 @@ def setUp(self):
self.test_dir = tempfile.mkdtemp()

def tearDown(self):
"""Tear Down of tests."""
# remove temporary directory
shutil.rmtree(self.test_dir)

def test_load_and_write(self):
"""
Test loading and writing.
"""
"""Test loading and writing."""
# read in yaml
yaml_dir = os.path.join(self.test_input_folder, 'ode_input2.yaml')
model = YamlModel.load_from_yaml(yaml_dir)
Expand All @@ -40,9 +41,7 @@ def test_load_and_write(self):
self.assertDictEqual(model._yaml_model, reloaded_model._yaml_model)

def test_time(self):
"""
Test all functionality regarding the time keyword.
"""
"""Test all functionality regarding the time keyword."""
model = YamlModel()
time_var = 't'

Expand All @@ -57,9 +56,7 @@ def test_time(self):
self.assertFalse(model.is_set_time())

def test_parameter(self):
"""
Test all functionality regarding the 'parameters' keyword.
"""
"""Test all functionality regarding the 'parameters' keyword."""
model = YamlModel()
parameter_id = 'p1'
model.add_parameter(parameter_id,
Expand Down Expand Up @@ -87,9 +84,7 @@ def test_parameter(self):
self.assertListEqual(model.get_parameter_ids(), [])

def test_ode(self):
"""
Test all functionality regarding the 'odes' keyword.
"""
"""Test all functionality regarding the 'odes' keyword."""
model = YamlModel()

state_id = 's1'
Expand Down Expand Up @@ -120,9 +115,7 @@ def test_ode(self):
self.assertListEqual(model.get_ode_ids(), [])

def test_assignment(self):
"""
Test all functionality regarding the 'assignments' keyword.
"""
"""Test all functionality regarding the 'assignments' keyword."""
model = YamlModel()

assignment_id = 's1'
Expand All @@ -149,9 +142,7 @@ def test_assignment(self):
self.assertListEqual(model.get_assignment_ids(), [])

def test_function(self):
"""
Test all functionality regarding the 'functions' keyword.
"""
"""Test all functionality regarding the 'functions' keyword."""
model = YamlModel()

function_id = 'f'
Expand Down Expand Up @@ -179,9 +170,7 @@ def test_function(self):
self.assertListEqual(model.get_function_ids(), [])

def test_observable(self):
"""
Test all functionality regarding the 'observables' keyword.
"""
"""Test all functionality regarding the 'observables' keyword."""
model = YamlModel()

observable_id = 'obs'
Expand Down Expand Up @@ -220,9 +209,7 @@ def test_observable(self):
self.assertListEqual(model.get_observable_ids(), [])

def test_condition(self):
"""
Test all functionality regarding the 'conditions' keyword.
"""
"""Test all functionality regarding the 'conditions' keyword."""
model = YamlModel()

condition_id = 'cond'
Expand Down
12 changes: 5 additions & 7 deletions tests/test_yaml2petab.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Tests of the yaml2petab functionalities of yaml2sbml."""
import os
import shutil
import unittest
Expand All @@ -6,23 +7,20 @@


class TestYaml2PEtab(unittest.TestCase):
"""
TestCase class for testing ODE import from a generic yaml file
and conversion to PEtab.
"""
"""This tests ODE import from yaml & conversion to PEtab."""

def setUp(self):
"""Set Up of tests."""
this_dir, _ = os.path.split(__file__)
self.input_folder = os.path.join(this_dir, 'test_yaml2sbml')
self.output_folder = os.path.join(this_dir, 'test_yaml2sbml_output')

def tearDown(self):
"""Tear Down od tests."""
shutil.rmtree(self.output_folder)

def test_petab_export(self):
"""
Test PEtab export
"""
"""Test PEtab export."""
input_yaml_dir = os.path.join(self.input_folder, 'ode_input2.yaml')

yaml2PEtab.yaml2petab(input_yaml_dir,
Expand Down
23 changes: 7 additions & 16 deletions tests/test_yaml2sbml.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
"""Tests of the yamls2bml function."""
import os
import unittest

from yaml2sbml.yaml2sbml import yaml2sbml, _parse_yaml


class TestYaml2SBML(unittest.TestCase):
"""
TestCase class for testing ODE import from a generic yaml file
and conversion to SBML.
"""
"""Tests ODE import yaml file and conversion to SBML."""

def setUp(self):
"""Set Up of tests."""
this_dir, _ = os.path.split(__file__)
self.test_folder = os.path.join(this_dir, 'test_yaml2sbml')

def test_yaml_import(self):
"""
Test yaml import/SBML generation...
"""
"""Test yaml import & SBML generation."""
yaml_dir = os.path.join(self.test_folder, 'ode_input1.yaml')
expected_result_file = os.path.join(self.test_folder,
'true_sbml_output.xml')
Expand All @@ -43,9 +40,7 @@ def test_yaml_import(self):
os.remove(sbml_test_dir)

def test_yaml_import_observables(self):
"""
Test yaml import/export for a model containing observables.
"""
"""Test yaml import/export for a model containing observables."""
yaml_dir = os.path.join(self.test_folder, 'ode_input2.yaml')

expected_result_file = \
Expand Down Expand Up @@ -77,19 +72,15 @@ def test_yaml_import_observables(self):
os.remove(sbml_test_dir)

def test_catch_invalid_sbml_identifier(self):
"""
Check for invalid SBML identifiers.
"""
"""Check for invalid SBML identifiers."""
yaml_dir = os.path.join(self.test_folder,
'ode_input_invalid_SBML_identifier.yaml')
with self.assertRaises(RuntimeError):
_parse_yaml(yaml_dir,
'Test_Model')

def test_catch_invalid_math(self):
"""
Check for strings that parseL3Formula can not parse.
"""
"""Check for strings that parseL3Formula can not parse."""
yaml_dir = os.path.join(self.test_folder,
'ode_input_invalid_formula.yaml')
with self.assertRaises(RuntimeError):
Expand Down
17 changes: 10 additions & 7 deletions tests/test_yaml_validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test for yaml-file validation."""
import os
import unittest

Expand All @@ -7,50 +8,52 @@


class TestYamlValidation(unittest.TestCase):
"""TestCase class for yaml model validation."""

def setUp(self):
"""Set Up of Tests."""
this_dir, _ = os.path.split(__file__)
self.test_folder = os.path.join(this_dir, 'test_yaml2sbml')

def test_validate_yaml_valid_1(self):
# Test validation for a valid yaml model.
"""Test validation for a valid yaml model."""
file_in = os.path.join(self.test_folder, 'ode_input1.yaml')
validate_yaml(file_in)

def test_validate_yaml_valid_2(self):
# Test validation for a second valid yaml model.
"""Test validation for a second valid yaml model."""
file_in = os.path.join(self.test_folder, 'ode_input2.yaml')
validate_yaml(file_in)

def test_validate_yaml_typos(self):
# Test if Error is thrown due to typos.
"""Test if Error is thrown due to typos."""
file_in = os.path.join(self.test_folder, 'ode_input_typos.yaml')
with self.assertRaises(ValidationError):
validate_yaml(file_in)

def test_validate_yaml_typos_required(self):
# Test if Error is thrown due to typos.
"""Test if Error is thrown due to typos."""
file_in = os.path.join(self.test_folder,
'ode_input_typos_required.yaml')
with self.assertRaises(ValidationError):
validate_yaml(file_in)

def test_validate_yaml_empty_section(self):
# Test if Error is thrown due to empty observable section.
"""Test if Error is thrown due to empty observable section."""
file_in = os.path.join(self.test_folder,
'ode_input_empty_section.yaml')
with self.assertRaises(ValidationError):
validate_yaml(file_in)

def test_catch_invalid_time_block_missing_variable_key(self):
# Test time block without kew word "variable".
"""Test time block without kew word "variable"."""
file_in = os.path.join(self.test_folder,
'ode_input_invalid_time_1.yaml')
with self.assertRaises(ValidationError):
validate_yaml(file_in)

def test_catch_invalid_time_block_as_array(self):
# Test time block as array instead of single object.
"""Test time block as array instead of single object."""
file_in = os.path.join(self.test_folder,
'ode_input_invalid_time_2.yaml')
with self.assertRaises(ValidationError):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ deps =
pep8-naming >= 0.11.1
pydocstyle >= 5.1.1
commands =
flake8 yaml2sbml tests setup.py
flake8 yaml2sbml tests
pydocstyle yaml2sbml tests setup.py
description =
Run flake8 with various plugins, and pydocstyle
Expand Down
19 changes: 11 additions & 8 deletions yaml2sbml/yaml2PEtab.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import petab
import yaml
from pathlib import Path
from petab.models.sbml_model import SbmlModel


from .yaml2sbml import _parse_yaml_dict, _load_yaml_file
Expand Down Expand Up @@ -97,7 +98,8 @@ def _yaml2petab(yaml_model_dict: dict,

warnings.warn('Since no petab_yaml_file_name is specified, the '
'specified measurement_table_name will have no effect.',
RuntimeWarning)
RuntimeWarning,
stacklevel=2)

elif petab_yaml_name is not None:
_create_petab_problem_yaml(yaml_model_dict,
Expand Down Expand Up @@ -284,15 +286,15 @@ def validate_petab_tables(sbml_dir: str,
condition_df = pd.read_csv(condition_table_dir,
sep='\t',
index_col='conditionId')
petab.lint.check_condition_df(condition_df, model)
petab.lint.check_condition_df(condition_df, SbmlModel(model))

# check parameter table
parameter_df = pd.read_csv(parameter_file_dir,
sep='\t',
index_col='parameterId')

petab.lint.check_parameter_df(parameter_df,
sbml_model=model,
model=SbmlModel(model),
observable_df=observable_df)


Expand All @@ -319,7 +321,8 @@ def _create_petab_table(block_list: list,
for col_name in petab_table.head():
if not (col_name in mandatory_id_list or col_name in optional_id_list):
warnings.warn(f'PEtab warning: {col_name} is not part of the '
f'PEtab standard and hence might have noe effect.')
f'PEtab standard and hence might have noe effect.',
stacklevel=2)
return petab_table


Expand Down Expand Up @@ -359,11 +362,11 @@ def main():

args = parser.parse_args()

print(f'Path to yaml file: {args.yaml_file}')
print(f'Output directory: {args.output_dir}')
print(f'Path to sbml/petab files: {args.model_name}')
print(f'Path to yaml file: {args.yaml_file}') # noqa:T201
print(f'Output directory: {args.output_dir}') # noqa:T201
print(f'Path to sbml/petab files: {args.model_name}') # noqa:T201

print('Converting...')
print('Converting...') # noqa:T201

yaml2petab(args.yaml_file,
args.output_dir,
Expand Down
Loading