From abf20303c2517f902c864a76e70254cc36b0a3fb Mon Sep 17 00:00:00 2001 From: Kevin Velghe Date: Tue, 2 Jun 2026 18:45:43 +0200 Subject: [PATCH 1/2] make score_keys a list If nothing was found, we return the first element as fallback. However, score_keys isn't subscriptable, resulting in issue #258 when none of the standard search engine scores were found. Making this a list fixes this. However, if the order isn't significant (the order of the keys will be the order of insertion in current (C?)Python implementations, the order of the set would de-facto be according to the order of the hashes) we could also use a set here, and then use `score_keys.pop()` as fallback instead of `score_keys[0]`. --- psm_utils/io/pepxml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psm_utils/io/pepxml.py b/psm_utils/io/pepxml.py index af81400..325bca1 100644 --- a/psm_utils/io/pepxml.py +++ b/psm_utils/io/pepxml.py @@ -75,7 +75,7 @@ def _infer_score_name(self) -> str | None: for spectrum_query in reader: if "search_hit" not in spectrum_query: continue - score_keys = spectrum_query["search_hit"][0]["search_score"].keys() + score_keys = list(spectrum_query["search_hit"][0]["search_score"].keys()) break else: score_keys = [] From fa6246c5a5925b1162f941a990ce9bfa492df151 Mon Sep 17 00:00:00 2001 From: Ralf Gabriels Date: Fri, 5 Jun 2026 10:53:10 +0000 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index faa356c..977c6ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.5.5] - 2026-06-05 +### Fixed + +- `io.pepxml`: Fix a `TypeError` when none of the standard search engine scores are found and the fallback (`score_keys[0]`) is accessed (fixes #150) + ### Changed - Pin version bounds for all core dependencies. Most notably, `pyteomics` is now constrained to `< 5` to avoid breaking changes introduced in the upcoming major release.