Repository navigation
Keep MS1/MS2 arrays aligned and read MS2 peaks without a resolution - #228
Merged
Merged
Conversation
MS1Base._handle_peak appended the m/z and then swallowed the IndexError for a line without intensity, so the intensity array came out short and later intensities were attributed to the wrong m/z, as fixed for MGF in 53ad9c4. Store NaN for the missing intensity instead. MS2Base._handle_peak read sline[3] for the resolution after checking only len(sline) > 2, so an 'm/z intensity charge' line raised IndexError. Record resolution 0 when the column is missing.
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.
#227 fixed MGF peak lines that have only an m/z.
MS1Base._handle_peakhas the same pattern: it appends the m/z, thenfloat(sline[1])raisesIndexError, which is swallowed, so the intensity array is one short and every later intensity belongs to the wrong m/z.MS2Base._handle_peakcalls it first, so MS2 has it too.The same MS2 function also reads
sline[3]for the resolution after only checkinglen(sline) > 2, so a peak linem/z intensity charge(charge is documented as the third column, resolution as the fourth) raises a bareIndexErrorwith the defaultread_resolutions=True.The MS1 change mirrors 53ad9c4 (NaN intensity, append after parsing). For MS2 the existing
else: append(0)now applies when the resolution column is missing. Lines with all columns, and both test files, parse exactly as before. As with MGF since #227, an integer intensity dtype now raises on an m/z-only line instead of misaligning.Tests:
test_mz_only_peak_linesintest_ms1.pyandtest_ms2.py(modelled on the MGF one) andtest_peak_lines_without_resolutionintest_ms2.py; they fail without the change.test_ms1.py,test_ms2.pyandtest_mgf.pypass locally on Python 3.12, and the full test directory passed except the PostgreSQL Unimod test, which needs a server.Written with AI assistance (Claude); I have reviewed the change.