From bc51050602bb1833342457ab7d644543a246ff0f Mon Sep 17 00:00:00 2001 From: RalfG Date: Wed, 17 Apr 2024 17:39:11 +0200 Subject: [PATCH] Mokapot: Also consider run for merging peptide level info --- ms2rescore/__init__.py | 2 +- ms2rescore/rescoring_engines/mokapot.py | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ms2rescore/__init__.py b/ms2rescore/__init__.py index 1754ae4..2cb335d 100644 --- a/ms2rescore/__init__.py +++ b/ms2rescore/__init__.py @@ -1,6 +1,6 @@ """MSĀ²Rescore: Sensitive PSM rescoring with predicted MSĀ² peak intensities and RTs.""" -__version__ = "3.1.0-dev3" +__version__ = "3.1.0-dev4" from warnings import filterwarnings diff --git a/ms2rescore/rescoring_engines/mokapot.py b/ms2rescore/rescoring_engines/mokapot.py index e2f503f..448881c 100644 --- a/ms2rescore/rescoring_engines/mokapot.py +++ b/ms2rescore/rescoring_engines/mokapot.py @@ -111,17 +111,19 @@ def rescore( psm_list["pep"] = q[:, 2] # Repeat for peptide-level scores - peptide_info = pd.concat( - [ - confidence_results.confidence_estimates["peptides"].set_index(["peptide"])[keys], - confidence_results.decoy_confidence_estimates["peptides"].set_index(["peptide"])[keys], - ], - axis=0, - ).to_dict(orient="index") + peptides_targets = confidence_results.confidence_estimates["peptides"].set_index( + ["peptide", "run"] + )[keys] + peptides_decoys = confidence_results.decoy_confidence_estimates["peptides"].set_index( + ["peptide", "run"] + )[keys] + peptide_info = pd.concat([peptides_targets, peptides_decoys], axis=0).to_dict(orient="index") peptidoform_without_charge = re.compile(r"(/\d+$)") for psm in psm_list: - peptide_scores = peptide_info[peptidoform_without_charge.sub("", str(psm.peptidoform), 1)] + peptide_scores = peptide_info[ + (peptidoform_without_charge.sub("", str(psm.peptidoform), 1), psm.run) + ] psm.metadata.update( { "peptide_score": peptide_scores["mokapot score"],