fix: guard mzenumeration column check in _merge_filter_cardinality for MS1 data - #265
Open
abhi-0203 wants to merge 1 commit into
Open
fix: guard mzenumeration column check in _merge_filter_cardinality for MS1 data#265abhi-0203 wants to merge 1 commit into
abhi-0203 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CARDINALITYqualifier on an MS1 condition raisesKeyError: 'mzenumeration'because MS1 peak data lacks themzenumerationcolumn that the MS2 processing pipeline adds.Root cause:
_merge_filter_cardinalitydoesgroupby(["scan", "mzenumeration"])on the concatenated peak DataFrame. MS2 data hasmzenumeration(set at line 271 before appending toms2_list), but MS1 data never gets this column assigned, so the groupby raisesKeyError.Fix: Add a column-existence guard before the groupby — if
mzenumerationis 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.pyAdded 4 lines to
_merge_filter_cardinality:Closes #264