-
Notifications
You must be signed in to change notification settings - Fork 121
skyline: Stop skipping spectra that have empty m/z intensity arrays #4589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nickshulman
wants to merge
12
commits into
master
Choose a base branch
from
Skyline/work/20260818_AcceptZeroLengthSpectra
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5bc56a3
Stop filtering out spectra that have zero m/z intensity pairs.
nickshulman 8c424a8
Add ZeroLengthSpectraTest
nickshulman 8c680b7
Update expected values in SettingsChangeReimportTest.
nickshulman 9885e0f
Restricted the zero length spectrum change to spectra with no scan wi…
nickshulman d17f952
Change data type of expected value to float
nickshulman 9afe673
Fixed the Full Scan graph being blank for a scan which measured no ions
nickshulman 267afc7
Merge remote-tracking branch 'origin/master' into Skyline/work/202608…
nickshulman dbd9b93
Merge branch 'master' of https://github.com/ProteoWizard/pwiz into Sk…
nickshulman 0b41b4b
Update expected values.
nickshulman abe6772
Merge branch 'master' into Skyline/work/20260818_AcceptZeroLengthSpectra
nickshulman 0d607f8
Merge branch 'master' into Skyline/work/20260818_AcceptZeroLengthSpectra
nickshulman cf4c14e
Merge branch 'master' into Skyline/work/20260818_AcceptZeroLengthSpectra
nickshulman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
100 changes: 100 additions & 0 deletions
100
pwiz_tools/Skyline/TestFunctional/ZeroLengthSpectraTest.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /* | ||
| * Original author: Nicholas Shulman <nicksh .at. u.washington.edu>, | ||
| * MacCoss Lab, Department of Genome Sciences, UW | ||
| * | ||
| * Copyright 2026 University of Washington - Seattle, WA | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| using pwiz.CommonMsData; | ||
| using pwiz.Skyline.Controls.Graphs; | ||
| using pwiz.Skyline.Model; | ||
| using pwiz.Skyline.Model.Results; | ||
| using pwiz.SkylineTestUtil; | ||
| using System.Linq; | ||
| using ZedGraph; | ||
|
|
||
| namespace pwiz.SkylineTestFunctional | ||
| { | ||
| /// <summary> | ||
| /// Verifies that spectra with no m/z's and intensities are still included in the extracted chromatogram. | ||
| /// </summary> | ||
| [TestClass] | ||
| public class ZeroLengthSpectraTest : AbstractFunctionalTestEx | ||
| { | ||
| [TestMethod] | ||
| public void TestZeroLengthSpectra() | ||
| { | ||
| TestFilesZip = @"TestFunctional\ZeroLengthSpectraTest.zip"; | ||
| RunFunctionalTest(); | ||
| } | ||
|
|
||
| protected override void DoTest() | ||
| { | ||
| RunUI(()=>SkylineWindow.OpenFile(TestFilesDir.GetTestPath("ZeroLengthSpectraTest.sky"))); | ||
| var msDataFilePath = new MsDataFilePath(TestFilesDir.GetTestPath("S_1.mzML")); | ||
| ImportResultsFile(msDataFilePath.FilePath); | ||
| using var dataFile = msDataFilePath.OpenMsDataFile(new OpenMsDataFileParams()); | ||
| var ms1Spectra = Enumerable.Range(0, dataFile.SpectrumCount).Select(dataFile.GetSpectrum) | ||
| .Where(spectrum => spectrum.Level == 1).ToList(); | ||
| var emptyMs1Spectra = ms1Spectra.Where(spectrum => spectrum.Mzs.Length == 0).ToList(); | ||
| Assert.AreNotEqual(0, emptyMs1Spectra.Count); | ||
| Assert.AreNotEqual(emptyMs1Spectra.Count, ms1Spectra.Count); | ||
| var document = SkylineWindow.Document; | ||
| var peptideDocNode = document.Molecules.First(); | ||
| Assert.IsTrue(document.MeasuredResults.TryLoadChromatogram(0, peptideDocNode, peptideDocNode.TransitionGroups.First(), (float) document.Settings.TransitionSettings.Instrument.MzMatchTolerance, out var chromatogramGroupInfos)); | ||
| Assert.AreEqual(1, chromatogramGroupInfos.Length); | ||
| var chromatogramInfo = chromatogramGroupInfos[0].GetRawTransitionInfo(0); | ||
| Assert.IsNotNull(chromatogramInfo); | ||
| Assert.AreEqual(ms1Spectra.Count, chromatogramInfo.Times.Count); | ||
| RunUI(() => | ||
| { | ||
| SkylineWindow.SelectedPath = | ||
| SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.TransitionGroups, 0); | ||
| SkylineWindow.SetTransformChrom(TransformChrom.raw); | ||
| }); | ||
|
|
||
| // Click on a point in the chromatogram which came from one of the empty spectra | ||
| ClickChromatogram(22.3, 1e4); | ||
| var graphFullScan = WaitForOpenForm<GraphFullScan>(); | ||
| RunUI(() => | ||
| { | ||
| graphFullScan.SetZoom(false); | ||
| AssertAxesNotDegenerate(graphFullScan.ZedGraphControl.GraphPane); | ||
|
|
||
| // The empty spectrum still says which m/z values it was measuring, and the x-axis | ||
| // is supposed to show that range instead of collapsing to nothing | ||
| var scanWindowUpperLimit = emptyMs1Spectra.Max(spectrum => spectrum.Metadata.ScanWindowUpperLimit); | ||
| Assert.IsNotNull(scanWindowUpperLimit); | ||
| AssertEx.IsGreaterThanOrEqual(graphFullScan.ZedGraphControl.GraphPane.XAxis.Scale.Max, | ||
| scanWindowUpperLimit.Value); | ||
| }); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Asserts that the graph will actually be drawn. ZedGraph skips the axes, the grid and the | ||
| /// curves when the minimum of any of a pane's axis scales is not less than its maximum, | ||
| /// which leaves nothing but the title, so a degenerate range means a blank graph. | ||
| /// </summary> | ||
| private static void AssertAxesNotDegenerate(GraphPane graphPane) | ||
| { | ||
| AssertEx.IsGreaterThan(graphPane.XAxis.Scale.Max, graphPane.XAxis.Scale.Min); | ||
| AssertEx.IsGreaterThan(graphPane.X2Axis.Scale.Max, graphPane.X2Axis.Scale.Min); | ||
| foreach (var yAxis in graphPane.YAxisList) | ||
| AssertEx.IsGreaterThan(yAxis.Scale.Max, yAxis.Scale.Min); | ||
| foreach (var y2Axis in graphPane.Y2AxisList) | ||
| AssertEx.IsGreaterThan(y2Axis.Scale.Max, y2Axis.Scale.Min); | ||
| } | ||
| } | ||
| } |
Binary file not shown.
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving this one as
publicfor now.SpectraChromDataProvideris declaredinternal sealed, so apublicmember on it is already scoped to this assembly rather than exposed to anything outside it - the accessibility change would be a stylistic one rather than a real narrowing of the public surface. It also matchesHasSpectrumDataimmediately above it, which ispublic staticin the same position for the same reason.Beyond consistency,
IsEmptySpectrumencodes a policy decision - what counts as an empty spectrum, and specifically that a scan declaring scan window limits is a valid measurement of zero rather than an absence of data. That rule is a plausible thing for other extraction code to need to share rather than restate, so I would rather not close it off yet.Leaving the thread unresolved so a human reviewer can overrule this if they would rather keep the enclosing type's surface minimal - it is a one-word change either way.