-
Notifications
You must be signed in to change notification settings - Fork 111
Library spectrum match graph tooltip implementation #3210
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
base: master
Are you sure you want to change the base?
Conversation
…github.com/ProteoWizard/pwiz into Skyline/work/20241021_GraphSpectrumTooltip
nickshulman
left a comment
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.
|
|
||
| public Size RenderTip(Graphics g, Size sizeMax, bool draw) | ||
| { | ||
| if (HasTip) |
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.
When the entire body of a function is inside of an if statement, I usually try to arrange things to reduce the amount that the code has to be indented.
That would be:
if (!HasTip)
{
return Size.Empty;
}
// rest of the body of the function
| } | ||
| return false; | ||
| } | ||
| public static int Between<T>(T x, T low, T high) where T : IComparable<T> |
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.
I would recommend getting rid of this method.
The problem with implementing a method "Between" is that the order of parameters and return value are not something that is universally agreed upon.
The natural ordering of arguments is "low, middle, high", but a case can also be made for the "middle, low, high" that you have here.
| if (xVal != PointPair.Missing && | ||
| yVal != PointPair.Missing) | ||
| { | ||
| if (Between(yAct, 0, yVal) != 0) |
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.
Is this equivalent to if (yAct < 0 || yAct > yVal)?
| <value>Failure loading spectrum. Library may be corrupted.</value> | ||
| </data> | ||
| <data name="GraphSpectrum_ToolTip_mz"> | ||
| <value>Observed M/z:</value> |
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.
The "m" and the "z" must have the same case as each other.
In the Document Grid, "M/Z" is written in upper case, but I'm not sure that's correct.
I see that many menu items have it in lowercase.
I'm not sure whether this should be "Observed M/Z:" or "Observed m/z:"
| <value>No quantitative chromatograms found</value> | ||
| </data> | ||
| <data name="ToolTipImplementation_RenderTip_Calculated_Mass" xml:space="preserve"> | ||
| <value>Calculated M/z</value> |
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.
| var massError = mfi.PredictedMz - rmi.ObservedMz; | ||
| massError = SequenceMassCalc.GetPpm(mfi.PredictedMz, massError); | ||
| massError = Math.Round(massError, 1); | ||
| sb.Append(string.Format(Resources.GraphSpectrum_MassErrorFormat_ppm, (massError > 0 ? @"+" : string.Empty), massError)); |
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.
The StringBuilder here is unnecessary.
This could just be:
return string.Format(Resources.GraphSpectrum_MassErrorFormat_ppm, (massError > 0 ? @"+" : string.Empty), massError);
| <value>Number of measured spectra for this peptide in the library</value> | ||
| </data> | ||
| <data name="Description_PeakCount"> | ||
| <value>Number of non-zero peaks in the library spectrum</value> |
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.
I don't think "non-zero peaks" means anything (specifically, there's no such thing as a zero peak).
I might say "Number of m/z values in the spectrum that had non-zero intensity", but I also might be wrong.
|
|
||
| double yPixPerUnitAct, yAct, yMinAct, yMaxAct, xAct; | ||
| double minDist = 1e20; | ||
| double xVal, yVal, dist = 99999, distX, distY; |
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.
dist, distX and distY are not used.
By default, ReSharper does not perform code analysis on the files in the ZedGraph project but you can right-click on the pause button in the top right corner of the code editor and choose "Resume Analysis"

There are quite a few unused local variables in this function.
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.
The original ZedGraph code has too many code inspection problem, so I usually keep it disabled there. I cleaned that FindNearestStick method from the unused variables, though.
…github.com/ProteoWizard/pwiz into Skyline/work/20241021_GraphSpectrumTooltip
| } | ||
| return false; | ||
| } | ||
| private double LogScalePixelDistance(double positionA, double positionB, double totalDistance) |
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.
I know this isn't part of this pull request, but I don't trust the math in this "LogScalePixelDistance".
Typically, the way to figure out the pixel distance between two coordinate values is to call "axis.Scale.Transform" on both of them and subtract the two results. That works for all types of scales.
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.
Yes, your intuition was right, as usual. That function returned incorrect values. Removed.
| : mirrorSpectrum.SpectrumPeaksInfo; | ||
| mirrorGraphItem = MakeGraphItem(mirrorSpectrum, selection, settings, peaksInfo); | ||
| mirrorGraphItem.Invert = true; | ||
| MirrorGraphItem = MakeGraphItem(mirrorSpectrum, selection, settings, peaksInfo); |
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.
The local variable mirrorGraphItem is still being used in a few places in this function and causes NullReferenceException's.
Those need to be changed to the capital MirrorGraphItem
| private string GetLabel(MatchedFragmentIon mfi, int rank, bool showMz) | ||
| public static string GetMassErrorString(LibraryRankedSpectrumInfo.RankedMI rmi, MatchedFragmentIon mfi) | ||
| { | ||
| var sb = new StringBuilder(); |
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.
This StringBuilder is no longer used.
…github.com/ProteoWizard/pwiz into Skyline/work/20241021_GraphSpectrumTooltip
|
Any other comments before I merge this? |
pwiz_tools/Skyline/Skyline.csproj
Outdated
| <Compile Include="Alerts\ArdiaLogoutDlg.cs"> | ||
| <SubType>Form</SubType> | ||
| </Compile> | ||
| <Compile Include="Alerts\ArdiaLogoutDlg.cs" /> |
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.
This file looks like all changes that are not relevant to your PR.
|
|
||
| private void TestLibraryMatchPropertySheet() | ||
| { | ||
| //TODO: [RC] Fix tests, add some tooltip testing code |
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.
Is there any testing of this new code? Would prefer to see this removed before you merge, and ideally clear new testing added. Please run code coverage and make sure your new code gets hit and covered well during some test run.
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.
nickshulman
left a comment
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.
Looks good to me.
| // 191, 95; 169, 175 | ||
| var testData = new Dictionary<Point, string>() | ||
| { | ||
| {new Point(191, 95), "Observed m/z:\t951.6229\nIntensity:\t3814516\nRank:\t1\nMatched Ions\tIon m/z (calculated)\ny8\t951.4782 -152.1 ppm"}, |
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.
This test seems to fail in French , Chinese and Japanese.
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.
Thank you, Nick. I think it's the numbers formatting.
…github.com/ProteoWizard/pwiz into Skyline/work/20241021_GraphSpectrumTooltip




No description provided.