Skip to content

Commit 3b42ece

Browse files
authored
Merge pull request #645 from MannLabs/fix_library_init
reverting fd86f3f
2 parents ebd1e24 + fc2bdfd commit 3b42ece

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

alphadia/workflow/optimizers/optimization_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def set_batch_dfs(self, eg_idxes: None | np.ndarray = None):
213213
if eg_idxes is None:
214214
eg_idxes = self._elution_group_order[self.start_idx : self.stop_idx]
215215
self.batch_library = SpecLibFlat()
216-
# TODO using batch_library.precursor_df here will trigger the setter method, which will additionally call refine_precursor_df()
216+
# TODO using batch_library.precursor_df (no underscore) here will trigger the setter method, which will additionally call refine_precursor_df()
217217
self.batch_library._precursor_df, (self.batch_library._fragment_df,) = (
218218
remove_unused_fragments(
219219
self._library._precursor_df[

alphadia/workflow/peptidecentric/library_init.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,39 @@ def init_spectral_library(
3939
- precursor_df_unfiltered attribute is set to the original precursor dataframe.
4040
"""
4141
# normalize RT
42-
spectral_library.precursor_df["rt_library"] = _norm_to_rt(
43-
dia_rt_values, spectral_library.precursor_df["rt_library"].values
42+
spectral_library._precursor_df["rt_library"] = _norm_to_rt(
43+
dia_rt_values, spectral_library._precursor_df["rt_library"].values
4444
)
4545

4646
# filter based on precursor observability
4747
lower_mz_limit = dia_cycle[dia_cycle > 0].min()
4848
upper_mz_limit = dia_cycle[dia_cycle > 0].max()
4949

50-
n_precursor_before = np.sum(spectral_library.precursor_df["decoy"] == 0)
51-
spectral_library.precursor_df = spectral_library.precursor_df[
52-
(spectral_library.precursor_df["mz_library"] >= lower_mz_limit)
53-
& (spectral_library.precursor_df["mz_library"] <= upper_mz_limit)
50+
# TODO using spectral_library.precursor_df (no underscore) here will trigger the setter method, which will additionally call refine_precursor_df()
51+
52+
n_precursor_before = np.sum(spectral_library._precursor_df["decoy"] == 0)
53+
spectral_library._precursor_df = spectral_library._precursor_df[
54+
(spectral_library._precursor_df["mz_library"] >= lower_mz_limit)
55+
& (spectral_library._precursor_df["mz_library"] <= upper_mz_limit)
5456
]
55-
n_precursors_after = np.sum(spectral_library.precursor_df["decoy"] == 0)
57+
n_precursors_after = np.sum(spectral_library._precursor_df["decoy"] == 0)
5658
reporter.log_string(
5759
f"Initializing spectral library: {n_precursors_after:,} target precursors potentially observable ({n_precursor_before - n_precursors_after:,} removed)",
5860
verbosity="progress",
5961
)
6062

6163
# filter spectral library to only contain precursors from allowed channels
62-
spectral_library.precursor_df_unfiltered = spectral_library.precursor_df.copy()
64+
spectral_library.precursor_df_unfiltered = spectral_library._precursor_df.copy()
6365

6466
if channel_filter:
6567
selected_channels = [int(c) for c in channel_filter.split(",")]
6668

67-
spectral_library.precursor_df = spectral_library.precursor_df_unfiltered[
69+
spectral_library._precursor_df = spectral_library.precursor_df_unfiltered[
6870
spectral_library.precursor_df_unfiltered["channel"].isin(selected_channels)
6971
].copy()
7072

7173
reporter.log_string(
72-
f"Initializing spectral library: applied channel filter using only {selected_channels}, {len(spectral_library.precursor_df):,} precursors left",
74+
f"Initializing spectral library: applied channel filter using only {selected_channels}, {len(spectral_library._precursor_df):,} precursors left",
7375
)
7476

7577

0 commit comments

Comments
 (0)