Skip to content

Conversation

@rita-gwen
Copy link
Contributor

No description provided.

Copy link
Contributor

@nickshulman nickshulman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooltips look nice.
image

New properties on the property sheet also look nice.
image

Here are some cosmetic comments about the code.


public Size RenderTip(Graphics g, Size sizeMax, bool draw)
{
if (HasTip)
Copy link
Contributor

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>
Copy link
Contributor

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)
Copy link
Contributor

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>
Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, I wonder this should be "Ion m/z" because the context menu item which causes these numbers to be shown on the graph is "Ion m/z Values"
image

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));
Copy link
Contributor

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>
Copy link
Contributor

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;
Copy link
Contributor

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"
image

There are quite a few unused local variables in this function.

Copy link
Contributor Author

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.

}
return false;
}
private double LogScalePixelDistance(double positionA, double positionB, double totalDistance)
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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();
Copy link
Contributor

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.

@rita-gwen
Copy link
Contributor Author

Any other comments before I merge this?

<Compile Include="Alerts\ArdiaLogoutDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Alerts\ArdiaLogoutDlg.cs" />
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the testing code and run the code coverage. Looks like the new tooltip code is exercised well.
image

Copy link
Contributor

@nickshulman nickshulman left a 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"},
Copy link
Contributor

@nickshulman nickshulman Aug 26, 2025

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.

Copy link
Contributor Author

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants