diff --git a/.gitignore b/.gitignore index 09b903c..b2b7623 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 /versions publi/ +/physiofit/data/ diff --git a/physiofit/base/io.py b/physiofit/base/io.py index dc3dcb8..e4653c2 100644 --- a/physiofit/base/io.py +++ b/physiofit/base/io.py @@ -49,7 +49,7 @@ def __init__(self): self.simulated_data_sds = None self.simulated_data = None self.experimental_data = None - self.home_path = None + self.wkdir = None self.data_path = None self.res_path = None self.has_config_been_read = False @@ -145,16 +145,16 @@ def _verify_data(data: DataFrame): "DataFrame has not been generated" ) - for x in ["time", "X"]: + for x in ["time", "X", "experiments"]: if x not in data.columns: raise ValueError(f"Column {x} is missing from the dataset") + if data.columns[0] != "experiments": + raise ValueError("First column should be 'experiments'") + if data.columns[1] != "time": + raise ValueError("Second column should be 'time'") - if "experiment" in data.columns: - if len(data.columns) <= 3: - raise ValueError(f"Data does not contain any metabolite columns") - else: - if len(data.columns) <= 2: - raise ValueError(f"Data does not contain any metabolite columns") + if len(data.columns) <= 3: + raise ValueError(f"Data does not contain any metabolite columns") for x in data.columns: if x != "experiments" and data[x].dtypes != np.int64 and data[x].dtypes != np.float64: @@ -219,7 +219,7 @@ def add_model(model_file): def read_yaml(yaml_file: str | bytes) -> ConfigParser: """ - Import raml configuration file and parse keyword arguments + Import yaml configuration file and parse keyword arguments :param yaml_file: path to the yaml file or json file :return config_parser: Dictionary containing arguments parsed from yaml file diff --git a/physiofit/data/data_example.tsv b/physiofit/data/data_example.tsv deleted file mode 100644 index b13b12b..0000000 --- a/physiofit/data/data_example.tsv +++ /dev/null @@ -1,17 +0,0 @@ -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/data/test-data_single_exp.tsv b/physiofit/data/test-data_single_exp.tsv deleted file mode 100644 index c9c14ab..0000000 --- a/physiofit/data/test-data_single_exp.tsv +++ /dev/null @@ -1,17 +0,0 @@ -experiments time X Glc Ace -A 1.694722222 6.20E-02 NA NA -A 2.300277778 8.62E-02 NA NA -A 2.698333333 0.110376 NA NA -A 3.436111111 0.178416 NA NA -A 3.821111111 0.208656 NA NA -A 4.201111111 0.3024 NA NA -A 4.598055556 0.378 NA NA -A 4.995 0.545832 NA NA -A 5.375277778 0.609336 NA NA -A 1.35 NA 13.62768138 0.216958848 -A 1.916666667 NA 13.57921333 0.371914222 -A 2.866666667 NA 12.62004575 0.707537683 -A 4 NA 11.24998175 1.464367755 -A 4.8 NA 9.365603478 2.13574936 -A 5.183333333 NA 8.200209151 2.546579626 -A 5.583333333 NA 6.551724322 2.885181161 diff --git a/physiofit/models/template.py b/physiofit/models/template.py deleted file mode 100644 index 1482601..0000000 --- a/physiofit/models/template.py +++ /dev/null @@ -1,12 +0,0 @@ -""" - -Explications - -""" - -from physiofit.models.methods import Model - -class MyModel(Model): - - pass - diff --git a/physiofit/ui/cli.py b/physiofit/ui/cli.py index 2304ef4..84204e7 100644 --- a/physiofit/ui/cli.py +++ b/physiofit/ui/cli.py @@ -14,7 +14,6 @@ import logging from pathlib import Path import sys -# import shutil import pandas as pd @@ -93,8 +92,11 @@ def run(data, args, logger, experiments): io = IoHandler() exp_data = data.loc[exp, :].sort_values("time").copy() logger.info(f"Input Data: \n{exp_data}") - io.home_path = Path(args.data).parent - logger.info(f"Home path: {io.home_path}") + if hasattr(args, 'galaxy'): + io.wkdir = Path('.') + else: + io.wkdir = Path(args.data).parent + logger.info(f"Home path: {io.wkdir}") logger.info(f"Reading configuration file at {args.config}") io.configparser = io.read_yaml(args.config) logger.info(f"Config File:\n{io.configparser}") @@ -128,9 +130,9 @@ def run(data, args, logger, experiments): io.multiple_experiments = [] io.multiple_experiments.append(df) if exp is not None: - res_path = io.home_path / (io.home_path.name + "_res") / exp + res_path = io.wkdir / (io.wkdir.name + "_res") / exp else: - res_path = io.home_path / (io.home_path.name + "_res") + res_path = io.wkdir / (io.wkdir.name + "_res") logger.info(res_path) if not res_path.is_dir(): res_path.mkdir(parents=True) diff --git a/physiofit/ui/gui.py b/physiofit/ui/gui.py index fa600b6..150ac09 100644 --- a/physiofit/ui/gui.py +++ b/physiofit/ui/gui.py @@ -94,7 +94,7 @@ def _initialize_opt_menu(self): except Exception: st.error("An error has occurred when reading the yaml configuration file.") raise - elif file_extension in ["tsv", "txt"]: + elif file_extension in ["tsv", "txt"]: try: self.io.data = self.io.read_data(self.data_file) # Initialize default SDs @@ -141,10 +141,10 @@ def _initialize_opt_menu(self): except Exception: st.error("An error has occurred when initializing the model") raise - if not self.io.home_path: + if not self.io.wkdir: 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.wkdir / self.data_file.name, selected_model= self.model, sds = self.sd, mc = self.mc, @@ -284,8 +284,8 @@ def _initialize_opt_menu_widgets(self, file_extension): self._output_directory_selector() else: - self.io.home_path = Path(self.config_parser.path_to_data).resolve().parent - self.io.res_path = self.io.home_path / (self.io.home_path.name + "_res") + self.io.wkdir = Path(self.config_parser.path_to_data).resolve().parent + self.io.res_path = self.io.wkdir / (self.io.wkdir.name + "_res") # Build the form for advanced parameters form = st.form("Parameter_form") @@ -500,28 +500,28 @@ def _output_directory_selector(self): # Initialize home path from directory selector and add # to session state - st.session_state.home_path = Path(st.text_input( + st.session_state.wkdir = Path(st.text_input( "Selected output data directory:", filedialog.askdirectory(master=root) )) - if st.session_state.home_path == Path(".") \ - or not st.session_state.home_path.exists(): + if st.session_state.wkdir == Path(".") \ + or not st.session_state.wkdir.exists(): raise RuntimeError("Please provide a valid output directory") - self.io.home_path = copy( - st.session_state.home_path) + self.io.wkdir = copy( + st.session_state.wkdir) - elif hasattr(st.session_state, "home_path"): + elif hasattr(st.session_state, "wkdir"): - self.io.home_path = Path(st.text_input( + self.io.wkdir = Path(st.text_input( "Selected output data directory:", - st.session_state.home_path + st.session_state.wkdir )) - if self.io.home_path == Path(".") \ - or not self.io.home_path.exists(): + if self.io.wkdir == Path(".") \ + or not self.io.wkdir.exists(): raise RuntimeError("Please provide a valid output directory") # Initialize the result export directory - self.io.res_path = self.io.home_path / (self.io.home_path.name + "_res") + self.io.res_path = self.io.wkdir / (self.io.wkdir.name + "_res") if not clicked: if not self.io.res_path.is_dir(): self.io.res_path.mkdir() diff --git a/pyproject.toml b/pyproject.toml index d11c968..f59ab50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "physiofit" -version = "3.3.1" +version = "3.3.2" description = "Calculate extracellular fluxes from metabolite concentrations and biomass data" authors = ["llegregam "] license = "GNU General Public License (GPL)" diff --git a/validation/Validation.pdf b/validation/Validation.pdf new file mode 100644 index 0000000..a10633e Binary files /dev/null and b/validation/Validation.pdf differ diff --git a/validation/models/Monod_model/physiofit_results/config_file.yml b/validation/models/Monod_model/physiofit_results/config_file.yml index 8769f50..af50021 100644 --- a/validation/models/Monod_model/physiofit_results/config_file.yml +++ b/validation/models/Monod_model/physiofit_results/config_file.yml @@ -18,7 +18,7 @@ model: S_GlcEq_s_0: 100 X_0: 1 y_BM: 1 -path_to_data: ..\data.tsv +path_to_data: ".\\validation\\models\\Monod_model\\physiofit_results\\data.tsv" sds: P_ethanol: 3 S_GlcEq: 7 diff --git a/validation/models/Steady-state_model/physiofit_results/results/config_file.yml b/validation/models/Steady-state_model/physiofit_results/results/config_file.yml index f1b12eb..1983ba6 100644 --- a/validation/models/Steady-state_model/physiofit_results/results/config_file.yml +++ b/validation/models/Steady-state_model/physiofit_results/results/config_file.yml @@ -16,7 +16,7 @@ model: Glc_q: 1 X_0: 1 growth_rate: 1 -path_to_data: C:\Users\millard\Documents\GIT\PhysioFit\data_test\Steady-state_model\data.txt +path_to_data: ".\\validation\\models\\Steady-state_model\\physiofit_results\\results\\config_file.yml" sds: Ace: 0.2 Glc: 0.46 diff --git a/validation/models/~$results.xlsx b/validation/models/~$results.xlsx deleted file mode 100644 index ff670a7..0000000 Binary files a/validation/models/~$results.xlsx and /dev/null differ