From d9639830d62e9980362679dc3ba853a88ae8d124 Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 16 Dec 2024 14:41:41 -0600 Subject: [PATCH 1/8] Added parent accession check back to PeptideWithSetMods --- .../ProteolyticDigestion/PeptideWithSetModifications.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index 1e7399fd..0e8ee786 100644 --- a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs +++ b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs @@ -898,7 +898,8 @@ public bool Equals(PeptideWithSetModifications other) // interface equals first because it does null and reference checks return (this as IBioPolymerWithSetMods).Equals(other) && OneBasedStartResidue == other!.OneBasedStartResidue - && Equals(Parent, other.Parent); + && (Parent?.Accession == null && other?.Parent.Accession == null + || other.Parent.Accession.Equals(Parent?.Accession)); } public override int GetHashCode() From 424f13fdf4aeba5b748c816a19bd1b6d07f19d7b Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 16 Dec 2024 14:46:05 -0600 Subject: [PATCH 2/8] Added Test --- mzLib/Test/TestPeptideWithSetMods.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mzLib/Test/TestPeptideWithSetMods.cs b/mzLib/Test/TestPeptideWithSetMods.cs index 438395c2..bcba4c09 100644 --- a/mzLib/Test/TestPeptideWithSetMods.cs +++ b/mzLib/Test/TestPeptideWithSetMods.cs @@ -1194,6 +1194,34 @@ public static void TestPeptideWithSetModsNoParentProtein() Assert.AreEqual('-', last.NextResidue); } + [Test] + public static void TestPeptideWithSetModsEquals() + { + // Create two proteins + Protein protein1 = new Protein("SEQUENCEK", "accession1"); + Protein protein2 = new Protein("SEQUENCEK", "accession2"); + + // Create digestion parameters + DigestionParams digestionParams = new DigestionParams(protease: "trypsin", maxMissedCleavages: 0, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); + + // Digest the proteins to get peptides + PeptideWithSetModifications peptide1 = protein1.Digest(digestionParams, new List(), new List()).First(); + PeptideWithSetModifications peptide2 = protein2.Digest(digestionParams, new List(), new List()).First(); + + // Test equality + Assert.IsTrue(!peptide1.Equals(peptide2)); + Assert.IsTrue(!peptide1.Equals((object)peptide2)); + Assert.AreNotEqual(peptide1.GetHashCode(), peptide2.GetHashCode()); + + // Test inequality with different start residue + PeptideWithSetModifications peptide3 = new PeptideWithSetModifications(protein1, digestionParams, 2, 9, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); + Assert.IsFalse(peptide1.Equals(peptide3)); + + // Test inequality with different parent accession + PeptideWithSetModifications peptide4 = new PeptideWithSetModifications(protein2, digestionParams, 1, 9, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); + Assert.IsFalse(peptide1.Equals(peptide4)); + } + [Test] public static void TestIBioPolymerWithSetModsModificationFromFullSequence() { From f1eec4c25fb7245826d7bebe8f39e01adea28ec9 Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 16 Dec 2024 14:57:06 -0600 Subject: [PATCH 3/8] oopsies --- .../ProteolyticDigestion/PeptideWithSetModifications.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index 0e8ee786..9cc9756b 100644 --- a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs +++ b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs @@ -898,8 +898,7 @@ public bool Equals(PeptideWithSetModifications other) // interface equals first because it does null and reference checks return (this as IBioPolymerWithSetMods).Equals(other) && OneBasedStartResidue == other!.OneBasedStartResidue - && (Parent?.Accession == null && other?.Parent.Accession == null - || other.Parent.Accession.Equals(Parent?.Accession)); + && Equals(Parent?.Accession, other.Parent?.Accession); } public override int GetHashCode() From 7acdccb1838b039c1d3ad571d68fdee3f6764502 Mon Sep 17 00:00:00 2001 From: Nic Bollis Date: Tue, 17 Dec 2024 01:50:11 -0600 Subject: [PATCH 4/8] Refactor Equals methods and add IEquatable regions Removed Equals from IBioPolymerWithSetMods interface in Omics. Updated Equals in PeptideWithSetModifications to check OneBasedStartResidue and Parent?.Accession. Updated Equals in OligoWithSetMods to check FullSequence and DigestionParams?.DigestionAgent. Added IEquatable regions to PeptideWithSetModifications and OligoWithSetMods. Organized Equals methods with #region IEquatable directives. --- mzLib/Omics/IBioPolymerWithSetMods.cs | 23 -------------- .../PeptideWithSetModifications.cs | 31 +++++++++++++++++-- .../Digestion/OligoWithSetMods.cs | 29 ++++++++++++++++- 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/mzLib/Omics/IBioPolymerWithSetMods.cs b/mzLib/Omics/IBioPolymerWithSetMods.cs index eb1ed78c..47186b89 100644 --- a/mzLib/Omics/IBioPolymerWithSetMods.cs +++ b/mzLib/Omics/IBioPolymerWithSetMods.cs @@ -44,29 +44,6 @@ public interface IBioPolymerWithSetMods : IHasChemicalFormula, IEquatable BaseSequence[zeroBasedIndex]; IBioPolymer Parent { get; } - /// - /// Default Equals Method for IBioPolymerWithSetMods - /// - /// - /// - /// - /// Different parent but same sequence and digestion condition => are equal - /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) - /// - bool IEquatable.Equals(IBioPolymerWithSetMods? other) - { - if (other is null) return false; - if (ReferenceEquals(this, other)) return true; - if (other.GetType() != GetType()) return false; - - // for those constructed from sequence and mods only - if (Parent is null && other.Parent is null) - return FullSequence.Equals(other.FullSequence); - - return FullSequence == other.FullSequence - && Equals(DigestionParams?.DigestionAgent, other.DigestionParams?.DigestionAgent); - } - public void Fragment(DissociationType dissociationType, FragmentationTerminus fragmentationTerminus, List products); diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index 9cc9756b..e55d5341 100644 --- a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs +++ b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs @@ -884,6 +884,12 @@ public override string ToString() return FullSequence + string.Join("\t", AllModsOneIsNterminus.Select(m => m.ToString())); } + #region IEquatable + + /// + /// Different parent but same sequence and digestion condition => are not equal. + /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// public override bool Equals(object obj) { if (obj is PeptideWithSetModifications peptide) @@ -893,10 +899,29 @@ public override bool Equals(object obj) return false; } + /// + /// Different parent but same sequence and digestion condition => are not equal. + /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// + public bool Equals(IBioPolymerWithSetMods other) => Equals(other as PeptideWithSetModifications); + + /// + /// Different parent but same sequence and digestion condition => are not equal. + /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// public bool Equals(PeptideWithSetModifications other) { - // interface equals first because it does null and reference checks - return (this as IBioPolymerWithSetMods).Equals(other) + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + if (other.GetType() != GetType()) return false; + + // for those constructed from sequence and mods only + if (Parent is null && other.Parent is null) + return FullSequence.Equals(other.FullSequence); + + return FullSequence == other.FullSequence + && Equals(DigestionParams?.DigestionAgent, other.DigestionParams?.DigestionAgent) + // These last two are important for parsimony in MetaMorpheus && OneBasedStartResidue == other!.OneBasedStartResidue && Equals(Parent?.Accession, other.Parent?.Accession); } @@ -917,6 +942,8 @@ public override int GetHashCode() return hash.ToHashCode(); } + #endregion + /// /// This should be run after deserialization of a PeptideWithSetModifications, in order to set its Protein and Modification objects, which were not serialized /// diff --git a/mzLib/Transcriptomics/Digestion/OligoWithSetMods.cs b/mzLib/Transcriptomics/Digestion/OligoWithSetMods.cs index 6d35d80a..ced4dc01 100644 --- a/mzLib/Transcriptomics/Digestion/OligoWithSetMods.cs +++ b/mzLib/Transcriptomics/Digestion/OligoWithSetMods.cs @@ -215,6 +215,12 @@ public void Fragment(DissociationType dissociationType, FragmentationTerminus fr products.AddRange(GetNeutralFragments(type, sequence)); } + #region IEquatable + + /// + /// Different parent but same sequence and digestion condition => are equal. + /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// public override bool Equals(object? obj) { if (obj is OligoWithSetMods oligo) @@ -224,9 +230,28 @@ public override bool Equals(object? obj) return false; } + /// + /// Different parent but same sequence and digestion condition => are equal. + /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// + public bool Equals(IBioPolymerWithSetMods? other) => Equals(other as OligoWithSetMods); + + /// + /// Different parent but same sequence and digestion condition => are equal. + /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// public bool Equals(OligoWithSetMods? other) { - return (this as IBioPolymerWithSetMods).Equals(other); + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + if (other.GetType() != GetType()) return false; + + // for those constructed from sequence and mods only + if (Parent is null && other.Parent is null) + return FullSequence.Equals(other.FullSequence); + + return FullSequence == other.FullSequence + && Equals(DigestionParams?.DigestionAgent, other.DigestionParams?.DigestionAgent); } public override int GetHashCode() @@ -245,6 +270,8 @@ public override int GetHashCode() return hash.ToHashCode(); } + #endregion + /// /// Generates theoretical internal fragments for given dissociation type for this peptide. /// The "products" parameter is filled with these fragments. From 9e4eb681922192f4a2a15df9720466e76415b0ba Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 13 Dec 2024 19:28:44 -0600 Subject: [PATCH 5/8] workflow edit --- .github/workflows/dotnet.yml | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index f89904dc..3efc89e5 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -38,3 +38,55 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} verbose: true files: mzLib/Test*/TestResults/*/coverage.cobertura.xml + integration: + runs-on: windows-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v2 + - name: Set up .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: cd mzLib && dotnet restore + - name: Build + run: cd mzLib && dotnet build --no-restore --configuration Release + - name: Change mzLib version, pack, add source + run: | + cd mzLib; + (Get-Content mzLib.nuspec) -replace "\(.*)\", "9.9.9" | Set-Content mzLib.nuspec; + $mzlibMatch = Select-String -Path mzLib.nuspec -Pattern "(?<=\)(.*)(?=\ Date: Tue, 17 Dec 2024 11:32:06 -0600 Subject: [PATCH 6/8] Even more equality tetsts --- mzLib/Test/TestPeptideWithSetMods.cs | 15 +++++++++- .../Transcriptomics/TestOligoWithSetMods.cs | 28 +++++++++++++------ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/mzLib/Test/TestPeptideWithSetMods.cs b/mzLib/Test/TestPeptideWithSetMods.cs index bcba4c09..c2e19749 100644 --- a/mzLib/Test/TestPeptideWithSetMods.cs +++ b/mzLib/Test/TestPeptideWithSetMods.cs @@ -71,6 +71,8 @@ public static void TestPeptideOligoEquality() Assert.That(!peptide.Equals(oligo)); Assert.That(!((IBioPolymerWithSetMods)oligo).Equals(peptide)); Assert.That(!((IBioPolymerWithSetMods)peptide).Equals(oligo)); + Assert.That(!((object)oligo).Equals(peptide)); + Assert.That(!((object)peptide).Equals(oligo)); } [Test] @@ -1208,9 +1210,13 @@ public static void TestPeptideWithSetModsEquals() PeptideWithSetModifications peptide1 = protein1.Digest(digestionParams, new List(), new List()).First(); PeptideWithSetModifications peptide2 = protein2.Digest(digestionParams, new List(), new List()).First(); - // Test equality + // Test equality - same peptide + Assert.IsTrue(peptide1.Equals(peptide1)); + + // different peptide Assert.IsTrue(!peptide1.Equals(peptide2)); Assert.IsTrue(!peptide1.Equals((object)peptide2)); + Assert.IsTrue(!peptide1.Equals((IBioPolymerWithSetMods)peptide2)); Assert.AreNotEqual(peptide1.GetHashCode(), peptide2.GetHashCode()); // Test inequality with different start residue @@ -1220,8 +1226,15 @@ public static void TestPeptideWithSetModsEquals() // Test inequality with different parent accession PeptideWithSetModifications peptide4 = new PeptideWithSetModifications(protein2, digestionParams, 1, 9, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); Assert.IsFalse(peptide1.Equals(peptide4)); + + // all fail on null + Assert.That(!peptide1.Equals(null)); + Assert.That(!peptide1.Equals((object)null)); + Assert.That(!peptide1.Equals((PeptideWithSetModifications)null)); } + + [Test] public static void TestIBioPolymerWithSetModsModificationFromFullSequence() { diff --git a/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs b/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs index ceeaf3b7..1b83ec46 100644 --- a/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs +++ b/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs @@ -91,22 +91,34 @@ public static void TestEquality() .Digest(new RnaDigestionParams(), [], []) .ElementAt(1); - Assert.That(oligoWithSetMods, Is.EqualTo(oligoWithSetMods2)); + // same oligos + Assert.That(oligoWithSetMods.Equals(oligoWithSetMods2)); + Assert.That(oligoWithSetMods.Equals((object)oligoWithSetMods2)); + Assert.That(oligoWithSetMods.Equals((OligoWithSetMods)oligoWithSetMods2)); + Assert.That(oligoWithSetMods.Equals(oligoWithSetMods)); + Assert.That(oligoWithSetMods.Equals((object)oligoWithSetMods)); + Assert.That(oligoWithSetMods.Equals((OligoWithSetMods)oligoWithSetMods)); Assert.That(oligoWithSetMods.GetHashCode(), Is.EqualTo(oligoWithSetMods2.GetHashCode())); - Assert.That(oligoWithSetMods.Equals((object)oligoWithSetMods2)); // Test the Equals(Object obj) method + + // all fail on null Assert.That(!oligoWithSetMods2.Equals(null)); + Assert.That(!oligoWithSetMods2.Equals((object)null)); + Assert.That(!oligoWithSetMods2.Equals((OligoWithSetMods)null)); // Null parent checks oligoWithSetMods = new(oligoWithSetMods.FullSequence, modDict.ToDictionary(p => p.Value.First().IdWithMotif, p => p.Value.First())); oligoWithSetMods2 = new OligoWithSetMods(oligoWithSetMods.FullSequence, modDict.ToDictionary(p => p.Value.First().IdWithMotif, p => p.Value.First())); var oligoWithSetMods3 = new OligoWithSetMods(oligoWithSetMods.FullSequence + "AGAUA", modDict.ToDictionary(p => p.Value.First().IdWithMotif, p => p.Value.First())); - Assert.That(oligoWithSetMods, Is.EqualTo(oligoWithSetMods2)); - Assert.That(oligoWithSetMods, Is.EqualTo((object)oligoWithSetMods2)); - Assert.That(oligoWithSetMods, Is.EqualTo((OligoWithSetMods)oligoWithSetMods2)); - Assert.That(oligoWithSetMods, Is.Not.EqualTo(oligoWithSetMods3)); - Assert.That(oligoWithSetMods, Is.Not.EqualTo((object)oligoWithSetMods3)); - Assert.That(oligoWithSetMods, Is.Not.EqualTo((IBioPolymerWithSetMods)oligoWithSetMods3)); + // same oligo null parent + Assert.That(oligoWithSetMods.Equals(oligoWithSetMods2)); + Assert.That(oligoWithSetMods.Equals((object)oligoWithSetMods2)); + Assert.That(oligoWithSetMods.Equals((OligoWithSetMods)oligoWithSetMods2)); + + // different oligo null parent + Assert.That(!oligoWithSetMods.Equals(oligoWithSetMods3)); + Assert.That(!oligoWithSetMods.Equals((object)oligoWithSetMods3)); + Assert.That(!oligoWithSetMods.Equals((IBioPolymerWithSetMods)oligoWithSetMods3)); } [Test] From 1b8f32261b5f2a3827964a477f81efd03318fec6 Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 17 Dec 2024 14:29:35 -0600 Subject: [PATCH 7/8] adjusted oligo with set mods --- .../PeptideWithSetModifications.cs | 13 +++++-------- .../Transcriptomics/TestOligoWithSetMods.cs | 8 ++++---- .../Digestion/OligoWithSetMods.cs | 18 +++++++++++------- mzLib/mzLib.sln.DotSettings | 1 + 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index e55d5341..d3ca8dc2 100644 --- a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs +++ b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs @@ -16,7 +16,7 @@ namespace Proteomics.ProteolyticDigestion [Serializable] public class PeptideWithSetModifications : ProteolyticPeptide, IBioPolymerWithSetMods, IEquatable { - public string FullSequence { get; private set; } //sequence with modifications + public string FullSequence { get; init; } //sequence with modifications public int NumFixedMods { get; } // Parameter to store the full sequence of the corresponding Target or Decoy peptide // If the peptide in question is a decoy, this pairs it to the target it was generated from @@ -885,10 +885,9 @@ public override string ToString() } #region IEquatable - + /// - /// Different parent but same sequence and digestion condition => are not equal. - /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// Peptides are equal if they have the same full sequence, parent, and digestion agent /// public override bool Equals(object obj) { @@ -900,14 +899,12 @@ public override bool Equals(object obj) } /// - /// Different parent but same sequence and digestion condition => are not equal. - /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// Peptides are equal if they have the same full sequence, parent, and digestion agent /// public bool Equals(IBioPolymerWithSetMods other) => Equals(other as PeptideWithSetModifications); /// - /// Different parent but same sequence and digestion condition => are not equal. - /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// Peptides are equal if they have the same full sequence, parent, and digestion agent /// public bool Equals(PeptideWithSetModifications other) { diff --git a/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs b/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs index 1b83ec46..7822c8dc 100644 --- a/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs +++ b/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs @@ -124,7 +124,7 @@ public static void TestEquality() [Test] [TestCase("GUACUG", "GUACUGGUACUG", "RNase A")] [TestCase("GUAGGAG", "GUAGCAG", "RNase A")] - public static void TestEquality_DifferentParentSameDigestionProduct(string sequence1, string sequence2, string enzyme) + public static void TestInequality_DifferentParentSameDigestionProduct(string sequence1, string sequence2, string enzyme) { var digestionParams = new RnaDigestionParams(rnase: enzyme, minLength: 1, maxMissedCleavages: 0); @@ -136,10 +136,10 @@ public static void TestEquality_DifferentParentSameDigestionProduct(string seque .Digest(digestionParams, [], []) .First(); - Assert.That(oligo1, Is.EqualTo(oligo2)); + Assert.That(oligo1, Is.Not.EqualTo(oligo2)); Assert.That(oligo1.Equals(oligo1)); - Assert.That(oligo1, Is.EqualTo((object)oligo2)); - Assert.That(oligo1.GetHashCode(), Is.EqualTo(oligo2.GetHashCode())); + Assert.That(oligo1, Is.Not.EqualTo((object)oligo2)); + Assert.That(oligo1.GetHashCode(), Is.Not.EqualTo(oligo2.GetHashCode())); } /// diff --git a/mzLib/Transcriptomics/Digestion/OligoWithSetMods.cs b/mzLib/Transcriptomics/Digestion/OligoWithSetMods.cs index ced4dc01..6455e209 100644 --- a/mzLib/Transcriptomics/Digestion/OligoWithSetMods.cs +++ b/mzLib/Transcriptomics/Digestion/OligoWithSetMods.cs @@ -218,8 +218,7 @@ public void Fragment(DissociationType dissociationType, FragmentationTerminus fr #region IEquatable /// - /// Different parent but same sequence and digestion condition => are equal. - /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// Oligos are equal if they have the same full sequence, parent, and digestion agent, and terminal caps /// public override bool Equals(object? obj) { @@ -231,14 +230,12 @@ public override bool Equals(object? obj) } /// - /// Different parent but same sequence and digestion condition => are equal. - /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// Oligos are equal if they have the same full sequence, parent, and digestion agent, and terminal caps /// public bool Equals(IBioPolymerWithSetMods? other) => Equals(other as OligoWithSetMods); /// - /// Different parent but same sequence and digestion condition => are equal. - /// Different Digestion agent but same sequence => are not equal (this is for multi-protease analysis in MetaMorpheus) + /// Oligos are equal if they have the same full sequence, parent, and digestion agent, and terminal caps /// public bool Equals(OligoWithSetMods? other) { @@ -251,7 +248,12 @@ public bool Equals(OligoWithSetMods? other) return FullSequence.Equals(other.FullSequence); return FullSequence == other.FullSequence - && Equals(DigestionParams?.DigestionAgent, other.DigestionParams?.DigestionAgent); + && Equals(DigestionParams?.DigestionAgent, other.DigestionParams?.DigestionAgent) + && _fivePrimeTerminus.Equals(other._fivePrimeTerminus) + && _threePrimeTerminus.Equals(other._threePrimeTerminus) + // These last two are important for parsimony in MetaMorpheus + && OneBasedStartResidue == other!.OneBasedStartResidue + && Equals(Parent?.Accession, other.Parent?.Accession); } public override int GetHashCode() @@ -267,6 +269,8 @@ public override int GetHashCode() { hash.Add(DigestionParams.DigestionAgent); } + hash.Add(FivePrimeTerminus); + hash.Add(ThreePrimeTerminus); return hash.ToHashCode(); } diff --git a/mzLib/mzLib.sln.DotSettings b/mzLib/mzLib.sln.DotSettings index 6c67babc..69660cbf 100644 --- a/mzLib/mzLib.sln.DotSettings +++ b/mzLib/mzLib.sln.DotSettings @@ -8,6 +8,7 @@ True True True + True True True True From fac3c40c4fecf4cf36052a857e30849c46a9f7a5 Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 17 Dec 2024 15:03:33 -0600 Subject: [PATCH 8/8] ugh --- mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs | 4 ++-- mzLib/Transcriptomics/RNA.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs b/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs index 7822c8dc..2da62943 100644 --- a/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs +++ b/mzLib/Test/Transcriptomics/TestOligoWithSetMods.cs @@ -128,11 +128,11 @@ public static void TestInequality_DifferentParentSameDigestionProduct(string seq { var digestionParams = new RnaDigestionParams(rnase: enzyme, minLength: 1, maxMissedCleavages: 0); - var oligo1 = new RNA(sequence1) + var oligo1 = new RNA(sequence1, "", "rna1", "", "") .Digest(digestionParams, [], []) .First(); - var oligo2 = new RNA(sequence2) + var oligo2 = new RNA(sequence2, "", "rna3", "", "") .Digest(digestionParams, [], []) .First(); diff --git a/mzLib/Transcriptomics/RNA.cs b/mzLib/Transcriptomics/RNA.cs index 41e3a64e..a7a5a480 100644 --- a/mzLib/Transcriptomics/RNA.cs +++ b/mzLib/Transcriptomics/RNA.cs @@ -23,7 +23,7 @@ public RNA(string sequence, IHasChemicalFormula? fivePrimeTerm = null, IHasChemi /// /// /// - /// + /// /// /// /// @@ -33,12 +33,12 @@ public RNA(string sequence, IHasChemicalFormula? fivePrimeTerm = null, IHasChemi /// /// /// - public RNA(string sequence, string name, string identifier, string organism, string databaseFilePath, + public RNA(string sequence, string name, string accession, string organism, string databaseFilePath, IHasChemicalFormula? fivePrimeTerminus = null, IHasChemicalFormula? threePrimeTerminus = null, IDictionary>? oneBasedPossibleModifications = null, bool isContaminant = false, bool isDecoy = false, List> geneNames = null, Dictionary? databaseAdditionalFields = null) - : base(sequence, name, identifier, organism, databaseFilePath, fivePrimeTerminus, threePrimeTerminus, + : base(sequence, name, accession, organism, databaseFilePath, fivePrimeTerminus, threePrimeTerminus, oneBasedPossibleModifications, isContaminant, isDecoy, geneNames, databaseAdditionalFields) {