WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 2a1f2a1

Browse files
committed
Implement suggested fixes
1 parent 15d58a4 commit 2a1f2a1

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

ms2rescore/config_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _validate_regular_expressions(config: Dict) -> Dict:
104104
if pattern.groups != 1:
105105
raise MS2RescoreConfigurationError(
106106
f"Regular expression for '{field}' should contain exactly one "
107-
"capturing group. Please check and try again."
107+
"capturing group. Please check and try again. "
108108
"See https://ms2rescore.readthedocs.io/en/stable/userguide/configuration/#mapping-psms-to-spectra "
109109
"for more information."
110110
)

ms2rescore/parse_spectra.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,19 @@ def _apply_spectrum_id_pattern(
171171
)
172172

173173
# Validate that the same number of unique IDs were matched
174-
elif len(set(id_mapping.keys())) != len(set(precursors.keys())):
175-
example_old_id, example_new_id = next(iter(id_mapping.items()))
174+
elif len(id_mapping) != len(precursors):
175+
new_id, old_id = next(iter(id_mapping.items()))
176176
raise MS2RescoreConfigurationError(
177177
"'spectrum_id_pattern' resulted in a different number of unique PSM IDs. This might "
178178
"indicate issues with the regex pattern. Please check and try again. "
179-
f"Example old ID: '{example_old_id}' -> new ID: '{example_new_id}'. "
179+
f"Example old ID: '{old_id}' -> new ID: '{new_id}'. "
180180
"See https://ms2rescore.readthedocs.io/en/stable/userguide/configuration/#mapping-psms-to-spectra "
181181
"for more information."
182182
)
183183

184184
precursors = {new_id: precursors[orig_id] for new_id, orig_id in id_mapping.items()}
185185

186-
return id_mapping
186+
return precursors
187187

188188

189189
def _get_precursor_values(
@@ -201,13 +201,6 @@ def _get_precursor_values(
201201
LOGGER.debug("Reading spectrum file: '%s'", spectrum_file)
202202
precursors: dict[str, Precursor] = get_precursor_info(str(spectrum_file))
203203

204-
# Ensure unique spectrum IDs
205-
if len(precursors) != len(set(precursors.keys())):
206-
raise SpectrumParsingError(
207-
f"Spectrum file '{spectrum_file}' contains duplicate spectrum IDs. "
208-
"Please ensure that all spectrum IDs are unique."
209-
)
210-
211204
# Parse spectrum IDs with regex pattern if provided
212205
if spectrum_id_pattern:
213206
precursors = _apply_spectrum_id_pattern(precursors, spectrum_id_pattern)
@@ -216,8 +209,8 @@ def _get_precursor_values(
216209
for psm in psm_list_run:
217210
if psm.spectrum_id not in precursors:
218211
raise MS2RescoreConfigurationError(
219-
"Mismatch between PSM and spectrum file IDs. Could find precursor values "
220-
f"for PSM with ID {psm.spectrum_id} in run {run_name}.\n"
212+
"Mismatch between PSM and spectrum file IDs. Could not find precursor "
213+
f"values for PSM with ID {psm.spectrum_id} in run {run_name}.\n"
221214
"Please check that the `spectrum_id_pattern` and `psm_id_pattern` options "
222215
"are configured correctly. See "
223216
"https://ms2rescore.readthedocs.io/en/stable/userguide/configuration/#mapping-psms-to-spectra"

0 commit comments

Comments
 (0)