Skip to content

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

Description

@hsingh84ai

What happens

CARDINALITY on an MS1 condition raises KeyError: 'mzenumeration'. The same qualifier
on the equivalent MS2 condition works.

QUERY scaninfo(MS1DATA) WHERE MS1MZ=(100 OR 200):CARDINALITY=range(min=2, max=2)
KeyError: 'mzenumeration'

Why

_merge_filter_cardinality in massql/msql_engine_filters.py groups on that column:

enumeration_df = ms_peak_df.groupby(["scan", "mzenumeration"]).first().reset_index()

The MS2 path sets it before appending each per-value frame:

ms2_filtered_df["mzenumeration"] = i

The MS1 path (ms1_condition) has no equivalent assignment, so the column never exists by
the time the merge reads it.

Suggested fix

Set ms1_filtered_df["mzenumeration"] = i in the MS1 loop, mirroring the MS2 path.

The same gap is in ms2prec_condition

ms2prec_condition also appends a per-value frame without setting mzenumeration, so a
multi-valued MS2PREC carrying CARDINALITY should reach the same KeyError. Grepping the
three condition functions for the assignment finds it only in the MS2 product path. I read
that one rather than running it, so it is worth confirming before fixing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions