Skip to content

Commit

Permalink
prevent users from editing global config
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhsmit committed Jan 17, 2024
1 parent bdba7ce commit fa46e2e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pyhdx/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def __init__(self, data: pd.DataFrame, **metadata: Any):
)

@classmethod
def from_dataset(cls, dataset: HDXDataSet, state: str | int, **metadata) -> HDXMeasurement:
def from_dataset(cls, dataset: HDXDataSet, state: str | int, drop_first=cfg.analysis.drop_first, **metadata) -> HDXMeasurement:
"""Create an HDXMeasurement object from a HDXDataSet object.
Args:
Expand Down Expand Up @@ -318,7 +318,7 @@ def from_dataset(cls, dataset: HDXDataSet, state: str | int, **metadata) -> HDXM
peptides = apply_control(peptides, fd_peptides, nd_peptides)
peptides = correct_d_uptake(
peptides,
drop_first=cfg.analysis.drop_first,
drop_first=drop_first,
d_percentage=metadata.get("d_percentage", 100.0),
)

Expand Down
35 changes: 18 additions & 17 deletions pyhdx/web/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,17 @@ class GlobalSettingsControl(ControlPanel):
doc="Select the number of N-terminal residues to ignore.",
)

weight_exponent = param.Number(
default=cfg.analysis.weight_exponent,
bounds=(0, None),
doc="Value of the exponent use for weighted averaging of RFU values",
)
# weight_exponent = param.Number(
# default=cfg.analysis.weight_exponent,
# bounds=(0, None),
# doc="Value of the exponent use for weighted averaging of RFU values",
# )

def make_dict(self):
widgets = self.generate_widgets()
widgets["config_download"] = pn.widgets.FileDownload(
label="Download config file", callback=self.config_download_callback
)
# widgets["config_download"] = pn.widgets.FileDownload(
# label="Download config file", callback=self.config_download_callback
# )

return widgets

Expand All @@ -258,13 +258,13 @@ def config_download_callback(self) -> StringIO:

return sio

@param.depends("drop_first", watch=True)
def _update_drop_first(self):
cfg.analysis.drop_first = self.drop_first
# @param.depends("drop_first", watch=True)
# def _update_drop_first(self):
# cfg.analysis.drop_first = self.drop_first

@param.depends("weight_exponent", watch=True)
def _update_weight_exponent(self):
cfg.analysis.weight_exponent = self.weight_exponent
# @param.depends("weight_exponent", watch=True)
# def _update_weight_exponent(self):
# cfg.analysis.weight_exponent = self.weight_exponent


class PeptideFileInputControl(PyHDXControlPanel):
Expand Down Expand Up @@ -857,13 +857,14 @@ def _action_load_datasets(self) -> None:
self.widgets["load_dataset_button"].disabled = True
try:
config_ctrl = self.parent.control_panels["GlobalSettingsControl"]
drop_first = config_ctrl.drop_first
config_ctrl.widgets["drop_first"].disabled = True
config_ctrl.widgets["weight_exponent"].disabled = True
# config_ctrl.widgets["weight_exponent"].disabled = True
except KeyError:
pass
drop_first = 2

for state in dataset.states:
hdxm = HDXMeasurement.from_dataset(dataset, state)
hdxm = HDXMeasurement.from_dataset(dataset, state, drop_first=drop_first)
self.src.add(hdxm, state)
self.parent.logger.info(
f"Loaded experiment peptides state {hdxm.state} "
Expand Down

0 comments on commit fa46e2e

Please sign in to comment.