Skip to content

fix: guard mzenumeration column check in _merge_filter_cardinality for MS1 data - #265

Open
abhi-0203 wants to merge 1 commit into
mwang87:masterfrom
abhi-0203:fix/ms1-cardinality-keyerror
Open

fix: guard mzenumeration column check in _merge_filter_cardinality for MS1 data#265
abhi-0203 wants to merge 1 commit into
mwang87:masterfrom
abhi-0203:fix/ms1-cardinality-keyerror

Conversation

@abhi-0203

Copy link
Copy Markdown

Summary

CARDINALITY qualifier on an MS1 condition raises KeyError: 'mzenumeration' because MS1 peak data lacks the mzenumeration column that the MS2 processing pipeline adds.

Root cause: _merge_filter_cardinality does groupby(["scan", "mzenumeration"]) on the concatenated peak DataFrame. MS2 data has mzenumeration (set at line 271 before appending to ms2_list), but MS1 data never gets this column assigned, so the groupby raises KeyError.

Fix: Add a column-existence guard before the groupby — if mzenumeration is absent, return the peak DataFrame unchanged. This is the correct behavior since cardinality filtering is an MS2-specific concept and should be a no-op for MS1 scans.

Changes

massql/msql_engine_filters.py

Added 4 lines to _merge_filter_cardinality:

if "mzenumeration" not in ms_peak_df.columns:
    # MS1 data does not have per-peak enumeration — cardinality filtering is not applicable
    return ms_peak_df

Closes #264

…r MS1 data

MS1 peak data does not have a 'mzenumeration' column (that column is
added by MS2 processing at line 271). When CARDINALITY is applied to an
MS1 condition, groupby(['scan', 'mzenumeration']) raises KeyError.

Add a column-existence guard before the groupby so MS1 data returns
unchanged, letting the cardinality qualifier be a no-op for MS1 scans.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CARDINALITY on an MS1 condition raises KeyError: 'mzenumeration'

1 participant