Skip to content

Commit

Permalink
Merge branch 'add_rt_length_to_output' into add_rt_length_to_output_II
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer authored Nov 14, 2024
2 parents 1209134 + e29d44f commit 6a8b717
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion alphadia/workflow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def load(
)

self._dia_data = raw_file_manager.get_dia_data_object(dia_data_path)
raw_file_manager.calc_stats(self._dia_data)
raw_file_manager.save()

self.reporter.log_event("loading_data", {"progress": 1})
Expand Down
1 change: 1 addition & 0 deletions alphadia/workflow/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(
self.reporter = reporting.LogBackend() if reporter is None else reporter

if load_from_file:
# Note: be careful not to overwrite loaded values by initializing them in child classes after calling super().__init__()
self.load()

@property
Expand Down
17 changes: 11 additions & 6 deletions alphadia/workflow/managers/raw_file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ def __init__(
load_from_file: bool = False,
**kwargs,
):
"""Contains and updates timing information for the portions of the workflow."""
self.stats = {} # needs to be before super().__init__ to avoid overwriting when loading
"""Handles raw file loading and contains information on the raw file."""
self.stats = {} # needs to be before super().__init__ to avoid overwriting loaded values

super().__init__(path=path, load_from_file=load_from_file, **kwargs)

self._config: Config = config
Expand Down Expand Up @@ -52,7 +53,7 @@ def get_dia_data_object(

is_wsl = self._config["general"]["wsl"]
if is_wsl:
# copy file to /tmp # TODO why is that?
# copy file to /tmp # TODO check if WSL support can be dropped
import shutil

tmp_path = "/tmp"
Expand Down Expand Up @@ -106,9 +107,15 @@ def get_dia_data_object(
if is_wsl:
os.remove(tmp_dia_data_path)

self._calc_stats(dia_data)

self._log_stats()

return dia_data

def calc_stats(self, dia_data: bruker.TimsTOFTranspose | alpharaw_wrapper.AlphaRaw):
def _calc_stats(
self, dia_data: bruker.TimsTOFTranspose | alpharaw_wrapper.AlphaRaw
):
"""Calculate statistics from the DIA data."""
rt_values = dia_data.rt_values
cycle = dia_data.cycle
Expand All @@ -132,8 +139,6 @@ def calc_stats(self, dia_data: bruker.TimsTOFTranspose | alpharaw_wrapper.AlphaR

self.stats = stats

self._log_stats()

def _log_stats(self):
"""Log the statistics calculated from the DIA data."""
rt_duration_min = self.stats["rt_duration_sec"] / 60
Expand Down

0 comments on commit 6a8b717

Please sign in to comment.