From 76ce1f35401203d012ab3b090e10cbc7aa5790b4 Mon Sep 17 00:00:00 2001 From: legregam Date: Thu, 6 Apr 2023 12:23:34 +0200 Subject: [PATCH 1/3] Modified gitignore --- .gitignore | 1 + physiofit/ui/gui.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fd05c83..97d4577 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ physiofit.egg-info/requires.txt physiofit.egg-info/SOURCES.txt physiofit.egg-info/top_level.txt /data/KEIO_test_data/KEIO_ROBOT6_1/KEIO_ROBOT6_1_res/ +/versions publi/ diff --git a/physiofit/ui/gui.py b/physiofit/ui/gui.py index 87b8dea..4fa3b5c 100644 --- a/physiofit/ui/gui.py +++ b/physiofit/ui/gui.py @@ -143,7 +143,7 @@ def _initialize_opt_menu(self): if not self.io.home_path: raise ValueError("No output directory selected") self.config_parser = ConfigParser( - path_to_data =self.io.home_path / self.data_file.name, + path_to_data = self.io.home_path / self.data_file.name, selected_model= self.model, sds = self.sd, mc = self.mc, From 7534800361c7bc87ee380139a262360ecff93272 Mon Sep 17 00:00:00 2001 From: legregam Date: Fri, 14 Apr 2023 11:44:45 +0200 Subject: [PATCH 2/3] Bump to 3.0.3 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 80a81be..f58f71d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "physiofit" -version = "3.0.2" +version = "3.0.3" description = "Calculate extracellular fluxes from metabolite concentrations and biomass data" authors = ["llegregam "] license = "GNU General Public License (GPL)" From 0ca4321a090eed81f893512d875c6bdf75425d22 Mon Sep 17 00:00:00 2001 From: legregam Date: Fri, 12 May 2023 10:48:28 +0200 Subject: [PATCH 3/3] Bump to 3.0.4 --- .gitignore | 1 - .../KEIO_ROBOT6_1/KEIO_ROBOT6_1.tsv | 17 ----- ...data_model_5.tsv => model_5_test_data.tsv} | 0 physiofit/base/fitter.py | 11 +-- physiofit/data/data_example.tsv | 17 +++++ physiofit/tests/conftest.py | 30 ++++++++ physiofit/tests/test_fitter.py | 28 ++++++++ poetry.lock | 68 ++++++++++++++++++- pyproject.toml | 6 +- 9 files changed, 153 insertions(+), 25 deletions(-) delete mode 100644 data/KEIO_test_data/KEIO_ROBOT6_1/KEIO_ROBOT6_1.tsv rename data/{data_model_5.tsv => model_5_test_data.tsv} (100%) create mode 100644 physiofit/data/data_example.tsv create mode 100644 physiofit/tests/conftest.py create mode 100644 physiofit/tests/test_fitter.py diff --git a/.gitignore b/.gitignore index 97d4577..09b903c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,4 @@ physiofit.egg-info/PKG-INFO physiofit.egg-info/requires.txt physiofit.egg-info/SOURCES.txt physiofit.egg-info/top_level.txt -/data/KEIO_test_data/KEIO_ROBOT6_1/KEIO_ROBOT6_1_res/ /versions publi/ diff --git a/data/KEIO_test_data/KEIO_ROBOT6_1/KEIO_ROBOT6_1.tsv b/data/KEIO_test_data/KEIO_ROBOT6_1/KEIO_ROBOT6_1.tsv deleted file mode 100644 index 86e9d79..0000000 --- a/data/KEIO_test_data/KEIO_ROBOT6_1/KEIO_ROBOT6_1.tsv +++ /dev/null @@ -1,17 +0,0 @@ -time X Glc Ace -1.69472222222222 6.1992000000000005E-2 NA NA -2.3002777777777799 8.6184000000000011E-2 NA NA -2.6983333333333301 0.11037599999999999 NA NA -3.43611111111111 0.17841599999999999 NA NA -3.8211111111111098 0.20865600000000001 NA NA -4.2011111111111097 0.3024 NA NA -4.5980555555555496 0.378 NA NA -4.9950000000000001 0.54583199999999998 NA NA -5.3752777777777796 0.60933599999999999 NA NA -1.35 NA 13.6276813815462 0.216958848225059 -1.91666666666667 NA 13.5792133323062 0.371914222400848 -2.86666666666667 NA 12.6200457520069 0.707537683463011 -4 NA 11.2499817544224 1.46436775470691 -4.8 NA 9.36560347817446 2.13574936032777 -5.18333333333333 NA 8.20020915137498 2.54657962639804 -5.58333333333333 NA 6.55172432249331 2.88518116059672 diff --git a/data/data_model_5.tsv b/data/model_5_test_data.tsv similarity index 100% rename from data/data_model_5.tsv rename to data/model_5_test_data.tsv diff --git a/physiofit/base/fitter.py b/physiofit/base/fitter.py index 6d3c2c8..60d7088 100644 --- a/physiofit/base/fitter.py +++ b/physiofit/base/fitter.py @@ -468,11 +468,12 @@ def khi2_test(self): ) logger.info(f"khi2 test results:\n" - f"khi2 value: {cost}\n" - f"Number of measurements: {number_measurements}\n" - f"Number of parameters to fit: {number_params}\n" - f"Degrees of freedom: {dof}\n" - f"p-value = {p_val}\n") + f"khi2 value: {cost}\n" + f"Number of measurements: {number_measurements}\n" + f"Number of parameters to fit: {number_params}\n" + f"Degrees of freedom: {dof}\n" + f"p-value = {p_val}\n" + ) if p_val < 0.95: logger.info( diff --git a/physiofit/data/data_example.tsv b/physiofit/data/data_example.tsv new file mode 100644 index 0000000..b13b12b --- /dev/null +++ b/physiofit/data/data_example.tsv @@ -0,0 +1,17 @@ +time X Glc Ace +1.7 6.2E-2 NA NA +2.3 8.6E-2 NA NA +2.7 0.11 NA NA +3.4 0.17 NA NA +3.8 0.21 NA NA +4.2 0.3 NA NA +4.6 0.38 NA NA +5 0.55 NA NA +5.4 0.61 NA NA +1.4 NA 13.63 0.22 +1.9 NA 13.58 0.37 +2.9 NA 12.62 0.71 +4 NA 11.25 1.46 +4.8 NA 9.37 2.14 +5.2 NA 8.20 2.55 +5.6 NA 6.55 2.89 diff --git a/physiofit/tests/conftest.py b/physiofit/tests/conftest.py new file mode 100644 index 0000000..8335ddd --- /dev/null +++ b/physiofit/tests/conftest.py @@ -0,0 +1,30 @@ + +""" +Configuration variables for the tests + +Shared pre-defined parameters +The return value of fixture function will be available as a predefined +parameter for all test functions. The test's parameter name must be the same as +the fixture function's name. +""" + +import pytest +from physiofit.base.io import IoHandler +from physiofit.models.base_model import StandardDevs + +@pytest.fixture +def data(): + """Test data to use in tests""" + + return IoHandler.read_data( + r"C:\Users\legregam\PycharmProjects\PhysioFit\physiofit\data\data_example.tsv" + ) + +@pytest.fixture +def sds(): + return StandardDevs( + X = 0.2, + Glc = 0.5, + Ace = 0.5 + ) + diff --git a/physiofit/tests/test_fitter.py b/physiofit/tests/test_fitter.py new file mode 100644 index 0000000..94ed20e --- /dev/null +++ b/physiofit/tests/test_fitter.py @@ -0,0 +1,28 @@ +""" +Test the creation and use of the PhysioFitter +""" + +import pytest +import physiofit as phyfit +from pandas import read_csv + + +def test_physiofitter(data, sds): + """ + Test that the model and PhysioFitter can be safely instanciated from IoHandler + """ + + io = phyfit.base.io.IoHandler() + model = io.select_model("Steady-state batch model", data) + assert isinstance(model, phyfit.models.base_model.Model) + model.get_params() + fitter = io.initialize_fitter( + model.data, + model=model, + sd=sds, + debug_mode=True + ) + assert isinstance(fitter, phyfit.base.fitter.PhysioFitter) + +def test_simulation(data, sds): + pass diff --git a/poetry.lock b/poetry.lock index 6b8be89..b8818b5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -274,6 +274,17 @@ category = "main" optional = false python-versions = ">=3.6" +[[package]] +name = "exceptiongroup" +version = "1.1.1" +description = "Backport of PEP 654 (exception groups)" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.extras] +test = ["pytest (>=6)"] + [[package]] name = "executing" version = "1.2.0" @@ -387,6 +398,14 @@ zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +category = "dev" +optional = false +python-versions = ">=3.7" + [[package]] name = "ipykernel" version = "6.22.0" @@ -856,6 +875,18 @@ python-versions = ">=3.7" docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] +[[package]] +name = "pluggy" +version = "1.0.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=3.6" + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + [[package]] name = "plumbum" version = "1.8.1" @@ -1002,6 +1033,25 @@ category = "main" optional = false python-versions = ">=3.7" +[[package]] +name = "pytest" +version = "7.3.1" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] + [[package]] name = "python-dateutil" version = "2.8.2" @@ -1538,7 +1588,7 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "1.1" python-versions = ">=3.8,<3.9.7 || >3.9.7,<3.12" -content-hash = "24513730158f06d73f41437f434cd6db04cff25d2f49d8e5bb37c633036c5e22" +content-hash = "bf263c4c2b91fba896df633f350f443f616424bfacf5a1932bc843d4ecf0d924" [metadata.files] alabaster = [ @@ -1862,6 +1912,10 @@ et-xmlfile = [ {file = "et_xmlfile-1.1.0-py3-none-any.whl", hash = "sha256:a2ba85d1d6a74ef63837eed693bcb89c3f752169b0e3e7ae5b16ca5e1b3deada"}, {file = "et_xmlfile-1.1.0.tar.gz", hash = "sha256:8eb9e2bc2f8c97e37a2dc85a09ecdcdec9d8a396530a6d5a33b30b9a92da0c5c"}, ] +exceptiongroup = [ + {file = "exceptiongroup-1.1.1-py3-none-any.whl", hash = "sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e"}, + {file = "exceptiongroup-1.1.1.tar.gz", hash = "sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785"}, +] executing = [ {file = "executing-1.2.0-py2.py3-none-any.whl", hash = "sha256:0314a69e37426e3608aada02473b4161d4caf5a4b244d1d0c48072b8fee7bacc"}, {file = "executing-1.2.0.tar.gz", hash = "sha256:19da64c18d2d851112f09c287f8d3dbbdf725ab0e569077efb6cdcbd3497c107"}, @@ -1898,6 +1952,10 @@ importlib-resources = [ {file = "importlib_resources-5.12.0-py3-none-any.whl", hash = "sha256:7b1deeebbf351c7578e09bf2f63fa2ce8b5ffec296e0d349139d43cca061a81a"}, {file = "importlib_resources-5.12.0.tar.gz", hash = "sha256:4be82589bf5c1d7999aedf2a45159d10cb3ca4f19b2271f8792bc8e6da7b22f6"}, ] +iniconfig = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] ipykernel = [ {file = "ipykernel-6.22.0-py3-none-any.whl", hash = "sha256:1ae6047c1277508933078163721bbb479c3e7292778a04b4bacf0874550977d6"}, {file = "ipykernel-6.22.0.tar.gz", hash = "sha256:302558b81f1bc22dc259fb2a0c5c7cf2f4c0bdb21b50484348f7bafe7fb71421"}, @@ -2304,6 +2362,10 @@ platformdirs = [ {file = "platformdirs-3.1.1-py3-none-any.whl", hash = "sha256:e5986afb596e4bb5bde29a79ac9061aa955b94fca2399b7aaac4090860920dd8"}, {file = "platformdirs-3.1.1.tar.gz", hash = "sha256:024996549ee88ec1a9aa99ff7f8fc819bb59e2c3477b410d90a16d32d6e707aa"}, ] +pluggy = [ + {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, + {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, +] plumbum = [ {file = "plumbum-1.8.1-py3-none-any.whl", hash = "sha256:07cf5f50bf739e91fb83ce304fc66b41dbd12db4d4546ff5266087dd9d148314"}, {file = "plumbum-1.8.1.tar.gz", hash = "sha256:88a40fc69247d0cd585e21ca169b3820f46c484535102e16455d2202727bb37b"}, @@ -2440,6 +2502,10 @@ pyrsistent = [ {file = "pyrsistent-0.19.3-py3-none-any.whl", hash = "sha256:ccf0d6bd208f8111179f0c26fdf84ed7c3891982f2edaeae7422575f47e66b64"}, {file = "pyrsistent-0.19.3.tar.gz", hash = "sha256:1a2994773706bbb4995c31a97bc94f1418314923bd1048c6d964837040376440"}, ] +pytest = [ + {file = "pytest-7.3.1-py3-none-any.whl", hash = "sha256:3799fa815351fea3a5e96ac7e503a96fa51cc9942c3753cda7651b93c1cfa362"}, + {file = "pytest-7.3.1.tar.gz", hash = "sha256:434afafd78b1d78ed0addf160ad2b77a30d35d4bdf8af234fe621919d9ed15e3"}, +] python-dateutil = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, diff --git a/pyproject.toml b/pyproject.toml index f58f71d..f4f66fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "physiofit" -version = "3.0.3" +version = "3.0.4" description = "Calculate extracellular fluxes from metabolite concentrations and biomass data" authors = ["llegregam "] license = "GNU General Public License (GPL)" @@ -27,6 +27,10 @@ Sphinx = "^6.1.3" sphinx-argparse = "^0.4.0" sphinx-rtd-theme = "^1.2.0" + +[tool.poetry.group.test.dependencies] +pytest = "^7.3.1" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"