From 149216b796356ffe2191fdaf5678d2fd07b4107c Mon Sep 17 00:00:00 2001 From: RalfG Date: Thu, 18 Dec 2025 14:11:47 +0100 Subject: [PATCH] report: Catch indexerror if no confidently identified PSMs (fixes #231) --- ms2rescore/report/charts.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ms2rescore/report/charts.py b/ms2rescore/report/charts.py index 669bcc6..1a24690 100644 --- a/ms2rescore/report/charts.py +++ b/ms2rescore/report/charts.py @@ -81,12 +81,16 @@ def score_histogram(psms: Union[PSMList, pd.DataFrame]) -> go.Figure: # Get score thresholds if all(psm_df["qvalue"]): - score_threshold = ( - psm_df[psm_df["qvalue"] <= 0.01] - .sort_values("qvalue", ascending=False)["qvalue"] - .iloc[0] - ) - fig.add_vline(x=score_threshold, line_dash="dash", line_color="black") + try: + score_threshold = ( + psm_df[psm_df["qvalue"] <= 0.01] + .sort_values("qvalue", ascending=False)["qvalue"] + .iloc[0] + ) + except IndexError: # No PSMs below threshold + pass + else: + fig.add_vline(x=score_threshold, line_dash="dash", line_color="black") return fig