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

Dev #44

Merged
merged 7 commits into from
Oct 17, 2023
Merged

Dev #44

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
17 changes: 15 additions & 2 deletions physiofit/base/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ def get_models(self, data=None):
else:
self.models.append(model_class(self.data))

def get_local_model_folder(self) -> str:
"""
Return the path towards the actual environment's used models folder
"""

model_dir = Path(__file__).parent / "models"
return str(model_dir)

# TODO: Implement this function to add model to model folder and add button to GUI
@staticmethod
def add_model(model_file):
pass

@staticmethod
def read_yaml(yaml_file: str | bytes) -> ConfigParser:

Expand All @@ -227,7 +240,7 @@ def read_yaml(yaml_file: str | bytes) -> ConfigParser:
)
return config_parser

def initialize_fitter(self, data, **kwargs):
def initialize_fitter(self, data: pd.DataFrame, **kwargs) -> PhysioFitter:
"""
Initialize a PhysioFitter object

Expand Down Expand Up @@ -266,7 +279,7 @@ def initialize_fitter(self, data, **kwargs):
return fitter


def output_pdf(self, fitter, export_path: str | Path = None):
def output_pdf(self, fitter: PhysioFitter, export_path: str | Path = None):
"""
Handle the creation and output of a pdf file containing fit results as
a plot
Expand Down
9 changes: 9 additions & 0 deletions physiofit/ui/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
"""
Module containing the Command-Line Interface control logic.

The Command-Line Interface has two goals:

i) Have a local CLI that can be used to launch jobs in a concise and quick manner, without use of the Graphical
User Interface. This can help when testing many different parameter sets, and also permits easy pipelining of the
tool, as described below.
ii) Have a version compatible with an integration onto the Galaxy W4M platform to be used in automated flux
calculation workflows

"""
import argparse
import logging
Expand Down
12 changes: 8 additions & 4 deletions physiofit/ui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _initialize_opt_menu(self):

self.io.res_path = results_path / experiment
if not self.io.res_path.is_dir():
self.io.res_path.mkdir()
self.io.res_path.mkdir(parents=True)
# Initialize the fitter object
self.io.names = self.io.data.columns[1:].to_list()
kwargs = self._build_fitter_kwargs()
Expand Down Expand Up @@ -220,17 +220,21 @@ def _initialize_opt_menu_widgets(self, file_extension):
model_options = [
model.model_name for model in self.io.models
]
model_options.insert(0, "--")
if self.config_parser.model:
idx = model_options.index(self.config_parser.model["model_name"])
else:
idx = None
model_name = st.selectbox(
label="Model",
options=model_options,
key="model_selector",
help="Select the flux calculation model"
help="Select the flux calculation model",
index=idx
)

#if model_name == "Dynamic system (only substrates)":
# st.error("Not yet implemented...")
if model_name != "--":
if model_name:
# Initialize selected model
self.model = self.io.select_model(model_name)
try:
Expand Down
497 changes: 238 additions & 259 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "physiofit"
version = "3.1.1"
version = "3.2.0"
description = "Calculate extracellular fluxes from metabolite concentrations and biomass data"
authors = ["llegregam <[email protected]>"]
license = "GNU General Public License (GPL)"
Expand All @@ -16,7 +16,6 @@ numpy = "^1.24.2"
scipy = "^1.10.1"
streamlit = "^1.20.0"
matplotlib = "^3.7.1"
openpyxl = "^3.0.9"
pyyaml = "^6.0"

[tool.poetry.group.dev.dependencies]
Expand Down
20 changes: 10 additions & 10 deletions validation/models/Monod_model/data.tsv
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
time X S_GlcEq P_ethanol
0 1.1059872 75.04926 0
2 1.1495275 73.038826 0.57032937
4 1.9303926 70.92306 1.6142677
6 2.7112577 68.06932 2.5530024
10 5.3252807 58.518 6.1151433
16 11.72252 33.73693 18.411366
22 21.279594 1.3718239 31.23335
34 21.328758 0 31.5461
45 21.27246 0 31.384602
experiments time X S_GlcEq P_ethanol
A 0 1.1059872 75.04926 0
A 2 1.1495275 73.038826 0.57032937
A 4 1.9303926 70.92306 1.6142677
A 6 2.7112577 68.06932 2.5530024
A 10 5.3252807 58.518 6.1151433
A 16 11.72252 33.73693 18.411366
A 22 21.279594 1.3718239 31.23335
A 34 21.328758 0 31.5461
A 45 21.27246 0 31.384602
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ model:
S_GlcEq_s_0: 100
X_0: 1
y_BM: 1
path_to_data: C:\Users\millard\Documents\GIT\PhysioFit\data_test\config_file.yml
path_to_data: ..\data.tsv
sds:
P_ethanol: 3
S_GlcEq: 7
Expand Down