Skip to content

Commit

Permalink
missing features bugfix, deeplc logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurDeclercq committed Aug 21, 2023
1 parent dfa0c93 commit 5599e44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 6 additions & 6 deletions ms2rescore/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ def rescore(configuration: Dict) -> None:
(set(psm.rescoring_features.keys()) == all_feature_names) for psm in psm_list
]

psm_list = psm_list[psms_with_features]

if psms_with_features.count(False) > 0:
removed_psms = psm_list[[not psm for psm in psms_with_features]]
missing_features = {
feature_name
for present_features in psm_list[[not presence for presence in psms_with_features]]
for feature_name in (all_feature_names - present_features)
for psm in removed_psms
for feature_name in all_feature_names - set(psm.rescoring_features.keys())
}
logger.warning(
f"Removed {psms_with_features.count(False)} PSMs that were missing one or more"
f"rescoring feature, {missing_features}."
f"Removed {psms_with_features.count(False)} PSMs that were missing one or more "
f"rescoring feature(s), {missing_features}."
)

psm_list = psm_list[psms_with_features]
# Write feature names to file
_write_feature_names(feature_names, output_file_root)

Expand Down
7 changes: 6 additions & 1 deletion ms2rescore/feature_generators/deeplc.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ def add_features(self, psm_list: PSMList) -> None:
)

# Run MS²PIP for each spectrum file
total_runs = len(psm_dict.keys())
current_run = 1
for runs in psm_dict.values():
# Reset DeepLC predictor for each collection of runs
self.deeplc_predictor = None
self.selected_model = None
for run, psms in runs.items():
logger.info(f"Running DeepLC for PSMs from run `{run}`...")
logger.info(
f"Running DeepLC for PSMs from run ({current_run}/{total_runs}): `{run}`..."
)
# Prepare PSM file
with contextlib.redirect_stdout(
open(os.devnull, "w")
Expand Down Expand Up @@ -182,6 +186,7 @@ def add_features(self, psm_list: PSMList) -> None:
"predicted_retention_time_best": predictions[i],
"rt_diff_best": rt_diffs_run[i],
}
current_run += 1

for psm in psm_list:
psm["rescoring_features"].update(
Expand Down

0 comments on commit 5599e44

Please sign in to comment.