Skip to content

Commit

Permalink
Remove redundant fract_paths
Browse files Browse the repository at this point in the history
The paths in fract_paths are redundant with the keys in fract_indata and others. Remove.
  • Loading branch information
dweindl committed Feb 15, 2025
1 parent fc7b2be commit e43c8fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
5 changes: 0 additions & 5 deletions src/ccompass/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,6 @@ class SessionModel(BaseModel):

## User input fractionation data

#: Filepaths for fractionation data
fract_paths: list[Filepath] = []
#: Fractionation column assignments
# filepath => [column ID, condition, replicate, fraction]
fract_tables: dict[Filepath, list[list[int | str]]] = {}
Expand Down Expand Up @@ -491,12 +489,9 @@ def reset_input_tp(self):
self.tp_data = {}

def reset_input_fract(self):
self.fract_paths = []
self.fract_tables = {}
self.fract_pos = {}
self.fract_data = {}

def reset_infract(self):
self.fract_indata = {}
self.fract_identifiers = {}

Expand Down
49 changes: 27 additions & 22 deletions src/ccompass/main_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import copy
import logging
import pickle
from collections.abc import Sequence
from datetime import datetime
from pathlib import Path
from tkinter import messagebox, simpledialog
Expand All @@ -27,7 +28,7 @@
logger = logging.getLogger(__package__)


def create_fractionation_tab(fract_paths) -> sg.Tab:
def create_fractionation_tab(fract_paths: Sequence[Any]) -> sg.Tab:
"""Create the "Fractionation" tab."""
layout_fractionation = [
[
Expand Down Expand Up @@ -197,7 +198,7 @@ def create_fractionation_tab(fract_paths) -> sg.Tab:
)


def create_total_proteome_tab(tp_paths) -> sg.Tab:
def create_total_proteome_tab(tp_paths: Sequence[Any]) -> sg.Tab:
"""Create the "Total Proteome" tab."""
layout = [
[
Expand Down Expand Up @@ -365,7 +366,9 @@ def create_total_proteome_tab(tp_paths) -> sg.Tab:
)


def create_data_import_frame(fract_paths, tp_paths) -> sg.Frame:
def create_data_import_frame(
fract_paths: Sequence[Any], tp_paths: Sequence[Any]
) -> sg.Frame:
"""Create the "Data Import" frame."""
return sg.Frame(
layout=[
Expand Down Expand Up @@ -987,7 +990,7 @@ def create_main_window(model: SessionModel) -> sg.Window:
[sg.Menu(menu_def, tearoff=False)],
[
create_data_import_frame(
fract_paths=model.fract_paths, tp_paths=model.tp_paths
fract_paths=list(model.fract_indata), tp_paths=model.tp_paths
),
create_spatial_prediction_frame(),
],
Expand Down Expand Up @@ -1103,7 +1106,7 @@ def run(self):
values=["[IDENTIFIER]"], value=""
)
elif event == "-fractionation_start-":
if self.model.fract_paths:
if self.model.fract_indata:
from .FDP import FDP_exec

(
Expand Down Expand Up @@ -1817,9 +1820,8 @@ def fract_add(
if not filename:
return

model.fract_paths.append(filename)
window["-fractionation_path-"].update(
values=model.fract_paths, value=filename
values=list(model.fract_indata), value=filename
)
data = pd.read_csv(filename, sep="\t", header=0)
data = data.replace("NaN", np.nan)
Expand All @@ -1843,15 +1845,19 @@ def fract_remove_file(values, window, model: SessionModel):
if sure != "Yes":
return

model.fract_paths.remove(values["-fractionation_path-"])
del model.fract_tables[values["-fractionation_path-"]]
if model.fract_paths:
curr = model.fract_paths[0]
fract_refreshtable(window, model.fract_tables[curr])
else:
curr = []
fract_refreshtable(window, curr)
window["-fractionation_path-"].update(values=model.fract_paths, value=curr)
filepath = values["-fractionation_path-"]
del model.fract_tables[filepath]
del model.fract_indata[filepath]
del model.fract_pos[filepath]
del model.fract_identifiers[filepath]

filepath = next(iter(model.fract_indata)) if model.fract_indata else []
fract_refreshtable(
window, model.fract_indata[filepath] if filepath else []
)
window["-fractionation_path-"].update(
values=list(model.fract_indata), value=filepath
)


def fract_remove_row(values, window, fract_tables):
Expand Down Expand Up @@ -2333,16 +2339,15 @@ def session_open(window: sg.Window, filename: str, model: SessionModel):
model.reset(tmp_session)

# update GUI
if model.fract_paths:
fract_refreshtable(window, model.fract_tables[model.fract_paths[0]])
if model.fract_indata:
fract_filepaths = list(model.fract_indata)
fract_refreshtable(window, model.fract_tables[fract_filepaths[0]])
window["-fractionation_path-"].update(
values=model.fract_paths, value=model.fract_paths[0]
values=fract_filepaths, value=fract_filepaths[0]
)
else:
fract_refreshtable(window, [])
window["-fractionation_path-"].update(
values=model.fract_paths, value=""
)
window["-fractionation_path-"].update(values=[], value="")

fract_buttons(window, bool(model.fract_data["class"]))

Expand Down

0 comments on commit e43c8fd

Please sign in to comment.