Skip to content
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

Edited the MatchedFramgentIon Equals method #751

Merged
merged 7 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mzLib/Omics/Fragmentation/MatchedFragmentIon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@
return NeutralTheoreticalProduct.ProductType + "" + NeutralTheoreticalProduct.FragmentNumber + "+" + Charge + "\t;" + NeutralTheoreticalProduct.NeutralMass;
}

public override bool Equals(object obj)

Check warning on line 75 in mzLib/Omics/Fragmentation/MatchedFragmentIon.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of type of parameter 'obj' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 75 in mzLib/Omics/Fragmentation/MatchedFragmentIon.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of type of parameter 'obj' doesn't match overridden member (possibly because of nullability attributes).
{
MatchedFragmentIon other = (MatchedFragmentIon)obj;

return this.NeutralTheoreticalProduct.Equals(other.NeutralTheoreticalProduct)
&& this.Charge == other.Charge
&& this.Mz == other.Mz
&& this.Intensity == other.Intensity;
&& Math.Abs(Mz - other.Mz) < 0.0001
&& Math.Abs(Intensity - other.Intensity) < 0.0001;
}

public override int GetHashCode()
Expand Down
9 changes: 9 additions & 0 deletions mzLib/Test/TestFragments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,15 @@ public static void Test_MatchedFragmentGetHashCode()
Assert.AreEqual(1072693248, m.GetHashCode());
}

[Test]
public static void TestMatchedFragmentIonEquals()
{
Product P = new Product(ProductType.b, FragmentationTerminus.N, 1, 1, 1, 0);
MatchedFragmentIon ion1 = new MatchedFragmentIon(P, experMz: 150, experIntensity: 99.99999, charge: 2);
MatchedFragmentIon ion2 = new MatchedFragmentIon(P, experMz: 149.99999, experIntensity: 100, charge: 2);
Assert.AreEqual(ion1, ion2);
}

[Test]
public static void Test_CID_Fragmentation_No_Unmodified_B1_ions()
{
Expand Down
Loading